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