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