Here is my init-function for OpenGL under SDL:
Code:
6 bool CSdlGlWin::InitGL(int x, int y, int bpp, unsigned int flags)
7 {
8 m_iWinX = x;
9 m_iWinY = y;
10 SDL_Init(SDL_INIT_VIDEO);
11 m_pSurface = SDL_SetVideoMode(x, y, bpp, flags | SDL_OPENGL);
12 if(m_pSurface == NULL)
13 return false;
14
15 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
16 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
17 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
18 SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
19 SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
20 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
21 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); // 16 Bit depth-buffer
22
23 glViewport(0, 0, x, y);
24
25 glMatrixMode(GL_PROJECTION);
26 glLoadIdentity();
27 gluPerspective(45, ((float)x)/((float)y), 0.0f, 100.0f);
28
29
30 glMatrixMode(GL_MODELVIEW);
31 glLoadIdentity();
32
33 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
34 glClearDepth(1.0);
35 glDepthFunc(GL_ALWAYS);
36 glEnable(GL_DEPTH_TEST);
37 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
38
39 glShadeModel(GL_SMOOTH);
40
41 //glEnable(GL_CULL_FACE);
42 //glCullFace(GL_FRONT);
43
44 ilInit();
45
46 return true;
47 }
And then i use the following to init the whole thing:
Code:
app.InitGL(1280, 800, 32, SDL_HWSURFACE | SDL_FULLSCREEN);
Also in all source-codes ive seen you set the attributes after you initiate the video-mode so that seems weird to say that it should be done before setting video-mode.