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