]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - gl_backend.h
cf828683c9848c68cddf2353d2249c44141b233b
[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_Orientation_Identity(void);
11 void GL_SetupView_Orientation_FromEntity(matrix4x4_t *matrix);
12 void GL_SetupView_Mode_Perspective(double fovx, double fovy, double zNear, double zFar);
13 void GL_SetupView_Mode_PerspectiveInfiniteFarClip(double fovx, double fovy, double zNear);
14 void GL_SetupView_Mode_Ortho(double x1, double y1, double x2, double y2, double zNear, double zFar);
15 void GL_BlendFunc(int blendfunc1, int blendfunc2);
16 void GL_DepthMask(int state);
17 void GL_DepthTest(int state);
18 void GL_VertexPointer(const float *p);
19 void GL_ColorPointer(const float *p);
20 void GL_Color(float cr, float cg, float cb, float ca);
21 void GL_TransformToScreen(const vec4_t in, vec4_t out);
22 void GL_LockArrays(int first, int count);
23 void GL_ActiveTexture(int num);
24 void GL_ClientActiveTexture(int num);
25 void GL_Scissor(int x, int y, int width, int height); // AK for DRAWQUEUE_SETCLIP
26 void GL_ScissorTest(int state); // AK for DRAWQUEUE_(RE)SETCLIP
27
28 extern cvar_t gl_lockarrays;
29 extern cvar_t gl_mesh_copyarrays;
30 extern cvar_t gl_paranoid;
31 extern cvar_t gl_printcheckerror;
32
33 extern int c_meshelements, c_meshs;
34
35 //input to R_Mesh_State
36 typedef struct
37 {
38         // textures
39         int tex1d[MAX_TEXTUREUNITS];
40         int tex[MAX_TEXTUREUNITS];
41         int tex3d[MAX_TEXTUREUNITS];
42         int texcubemap[MAX_TEXTUREUNITS];
43         // texture combine settings
44         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
45         int texalphascale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
46         int texcombinergb[MAX_TEXTUREUNITS]; // works with or without combine for some operations
47         int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine
48         // pointers
49         const float *pointer_texcoord[MAX_TEXTUREUNITS];
50 }
51 rmeshstate_t;
52
53 // adds console variables and registers the render module (only call from GL_Init)
54 void gl_backend_init(void);
55
56 // starts mesh rendering for the frame
57 void R_Mesh_Start(void);
58
59 // ends mesh rendering for the frame
60 // (only valid after R_Mesh_Start)
61 void R_Mesh_Finish(void);
62
63 // sets up the requested transform matrix
64 void R_Mesh_Matrix(const matrix4x4_t *matrix);
65
66 // sets up the requested transform matrix
67 void R_Mesh_TextureMatrix(int unitnumber, const matrix4x4_t *matrix);
68
69 // set up the requested state
70 void R_Mesh_State_Texture(const rmeshstate_t *m);
71
72 // renders a mesh
73 void R_Mesh_Draw(int numverts, int numtriangles, const int *elements);
74 // renders a mesh as lines
75 void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, int *elements);
76
77 // saves a section of the rendered frame to a .tga or .jpg file
78 qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean jpeg);
79 // used by R_Envmap_f and internally in backend, clears the frame
80 void R_ClearScreen(void);
81 // invoke refresh of frame
82 void SCR_UpdateScreen(void);
83
84 // public structure
85 typedef struct rcachearrayrequest_s
86 {
87         // for use by the code that is requesting the array, these are not
88         // directly used but merely compared to determine if cache items are
89         // identical
90         const void *id_pointer1;
91         const void *id_pointer2;
92         const void *id_pointer3;
93         int id_number1;
94         int id_number2;
95         int id_number3;
96         // size of array data
97         int data_size;
98         // array data pointer
99         void *data;
100 }
101 rcachearrayrequest_t;
102
103 int R_Mesh_CacheArray(rcachearrayrequest_t *r);
104
105 extern float varray_vertex3f[65536*3];
106 extern float varray_color4f[65536*4];
107 extern float varray_texcoord2f[4][65536*2];
108 extern float varray_texcoord3f[4][65536*3];
109 extern float varray_normal3f[65536*3];
110 extern int earray_element3i[65536];
111
112 #endif
113