Hi,
i have little problem with coordinates in OpenGL mixed with SDL. I mean usually when I program in ogl i just use some - i don't know, (virtual ?) coordinates - which means that point (0,0,0) is in the middle of screen and I use vectors like a [1, 2, 3] I mean coordinates in pure OpenGL aren't pixels. They just are relative. But i was looking at the code SDL+OGL i saw once snippet like this:
glBegin( GL_QUADS );
glColor4f( 1.0, 1.0, 1.0, 1.0 );
glVertex3f( 0, 0, 0 );
glVertex3f( SQUARE_WIDTH, 0, 0 );
glVertex3f( SQUARE_WIDTH, SQUARE_HEIGHT, 0 );
glVertex3f( 0, SQUARE_HEIGHT, 0 );
glEnd();
This code comes from LazyFoo lesson no. 36 and SQUARE_WIDTH == SQUARE_HEIGHT == 20. So this is typical SDL's style of coordinates, i mean pixel-style. Point (0,0,0) is in upper left corner. Ok, let's say this is ok for me :) But here comes the Nehe's lesson for instance lesson no. 5 and code is as below:
glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
//and so on...
glEnd();
So here is SDL conversion of this lesson by Ti Leggett (http://nehe.gamedev.net/data/lessons/linuxsdl/lesson05.tar.gz) and as far as i can see there is just normal OpenGL-style of coordinates insteed of previous SDL-style from LazyFoo. So i know both methodes of representing position of vertex is valid, but how SDL will know which one we are using ? For example when i write code with glVertex(0.0f, 1.0f, 0.0f) how SDL will know that it isn't (0,1,0) pixel but some opengl point ? Where and how i can tell sdl which one style i choose ? And what about mouse events ? They are given with pixels so how do i convert them to opengl coordinates ? Maybe i should use only sdl-style ?
I am SDL newbie and i'm just trying to master this library to connect it with OGL because i think SDL is simply awesome :) Thanks for any answers :)
PS: Sorry for my english, mates.