]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - gl_backend.h
varray_* rewritten to remove padding (varray_vertex3f, varray_texcoord2f, varray_texc...
[xonotic/darkplaces.git] / gl_backend.h
1
2 #ifndef GL_BACKEND_H
3 #define GL_BACKEND_H
4
5 #define MAX_TEXTUREUNITS 8
6
7 #define POLYGONELEMENTS_MAXPOINTS 258
8 extern int polygonelements[768];
9
10 void GL_SetupView_ViewPort (int x, int y, int width, int height);
11 void GL_SetupView_Orientation_Identity (void);
12 void GL_SetupView_Orientation_FromEntity (vec3_t origin, vec3_t angles);
13 void GL_SetupView_Mode_Perspective (double fovx, double fovy, double zNear, double zFar);
14 void GL_SetupView_Mode_PerspectiveInfiniteFarClip (double fovx, double fovy, double zNear);
15 void GL_SetupView_Mode_Ortho (double x1, double y1, double x2, double y2, double zNear, double zFar);
16 void GL_UseColorArray(void);
17 void GL_Color(float cr, float cg, float cb, float ca);
18 void GL_TransformToScreen(const vec4_t in, vec4_t out);
19
20 extern cvar_t gl_lockarrays;
21
22 extern int c_meshelements, c_meshs;
23
24 //input to R_Mesh_State
25 typedef struct
26 {
27         int depthwrite; // force depth writing enabled even if polygon is not opaque
28         int depthdisable; // disable depth read/write entirely
29         int blendfunc1;
30         int blendfunc2;
31         //int wantoverbright;
32         int tex1d[MAX_TEXTUREUNITS];
33         int tex[MAX_TEXTUREUNITS];
34         int tex3d[MAX_TEXTUREUNITS];
35         int texcubemap[MAX_TEXTUREUNITS];
36         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
37         int texalphascale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
38         int texcombinergb[MAX_TEXTUREUNITS]; // works with or without combine for some operations
39         int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine
40 }
41 rmeshstate_t;
42
43 // overbright rendering scale for the current state
44 extern int r_lightmapscalebit;
45 extern float r_colorscale;
46 extern float *varray_vertex3f;
47 extern float *varray_color4f;
48 extern float *varray_texcoord3f[MAX_TEXTUREUNITS];
49 extern float *varray_texcoord2f[MAX_TEXTUREUNITS];
50 extern int mesh_maxverts;
51
52 // adds console variables and registers the render module (only call from GL_Init)
53 void gl_backend_init(void);
54
55 // starts mesh rendering for the frame
56 void R_Mesh_Start(void);
57
58 // ends mesh rendering for the frame
59 // (only valid after R_Mesh_Start)
60 void R_Mesh_Finish(void);
61
62 // sets up the requested transform matrix
63 void R_Mesh_Matrix(const matrix4x4_t *matrix);
64
65 // sets up the requested state
66 void R_Mesh_State(const rmeshstate_t *m);
67
68 // sets up the requested main state
69 void R_Mesh_MainState(const rmeshstate_t *m);
70
71 // sets up the requested texture state
72 void R_Mesh_TextureState(const rmeshstate_t *m);
73
74 // prepares varray_* buffers for rendering a mesh
75 void R_Mesh_GetSpace(int numverts);
76 // renders the mesh in the varray_* buffers
77 void R_Mesh_Draw(int numverts, int numtriangles, const int *elements);
78
79 // copies a vertex3f array into varray_vertex3f
80 void R_Mesh_CopyVertex3f(const float *vertex3f, int numverts);
81 // copies a texcoord2f array into varray_texcoord[tmu]
82 void R_Mesh_CopyTexCoord2f(int tmu, const float *texcoord2f, int numverts);
83 // copies a color4f array into varray_color4f
84 void R_Mesh_CopyColor4f(const float *color4f, int numverts);
85
86 // saves a section of the rendered frame to a .tga file
87 qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height);
88 // used by R_Envmap_f and internally in backend, clears the frame
89 void R_ClearScreen(void);
90 // invoke refresh of frame
91 void SCR_UpdateScreen (void);
92
93 #endif
94