Jump to content
  • Advertisement
Sign in to follow this  
Dysprosium

OpenGL Small problem with SDL and OpenGL

This topic is 3811 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

Hey guys! I have a small problem I haven't been able to solve in the past few hours. I have just switched from GLUT to SDL for obvious reasons, and after having set up the window, I can't get my program to actually draw anything. I have located the problem and it is the lack of glutPostRedisplay(). I haven't been able to find the equivalent of this function anywhere. Does anyone know what to call? This is the code for my screen updating function.
void updateScreen(){
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    updateObjects(timer.getTime());
    for(int i = 0; i < totalObjects; i++) {
        objects->draw();
    }
    SDL_GL_SwapBuffers();
    
    if (timer.elapsed(randObjTime)){
        createRandomObject();
        randObjTime += 200;
    }
    //glutPostRedisplay();
}

Thanks in advance. [Edited by - Dysprosium on March 14, 2008 8:45:05 PM]

Share this post


Link to post
Share on other sites
Advertisement
SDL_GL_SwapBuffers should do that for you. I can't really tell what's wrong with your code, can you post a small program that replicates it? Often in writing the smaller, more simple program you see what's wrong.

Perhaps the problem is with the OpenGL calls. I'd call glMatrixMode(GL_MODELVIEW) before glLoadIdentity just in case. If you never called glMatrixMode after setting up your projection matrix, you can often see something the first frame then nothing in later frames.

Oh, and when posting code, put the code in source tag, like this (but without that spaces in the tags):

[ source ]
code goes here

[ /source ]

Share this post


Link to post
Share on other sites
That didn't work. Though now I know that the lack of glutPostRedisplay is not the problem. I'll look for the issue elsewhere in the code then, before asking another question. Thanks for the quick reply! :)

P.S. And thanks for the
 tip!

Share this post


Link to post
Share on other sites
For those of you who were curious, I managed to find out what it was.

I cleared the background after a few seconds, and noticed that worked, so it WAS actually drawing on my screen.
Then I changed one of my objects coordinates to (0,0) and noticed it being drawn, hideously malformed.

Turns out the problem was my 'reshape' function that GLUT used to call, wasn't used in my new program (duh!). I have solved the problem for fullscreen mode, so I'm happy. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!