Go to the documentation of this file.
30 #define DYNAMIC_LIGHT_WIDTH 128
31 #define DYNAMIC_LIGHT_HEIGHT 128
33 #define LIGHTMAP_BYTES 4
35 #define BLOCK_WIDTH 128
36 #define BLOCK_HEIGHT 128
38 #define MAX_LIGHTMAPS 128
43 #define GL_LIGHTMAP_FORMAT GL_RGBA
150 qglBegin (GL_TRIANGLE_FAN);
154 qglTexCoord2f (
v[3],
v[4]);
159 void DrawGLWaterPolyLightmap (
glpoly_t *p)
165 qglBegin (GL_TRIANGLE_FAN);
169 qglTexCoord2f (
v[5],
v[6]);
186 qglBegin (GL_POLYGON);
190 qglTexCoord2f (
v[3],
v[4]);
216 qglBegin (GL_POLYGON);
220 qglTexCoord2f ((
v[3] + scroll),
v[4]);
239 qglDisable (GL_TEXTURE_2D);
240 qglDisable (GL_DEPTH_TEST);
241 qglColor4f (1,1,1,1);
250 for ( ; p ; p=p->
chain)
254 qglBegin (GL_LINE_STRIP);
255 qglVertex3fv (p->
verts[0]);
256 qglVertex3fv (p->
verts[
j-1]);
257 qglVertex3fv (p->
verts[
j]);
258 qglVertex3fv (p->
verts[0]);
265 qglEnable (GL_DEPTH_TEST);
266 qglEnable (GL_TEXTURE_2D);
274 if ( soffset == 0 && toffset == 0 )
276 for ( ; p != 0; p = p->
chain )
281 qglBegin (GL_POLYGON);
285 qglTexCoord2f (
v[5],
v[6] );
293 for ( ; p != 0; p = p->
chain )
298 qglBegin (GL_POLYGON);
302 qglTexCoord2f (
v[5] - soffset,
v[6] - toffset );
336 qglEnable (GL_BLEND);
340 qglBlendFunc( GL_ONE, GL_ONE );
349 qglBlendFunc (GL_ZERO, GL_SRC_COLOR );
352 qglBlendFunc (GL_ZERO, GL_SRC_COLOR );
356 qglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
362 qglBlendFunc (GL_ZERO, GL_SRC_COLOR );
408 smax = (surf->
extents[0]>>4)+1;
409 tmax = (surf->
extents[1]>>4)+1;
426 for ( drawsurf = newdrawsurf; drawsurf != surf; drawsurf = drawsurf->
lightmapchain )
428 if ( drawsurf->
polys )
434 newdrawsurf = drawsurf;
442 ri.
Sys_Error(
ERR_FATAL,
"Consecutive calls to LM_AllocBlock(%d,%d) failed (dynamic)\n", smax, tmax );
458 for ( surf = newdrawsurf; surf != 0; surf = surf->
lightmapchain )
468 qglDisable (GL_BLEND);
469 qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
545 unsigned temp[34*34];
556 qglTexSubImage2D( GL_TEXTURE_2D, 0,
560 GL_UNSIGNED_BYTE, temp );
598 qglEnable (GL_BLEND);
610 qglColor4f (intens,intens,intens,0.33);
612 qglColor4f (intens,intens,intens,0.66);
614 qglColor4f (intens,intens,intens,1);
624 qglColor4f (1,1,1,1);
625 qglDisable (GL_BLEND);
645 if ( !qglSelectTextureSGIS && !qglActiveTextureARB )
656 for ( ;
s ;
s=
s->texturechain)
688 for ( ;
s ;
s=
s->texturechain)
734 unsigned temp[128*128];
739 smax = (surf->
extents[0]>>4)+1;
740 tmax = (surf->
extents[1]>>4)+1;
749 qglTexSubImage2D( GL_TEXTURE_2D, 0,
753 GL_UNSIGNED_BYTE, temp );
758 smax = (surf->
extents[0]>>4)+1;
759 tmax = (surf->
extents[1]>>4)+1;
767 qglTexSubImage2D( GL_TEXTURE_2D, 0,
771 GL_UNSIGNED_BYTE, temp );
793 qglBegin (GL_POLYGON);
808 qglBegin (GL_POLYGON);
841 qglBegin (GL_POLYGON);
858 qglBegin (GL_POLYGON);
902 qglEnable (GL_BLEND);
903 qglColor4f (1,1,1,0.25);
913 pplane = psurf->
plane;
941 if ( !qglMTexCoord2fSGIS )
946 qglDisable (GL_BLEND);
947 qglColor4f (1,1,1,1);
972 for (
i=0 ;
i<3 ;
i++)
1038 int c, side, sidebit;
1083 plane = node->
plane;
1085 switch (plane->
type)
1212 memset (&ent, 0,
sizeof(ent));
1222 if ( qglMTexCoord2fSGIS )
1303 for (
i=0 ;
i<c ;
i++)
1304 ((
int *)fatvis)[
i] |= ((
int *)vis)[
i];
1313 if (vis[cluster>>3] & (1<<(cluster&7)))
1329 if (vis[
i>>3] & (1<<(
i&7)))
1374 qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1375 qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1387 qglTexSubImage2D( GL_TEXTURE_2D,
1397 qglTexImage2D( GL_TEXTURE_2D,
1422 for (
j=0 ;
j<
w ;
j++)
1439 for (
i=0 ;
i<
w ;
i++)
1452 int i, lindex, lnumverts;
1475 for (
i=0 ;
i<lnumverts ;
i++)
1536 smax = (surf->
extents[0]>>4)+1;
1537 tmax = (surf->
extents[1]>>4)+1;
1569 unsigned dummy[128*128];
1584 lightstyles[
i].
rgb[0] = 1;
1585 lightstyles[
i].
rgb[1] = 1;
1586 lightstyles[
i].
rgb[2] = 1;
1587 lightstyles[
i].
white = 3;
1641 qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
1642 qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
1643 qglTexImage2D( GL_TEXTURE_2D,
byte styles[MAXLIGHTMAPS]
CONST PIXELFORMATDESCRIPTOR int
#define VectorSubtract(a, b, c)
void R_DrawAlphaSurfaces(void)
void GL_MBind(GLenum target, int texnum)
float verts[4][VERTEXSIZE]
cvar_t * gl_saturatelighting
msurface_t ** firstmarksurface
image_t * R_TextureAnimation(mtexinfo_t *tex)
struct mnode_s * children[2]
msurface_t * r_alpha_surfaces
int registration_sequence
void R_MarkLights(dlight_t *light, int bit, mnode_t *node)
float cached_light[MAXLIGHTMAPS]
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
image_t gltextures[MAX_GLTEXTURES]
void R_DrawInlineBModel(void)
void GL_EnableMultitexture(qboolean enable)
static void LM_InitBlock(void)
void R_BlendLightmaps(void)
void R_DrawTriangleOutlines(void)
void R_AddSkySurface(msurface_t *fa)
static qboolean LM_AllocBlock(int w, int h, int *x, int *y)
void(* Sys_Error)(int err_level, char *str,...)
struct msurface_s * texturechain
struct msurface_s * lightmapchain
void DrawGLFlowingPoly(msurface_t *fa)
void DrawGLPolyChain(glpoly_t *p, float soffset, float toffset)
byte lightmap_buffer[4 *BLOCK_WIDTH *BLOCK_HEIGHT]
int current_lightmap_texture
static void GL_RenderLightmappedPoly(msurface_t *surf)
#define VectorAdd(a, b, c)
void R_RenderBrushPoly(msurface_t *fa)
static gllightmapstate_t gl_lms
msurface_t * lightmap_surfaces[MAX_LIGHTMAPS]
void R_RecursiveWorldNode(mnode_t *node)
lightstyle_t * lightstyles
glpoly_t * WaterWarpPolyVerts(glpoly_t *p)
qboolean R_CullBox(vec3_t mins, vec3_t maxs)
unsigned short firstsurface
void EmitWaterPolys(msurface_t *fa)
void GL_TexEnv(GLenum mode)
void DrawTextureChains(void)
void GL_BuildPolygonFromSurface(msurface_t *fa)
void DrawGLPoly(glpoly_t *p)
void GL_CreateSurfaceLightmap(msurface_t *surf)
void R_RotateForEntity(entity_t *e)
GLdouble GLdouble GLdouble w
#define GL_LIGHTMAP_FORMAT
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride)
void R_SetCacheState(msurface_t *surf)
unsigned short numsurfaces
void GL_SelectTexture(GLenum texture)
void R_DrawBrushModel(entity_t *e)
byte * Mod_ClusterPVS(int cluster, model_t *model)
void * Hunk_Alloc(int size)
static void LM_UploadBlock(qboolean dynamic)
void GL_BeginBuildingLightmaps(model_t *m)
int allocated[BLOCK_WIDTH]
void GL_EndBuildingLightmaps(void)
struct msurface_s * texturechain