2 Copyright (C) 2003 T. Joseph Carter
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 // Tell startup code that we have a client
26 int cl_available = true;
28 static SDL_Surface *screen;
30 void *GL_GetProcAddress(const char *name)
33 p = SDL_GL_GetProcAddress(name);
39 if (SDL_Init(SDL_INIT_VIDEO) < 0)
40 printf ("Failed to init video: %s\n", SDL_GetError());
43 int VID_InitMode(int fullscreen, int width, int height, int bpp)
46 int flags = SDL_OPENGL;
50 drivername = "opengl32.dll";
51 #elif defined(__APPLE__) && defined(__MACH__)
52 drivername = "OpenGL.framework";
54 drivername = "libGL.so.1";
57 i = COM_CheckParm("-gl_driver");
58 if (i && i < com_argc - 1)
59 drivername = com_argv[i + 1];
60 if (!SDL_GL_LoadLibrary(drivername))
62 Con_Printf("Unable to load GL driver \"%s\"\n: ", drivername, SDL_GetError());
66 qglGetString = GL_GetProcAddress("glGetString");
68 // Knghtbrd: should do platform-specific extension string function here
70 if (qglGetString == NULL)
73 Con_Printf("Required OpenGL function glGetString not found\n");
78 // flags |= SDL_FULLSCREEN;
80 SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 1);
81 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 1);
82 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 1);
83 SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16);
84 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
86 screen = SDL_SetVideoMode(width, height, bpp, flags);
89 Con_Printf("Failed to set video mode to %ix%i: %s\n", width, height, SDL_GetError);
94 gl_renderer = qglGetString(GL_RENDERER);
95 gl_vendor = qglGetString(GL_VENDOR);
96 gl_version = qglGetString(GL_VERSION);
97 gl_extensions = qglGetString(GL_EXTENSIONS);
99 // Knghtbrd: should assign platform-specific extensions here
100 gl_platformextensions = "";
108 void VID_Shutdown (void)
113 int VID_SetGamma (unsigned short *ramps)
118 int VID_GetGamma (unsigned short *ramps)
123 void VID_GetWindowSize (int *x, int *y, int *width, int *height)
130 void VID_Finish (void)
133 SDL_GL_SwapBuffers();
136 void IN_Commands (void)
140 void IN_Move (usercmd_t *cmd)
144 void Sys_SendKeyEvents (void)