FTEQW
Documentation of the FTE engine source tree.
vid.h
Go to the documentation of this file.
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20// vid.h -- video driver defs
21
22#define VID_CBITS 6
23#define VID_GRADES (1 << VID_CBITS)
24
25// a pixel can be one, two, or four bytes
26typedef qbyte pixel_t;
27
28typedef enum
29{
30 QR_NONE, //server-style operation (no rendering).
31 QR_HEADLESS, //no window/rendering at all (system tray only)
32 QR_OPENGL, //gl+gles+etc.
35 QR_SOFTWARE, //not worth using
37 QR_DIRECT3D12, //no implementation
38 QR_METAL, //no implementation
39 QR_DIRECT3D8 //liimted. available for win95 where d3d8.1+ does not. also only renderer supported on the original xbox, if that's ever relevant.
41
42typedef struct {
43 //you are not allowed to make anything not work if it's not based on these vars...
44 int width;
45 int height;
46 int fullscreen; //0 = windowed. 1 = fullscreen (mode changes). 2 = borderless+maximized
48 int srgb; //<0 = gamma-only. 0 = no srgb at all, >0 full srgb, including textures and stuff
49 int bpp; //16, 24(aka 32), 30, and 48 are meaningful
51 int rate;
52 int wait; //-1 = default, 0 = off, 1 = on, 2 = every other
53 int multisample; //for opengl antialiasing (which requires context stuff)
55 char subrenderer[MAX_QPATH]; //external driver
56 char devicename[MAX_QPATH]; //device name (usually monitor)
58 struct plugvrfuncs_s *vr; //the vr driver we're trying to use.
60#ifndef SERVERONLY
62#endif
63
64typedef struct vrect_s
65{
66 float x,y,width,height;
68typedef struct
69{
70 int x;
71 int y;
72 int width;
73 int height;
74 int maxheight; //vid.pixelheight or so
75} pxrect_t;
76
77//srgb colourspace displays smoother visual gradients, but its more of an illusion than anything else.
78//we can be in a few different modes:
79//linear - rendering is done using some float framebuffer or so. lighting is more correct. textures are converted from srgb colourspace when reading.
80//non-linear - the lame option where lighting is wrong, but used anyway for compat. final colours will be whatever the screen uses (probably srgb, so artwork looks fine)
81//srgb - like linear, except our framebuffer does extra transforms to hide that its storage is actually non-linear.
82#define VID_SRGBAWARE (1u<<0) //we need to convert input srgb values to actual linear values (requires vid_reload to change...)
83#define VID_SRGB_FB_LINEAR (1u<<1) //framebuffer is linear (either the presentation engine is linear, or the blend unit is faking it)
84#define VID_SRGB_FB_FAKED (1u<<2) //renderer is faking it with a linear texture
85#define VID_SRGB_CAPABLE (1u<<3) //we can toggle VID_SRGB_FB_LINEARISED on or off.
86#define VID_FP16 (1u<<4) //use 16bit currentrender etc to avoid banding
87#define VID_SRGB_FB (VID_SRGB_FB_LINEAR|VID_SRGB_FB_FAKED)
88
89typedef struct
90{
92 qboolean isminimized; //can omit rendering as it won't be seen anyway.
93 int fullbright; // index of first fullbright color
94 int gammarampsize; //typically 256. but can be up to 1024 (yay 10-bit hardware that's crippled to only actually use 8)
95
96 unsigned fbvwidth; /*virtual 2d width of the current framebuffer image*/
97 unsigned fbvheight; /*virtual 2d height*/
98 unsigned fbpwidth; /*physical 2d width of the current framebuffer image*/
99 unsigned fbpheight; /*physical 2d height*/
100 struct image_s *framebuffer; /*the framebuffer fbo (set by democapture)*/
101
102 unsigned width; /*virtual 2d screen width*/
103 unsigned height; /*virtual 2d screen height*/
104
106 unsigned int flags; //VID_* flags
107
108 unsigned rotpixelwidth; /*width after rotation in pixels*/
109 unsigned rotpixelheight; /*pixel after rotation in pixels*/
110 unsigned pixelwidth; /*true height in pixels*/
111 unsigned pixelheight; /*true width in pixels*/
112
113 float dpi_x;
114 float dpi_y;
115
116 conchar_t *ime_preview; //pending IME preview text that has been entered but isn't committed yet. set by video code.
118 size_t ime_caret;
119 float ime_position[2]; //where to display any ime popups (virtual coords)
120 qboolean ime_allow; //enable the ime (ie: at the console or messagemode)
121
123 float forcecursorpos[2]; //in physical pixels
124
125 struct plugvrfuncs_s *vr; //how do deal with VR contexts.
126} viddef_t;
127
128extern viddef_t vid; // global video state
129
130extern unsigned int d_8to24rgbtable[256];
131extern unsigned int d_8to24srgbtable[256];
132extern unsigned int d_8to24bgrtable[256];
133extern unsigned int d_quaketo24srgbtable[256];
qboolean
Definition: api_menu.h:34
unsigned int conchar_t
Definition: common.h:476
unsigned char qbyte
Definition: common.h:127
Definition: merged.h:238
Definition: vr.h:72
Definition: vid.h:69
int width
Definition: vid.h:72
int x
Definition: vid.h:70
int height
Definition: vid.h:73
int maxheight
Definition: vid.h:74
int y
Definition: vid.h:71
Definition: merged.h:422
Definition: vid.h:42
qboolean stereo
Definition: vid.h:47
int wait
Definition: vid.h:52
int width
Definition: vid.h:44
int triplebuffer
Definition: vid.h:54
int multisample
Definition: vid.h:53
int srgb
Definition: vid.h:48
int rate
Definition: vid.h:51
int bpp
Definition: vid.h:49
struct rendererinfo_s * renderer
Definition: vid.h:57
struct plugvrfuncs_s * vr
Definition: vid.h:58
int depthbits
Definition: vid.h:50
int fullscreen
Definition: vid.h:46
int height
Definition: vid.h:45
Definition: vid.h:90
qboolean isminimized
Definition: vid.h:92
struct image_s * framebuffer
Definition: vid.h:100
unsigned width
Definition: vid.h:102
size_t ime_previewlen
Definition: vid.h:117
unsigned fbpwidth
Definition: vid.h:98
qboolean ime_allow
Definition: vid.h:120
unsigned pixelheight
Definition: vid.h:111
int gammarampsize
Definition: vid.h:94
unsigned int flags
Definition: vid.h:106
unsigned fbpheight
Definition: vid.h:99
struct plugvrfuncs_s * vr
Definition: vid.h:125
size_t ime_caret
Definition: vid.h:118
float dpi_x
Definition: vid.h:113
qboolean forcecursor
Definition: vid.h:122
unsigned rotpixelwidth
Definition: vid.h:108
unsigned height
Definition: vid.h:103
qboolean activeapp
Definition: vid.h:91
int numpages
Definition: vid.h:105
conchar_t * ime_preview
Definition: vid.h:116
int fullbright
Definition: vid.h:93
unsigned fbvwidth
Definition: vid.h:96
unsigned rotpixelheight
Definition: vid.h:109
float dpi_y
Definition: vid.h:114
unsigned fbvheight
Definition: vid.h:97
unsigned pixelwidth
Definition: vid.h:110
Definition: vid.h:65
float y
Definition: vid.h:66
float width
Definition: vid.h:66
float x
Definition: vid.h:66
float height
Definition: vid.h:66
rendererstate_t currentrendererstate
Definition: renderer.c:356
unsigned int d_quaketo24srgbtable[256]
Definition: renderer.c:50
unsigned int d_8to24srgbtable[256]
Definition: renderer.c:48
qbyte pixel_t
Definition: vid.h:26
r_qrenderer_t
Definition: vid.h:29
@ QR_DIRECT3D8
Definition: vid.h:39
@ QR_NONE
Definition: vid.h:30
@ QR_SOFTWARE
Definition: vid.h:35
@ QR_HEADLESS
Definition: vid.h:31
@ QR_DIRECT3D12
Definition: vid.h:37
@ QR_DIRECT3D11
Definition: vid.h:34
@ QR_DIRECT3D9
Definition: vid.h:33
@ QR_OPENGL
Definition: vid.h:32
@ QR_VULKAN
Definition: vid.h:36
@ QR_METAL
Definition: vid.h:38
struct vrect_s vrect_t
viddef_t vid
Definition: cl_screen.c:226
unsigned int d_8to24rgbtable[256]
Definition: renderer.c:47
unsigned int d_8to24bgrtable[256]
Definition: renderer.c:49