]> icculus.org git repositories - theoddone33/hheretic.git/blob - include/ogl_def.h
Initial revision
[theoddone33/hheretic.git] / include / ogl_def.h
1 #ifndef __H2OPENGL__
2 #define __H2OPENGL__
3
4 #include "r_local.h"
5 #include <GL/gl.h>
6
7
8 #ifdef __linux__
9 #define _alloca alloca
10 #endif
11
12
13 enum {VX, VY};  // Vertex indices.
14
15 typedef struct // For dynamic lighting.
16 {
17         int             use;                            
18         mobj_t  *thing;
19         float   top, height;
20 } lumobj_t;
21
22 // ScreenBits is currently unused.
23 extern int screenWidth, screenHeight, screenBits;
24
25 void I_InitGraphics(void);
26 void I_ShutdownGraphics(void);
27
28 void OGL_InitRenderer(void);
29 void OGL_InitData(void);
30 void OGL_ResetData(void);
31
32 void OGL_SwitchTo3DState();
33 void OGL_Restore2DState(int step);      // Step 1: matrices, 2: attributes.
34 void OGL_UseWhiteFog(int yes);
35
36 float PointDist2D(float c[2]);
37
38 void R_RenderSprite(vissprite_t *spr);
39
40 // 2D drawing routines.
41 void OGL_DrawPatch_CS(int x, int y, int lumpnum);
42 void OGL_DrawPatch(int x, int y, int lumpnum);
43 void OGL_DrawFuzzPatch(int x, int y, int lumpnum);
44 void OGL_DrawAltFuzzPatch(int x, int y, int lumpnum);
45 void OGL_DrawShadowedPatch(int x, int y, int lumpnum);
46 void OGL_DrawRawScreen(int lump);       // Raw screens are 320 x 200.
47 void OGL_DrawLine(float x1, float y1, float x2, float y2, 
48                                   float r, float g, float b, float a);
49 void OGL_DrawRect(float x, float y, float w, float h, float r, float g, float b, float a);
50 void OGL_DrawRectTiled(int x, int y, int w, int h, int tw, int th);
51 void OGL_DrawCutRectTiled(int x, int y, int w, int h, int tw, int th, 
52                                                   int cx, int cy, int cw, int ch);
53 void OGL_SetColor(int palidx);
54 void OGL_SetColorAndAlpha(float r, float g, float b, float a);
55 void OGL_DrawPSprite(int x, int y, float scale, int flip, int lump);
56
57 // Filters.
58 void OGL_SetFilter(int filter);
59 int OGL_DrawFilter();
60
61
62 // ogl_tex.c
63 typedef struct
64 {
65         unsigned short  w, h;
66         short                   offx, offy;
67         unsigned short  w2;             // For split textures, width of the other part.
68 } texsize_t;
69
70 extern texsize_t *lumptexsizes; // Sizes for all the lumps. 
71 extern unsigned short *spriteheights;
72
73 extern float            texw, texh;
74 extern int                      texmask;        
75 extern unsigned int     curtex;
76 extern int                      pallump;
77
78 int FindNextPower2(int num);
79 float NextPower2Ratio(int num);
80 void OGL_TexInit();
81 void OGL_TexReset();
82 void OGL_ResetLumpTexData();
83 void PalToRGB(byte *palidx, byte *rgb);
84 void PalIdxToRGB(byte *pal, int idx, byte *rgb);
85 unsigned int OGL_BindTexFlat(int lump);
86 void OGL_SetFlat(int idx);
87 void OGL_BindTexture(GLuint texname);
88
89 // Returns the OpenGL texture name.
90 GLuint OGL_PrepareTexture(int idx);
91 GLuint OGL_PrepareFlat(int idx);// Returns the OpenGL name of the texture.
92 GLuint OGL_PrepareLightTexture();       // The dynamic light map.
93
94 void OGL_SetTexture(int idx);
95 unsigned int OGL_PrepareSky(int idx, boolean zeroMask);
96 void GL_GetSkyTopColor(int texidx, byte *rgb);
97
98 void OGL_SetSprite(int pnum);
99 unsigned int OGL_PrepareSprite(int pnum);
100 void OGL_NewSplitTex(int lump, GLuint part2name);
101 GLuint OGL_GetOtherPart(int lump);
102
103 // Part is either 1 or 2. Part 0 means only the left side is loaded.
104 // No splittex is created in that case. Once a raw image is loaded
105 // as part 0 it must be deleted before the other part is loaded at the
106 // next loading.
107 void OGL_SetRawImage(int lump, int part);
108 void OGL_SetPatch(int lump);    // No mipmaps are generated.
109 void OGL_SetNoTexture();
110
111 int OGL_GetLumpTexWidth(int lump);
112 int OGL_GetLumpTexHeight(int lump);
113 int OGL_ValidTexHeight2(int width, int height);
114
115 void OGL_UpdateTexParams(int mipmode);
116 void OGL_UpdateRawScreenParams(int smoothing);
117
118
119 #include "m_bams.h"
120
121 // ogl_clip.c
122 typedef struct clipnode_s
123 {
124         int                                     used;                   // 1 if the node is in use.
125         struct clipnode_s       *prev, *next;   // Previous and and nodes.
126         binangle                        start, end;             // The start and end angles (start < end).
127 } clipnode_t;
128
129 extern clipnode_t *clipnodes;   // The list of clipnodes.
130 extern clipnode_t *cliphead;    // The head node.
131
132 void C_Init();
133 void C_ClearRanges();
134 void C_Ranger();
135 void C_SafeAddRange(binangle startAngle, binangle endAngle);
136
137 // Add a segment relative to the current viewpoint.
138 void C_AddViewRelSeg(float x1, float y1, float x2, float y2);
139
140 // Check a segment relative to the current viewpoint.
141 int C_CheckViewRelSeg(float x1, float y1, float x2, float y2);
142
143 // Returns 1 if the specified angle is visible.
144 int C_IsAngleVisible(binangle bang);
145
146 clipnode_t *C_AngleClippedBy(binangle bang);
147
148 // Returns 1 if the subsector might be visible.
149 int C_CheckSubsector(subsector_t *ssec);
150
151
152 // ogl_sky.c
153
154 // Sky hemispheres.
155 #define SKYHEMI_UPPER           0x1
156 #define SKYHEMI_LOWER           0x2
157 #define SKYHEMI_JUST_CAP        0x4     // Just draw the top or bottom cap.
158 #define SKYHEMI_FADEOUT_BG      0x8     // Draw the fadeout bg when drawing the cap.
159
160 typedef struct
161 {
162         float   rgb[3];                         // The RGB values.
163         short   set, use;                       // Is this set? Should be used?
164         float   limit;                          // .3 by default.
165 } fadeout_t;
166
167 #define SLF_ENABLED             0x1             // Layer enabled.
168 #define SLF_MASKED              0x2             // Mask the layer texture.
169
170 typedef struct
171 {
172         int                     flags;
173         int                     texture;                // Not the OpenGL texture.
174         float           offset;
175         fadeout_t       fadeout;
176 } skylayer_t;
177
178 void R_RenderSky(int hemis);
179 void R_SkyInit();
180
181 #endif