]> icculus.org git repositories - divverent/darkplaces.git/blob - gl_backend.h
some cleanup of map texture loading and related code (mainly better support for untex...
[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 extern int c_meshtris, c_meshs, c_transtris, c_transmeshs;
8
9 typedef struct
10 {
11         int transparent;
12         int depthwrite; // force depth writing enabled even if polygon is not opaque
13         int depthdisable; // disable depth read/write entirely
14         int blendfunc1;
15         int blendfunc2;
16         int numtriangles;
17         int *index;
18         int numverts;
19         float *vertex;
20         int vertexstep;
21         float *color;
22         int colorstep;
23         float cr, cg, cb, ca; // if color is NULL, these are used for all vertices
24         int tex[MAX_TEXTUREUNITS];
25         float *texcoords[MAX_TEXTUREUNITS];
26         int texcoordstep[MAX_TEXTUREUNITS];
27         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
28 }
29 rmeshinfo_t;
30
31 typedef struct
32 {
33         //input to R_Mesh_Draw_GetBuffer
34         int transparent;
35         int depthwrite; // force depth writing enabled even if polygon is not opaque
36         int depthdisable; // disable depth read/write entirely
37         int blendfunc1;
38         int blendfunc2;
39         int numtriangles;
40         int numverts;
41         int tex[MAX_TEXTUREUNITS];
42         int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
43
44         // output
45         int *index;
46         float *vertex;
47         float *color;
48         float colorscale;
49         float *texcoords[MAX_TEXTUREUNITS];
50 }
51 rmeshbufferinfo_t;
52
53 // adds console variables and registers the render module (only call from GL_Init)
54 void gl_backend_init(void);
55
56 // starts mesh rendering for the frame
57 void R_Mesh_Start(void);
58
59 // ends mesh rendering for the frame
60 // (only valid after R_Mesh_Start)
61 void R_Mesh_Finish(void);
62
63 // clears depth buffer, used for masked sky rendering
64 // (only valid between R_Mesh_Start and R_Mesh_Finish)
65 void R_Mesh_ClearDepth(void);
66
67 // renders current batch of meshs
68 // (only valid between R_Mesh_Start and R_Mesh_Finish)
69 void R_Mesh_Render(void);
70
71 // queues a mesh to be rendered (invokes Render if queue is full)
72 // (only valid between R_Mesh_Start and R_Mesh_Finish)
73 void R_Mesh_Draw(const rmeshinfo_t *m);
74
75 // renders the queued transparent meshs
76 // (only valid between R_Mesh_Start and R_Mesh_Finish)
77 void R_Mesh_AddTransparent(void);
78
79 // ease-of-use frontend to R_Mesh_Draw, set up meshinfo, except for index and numtriangles and numverts, then call this
80 // (only valid between R_Mesh_Start and R_Mesh_Finish)
81 void R_Mesh_DrawPolygon(rmeshinfo_t *m, int numverts);
82
83 // same as normal, except for harsh format restrictions (vertex must be 4 float, color must be 4 float, texcoord must be 2 float, flat color not supported)
84 // (only valid between R_Mesh_Start and R_Mesh_Finish)
85 void R_Mesh_Draw_NativeOnly(const rmeshinfo_t *m);
86
87 // allocates space in geometry buffers, and fills in pointers to the buffers in passsed struct
88 // (this is used for very high speed rendering, no copying)
89 // (only valid between R_Mesh_Start and R_Mesh_Finish)
90 int R_Mesh_Draw_GetBuffer(rmeshbufferinfo_t *m);
91
92 // saves a section of the rendered frame to a .tga file
93 qboolean SCR_ScreenShot(char *filename, int x, int y, int width, int height);
94 // used by R_Envmap_f and internally in backend, clears the frame
95 void R_ClearScreen(void);
96 // invoke refresh of frame
97 void SCR_UpdateScreen (void);
98
99 #endif
100