OpenGL - XY Coordinate Rendering

I've recently been trying to learn OpenGL (the 2d elements of it) for use in games. I know about the glOrtho() function, and how you can reset the rendering coordinates (the 1.0 through -1.0 annoys me to no end). However, I can't figure out how to set it to have no negative coordinates, for those of you who are familiar with SDL-style coordinates, this is what I'm going for:
http://bit.ly/12nsoty

But with OpenGL, it seems that glOrtho() takes it's X an Y parameters, halves them, and assigns them a positive and a negative (ex. 640X480, supposed to be 0-640 and 0-480, but instead uses -320-320 and -240-240).

My test program and its results (lines and text added later)
http://imgur.com/6wWBkgl

My code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        ...
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	glOrtho( 0.0, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0, 1.0, -1.0 );

	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	glClearColor( 0.f, 0.f, 0.f, 1.f );

        ...

        glClear( GL_COLOR_BUFFER_BIT );

	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	glTranslatef( SCREEN_WIDTH / 2.f, SCREEN_HEIGHT / 2.f, 0.f );

	glBegin( GL_QUADS );
		glColor3f( 0.f, 1.f, 1.f );
		glVertex2f( 100.f, 100.f );
		glVertex2f( 0.f, 100.f );
		glVertex2f( 0.f, 0.f );
		glVertex2f( 100.f, 0.f );
	glEnd();
        ...


Does anyone have any good suggestions as to how I could either fix and/or work around this problem? any and all help would be appreciated. Thanks,
Aunvre
Last edited on
Can you just change the arguments to glTranslatef appropriately? If not you can just abstract the rendering call and convert the coordinates before rendering.

On a side note you might want to start learning a more modern version of openGL. The functions you're using have been depreciated for years; although with 2d, performance probably isn't an issue.

Last edited on
FWIW, you are learning outdated and deprecated OpenGL. I highly recommend abandoning whatever source you're using and use a more recent tutorial/source.

This was is pretty good:

http://www.arcsynthesis.org/gltut/
Topic archived. No new replies allowed.