glBegin(GL_QUADS);
glColor3ub(255, 0, 0);
glVertex2i(0, 0);
glVertex2i(0, 64);
glVertex2i(64, 64);
glVertex2i(64, 0);
glEnd();
also is there any good books on doing 2d in ogl ?
2d in ogl question
Okay now i got a window up and running .... i have also changed into 2d mode ( using the code found here : http://www.gamedev.net/community/forums/topic.asp?topic_id=104791 )
I have problems drawing a quad in the top left corner
the quad should be 64x64 pixels.
( i also wonder what i need to do in order to manipulate ogl into thinking that 0,0 = the top left corner and max_x && max_y = lower right corner ...
current code:
This has to with the point of origin, in OpenGL the origin is, I believe, exactly in the center of the screen. Just like a cartesian coordinate system. You might have thought the point of origin was in the upper-left corner.
"glOrtho(0, vPort[2], 0, vPort[3], -1, 1);"
now look up glOrtho:
glOrtho(left, right, bottom, top...
you yourself told opengl that 0,0 is supposed to be bottom left.
now look up glOrtho:
glOrtho(left, right, bottom, top...
you yourself told opengl that 0,0 is supposed to be bottom left.
thx m8 ...
dint know that i could change it like that ! !
*thot it would mess up ogl*
10pts to you !
dint know that i could change it like that ! !
*thot it would mess up ogl*
10pts to you !
yeah in case someone wonder what the sulution is
i have updated Dwarf with Axe''s code to create a "correct" 2d viewpoint
[/source]
i have updated Dwarf with Axe''s code to create a "correct" 2d viewpoint
void glEnable2D(){ int vPort[4]; glGetIntegerv(GL_VIEWPORT, vPort); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // this line was changed glOrtho(0, vPort[2], vPort[3], 0, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();}
[/source]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement