-#define MAX_TEXTUREUNITS 8
-
-extern int c_meshtris, c_meshs, c_transtris, c_transmeshs;
-
-typedef struct
-{
- int transparent;
- int depthwrite; // force depth writing enabled even if polygon is not opaque
- int depthdisable; // disable depth read/write entirely
- int blendfunc1;
- int blendfunc2;
- int numtriangles;
- int *index;
- int numverts;
- float *vertex;
- int vertexstep;
- float *color;
- int colorstep;
- float cr, cg, cb, ca; // if color is NULL, these are used for all vertices
- int tex[MAX_TEXTUREUNITS];
- float *texcoords[MAX_TEXTUREUNITS];
- int texcoordstep[MAX_TEXTUREUNITS];
- float texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
-}
-rmeshinfo_t;
-
-typedef struct
-{
- //input to R_Mesh_Draw_GetBuffer
- int transparent;
- int depthwrite; // force depth writing enabled even if polygon is not opaque
- int depthdisable; // disable depth read/write entirely
- int blendfunc1;
- int blendfunc2;
- int numtriangles;
- int numverts;
- int tex[MAX_TEXTUREUNITS];
- float texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
-
- // output
- int *index;
- float *vertex;
- float *color;
- float colorscale;
- float *texcoords[MAX_TEXTUREUNITS];
-}
-rmeshbufferinfo_t;
+#ifndef GL_BACKEND_H
+#define GL_BACKEND_H
+
+extern r_viewport_t gl_viewport;
+extern matrix4x4_t gl_modelmatrix;
+extern matrix4x4_t gl_viewmatrix;
+extern matrix4x4_t gl_modelviewmatrix;
+extern matrix4x4_t gl_projectionmatrix;
+extern matrix4x4_t gl_modelviewprojectionmatrix;
+extern float gl_modelview16f[16];
+extern float gl_modelviewprojection16f[16];
+extern qboolean gl_modelmatrixchanged;
+
+#define POLYGONELEMENTS_MAXPOINTS 258
+extern int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2)*3];
+extern unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2)*3];
+#define QUADELEMENTS_MAXQUADS 128
+extern int quadelement3i[QUADELEMENTS_MAXQUADS*6];
+extern unsigned short quadelement3s[QUADELEMENTS_MAXQUADS*6];
+
+void R_Viewport_TransformToScreen(const r_viewport_t *v, const vec4_t in, vec4_t out);
+qboolean R_ScissorForBBox(const float *mins, const float *maxs, int *scissor);
+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);
+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);
+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);
+void R_Viewport_InitCubeSideView(r_viewport_t *v, const matrix4x4_t *cameramatrix, int side, int size, float nearclip, float farclip, const float *nearplane);
+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);
+void R_SetViewport(const r_viewport_t *v);
+void R_GetViewport(r_viewport_t *v);
+
+void GL_BlendFunc(int blendfunc1, int blendfunc2);
+void GL_DepthMask(int state);
+void GL_DepthTest(int state);
+void GL_DepthFunc(int state);
+void GL_DepthRange(float nearfrac, float farfrac);
+void R_SetStencilSeparate(qboolean enable, int writemask, int frontfail, int frontzfail, int frontzpass, int backfail, int backzfail, int backzpass, int frontcompare, int backcompare, int comparereference, int comparemask);
+void R_SetStencil(qboolean enable, int writemask, int fail, int zfail, int zpass, int compare, int comparereference, int comparemask);
+void GL_PolygonOffset(float planeoffset, float depthoffset);
+void GL_CullFace(int state);
+void GL_AlphaTest(int state);
+void GL_AlphaFunc(int state, float value);
+void GL_ColorMask(int r, int g, int b, int a);
+void GL_Color(float cr, float cg, float cb, float ca);
+void GL_ActiveTexture(unsigned int num);
+void GL_ClientActiveTexture(unsigned int num);
+void GL_Scissor(int x, int y, int width, int height);
+void GL_ScissorTest(int state);
+void GL_Clear(int mask, const float *colorvalue, float depthvalue, int stencilvalue);
+void GL_ReadPixelsBGRA(int x, int y, int width, int height, unsigned char *outpixels);
+int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
+void R_Mesh_DestroyFramebufferObject(int fbo);
+void R_Mesh_ResetRenderTargets(void);
+void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
+
+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);
+void GL_Backend_FreeProgram(unsigned int prog);
+
+extern cvar_t gl_paranoid;
+extern cvar_t gl_printcheckerror;