1 /* $Id: sdlgl.c,v 1.6 2003-03-28 09:27:07 btb Exp $ */
4 * Graphics functions for SDL-GL.
15 #include <SDL_image.h>
24 static int curx=-1,cury=-1,curfull=0;
26 void ogl_do_fullscreen_internal(void){
27 ogl_init_window(curx,cury);
30 void ogl_swap_buffers_internal(void){
34 int ogl_init_window(int x, int y){
36 if (x==curx && y==cury && curfull==ogl_fullscreen)
38 if (ogl_fullscreen || curfull)
39 ogl_smash_texture_list_internal();//if we are or were fullscreen, changing vid mode will invalidate current textures
41 SDL_WM_SetCaption(DESCENT_VERSION, "Descent II");
45 #include "descent.xpm"
46 SDL_WM_SetIcon(IMG_ReadXPMFromArray(pixmap), NULL);
50 if (!SDL_SetVideoMode(x,y, 16, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0))) {
51 Error("Could not set %dx%dx16 opengl video mode\n",x,y);
55 curx=x;cury=y;curfull=ogl_fullscreen;
61 void ogl_destroy_window(void){
63 ogl_smash_texture_list_internal();
66 //well..SDL doesn't really let you kill the window.. so we just need to wait for sdl_quit
73 if ((t=FindArg("-gl_red")))
74 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, atoi(Args[t+1]) );
75 if ((t=FindArg("-gl_green")))
76 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, atoi(Args[t+1]) );
77 if ((t=FindArg("-gl_blue")))
78 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, atoi(Args[t+1]) );
79 if ((t=FindArg("-gl_alpha")))
80 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, atoi(Args[t+1]) );
81 if ((t=FindArg("-gl_buffer")))
82 SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, atoi(Args[t+1]) );
83 // SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
84 // SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
85 // SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
86 // SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
89 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,0);
90 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,0);
91 SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE,0);
92 SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE,0);
93 SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,0);
94 SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,0);
95 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
100 #if 0 // shouldn't really be necessary...
103 ogl_do_fullscreen_internal();
106 ogl_destroy_window();