]> icculus.org git repositories - btb/d2x.git/blob - video/ogl_sdl.c
Fullscreen toggle added to screen res menu
[btb/d2x.git] / video / ogl_sdl.c
1 /*
2  * $Source: /cvs/cvsroot/d2x/video/ogl_sdl.c,v $
3  * $Revision: 1.2 $
4  * $Author: bradleyb $
5  * $Date: 2001-01-29 13:47:52 $
6  *
7  * Graphics functions for SDL-GL.
8  *
9  * $Log: not supported by cvs2svn $
10  */
11
12 #ifdef HAVE_CONFIG_H
13 #include <conf.h>
14 #endif
15
16 #include <SDL/SDL.h>
17 #include <GL/gl.h>
18 #include <string.h>
19 #include "ogl_init.h"
20 #include "vers_id.h"
21 #include "error.h"
22 #include "event.h"
23 #include "mono.h"
24 #include "u_mem.h"
25
26 static int gl_initialized = 0;
27
28 void ogl_do_fullscreen_internal(void){
29     if (ogl_fullscreen)
30     {
31         SDL_Surface *screen;
32
33         screen = SDL_GetVideoSurface();
34         SDL_WM_ToggleFullScreen(screen);
35     }
36
37 }
38
39 inline void ogl_swap_buffers_internal(void){
40         SDL_GL_SwapBuffers();
41 }
42 int ogl_init_window(int x, int y){
43
44         Uint32 video_flags;
45         int bpp = 16;
46
47
48         if (SDL_Init(SDL_INIT_VIDEO) < 0)
49         {
50                 Error("SDL library video initialisation failed: %s.",SDL_GetError());
51         }
52         video_flags = SDL_OPENGL;
53         
54         if (ogl_fullscreen) video_flags |= SDL_FULLSCREEN;
55
56         SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
57         SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
58         SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
59 //        SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 1 );
60         SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, bpp );
61         SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
62
63         if ( SDL_SetVideoMode( x, y, bpp, video_flags ) == NULL ) {
64                 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
65                 SDL_Quit();
66                 exit(1);
67         }
68
69
70         printf( "Vendor     : %s\n", glGetString( GL_VENDOR ) );
71         printf( "Renderer   : %s\n", glGetString( GL_RENDERER ) );
72         printf( "Version    : %s\n", glGetString( GL_VERSION ) );
73         printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
74         printf("\n");
75
76                 
77         return 0;
78 }
79 void ogl_destroy_window(void){
80         return;
81 }
82 void ogl_init(void){
83         gl_initialized=1;
84 }
85 void ogl_close(void){
86         ogl_destroy_window();
87 }