Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BradDaBug

OpenGL Problems with OpenGL and SDL!

This topic is 5935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
To use 2D with the screen coordinates with the origin in the top left corner:

    
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!