]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_backend.h
DP_EF_RESTARTANIM_BIT
[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, double x1, double y1, double x2, double y2, double zNear, double zFar, const double *nearplane);
14 void R_Viewport_InitPerspective(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, double frustumx, double frustumy, double zNear, double zFar, const double *nearplane);
15 void R_Viewport_InitPerspectiveInfinite(r_viewport_t *v, const matrix4x4_t *cameramatrix, int x, int y, int width, int height, double frustumx, double frustumy, double zNear, const double *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 //input to R_Mesh_TextureState
46 typedef struct rmeshstate_s
47 {
48         // textures
49         int tex[MAX_TEXTUREUNITS];
50         int tex3d[MAX_TEXTUREUNITS];
51         int texcubemap[MAX_TEXTUREUNITS];
52         int texrectangle[MAX_TEXTUREUNITS];
53         // texture combine settings
54         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
55         int texalphascale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
56         int texcombinergb[MAX_TEXTUREUNITS]; // works with or without combine for some operations
57         int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine
58         // matrices
59         matrix4x4_t texmatrix[MAX_TEXTUREUNITS];
60         // pointers
61         const float *pointer_texcoord[MAX_TEXTUREUNITS]; // 2D
62         const float *pointer_texcoord3f[MAX_TEXTUREUNITS]; // 3D
63         int pointer_texcoord_bufferobject[MAX_TEXTUREUNITS]; // 2D and 3D
64         size_t pointer_texcoord_bufferoffset[MAX_TEXTUREUNITS]; // 2D and 3D
65 }
66 rmeshstate_t;
67
68 // adds console variables and registers the render module (only call from GL_Init)
69 void gl_backend_init(void);
70
71 // starts mesh rendering for the frame
72 void R_Mesh_Start(void);
73
74 // ends mesh rendering for the frame
75 // (only valid after R_Mesh_Start)
76 void R_Mesh_Finish(void);
77
78 // allocates a static element array buffer object
79 // (storing triangle data in video memory)
80 int R_Mesh_CreateStaticEBO(void *data, size_t size);
81 // frees an element array buffer object
82 void R_Mesh_DestroyEBO(int bufferobject);
83 // allocates a static vertex/element array buffer object
84 // (storing vertex or element data in video memory)
85 // target is GL_ELEMENT_ARRAY_BUFFER_ARB (triangle elements)
86 // or GL_ARRAY_BUFFER_ARB (vertex data)
87 int R_Mesh_CreateStaticBufferObject(unsigned int target, void *data, size_t size, const char *name);
88 // frees a vertex/element array buffer object
89 void R_Mesh_DestroyBufferObject(int bufferobject);
90 void GL_Mesh_ListVBOs(qboolean printeach);
91
92 // sets up the requested vertex transform matrix
93 void R_Mesh_Matrix(const matrix4x4_t *matrix);
94 // sets the vertex array pointer
95 void R_Mesh_VertexPointer(const float *vertex3f, int bufferobject, size_t bufferoffset);
96 // sets the color array pointer (GL_Color only works when this is NULL)
97 void R_Mesh_ColorPointer(const float *color4f, int bufferobject, size_t bufferoffset);
98 // sets the texcoord array pointer for an array unit
99 void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord, int bufferobject, size_t bufferoffset);
100 // 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)
101 void R_Mesh_TexBindAll(unsigned int unitnum, int tex2d, int tex3d, int texcubemap, int texrectangle);
102 // equivalent to R_Mesh_TexBindAll(unitnum,tex2d,0,0,0)
103 void R_Mesh_TexBind(unsigned int unitnum, int texnum);
104 // sets the texcoord matrix for a texenv unit
105 void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix);
106 // sets the combine state for a texenv unit
107 void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale);
108 // set up the requested texture state
109 void R_Mesh_TextureState(const rmeshstate_t *m);
110 // set up a blank texture state (faster/easier specialized version of R_Mesh_TextureState)
111 void R_Mesh_ResetTextureState(void);
112
113 // renders a mesh
114 void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const unsigned short *element3s, int bufferobject3i, int bufferobject3s);
115
116 // saves a section of the rendered frame to a .tga or .jpg file
117 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);
118 // used by R_Envmap_f and internally in backend, clears the frame
119 void R_ClearScreen(qboolean fogcolor);
120
121 #endif
122