]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_backend.h
more stupid error code passing
[divverent/darkplaces.git] / gl_backend.h
1
2 #ifndef GL_BACKEND_H
3 #define GL_BACKEND_H
4
5 // how many texture units to track state on (backendunits/backendimageunits/backendarrayunits are limited to this value)
6 #define MAX_TEXTUREUNITS 64
7
8 #define POLYGONELEMENTS_MAXPOINTS 258
9 extern int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2)*3];
10 extern unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2)*3];
11 #define QUADELEMENTS_MAXQUADS 128
12 extern int quadelement3i[QUADELEMENTS_MAXQUADS*6];
13 extern unsigned short quadelement3s[QUADELEMENTS_MAXQUADS*6];
14
15 void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out);
16 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);
17 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);
18 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);
19 void R_Viewport_InitCubeSideView(r_viewport_t *v, const matrix4x4_t *cameramatrix, int side, int size, float nearclip, float farclip, const float *nearplane);
20 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);
21 void R_SetViewport(const r_viewport_t *v);
22 void R_GetViewport(r_viewport_t *v);
23
24 void GL_BlendFunc(int blendfunc1, int blendfunc2);
25 void GL_DepthMask(int state);
26 void GL_DepthTest(int state);
27 void GL_DepthRange(float nearfrac, float farfrac);
28 void GL_PolygonOffset(float planeoffset, float depthoffset);
29 void GL_CullFace(int state);
30 void GL_AlphaTest(int state);
31 void GL_ColorMask(int r, int g, int b, int a);
32 void GL_Color(float cr, float cg, float cb, float ca);
33 void GL_LockArrays(int first, int count);
34 void GL_ActiveTexture(unsigned int num);
35 void GL_ClientActiveTexture(unsigned int num);
36 void GL_Scissor(int x, int y, int width, int height);
37 void GL_ScissorTest(int state);
38 void GL_Clear(int mask);
39
40 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);
41 void GL_Backend_FreeProgram(unsigned int prog);
42
43 extern cvar_t gl_lockarrays;
44 extern cvar_t gl_mesh_copyarrays;
45 extern cvar_t gl_paranoid;
46 extern cvar_t gl_printcheckerror;
47
48 //input to R_Mesh_TextureState
49 typedef struct rmeshstate_s
50 {
51         // textures
52         int tex1d[MAX_TEXTUREUNITS];
53         int tex[MAX_TEXTUREUNITS];
54         int tex3d[MAX_TEXTUREUNITS];
55         int texcubemap[MAX_TEXTUREUNITS];
56         int texrectangle[MAX_TEXTUREUNITS];
57         // texture combine settings
58         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
59         int texalphascale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
60         int texcombinergb[MAX_TEXTUREUNITS]; // works with or without combine for some operations
61         int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine
62         // matrices
63         matrix4x4_t texmatrix[MAX_TEXTUREUNITS];
64         // pointers
65         const float *pointer_texcoord[MAX_TEXTUREUNITS]; // 2D
66         const float *pointer_texcoord3f[MAX_TEXTUREUNITS]; // 3D
67         int pointer_texcoord_bufferobject[MAX_TEXTUREUNITS]; // 2D and 3D
68         size_t pointer_texcoord_bufferoffset[MAX_TEXTUREUNITS]; // 2D and 3D
69 }
70 rmeshstate_t;
71
72 // adds console variables and registers the render module (only call from GL_Init)
73 void gl_backend_init(void);
74
75 // starts mesh rendering for the frame
76 void R_Mesh_Start(void);
77
78 // ends mesh rendering for the frame
79 // (only valid after R_Mesh_Start)
80 void R_Mesh_Finish(void);
81
82 // allocates a static element array buffer object
83 // (storing triangle data in video memory)
84 int R_Mesh_CreateStaticEBO(void *data, size_t size);
85 // frees an element array buffer object
86 void R_Mesh_DestroyEBO(int bufferobject);
87 // allocates a static vertex/element array buffer object
88 // (storing vertex or element data in video memory)
89 // target is GL_ELEMENT_ARRAY_BUFFER_ARB (triangle elements)
90 // or GL_ARRAY_BUFFER_ARB (vertex data)
91 int R_Mesh_CreateStaticBufferObject(unsigned int target, void *data, size_t size, const char *name);
92 // frees a vertex/element array buffer object
93 void R_Mesh_DestroyBufferObject(int bufferobject);
94 void GL_Mesh_ListVBOs(qboolean printeach);
95
96 // sets up the requested vertex transform matrix
97 void R_Mesh_Matrix(const matrix4x4_t *matrix);
98 // sets the vertex array pointer
99 void R_Mesh_VertexPointer(const float *vertex3f, int bufferobject, size_t bufferoffset);
100 // sets the color array pointer (GL_Color only works when this is NULL)
101 void R_Mesh_ColorPointer(const float *color4f, int bufferobject, size_t bufferoffset);
102 // sets the texcoord array pointer for an array unit
103 void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord, int bufferobject, size_t bufferoffset);
104 // 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)
105 void R_Mesh_TexBindAll(unsigned int unitnum, int tex1d, int tex2d, int tex3d, int texcubemap, int texrectangle);
106 // sets these are like TexBindAll with only one of the texture indices non-zero
107 // (binds one texture type and unbinds all other types)
108 void R_Mesh_TexBind1D(unsigned int unitnum, int texnum);
109 void R_Mesh_TexBind(unsigned int unitnum, int texnum);
110 void R_Mesh_TexBind3D(unsigned int unitnum, int texnum);
111 void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum);
112 void R_Mesh_TexBindRectangle(unsigned int unitnum, int texnum);
113 // sets the texcoord matrix for a texenv unit
114 void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix);
115 // sets the combine state for a texenv unit
116 void R_Mesh_TexCombine(unsigned int unitnum, int combinergb, int combinealpha, int rgbscale, int alphascale);
117 // set up the requested texture state
118 void R_Mesh_TextureState(const rmeshstate_t *m);
119 // set up a blank texture state (faster/easier specialized version of R_Mesh_TextureState)
120 void R_Mesh_ResetTextureState(void);
121
122 // renders a mesh
123 void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const unsigned short *element3s, int bufferobject3i, int bufferobject3s);
124
125 // saves a section of the rendered frame to a .tga or .jpg file
126 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);
127 // used by R_Envmap_f and internally in backend, clears the frame
128 void R_ClearScreen(qboolean fogcolor);
129
130 #endif
131