]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_backend.h
no longer hits triangles of your own player model when tracing the prydoncursor from...
[divverent/darkplaces.git] / gl_backend.h
1
2 #ifndef GL_BACKEND_H
3 #define GL_BACKEND_H
4
5 #define MAX_TEXTUREUNITS 16
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_ColorMask(int r, int g, int b, int a);
19 void GL_Color(float cr, float cg, float cb, float ca);
20 void GL_ShowTrisColor(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 void GL_Clear(int mask);
28
29 unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int fragmentstrings_count, const char **fragmentstrings_list);
30 void GL_Backend_FreeProgram(unsigned int prog);
31
32 extern cvar_t gl_lockarrays;
33 extern cvar_t gl_mesh_copyarrays;
34 extern cvar_t gl_paranoid;
35 extern cvar_t gl_printcheckerror;
36
37 //input to R_Mesh_State
38 typedef struct
39 {
40         // textures
41         int tex1d[MAX_TEXTUREUNITS];
42         int tex[MAX_TEXTUREUNITS];
43         int tex3d[MAX_TEXTUREUNITS];
44         int texcubemap[MAX_TEXTUREUNITS];
45         // texture combine settings
46         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
47         int texalphascale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
48         int texcombinergb[MAX_TEXTUREUNITS]; // works with or without combine for some operations
49         int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine
50         // matrices
51         matrix4x4_t texmatrix[MAX_TEXTUREUNITS];
52         // pointers
53         const float *pointer_texcoord[MAX_TEXTUREUNITS]; // 2D
54         const float *pointer_texcoord3f[MAX_TEXTUREUNITS]; // 3D
55
56         // other state set by this
57         const float *pointer_vertex;
58         const float *pointer_color;
59 }
60 rmeshstate_t;
61
62 // adds console variables and registers the render module (only call from GL_Init)
63 void gl_backend_init(void);
64
65 // starts mesh rendering for the frame
66 void R_Mesh_Start(void);
67
68 // ends mesh rendering for the frame
69 // (only valid after R_Mesh_Start)
70 void R_Mesh_Finish(void);
71
72 // sets up the requested transform matrix
73 void R_Mesh_Matrix(const matrix4x4_t *matrix);
74
75 // set up the requested state
76 void R_Mesh_State(const rmeshstate_t *m);
77
78 // renders a mesh
79 void R_Mesh_Draw(int numverts, int numtriangles, const int *elements);
80 // renders a mesh as lines
81 void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, const int *elements);
82
83 // saves a section of the rendered frame to a .tga or .jpg file
84 qboolean SCR_ScreenShot(char *filename, qbyte *buffer1, qbyte *buffer2, qbyte *buffer3, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg);
85 // used by R_Envmap_f and internally in backend, clears the frame
86 void R_ClearScreen(void);
87 // invoke refresh of frame
88 void SCR_UpdateScreen(void);
89 // invoke refresh of loading plaque (nothing else seen)
90 void SCR_UpdateLoadingScreen(void);
91
92 // public structure
93 typedef struct rcachearrayrequest_s
94 {
95         // for use by the code that is requesting the array, these are not
96         // directly used but merely compared to determine if cache items are
97         // identical
98         const void *id_pointer1;
99         const void *id_pointer2;
100         const void *id_pointer3;
101         int id_number1;
102         int id_number2;
103         int id_number3;
104         // size of array data
105         int data_size;
106         // array data pointer
107         void *data;
108 }
109 rcachearrayrequest_t;
110
111 int R_Mesh_CacheArray(rcachearrayrequest_t *r);
112
113 extern float varray_vertex3f[65536*3];
114 extern float varray_svector3f[65536*3];
115 extern float varray_tvector3f[65536*3];
116 extern float varray_normal3f[65536*3];
117 extern float varray_color4f[65536*4];
118 extern float varray_texcoord2f[4][65536*2];
119 extern float varray_texcoord3f[4][65536*3];
120 extern int earray_element3i[65536];
121 extern float varray_vertex3f2[65536*3];
122
123 #endif
124