SDL with OpenGL

Started by
4 comments, last by Mushu 17 years, 11 months ago
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~
Dont need one.... i'm so cool, dont ask me just do what you do..... meet me in the trap its going down....
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.
I got the file, but I cant get Gzip to to work to unzip it so I can view it source.
Dont need one.... i'm so cool, dont ask me just do what you do..... meet me in the trap its going down....
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}
I think you should be able to open the files with WinZip. I know that you can open them with WinRar atleast.
Using SDL with OpenGL.

This topic is closed to new replies.

Advertisement