]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_backend.h
movement packet loss tracking
[divverent/darkplaces.git] / gl_backend.h
1
2 #ifndef GL_BACKEND_H
3 #define GL_BACKEND_H
4
5 #define POLYGONELEMENTS_MAXPOINTS 258
6 extern int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2)*3];
7 extern unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2)*3];
8 #define QUADELEMENTS_MAXQUADS 128
9 extern int quadelement3i[QUADELEMENTS_MAXQUADS*6];
10 extern unsigned short quadelement3s[QUADELEMENTS_MAXQUADS*6];
11
12 void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out);
13 void R_Viewport_InitOrtho(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float x1, float y1, float x2, float y2, float zNear, float zFar, const float *nearplane);
14 void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float zNear, float zFar, const float *nearplane);
15 void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, float frustumx, float frustumy, float zNear, const float *nearplane);
16 void R_Viewport_InitCubeSideView(r_viewport_t *v, const matrix4x4_t *cameramatrix, int side, int size, float nearclip, float farclip, const float *nearplane);
17 void R_Viewport_InitRectSideView(r_viewport_t *v, const matrix4x4_t *cameramatrix, int side, int size, int border, float nearclip, float farclip, const float *nearplane);
18 void R_SetViewport(const r_viewport_t *v);
19 void R_GetViewport(r_viewport_t *v);
20
21 void GL_BlendFunc(int blendfunc1, int blendfunc2);
22 void GL_DepthMask(int state);
23 void GL_DepthTest(int state);
24 void GL_DepthRange(float nearfrac, float farfrac);
25 void GL_PolygonOffset(float planeoffset, float depthoffset);
26 void GL_CullFace(int state);
27 void GL_AlphaTest(int state);
28 void GL_ColorMask(int r, int g, int b, int a);
29 void GL_Color(float cr, float cg, float cb, float ca);
30 void GL_LockArrays(int first, int count);
31 void GL_ActiveTexture(unsigned int num);
32 void GL_ClientActiveTexture(unsigned int num);
33 void GL_Scissor(int x, int y, int width, int height);
34 void GL_ScissorTest(int state);
35 void GL_Clear(int mask);
36
37 unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list);
38 void GL_Backend_FreeProgram(unsigned int prog);
39
40 extern cvar_t gl_lockarrays;
41 extern cvar_t gl_mesh_copyarrays;
42 extern cvar_t gl_paranoid;
43 extern cvar_t gl_printcheckerror;
44
45 // adds console variables and registers the render module (only call from GL_Init)
46 void gl_backend_init(void);
47
48 // starts mesh rendering for the frame
49 void R_Mesh_Start(void);
50
51 // ends mesh rendering for the frame
52 // (only valid after R_Mesh_Start)
53 void R_Mesh_Finish(void);
54
55 // allocates a static element array buffer object
56 // (storing triangle data in video memory)
57 int R_Mesh_CreateStaticEBO(void *data, size_t size);
58 // frees an element array buffer object
59 void R_Mesh_DestroyEBO(int bufferobject);
60 // allocates a static vertex/element array buffer object
61 // (storing vertex or element data in video memory)
62 // target is GL_ELEMENT_ARRAY_BUFFER_ARB (triangle elements)
63 // or GL_ARRAY_BUFFER_ARB (vertex data)
64 int R_Mesh_CreateStaticBufferObject(unsigned int target, void *data, size_t size, const char *name);
65 // frees a vertex/element array buffer object
66 void R_Mesh_DestroyBufferObject(int bufferobject);
67 void GL_Mesh_ListVBOs(qboolean printeach);
68
69 // sets up the requested vertex transform matrix
70 void R_Mesh_Matrix(const matrix4x4_t *matrix);
71 // sets the vertex array pointer
72 void R_Mesh_VertexPointer(const float *vertex3f, int bufferobject, size_t bufferoffset);
73 // sets the color array pointer (GL_Color only works when this is NULL)
74 void R_Mesh_ColorPointer(const float *color4f, int bufferobject, size_t bufferoffset);
75 // sets the texcoord array pointer for an array unit
76 void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord, int bufferobject, size_t bufferoffset);
77 // returns current texture bound to this identifier
78 int R_Mesh_TexBound(unsigned int unitnum, int id);
79 // sets all textures bound to an image unit (multiple can be non-zero at once, according to OpenGL rules the highest one overrides the others)
80 void R_Mesh_TexBindAll(unsigned int unitnum, int tex2d, int tex3d, int texcubemap, int texrectangle);
81 // equivalent to R_Mesh_TexBindAll(unitnum,tex2d,0,0,0)
82 void R_Mesh_TexBind(unsigned int unitnum, int texnum);
83 // sets the texcoord matrix for a texenv unit, can be NULL or blank (will use identity)
84 void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix);
85 // sets the combine state for a texenv unit
86 void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale);
87 // set up a blank texture state (unbinds all textures, texcoord pointers, and resets combine settings)
88 void R_Mesh_ResetTextureState(void);
89
90 // renders a mesh
91 void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const unsigned short *element3s, int bufferobject3i, int bufferobject3s);
92
93 // saves a section of the rendered frame to a .tga or .jpg file
94 qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *buffer2, unsigned char *buffer3, int x, int y, int width, int height, qboolean flipx, qboolean flipy, qboolean flipdiagonal, qboolean jpeg, qboolean gammacorrect);
95 // used by R_Envmap_f and internally in backend, clears the frame
96 void R_ClearScreen(qboolean fogcolor);
97
98 #endif
99