1 /* $Id: sdlgl.c,v 1.9 2003-11-27 04:59:49 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){
35 int ogl_check_mode(int x, int y)
37 return !SDL_VideoModeOK(x, y, 16, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0));
41 int ogl_init_window(int x, int y){
43 if (x==curx && y==cury && curfull==ogl_fullscreen)
45 #ifdef __linux__ // Windows, at least, seems to need to reload every time.
46 if (ogl_fullscreen || curfull)
48 ogl_smash_texture_list_internal();//if we are or were fullscreen, changing vid mode will invalidate current textures
50 SDL_WM_SetCaption(DESCENT_VERSION, "Descent II");
54 #include "descent.xpm"
55 SDL_WM_SetIcon(IMG_ReadXPMFromArray(pixmap), NULL);
59 if (!SDL_SetVideoMode(x,y, 16, SDL_OPENGL | (ogl_fullscreen?SDL_FULLSCREEN:0))) {
60 Error("Could not set %dx%dx16 opengl video mode\n",x,y);
64 curx=x;cury=y;curfull=ogl_fullscreen;
70 void ogl_destroy_window(void){
72 ogl_smash_texture_list_internal();
75 //well..SDL doesn't really let you kill the window.. so we just need to wait for sdl_quit
82 if ((t=FindArg("-gl_red")))
83 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, atoi(Args[t+1]) );
84 if ((t=FindArg("-gl_green")))
85 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, atoi(Args[t+1]) );
86 if ((t=FindArg("-gl_blue")))
87 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, atoi(Args[t+1]) );
88 if ((t=FindArg("-gl_alpha")))
89 SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, atoi(Args[t+1]) );
90 if ((t=FindArg("-gl_buffer")))
91 SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, atoi(Args[t+1]) );
92 // SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
93 // SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
94 // SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
95 // SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
98 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,0);
99 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,0);
100 SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE,0);
101 SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE,0);
102 SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE,0);
103 SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE,0);
104 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
108 void ogl_close(void){
109 #if 0 // shouldn't really be necessary...
112 ogl_do_fullscreen_internal();
115 ogl_destroy_window();