]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - vid.h
Fix crash in inputline.
[xonotic/darkplaces.git] / vid.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20 // vid.h -- video driver defs
21
22 #ifndef VID_H
23 #define VID_H
24
25 #define ENGINE_ICON ( (gamemode == GAME_NEXUIZ) ? nexuiz_xpm : darkplaces_xpm )
26
27 extern int cl_available;
28
29 #define MAX_TEXTUREUNITS 16
30
31 typedef enum renderpath_e
32 {
33         RENDERPATH_GL11,
34         RENDERPATH_GL13,
35         RENDERPATH_GL20,
36         RENDERPATH_D3D9,
37         RENDERPATH_D3D10,
38         RENDERPATH_D3D11,
39         RENDERPATH_SOFT,
40         RENDERPATH_GLES1,
41         RENDERPATH_GLES2
42 }
43 renderpath_t;
44
45 typedef struct viddef_support_s
46 {
47         qboolean gl20shaders;
48         qboolean gl20shaders130; // indicates glBindFragDataLocation is available
49         int glshaderversion; // typical values: 100 110 120 130 140 ...
50         qboolean amd_texture_texture4;
51         qboolean arb_depth_texture;
52         qboolean arb_draw_buffers;
53         qboolean arb_framebuffer_object;
54         qboolean arb_multitexture;
55         qboolean arb_occlusion_query;
56         qboolean arb_query_buffer_object;
57         qboolean arb_shadow;
58         qboolean arb_texture_compression;
59         qboolean arb_texture_cube_map;
60         qboolean arb_texture_env_combine;
61         qboolean arb_texture_gather;
62         qboolean arb_texture_non_power_of_two;
63         qboolean arb_vertex_buffer_object;
64         qboolean arb_uniform_buffer_object;
65         qboolean ati_separate_stencil;
66         qboolean ext_blend_minmax;
67         qboolean ext_blend_subtract;
68         qboolean ext_blend_func_separate;
69         qboolean ext_draw_range_elements;
70         qboolean ext_framebuffer_object;
71         qboolean ext_packed_depth_stencil;
72         qboolean ext_stencil_two_side;
73         qboolean ext_texture_3d;
74         qboolean ext_texture_compression_s3tc;
75         qboolean ext_texture_edge_clamp;
76         qboolean ext_texture_filter_anisotropic;
77         qboolean ext_texture_srgb;
78         qboolean arb_multisample;
79 }
80 viddef_support_t;
81
82 typedef struct viddef_mode_s
83 {
84         int width;
85         int height;
86         int bitsperpixel;
87         qboolean fullscreen;
88         float refreshrate;
89         qboolean userefreshrate;
90         qboolean stereobuffer;
91         int samples;
92 }
93 viddef_mode_t;
94
95 typedef struct viddef_s
96 {
97         // these are set by VID_Mode
98         viddef_mode_t mode;
99         // used in many locations in the renderer
100         int width;
101         int height;
102         int bitsperpixel;
103         qboolean fullscreen;
104         float refreshrate;
105         qboolean userefreshrate;
106         qboolean stereobuffer;
107         int samples;
108         qboolean stencil;
109         qboolean sRGB2D; // whether 2D rendering is sRGB corrected (based on sRGBcapable2D)
110         qboolean sRGB3D; // whether 3D rendering is sRGB corrected (based on sRGBcapable3D)
111         qboolean sRGBcapable2D; // whether 2D rendering can be sRGB corrected (renderpath, v_hwgamma)
112         qboolean sRGBcapable3D; // whether 3D rendering can be sRGB corrected (renderpath, v_hwgamma)
113
114         renderpath_t renderpath;
115         qboolean forcevbo; // some renderpaths can not operate without it
116         qboolean useinterleavedarrays; // required by some renderpaths
117         qboolean allowalphatocoverage; // indicates the GL_AlphaToCoverage function works on this renderpath and framebuffer
118
119         unsigned int texunits;
120         unsigned int teximageunits;
121         unsigned int texarrayunits;
122         unsigned int drawrangeelements_maxvertices;
123         unsigned int drawrangeelements_maxindices;
124
125         unsigned int maxtexturesize_2d;
126         unsigned int maxtexturesize_3d;
127         unsigned int maxtexturesize_cubemap;
128         unsigned int max_anisotropy;
129         unsigned int maxdrawbuffers;
130
131         viddef_support_t support;
132
133         // in RENDERPATH_SOFT this is a 32bpp native-endian ARGB framebuffer
134         // (native-endian ARGB meaning that in little endian it is BGRA bytes,
135         //  in big endian it is ARGB byte order, the format is converted during
136         //  blit to the window)
137         unsigned int *softpixels;
138         unsigned int *softdepthpixels;
139
140         int forcetextype; // always use GL_BGRA for D3D, always use GL_RGBA for GLES, etc
141 } viddef_t;
142
143 // global video state
144 extern viddef_t vid;
145 extern void (*vid_menudrawfn)(void);
146 extern void (*vid_menukeyfn)(int key);
147
148 #define MAXJOYAXIS 16
149 // if this is changed, the corresponding code in vid_shared.c must be updated
150 #define MAXJOYBUTTON 36
151 typedef struct vid_joystate_s
152 {
153         float axis[MAXJOYAXIS]; // -1 to +1
154         unsigned char button[MAXJOYBUTTON]; // 0 or 1
155         qboolean is360; // indicates this joystick is a Microsoft Xbox 360 Controller For Windows
156 }
157 vid_joystate_t;
158
159 extern vid_joystate_t vid_joystate;
160
161 extern cvar_t joy_index;
162 extern cvar_t joy_enable;
163 extern cvar_t joy_detected;
164 extern cvar_t joy_active;
165
166 float VID_JoyState_GetAxis(const vid_joystate_t *joystate, int axis, float sensitivity, float deadzone);
167 void VID_ApplyJoyState(vid_joystate_t *joystate);
168 void VID_BuildJoyState(vid_joystate_t *joystate);
169 void VID_Shared_BuildJoyState_Begin(vid_joystate_t *joystate);
170 void VID_Shared_BuildJoyState_Finish(vid_joystate_t *joystate);
171 int VID_Shared_SetJoystick(int index);
172 qboolean VID_JoyBlockEmulatedKeys(int keycode);
173 void VID_EnableJoystick(qboolean enable);
174
175 extern qboolean vid_hidden;
176 extern qboolean vid_activewindow;
177 extern cvar_t vid_hardwaregammasupported;
178 extern qboolean vid_usinghwgamma;
179 extern qboolean vid_supportrefreshrate;
180
181 extern cvar_t vid_soft;
182 extern cvar_t vid_soft_threads;
183 extern cvar_t vid_soft_interlace;
184
185 extern cvar_t vid_fullscreen;
186 extern cvar_t vid_width;
187 extern cvar_t vid_height;
188 extern cvar_t vid_bitsperpixel;
189 extern cvar_t vid_samples;
190 extern cvar_t vid_refreshrate;
191 extern cvar_t vid_userefreshrate;
192 extern cvar_t vid_touchscreen_density;
193 extern cvar_t vid_touchscreen_xdpi;
194 extern cvar_t vid_touchscreen_ydpi;
195 extern cvar_t vid_vsync;
196 extern cvar_t vid_mouse;
197 extern cvar_t vid_grabkeyboard;
198 extern cvar_t vid_touchscreen;
199 extern cvar_t vid_touchscreen_showkeyboard;
200 extern cvar_t vid_touchscreen_supportshowkeyboard;
201 extern cvar_t vid_stick_mouse;
202 extern cvar_t vid_resizable;
203 extern cvar_t vid_desktopfullscreen;
204 extern cvar_t vid_minwidth;
205 extern cvar_t vid_minheight;
206 extern cvar_t vid_sRGB;
207 extern cvar_t vid_sRGB_fallback;
208
209 extern cvar_t gl_finish;
210
211 extern cvar_t v_gamma;
212 extern cvar_t v_contrast;
213 extern cvar_t v_brightness;
214 extern cvar_t v_color_enable;
215 extern cvar_t v_color_black_r;
216 extern cvar_t v_color_black_g;
217 extern cvar_t v_color_black_b;
218 extern cvar_t v_color_grey_r;
219 extern cvar_t v_color_grey_g;
220 extern cvar_t v_color_grey_b;
221 extern cvar_t v_color_white_r;
222 extern cvar_t v_color_white_g;
223 extern cvar_t v_color_white_b;
224 extern cvar_t v_hwgamma;
225
226 // brand of graphics chip
227 extern const char *gl_vendor;
228 // graphics chip model and other information
229 extern const char *gl_renderer;
230 // begins with 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, or 1.4.0
231 extern const char *gl_version;
232 // extensions list, space separated
233 extern const char *gl_extensions;
234 // WGL, GLX, or AGL
235 extern const char *gl_platform;
236 // another extensions list, containing platform-specific extensions that are
237 // not in the main list
238 extern const char *gl_platformextensions;
239 // name of driver library (opengl32.dll, libGL.so.1, or whatever)
240 extern char gl_driver[256];
241
242 void *GL_GetProcAddress(const char *name);
243 qboolean GL_CheckExtension(const char *minglver_or_ext, const dllfunction_t *funcs, const char *disableparm, int silent);
244
245 void VID_Shared_Init(void);
246
247 void GL_Init (void);
248
249 void VID_ClearExtensions(void);
250 void VID_CheckExtensions(void);
251
252 void VID_Init (void);
253 // Called at startup
254
255 void VID_Shutdown (void);
256 // Called at shutdown
257
258 int VID_SetMode (int modenum);
259 // sets the mode; only used by the Quake engine for resetting to mode 0 (the
260 // base mode) on memory allocation failures
261
262 qboolean VID_InitMode(viddef_mode_t *mode);
263 // allocates and opens an appropriate OpenGL context (and its window)
264
265
266 // sets hardware gamma correction, returns false if the device does not
267 // support gamma control
268 // (ONLY called by VID_UpdateGamma and VID_RestoreSystemGamma)
269 int VID_SetGamma(unsigned short *ramps, int rampsize);
270 // gets hardware gamma correction, returns false if the device does not
271 // support gamma control
272 // (ONLY called by VID_UpdateGamma and VID_RestoreSystemGamma)
273 int VID_GetGamma(unsigned short *ramps, int rampsize);
274 // makes sure ramp arrays are big enough and calls VID_GetGamma/VID_SetGamma
275 // (ONLY to be called from VID_Finish!)
276 void VID_UpdateGamma(qboolean force, int rampsize);
277 // turns off hardware gamma ramps immediately
278 // (called from various shutdown/deactivation functions)
279 void VID_RestoreSystemGamma(void);
280
281 qboolean VID_HasScreenKeyboardSupport(void);
282 void VID_ShowKeyboard(qboolean show);
283 qboolean VID_ShowingKeyboard(void);
284
285 void VID_SetMouse (qboolean fullscreengrab, qboolean relative, qboolean hidecursor);
286 void VID_Finish (void);
287
288 void VID_Restart_f(void);
289
290 void VID_Start(void);
291 void VID_Stop(void);
292
293 extern unsigned int vid_gammatables_serial; // so other subsystems can poll if gamma parameters have changed; this starts with 0 and gets increased by 1 each time the gamma parameters get changed and VID_BuildGammaTables should be called again
294 extern qboolean vid_gammatables_trivial; // this is set to true if all color control values are at default setting, and it therefore would make no sense to use the gamma table
295 void VID_BuildGammaTables(unsigned short *ramps, int rampsize); // builds the current gamma tables into an array (needs 3*rampsize items)
296
297 typedef struct
298 {
299         int width, height, bpp, refreshrate;
300         int pixelheight_num, pixelheight_denom;
301 }
302 vid_mode_t;
303 vid_mode_t *VID_GetDesktopMode(void);
304 size_t VID_ListModes(vid_mode_t *modes, size_t maxcount);
305 size_t VID_SortModes(vid_mode_t *modes, size_t count, qboolean usebpp, qboolean userefreshrate, qboolean useaspect);
306 void VID_Soft_SharedSetup(void);
307
308 #endif
309