Sign in to follow this  
Mad_Koder

SDL with OpenGL

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
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

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