Problems with OpenGL and SDL!
I can''t draw anything! I can get it to start up and the screen is being cleared and everything, but I can''t draw anything. Nothing happens.
Here is my initialization code:
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
lpBackBuffer = SDL_SetVideoMode ( Settings.GetResWidth() , Settings.GetResHeight() , 16, SDL_FULLSCREEN | SDL_OPENGL) ;
glViewport(0,0, 800,600);
glLoadIdentity();
Here is my drawing code:
glColor3f(1.0,0.5, 1.0);
glBegin(GL_LINE_LOOP);
glVertex3i(destrect.x, destrect.y, 0);
glVertex3i(destrect.x + destrect.w, destrect.y, 0);
glVertex3i(destrect.x + destrect.w, destrect.y + destrect.h, 0);
glVertex3i(destrect.x, destrect.y + destrect.h, 0);
glEnd();
What''s wrong?
From that small amount of code I''m guessing you didn''t set up the projection matrix correction. Are you calling glPerspective, glFrustum, glOrtho, or gluOrtho2D anywhere in your code?
To use 2D with the screen coordinates with the origin in the top left corner:
Use that where you have glViewport.
[edited by - Null and Void on March 23, 2002 4:51:55 PM]
void Setup2D(int Width, int Height) { glViewport(0, 0, (GLsizei) Width, (GLsizei) Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f,X,Y,0.0f,-1.0f,1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}
Use that where you have glViewport.
[edited by - Null and Void on March 23, 2002 4:51:55 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement