1 /* $Id: sdlgl.c,v 1.5 2003-01-15 02:42:41 btb Exp $ */
4 * Graphics functions for SDL-GL.
21 static int curx=-1,cury=-1,curfull=0;
23 void ogl_do_fullscreen_internal(void){
24 ogl_init_window(curx,cury);
27 void ogl_swap_buffers_internal(void){
31 int ogl_init_window(int x, int y){
33 if (x==curx && y==cury && curfull==ogl_fullscreen)
35 if (ogl_fullscreen || curfull)
36 ogl_smash_texture_list_internal();//if we are or were fullscreen, changing vid mode will invalidate current textures
38 SDL_WM_SetCaption(DESCENT_VERSION, "Descent II");
39 if (!SDL_SetVideoMode(x,y, 16, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0))) {
40 Error("Could not set %dx%dx16 opengl video mode\n",x,y);
44 curx=x;cury=y;curfull=ogl_fullscreen;
50 void ogl_destroy_window(void){
52 ogl_smash_texture_list_internal();
55 //well..SDL doesn't really let you kill the window.. so we just need to wait for sdl_quit
62 if ((t=FindArg("-gl_red")))
63 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, atoi(Args[t+1]) );
64 if ((t=FindArg("-gl_green")))
65 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, atoi(Args[t+1]) );
66 if ((t=FindArg("-gl_blue")))
67 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, atoi(Args[t+1]) );
68 if ((t=FindArg("-gl_alpha")))
69 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, atoi(Args[t+1]) );
70 if ((t=FindArg("-gl_buffer")))
71 SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, atoi(Args[t+1]) );
72 // SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
73 // SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
74 // SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
75 // SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
78 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,0);
79 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,0);
80 SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE,0);
81 SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE,0);
82 SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,0);
83 SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,0);
84 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
89 #if 0 // shouldn't really be necessary...
92 ogl_do_fullscreen_internal();