]> icculus.org git repositories - theoddone33/hhexen.git/blob - include/ogl_def.h
osezer patch 003
[theoddone33/hhexen.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
97 void OGL_SetSprite(int pnum);
98 unsigned int OGL_PrepareSprite(int pnum);
99 void OGL_NewSplitTex(int lump, GLuint part2name);
100 GLuint OGL_GetOtherPart(int lump);
101
102 // Part is either 1 or 2. Part 0 means only the left side is loaded.
103 // No splittex is created in that case. Once a raw image is loaded
104 // as part 0 it must be deleted before the other part is loaded at the
105 // next loading.
106 void OGL_SetRawImage(int lump, int part);
107 void OGL_SetPatch(int lump);    // No mipmaps are generated.
108 void OGL_SetNoTexture();
109
110 int OGL_GetLumpTexWidth(int lump);
111 int OGL_GetLumpTexHeight(int lump);
112 int OGL_ValidTexHeight2(int width, int height);
113
114 void OGL_UpdateTexParams(int mipmode);
115 void OGL_UpdateRawScreenParams(int smoothing);
116
117
118 #include "m_bams.h"
119
120 // ogl_clip.c
121 typedef struct clipnode_s
122 {
123         int                                     used;                   // 1 if the node is in use.
124         struct clipnode_s       *prev, *next;   // Previous and and nodes.
125         binangle                        start, end;             // The start and end angles (start < end).
126 } clipnode_t;
127
128 extern clipnode_t *clipnodes;   // The list of clipnodes.
129 extern clipnode_t *cliphead;    // The head node.
130
131 void C_Init();
132 void C_ClearRanges();
133 void C_Ranger();
134 void C_SafeAddRange(binangle startAngle, binangle endAngle);
135
136 // Add a segment relative to the current viewpoint.
137 void C_AddViewRelSeg(float x1, float y1, float x2, float y2);
138
139 // Check a segment relative to the current viewpoint.
140 int C_CheckViewRelSeg(float x1, float y1, float x2, float y2);
141
142 // Returns 1 if the specified angle is visible.
143 int C_IsAngleVisible(binangle bang);
144
145 clipnode_t *C_AngleClippedBy(binangle bang);
146
147 // Returns 1 if the subsector might be visible.
148 int C_CheckSubsector(subsector_t *ssec);
149
150
151 // ogl_sky.c
152
153 // Sky hemispheres.
154 #define SKYHEMI_UPPER           0x1
155 #define SKYHEMI_LOWER           0x2
156 #define SKYHEMI_JUST_CAP        0x4     // Just draw the top or bottom cap.
157
158 typedef struct
159 {
160         float   rgb[3];                         // The RGB values.
161         short   set, use;                       // Is this set? Should be used?
162 } fadeout_t;
163
164 void R_RenderSkyHemispheres(int hemis);
165
166 #endif
167