Advertisement

Hello everyone! (and a 2d question)

Started by July 12, 2001 10:10 PM
8 comments, last by GLnewbie 23 years, 7 months ago
Hey everyone, I''m new to this board and I''m just getting my hands into the WinAPI and OpenGL. I am just wondering if anyone knows of any good 2d tutorials. I was told this was the place to start (NeHe) and to start w/ 2d then move into 3d. Is NeHe''s source for that Zelda game he made (or anything like it) online? I couldn''t find it. Thanks
hey,
welcome to NeHe, about that 2d question, read all tuts in their original order, and move on to the next one only in case you completely understand it. i suggest you read c++ books first, but you can try the tuts. about 2d, i don''t think it''s much (if at all) easier than 3d, but i think tut 21 covers it... anyway, read all tuts before that, and you''ll get there. good luck with your newbiness, and visit http://www.warwormsdev.f2s.com/ . thanks,
shurcool.
Advertisement
Hi!!

ShurCool :
I get a 404 when trying to acces your site!!
For tutorials on pure 2D in Opengl, you should check out
opengl.org!! I won''t be surprised if they got some stuff
covering the topic!!
You might even wanna try on CFXWeb (cfxweb.net), and FlipCode (flipcode.com)!!


Hope this helps a little bit!!


Take Care!

- -- ---[XaOs]--- -- -
- -- ---[XaOs]--- -- -[ Project fy ||| CyberTux ]
Hey thanks for helping out, I''m doing the Nehe tutorials.. (and in response to shurcool) I am already fairly experienced in C++ and programming in general, just not much Graphics programming yet.
Ahhh!! NeHe is getting into 3d texture mapping and stuff that my Borland Compiler doesn''t like and I''m afraid I''m not learning any of the 2d yet (but i did make one hell of a textured teapot.. :D). Can someone point me towards an Orthographic tutorial (please don''t say lesson 21) for someone that really want to finish a 2d game before doing any 3d.

(And btw hey Eber-Kain -It''s me jturk@conceptofzero.com)

Thanks again everyone.
GLnewbie,

I''m in the same boat. I''m doing a sprite/2d game in OpenGL. What you need are one of two functions...

gluOrtho2d(left,right,bottom,top);
glOrtho(left,right,bottom,top,near,far);

and make sure you viewport is 1:1

glViewport(0,0,right-left,top-bottom);

If you don''t have a 1:1 viewport your sprites may go through the scaler and come out looking a little soft or pixelated.


Next.. texture loading. Read up on all of the 3d tuts on this and steal the code, it will be very similar.

For alpha channel images make sure to enable blending.

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

you don''t need to enable GL_DEPTH or GL_CULL_FACE because we are not dealing with 3d right now.

You can use the 2{bifd} version of the functions because they assume you are drawing a z=0 whick is fine for 2d on GL.

Hope that makes some sense... here is a snippet of setup code from my java app...

	public void init()	{		LoadGLTextures();		gl.glEnable(GL_TEXTURE_2D);		gl.glEnable(GL_BLEND);		gl.glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);		gl.glClearColor(1.0f,1.0f,1.0f, 0.0f);		gl.glMatrixMode(GL_PROJECTION);		glu.gluOrtho2D(0,640,480,0);		gl.glViewport(0,0,640,480);		gl.glMatrixMode(GL_MODELVIEW);		glj.gljCheckGL();	} 

Advertisement
You know... I would use the depth buffer. Even though you aren''t programming in 3D, you can use Z values like layer levels. It makes effects like scrolling backgrounds and the such easier.

-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
Thanks blackstream, and I agree with you on that point snowmoon. Also thanks to whoever emailed me that tutorial on Ortho. (sorry but I lost your email address)

by the way blackstream is glj as in glj.gljCheckGL(); a java thing? I assume so but I was just making sure
quote:
Original post by GLnewbie
Thanks blackstream, and I agree with you on that point snowmoon. Also thanks to whoever emailed me that tutorial on Ortho. (sorry but I lost your email address)

by the way blackstream is glj as in glj.gljCheckGL(); a java thing? I assume so but I was just making sure


I''m not sure :eek:

I''m still basically a OpenGL newbie myself, only slightly farther than you (I just got to texturing and blending), but I''m just sharing the little knowledge I do have, and unfortunately, that command is not one of them Sounds like it would be, based on the j (in glj) and the fact that it is a class, but I don''t know...


-Blackstream

Will you, won''t you, will you, won''t you, won''t you take my virus?

-The Mad Hacker

Blackstream''s Webpage
-Blackstream Will you, won't you, will you, won't you, won't you take my virus?-The Mad HackerBlackstream's Webpage
glj''s are java specific setup code. The code is in java, but the code is easly transfered to c.

I''m getting up to speed, I''m hoping to have a simple sprite manager this weekend. Heaps sprites into several categorys and then subtextures them into pre-allocated texture slots based on alpha/non-alpha and size 32,64 and all ittegular ones get there own texture.

Not to promote a particular language, but the gl4java bindings work well, you wouldn''t have to worry about your compiler craping out on you. Java is a quick learn, and 90% of the code for gl is the same as the c counterparts.

Cheers.

This topic is closed to new replies.

Advertisement