PDA

View Full Version : How to do 2d in modern opengl



EvilNando
05-23-2011, 06:09 AM
Im about to give up on this, so if anyone in here could please help me I would appreciate it

all I want is to be able to draw textured quads against an orthogonal projection where screen space is not from -1, 1 but from 0 to screen width and from 0 to screen height so I can map vertices directly to pixels

thanks

_arts_
05-23-2011, 07:29 AM
You said everything in your post. So by reading some docs about OpenGL you should easily find that:



glViewport (0,0,100,100);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho (0,100, 0,100, -1,1);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();


or so, will be great.

EvilNando
05-23-2011, 07:36 AM
Oh Im sorry I meant how to do this in modern opengl

mhagain
05-23-2011, 07:58 AM
Build the same ortho matrix by hand and send it to your shader. The man page for glOrtho (http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml) describes how the matrix is built, so that should give you the info you need to know to build it manually.