Jump to content
  • Advertisement
Sign in to follow this  
Mad_Koder

SDL with OpenGL

This topic is 4439 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
Advertisement
Check out NeHe's site. Most of the tutorials have downloads called Linux/SDL that you can look at. Even though it says linux the code should compile just fine under windows too. Here's lesson 2, which shows how to draw some simple shapes.

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
I think you should be able to open the files with WinZip. I know that you can open them with WinRar atleast.

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!