this will turn on & off windows-like coordinate system in opengl which has coordinate system like you described and uses 1 unit = 1 pixel.Code:// Dwarf with Axe - GAMEDEV forums: 18 July 2002 6:12:57 PM // // There have been thousands of posts along the lines of // "How do I do 2d in OpenGL" to "Duuuhde, I wunt too maek // a two dee gaem in ohpun jee el; how do eye set uhp two dee???!?" // // I have developed a simple, nice, pretty way for all of you to have your 2D fun. procedure GlEnable2D; var vport: array[0..3] of integer; begin glGetIntegerv(GL_VIEWPORT, @vPort); glMatrixMode(GL_PROJECTION); glPushMatrix; glLoadIdentity; glOrtho(0, vPort[2], 0, -vPort[3], -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix; glLoadIdentity; // flip Y axis glTranslatef(0, -vPort[3], 0); end; procedure GlDisable2D; begin glMatrixMode(GL_PROJECTION); glPopMatrix; glMatrixMode(GL_MODELVIEW); glPopMatrix; end;
Bookmarks