]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_backend.h
strncpy -> {strlcpy,memcpy}. Replaced the "forceloop" boolean in "channel_t" by a...
[divverent/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_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 extern cvar_t gl_lockarrays;
30 extern cvar_t gl_mesh_copyarrays;
31 extern cvar_t gl_paranoid;
32 extern cvar_t gl_printcheckerror;
33
34 extern int c_meshelements, c_meshs;
35
36 //input to R_Mesh_State
37 typedef struct
38 {
39         // textures
40         int tex1d[MAX_TEXTUREUNITS];
41         int tex[MAX_TEXTUREUNITS];
42         int tex3d[MAX_TEXTUREUNITS];
43         int texcubemap[MAX_TEXTUREUNITS];
44         // texture combine settings
45         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
46         int texalphascale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
47         int texcombinergb[MAX_TEXTUREUNITS]; // works with or without combine for some operations
48         int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine
49         // matrices
50         matrix4x4_t texmatrix[MAX_TEXTUREUNITS];
51         // pointers
52         const float *pointer_texcoord[MAX_TEXTUREUNITS]; // 2D
53         const float *pointer_texcoord3f[MAX_TEXTUREUNITS]; // 3D
54
55         // other state set by this
56         const float *pointer_vertex;
57         const float *pointer_color;
58 }
59 rmeshstate_t;
60
61 // adds console variables and registers the render module (only call from GL_Init)
62 void gl_backend_init(void);
63
64 // starts mesh rendering for the frame
65 void R_Mesh_Start(void);
66
67 // ends mesh rendering for the frame
68 // (only valid after R_Mesh_Start)
69 void R_Mesh_Finish(void);
70
71 // sets up the requested transform matrix
72 void R_Mesh_Matrix(const matrix4x4_t *matrix);
73
74 // set up the requested state
75 void R_Mesh_State(const rmeshstate_t *m);
76
77 // renders a mesh
78 void R_Mesh_Draw(int numverts, int numtriangles, const int *elements);
79 // renders a mesh as lines
80 void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, const int *elements);
81
82 // saves a section of the rendered frame to a .tga or .jpg file
83 qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height, qboolean jpeg);
84 // used by R_Envmap_f and internally in backend, clears the frame
85 void R_ClearScreen(void);
86 // invoke refresh of frame
87 void SCR_UpdateScreen(void);
88
89 // public structure
90 typedef struct rcachearrayrequest_s
91 {
92         // for use by the code that is requesting the array, these are not
93         // directly used but merely compared to determine if cache items are
94         // identical
95         const void *id_pointer1;
96         const void *id_pointer2;
97         const void *id_pointer3;
98         int id_number1;
99         int id_number2;
100         int id_number3;
101         // size of array data
102         int data_size;
103         // array data pointer
104         void *data;
105 }
106 rcachearrayrequest_t;
107
108 int R_Mesh_CacheArray(rcachearrayrequest_t *r);
109
110 extern float varray_vertex3f[65536*3];
111 extern float varray_color4f[65536*4];
112 extern float varray_texcoord2f[4][65536*2];
113 extern float varray_texcoord3f[4][65536*3];
114 extern float varray_normal3f[65536*3];
115 extern int earray_element3i[65536];
116
117 #endif
118