Sign in to follow this  

SDL with OpenGL

This topic is 4229 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 want to make a simple Pong game that will have simple input and a few blocks and thats about it; I want to use OpenGL bbut I dont want to use Glut because to me it seems to be 'limited' besides its portability. I am going to use SDL but I dont understand how it incorporates with OpenGL.Cone3D doesn't explain it well and I have googled for tuts and found nothing.Can someone give me a source of a basic application with SDL for the window and use Opengl for a square or something easy (i.e. glRect)? This will be a life saver thanks a bunch! ~Mad_Koder~

Share this post


Link to post
Share on other sites
You can create an OpenGL screen with SDL, you can do this with SDL instead of having to use "hwind" things and other MS Windows code in Windows.

I set up an OpenGL screen with SDL like this:


void screen(int width, int height, bool fullscreen, char *text)
{
int colorDepth = 32;

if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) //init audio if you want sound
{
printf("Unable to init SDL: %s\n", SDL_GetError());
SDL_Quit();
exit(1);
}
atexit(SDL_Quit);
if(fullscreen)
{
scr = SDL_SetVideoMode(width,height,colorDepth,SDL_SWSURFACE|SDL_FULLSCREEN|SDL_OPENGL);
lock();
fullscreenMode = 1;
}
else
{
scr = SDL_SetVideoMode(width,height,colorDepth,SDL_HWSURFACE|SDL_HWPALETTE|SDL_OPENGL);
fullscreenMode = 0;
}
if(scr == NULL)
{
printf("Unable to set video: %s\n", SDL_GetError());
SDL_Quit();
exit(1);
}
SDL_WM_SetCaption(text, NULL);

//initialize OpenGL now
}

Share this post


Link to post
Share on other sites

This topic is 4229 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this