Jump to content
  • Advertisement
Sign in to follow this  
Bluseed

OpenGL and 2D

This topic is 4342 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay so i just read a post and it said that if you turn the screen sorta say into an orthagraphic view, then openGL would be good to use for coding a 2D enviroment. Question: Are you suppose to put your images on a...
//Texture2
	glBindTexture(GL_TEXTURE_2D, texture[Score]);
	glTranslatef(-4.0f,-2.5f,-10.0f);
	
	glBegin(GL_QUADS);
		// Front Face
		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
		glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f,  1.0f);
		glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f,  1.0f,  1.0f);
		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);
	glEnd();

coz thats the only way i know how to display an image on the screen.. Is there a Blit function or something i dont know about? Maybe i dont know what im talking about, but imagine doing a tile engine using that????

Share this post


Link to post
Share on other sites
Advertisement
There is a blit function, glDrawPixels, but you definitely don't want to use it.

Drawing a textured quad is the right and best way of drawing a (e.g.) sprite in 2d (although often used in 3d as well, as a "billboard").

The textured quad can be scaled, rotated etc as you wish - also it can be drawing with blending and can be multitextured, use shaders etc. These things are all good and will enable you to do cool effects (relatively) efficiently (certainly compared with a software implementation).

Mark

Share this post


Link to post
Share on other sites
Quote:
Original post by Jovan
Ravuya for president :)


I'd vote for him!

And, yes, textured quads are great for 2D. You can even, *gasp* rotate and scale them. I know, it's amazing.

Share this post


Link to post
Share on other sites
That just gave me a great idea for a carnival-style shooter game where the target are flat... pieces of cardboard that rotate around as you try your best to shoot 'em up (working title). But yeah, 2-d in a 3-d environment to win :)

Share this post


Link to post
Share on other sites
Also, when in orthographic mode you can ignore most of the third dimension. And since this is a 2D environment you can just as well use glVertex2f as opposed to glVertex3f.


-Etyrn

Share this post


Link to post
Share on other sites
Quote:
Original post by Etyrn
Also, when in orthographic mode you can ignore most of the third dimension. And since this is a 2D environment you can just as well use glVertex2f as opposed to glVertex3f.


-Etyrn


Or you could use it for the layer system.

You could also add lots of nice effects, blurs, glows etc. by using shaders on the quads.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!