mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
GL1 big lightmaps and scrap
https://github.com/yquake2/yquake2/pull/1108 Merge remote-tracking branch 'yquake2/master'
This commit is contained in:
commit
faf86b72c5
10 changed files with 172 additions and 60 deletions
|
@ -484,6 +484,10 @@ Set `0` by default.
|
|||
|
||||
## Graphics (OpenGL 1.4 only)
|
||||
|
||||
* **gl1_biglightmaps**: Enables lightmaps and scrap to use a bigger
|
||||
texture size, which means fewer texture switches, improving
|
||||
performance. Default is `1` (enabled). Requires a `vid_restart`.
|
||||
|
||||
* **gl1_intensity**: Sets the color intensity. Must be a floating point
|
||||
value, at least `1.0` - default is `2.0`. Applied when textures are
|
||||
loaded, so it needs a `vid_restart`.
|
||||
|
|
|
@ -85,6 +85,7 @@ Sys_Error(const char *error, ...)
|
|||
void
|
||||
Sys_Quit(void)
|
||||
{
|
||||
const qboolean free_console = (dedicated && dedicated->value);
|
||||
timeEndPeriod(1);
|
||||
|
||||
#ifndef DEDICATED_ONLY
|
||||
|
@ -93,7 +94,7 @@ Sys_Quit(void)
|
|||
|
||||
Qcommon_Shutdown();
|
||||
|
||||
if (dedicated && dedicated->value)
|
||||
if (free_console)
|
||||
{
|
||||
FreeConsole();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ int numgltextures;
|
|||
static int image_max = 0;
|
||||
int base_textureid; /* gltextures[i] = base_textureid+i */
|
||||
extern qboolean scrap_dirty;
|
||||
extern byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT];
|
||||
extern byte *scrap_texels[MAX_SCRAPS];
|
||||
|
||||
static byte intensitytable[256];
|
||||
static unsigned char gammatable[256];
|
||||
|
@ -639,11 +639,6 @@ R_BuildPalettedTexture(unsigned char *paletted_texture, unsigned char *scaled,
|
|||
}
|
||||
}
|
||||
|
||||
// Windows headers don't define this constant.
|
||||
#ifndef GL_GENERATE_MIPMAP
|
||||
#define GL_GENERATE_MIPMAP 0x8191
|
||||
#endif
|
||||
|
||||
qboolean
|
||||
R_Upload32Native(unsigned *data, int width, int height, qboolean mipmap)
|
||||
{
|
||||
|
@ -1061,17 +1056,17 @@ R_LoadPic(const char *name, byte *pic, int width, int realwidth,
|
|||
|
||||
for (j = 0; j < image->width; j++, k++)
|
||||
{
|
||||
scrap_texels[texnum][(y + i) * BLOCK_WIDTH + x + j] = pic[k];
|
||||
scrap_texels[texnum][(y + i) * gl_state.scrap_width + x + j] = pic[k];
|
||||
}
|
||||
}
|
||||
|
||||
image->texnum = TEXNUM_SCRAPS + texnum;
|
||||
image->scrap = true;
|
||||
image->has_alpha = true;
|
||||
image->sl = (x + 0.01) / (float)BLOCK_WIDTH;
|
||||
image->sh = (x + image->width - 0.01) / (float)BLOCK_WIDTH;
|
||||
image->tl = (y + 0.01) / (float)BLOCK_WIDTH;
|
||||
image->th = (y + image->height - 0.01) / (float)BLOCK_WIDTH;
|
||||
image->sl = (float)x / gl_state.scrap_width;
|
||||
image->sh = (float)(x + image->width) / gl_state.scrap_width;
|
||||
image->tl = (float)y / gl_state.scrap_height;
|
||||
image->th = (float)(y + image->height) / gl_state.scrap_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -39,13 +39,19 @@ LM_FreeLightmapBuffers(void)
|
|||
}
|
||||
gl_lms.lightmap_buffer[i] = NULL;
|
||||
}
|
||||
|
||||
if (gl_lms.allocated)
|
||||
{
|
||||
free(gl_lms.allocated);
|
||||
gl_lms.allocated = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
LM_AllocLightmapBuffer(int buffer, qboolean clean)
|
||||
{
|
||||
static const unsigned int lightmap_size =
|
||||
BLOCK_WIDTH * BLOCK_HEIGHT * LIGHTMAP_BYTES;
|
||||
const unsigned int lightmap_size =
|
||||
gl_state.block_width * gl_state.block_height * LIGHTMAP_BYTES;
|
||||
|
||||
if (!gl_lms.lightmap_buffer[buffer])
|
||||
{
|
||||
|
@ -65,7 +71,7 @@ LM_AllocLightmapBuffer(int buffer, qboolean clean)
|
|||
void
|
||||
LM_InitBlock(void)
|
||||
{
|
||||
memset(gl_lms.allocated, 0, sizeof(gl_lms.allocated));
|
||||
memset(gl_lms.allocated, 0, gl_state.block_width * sizeof(int));
|
||||
|
||||
if (gl_config.multitexture)
|
||||
{
|
||||
|
@ -88,7 +94,7 @@ LM_UploadBlock(qboolean dynamic)
|
|||
int i;
|
||||
int height = 0;
|
||||
|
||||
for (i = 0; i < BLOCK_WIDTH; i++)
|
||||
for (i = 0; i < gl_state.block_width; i++)
|
||||
{
|
||||
if (gl_lms.allocated[i] > height)
|
||||
{
|
||||
|
@ -96,17 +102,18 @@ LM_UploadBlock(qboolean dynamic)
|
|||
}
|
||||
}
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, BLOCK_WIDTH,
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, gl_state.block_width,
|
||||
height, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE,
|
||||
gl_lms.lightmap_buffer[buffer]);
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LIGHTMAP_FORMAT,
|
||||
BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT,
|
||||
GL_UNSIGNED_BYTE, gl_lms.lightmap_buffer[buffer]);
|
||||
gl_state.block_width, gl_state.block_height,
|
||||
0, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE,
|
||||
gl_lms.lightmap_buffer[buffer]);
|
||||
|
||||
if (++gl_lms.current_lightmap_texture == MAX_LIGHTMAPS)
|
||||
if (++gl_lms.current_lightmap_texture == gl_state.max_lightmaps)
|
||||
{
|
||||
Com_Error(ERR_DROP,
|
||||
"%s() - MAX_LIGHTMAPS exceeded\n", __func__);
|
||||
|
@ -122,9 +129,9 @@ LM_AllocBlock(int w, int h, int *x, int *y)
|
|||
{
|
||||
int i, best;
|
||||
|
||||
best = BLOCK_HEIGHT;
|
||||
best = gl_state.block_height;
|
||||
|
||||
for (i = 0; i < BLOCK_WIDTH - w; i++)
|
||||
for (i = 0; i < gl_state.block_width - w; i++)
|
||||
{
|
||||
int j, best2;
|
||||
|
||||
|
@ -151,7 +158,7 @@ LM_AllocBlock(int w, int h, int *x, int *y)
|
|||
}
|
||||
}
|
||||
|
||||
if (best + h > BLOCK_HEIGHT)
|
||||
if (best + h > gl_state.block_height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -243,13 +250,13 @@ LM_BuildPolygonFromSurface(model_t *currentmodel, msurface_t *fa)
|
|||
s -= fa->texturemins[0];
|
||||
s += fa->light_s * (1 << fa->lmshift);
|
||||
s += (1 << fa->lmshift) * 0.5;
|
||||
s /= BLOCK_WIDTH * (1 << fa->lmshift);
|
||||
s /= gl_state.block_width * (1 << fa->lmshift);
|
||||
|
||||
t = DotProduct(vec, fa->lmvecs[1]) + fa->lmvecs[1][3];
|
||||
t -= fa->texturemins[1];
|
||||
t += fa->light_t * (1 << fa->lmshift);
|
||||
t += (1 << fa->lmshift) * 0.5;
|
||||
t /= BLOCK_HEIGHT * (1 << fa->lmshift);
|
||||
t /= gl_state.block_height * (1 << fa->lmshift);
|
||||
|
||||
vert->lmTexCoord[0] = s;
|
||||
vert->lmTexCoord[1] = t;
|
||||
|
@ -290,10 +297,10 @@ LM_CreateSurfaceLightmap(msurface_t *surf)
|
|||
buffer = (gl_config.multitexture)? surf->lightmaptexturenum : 0;
|
||||
|
||||
base = gl_lms.lightmap_buffer[buffer];
|
||||
base += (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES;
|
||||
base += (surf->light_t * gl_state.block_width + surf->light_s) * LIGHTMAP_BYTES;
|
||||
|
||||
R_SetCacheState(surf, &r_newrefdef);
|
||||
R_BuildLightMap(surf, base, BLOCK_WIDTH * LIGHTMAP_BYTES,
|
||||
R_BuildLightMap(surf, base, gl_state.block_width * LIGHTMAP_BYTES,
|
||||
&r_newrefdef, r_modulate->value, r_framecount);
|
||||
}
|
||||
|
||||
|
@ -318,8 +325,13 @@ LM_BeginBuildingLightmaps(model_t *m)
|
|||
static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
||||
int i;
|
||||
|
||||
memset(gl_lms.allocated, 0, sizeof(gl_lms.allocated));
|
||||
LM_FreeLightmapBuffers();
|
||||
gl_lms.allocated = (int*)malloc(gl_state.block_width * sizeof(int));
|
||||
if (!gl_lms.allocated)
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "Could not create lightmap allocator\n");
|
||||
}
|
||||
memset(gl_lms.allocated, 0, gl_state.block_width * sizeof(int));
|
||||
|
||||
r_framecount = 1; /* no dlightcache */
|
||||
|
||||
|
@ -357,8 +369,9 @@ LM_BeginBuildingLightmaps(model_t *m)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_LIGHTMAP_FORMAT,
|
||||
BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT,
|
||||
GL_UNSIGNED_BYTE, gl_lms.lightmap_buffer[0]);
|
||||
gl_state.block_width, gl_state.block_height,
|
||||
0, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE,
|
||||
gl_lms.lightmap_buffer[0]);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -92,6 +92,7 @@ cvar_t *gl1_particle_square;
|
|||
cvar_t *gl1_palettedtexture;
|
||||
cvar_t *gl1_pointparameters;
|
||||
cvar_t *gl1_multitexture;
|
||||
cvar_t *gl1_biglightmaps;
|
||||
|
||||
cvar_t *gl_drawbuffer;
|
||||
cvar_t *gl_lightmap;
|
||||
|
@ -146,6 +147,8 @@ cvar_t *gl1_stereo_convergence;
|
|||
refimport_t ri;
|
||||
|
||||
void LM_FreeLightmapBuffers(void);
|
||||
void Scrap_Free(void);
|
||||
void Scrap_Init(void);
|
||||
|
||||
void
|
||||
R_RotateForEntity(entity_t *e)
|
||||
|
@ -1231,6 +1234,7 @@ R_Register(void)
|
|||
gl1_palettedtexture = ri.Cvar_Get("r_palettedtextures", "0", CVAR_ARCHIVE);
|
||||
gl1_pointparameters = ri.Cvar_Get("gl1_pointparameters", "1", CVAR_ARCHIVE);
|
||||
gl1_multitexture = ri.Cvar_Get("gl1_multitexture", "2", CVAR_ARCHIVE);
|
||||
gl1_biglightmaps = ri.Cvar_Get("gl1_biglightmaps", "1", CVAR_ARCHIVE);
|
||||
|
||||
gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
|
||||
r_vsync = ri.Cvar_Get("r_vsync", "1", CVAR_ARCHIVE);
|
||||
|
@ -1411,7 +1415,7 @@ R_SetMode(void)
|
|||
qboolean
|
||||
RI_Init(void)
|
||||
{
|
||||
int j;
|
||||
int j, max_tex_size;
|
||||
byte *colormap;
|
||||
extern float r_turbsin[256];
|
||||
|
||||
|
@ -1654,9 +1658,42 @@ RI_Init(void)
|
|||
|
||||
// ----
|
||||
|
||||
/* Big lightmaps */
|
||||
R_Printf(PRINT_ALL, " - Big lightmaps: ");
|
||||
|
||||
gl_state.block_width = BLOCK_WIDTH;
|
||||
gl_state.block_height = BLOCK_HEIGHT;
|
||||
gl_state.max_lightmaps = MAX_LIGHTMAPS;
|
||||
gl_state.scrap_width = BLOCK_WIDTH;
|
||||
gl_state.scrap_height = BLOCK_HEIGHT;
|
||||
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_tex_size);
|
||||
if (max_tex_size > BLOCK_WIDTH)
|
||||
{
|
||||
if (gl1_biglightmaps->value)
|
||||
{
|
||||
gl_state.block_width = gl_state.block_height = Q_min(max_tex_size, 512);
|
||||
gl_state.max_lightmaps = (BLOCK_WIDTH * BLOCK_HEIGHT * MAX_LIGHTMAPS)
|
||||
/ (gl_state.block_width * gl_state.block_height);
|
||||
gl_state.scrap_width = gl_state.scrap_height =
|
||||
(gl_config.npottextures)? Q_min(max_tex_size, 384) : Q_min(max_tex_size, 256);
|
||||
R_Printf(PRINT_ALL, "Okay\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Disabled\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
R_Printf(PRINT_ALL, "Failed, detected texture size = %d\n", max_tex_size);
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
R_SetDefaultState();
|
||||
|
||||
R_VertBufferInit();
|
||||
Scrap_Init();
|
||||
R_InitImages();
|
||||
Mod_Init();
|
||||
R_InitParticleTexture();
|
||||
|
@ -1674,6 +1711,7 @@ RI_Shutdown(void)
|
|||
ri.Cmd_RemoveCommand("gl_strings");
|
||||
|
||||
LM_FreeLightmapBuffers();
|
||||
Scrap_Free();
|
||||
Mod_FreeAll();
|
||||
|
||||
R_ShutdownImages();
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* Allocate all the little status bar obejcts into a single texture
|
||||
* Allocate all the little status bar objects into a single texture
|
||||
* to crutch up inefficient hardware / drivers.
|
||||
*
|
||||
* =======================================================================
|
||||
|
@ -27,10 +27,9 @@
|
|||
|
||||
#include "header/local.h"
|
||||
|
||||
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
|
||||
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH * BLOCK_HEIGHT];
|
||||
int *scrap_allocated[MAX_SCRAPS];
|
||||
byte *scrap_texels[MAX_SCRAPS];
|
||||
qboolean scrap_dirty;
|
||||
int scrap_uploads;
|
||||
|
||||
qboolean R_Upload8(byte *data,
|
||||
int width,
|
||||
|
@ -43,14 +42,16 @@ int
|
|||
Scrap_AllocBlock(int w, int h, int *x, int *y)
|
||||
{
|
||||
int texnum;
|
||||
w += 2; // add an empty border to all sides
|
||||
h += 2;
|
||||
|
||||
for (texnum = 0; texnum < MAX_SCRAPS; texnum++)
|
||||
{
|
||||
int best, i;
|
||||
|
||||
best = BLOCK_HEIGHT;
|
||||
best = gl_state.scrap_height;
|
||||
|
||||
for (i = 0; i < BLOCK_WIDTH - w; i++)
|
||||
for (i = 0; i < gl_state.scrap_width - w; i++)
|
||||
{
|
||||
int best2, j;
|
||||
|
||||
|
@ -76,7 +77,7 @@ Scrap_AllocBlock(int w, int h, int *x, int *y)
|
|||
}
|
||||
}
|
||||
|
||||
if (best + h > BLOCK_HEIGHT)
|
||||
if (best + h > gl_state.scrap_height)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -85,6 +86,8 @@ Scrap_AllocBlock(int w, int h, int *x, int *y)
|
|||
{
|
||||
scrap_allocated[texnum][*x + i] = best + h;
|
||||
}
|
||||
(*x)++; // jump the border
|
||||
(*y)++;
|
||||
|
||||
return texnum;
|
||||
}
|
||||
|
@ -95,9 +98,58 @@ Scrap_AllocBlock(int w, int h, int *x, int *y)
|
|||
void
|
||||
Scrap_Upload(void)
|
||||
{
|
||||
scrap_uploads++;
|
||||
R_Bind(TEXNUM_SCRAPS);
|
||||
R_Upload8(scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, false);
|
||||
R_Upload8(scrap_texels[0], gl_state.scrap_width,
|
||||
gl_state.scrap_height, false, false);
|
||||
scrap_dirty = false;
|
||||
}
|
||||
|
||||
void
|
||||
Scrap_Free(void)
|
||||
{
|
||||
for (int i = 0; i < MAX_SCRAPS; i++)
|
||||
{
|
||||
if (scrap_allocated[i])
|
||||
{
|
||||
free(scrap_allocated[i]);
|
||||
}
|
||||
scrap_allocated[i] = NULL;
|
||||
|
||||
if (scrap_texels[i])
|
||||
{
|
||||
free(scrap_texels[i]);
|
||||
}
|
||||
scrap_texels[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Scrap_Init(void)
|
||||
{
|
||||
const unsigned int allocd_size = gl_state.scrap_width * sizeof(int);
|
||||
const unsigned int texels_size = gl_state.scrap_width
|
||||
* gl_state.scrap_height * sizeof(byte);
|
||||
int i;
|
||||
|
||||
Scrap_Free();
|
||||
|
||||
for (i = 0; i < MAX_SCRAPS; i++)
|
||||
{
|
||||
if (!scrap_allocated[i])
|
||||
{
|
||||
scrap_allocated[i] = malloc (allocd_size) ;
|
||||
}
|
||||
if (!scrap_texels[i])
|
||||
{
|
||||
scrap_texels[i] = malloc (texels_size) ;
|
||||
}
|
||||
|
||||
if (!scrap_allocated[i] || !scrap_texels[i])
|
||||
{
|
||||
ri.Sys_Error(ERR_FATAL, "Could not allocate scrap memory.\n");
|
||||
}
|
||||
memset (scrap_allocated[i], 0, allocd_size); // empty
|
||||
memset (scrap_texels[i], 255, texels_size); // transparent
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ R_DrawTriangleOutlines(void)
|
|||
glDisable(GL_DEPTH_TEST);
|
||||
glColor4f(1, 1, 1, 1);
|
||||
|
||||
for (i = 0; i < MAX_LIGHTMAPS; i++)
|
||||
for (i = 0; i < gl_state.max_lightmaps; i++)
|
||||
{
|
||||
msurface_t *surf;
|
||||
|
||||
|
@ -256,7 +256,7 @@ R_BlendLightmaps(const model_t *currentmodel)
|
|||
}
|
||||
|
||||
/* render static lightmaps first */
|
||||
for (i = 1; i < MAX_LIGHTMAPS; i++)
|
||||
for (i = 1; i < gl_state.max_lightmaps; i++)
|
||||
{
|
||||
if (gl_lms.lightmap_surfaces[i])
|
||||
{
|
||||
|
@ -315,10 +315,10 @@ R_BlendLightmaps(const model_t *currentmodel)
|
|||
if (LM_AllocBlock(smax, tmax, &surf->dlight_s, &surf->dlight_t))
|
||||
{
|
||||
base = gl_lms.lightmap_buffer[0];
|
||||
base += (surf->dlight_t * BLOCK_WIDTH +
|
||||
base += (surf->dlight_t * gl_state.block_width +
|
||||
surf->dlight_s) * LIGHTMAP_BYTES;
|
||||
|
||||
R_BuildLightMap(surf, base, BLOCK_WIDTH * LIGHTMAP_BYTES,
|
||||
R_BuildLightMap(surf, base, gl_state.block_width * LIGHTMAP_BYTES,
|
||||
&r_newrefdef, r_modulate->value, r_framecount);
|
||||
}
|
||||
else
|
||||
|
@ -343,8 +343,8 @@ R_BlendLightmaps(const model_t *currentmodel)
|
|||
}
|
||||
|
||||
R_DrawGLPolyChain(drawsurf->polys,
|
||||
(drawsurf->light_s - drawsurf->dlight_s) * (1.0 / BLOCK_WIDTH),
|
||||
(drawsurf->light_t - drawsurf->dlight_t) * (1.0 / BLOCK_WIDTH));
|
||||
(drawsurf->light_s - drawsurf->dlight_s) * (1.0 / (float)gl_state.block_width),
|
||||
(drawsurf->light_t - drawsurf->dlight_t) * (1.0 / (float)gl_state.block_height));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,10 +362,10 @@ R_BlendLightmaps(const model_t *currentmodel)
|
|||
}
|
||||
|
||||
base = gl_lms.lightmap_buffer[0];
|
||||
base += (surf->dlight_t * BLOCK_WIDTH +
|
||||
base += (surf->dlight_t * gl_state.block_width +
|
||||
surf->dlight_s) * LIGHTMAP_BYTES;
|
||||
|
||||
R_BuildLightMap(surf, base, BLOCK_WIDTH * LIGHTMAP_BYTES,
|
||||
R_BuildLightMap(surf, base, gl_state.block_width * LIGHTMAP_BYTES,
|
||||
&r_newrefdef, r_modulate->value, r_framecount);
|
||||
}
|
||||
}
|
||||
|
@ -388,8 +388,8 @@ R_BlendLightmaps(const model_t *currentmodel)
|
|||
}
|
||||
|
||||
R_DrawGLPolyChain(surf->polys,
|
||||
(surf->light_s - surf->dlight_s) * (1.0 / BLOCK_WIDTH),
|
||||
(surf->light_t - surf->dlight_t) * (1.0 / BLOCK_WIDTH));
|
||||
(surf->light_s - surf->dlight_s) * (1.0 / (float)gl_state.block_width),
|
||||
(surf->light_t - surf->dlight_t) * (1.0 / (float)gl_state.block_height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -732,6 +732,7 @@ R_UploadDynamicLights(msurface_t *surf)
|
|||
R_Bind(gl_state.lightmap_textures + surf->lightmaptexturenum);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, surf->light_s, surf->light_t, smax,
|
||||
tmax, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, temp);
|
||||
YQ2_VLAFREE(temp);
|
||||
}
|
||||
|
||||
/* Upload dynamic lights to each lightmap texture (multitexture path only) */
|
||||
|
@ -748,9 +749,9 @@ R_RegenAllLightmaps()
|
|||
return;
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, BLOCK_WIDTH);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, gl_state.block_width);
|
||||
|
||||
for (i = 1; i < MAX_LIGHTMAPS; i++)
|
||||
for (i = 1; i < gl_state.max_lightmaps; i++)
|
||||
{
|
||||
if (!gl_lms.lightmap_surfaces[i] || !gl_lms.lightmap_buffer[i])
|
||||
{
|
||||
|
@ -758,8 +759,8 @@ R_RegenAllLightmaps()
|
|||
}
|
||||
|
||||
affected_lightmap = false;
|
||||
bt = BLOCK_HEIGHT;
|
||||
bl = BLOCK_WIDTH;
|
||||
bt = gl_state.block_height;
|
||||
bl = gl_state.block_width;
|
||||
bb = br = 0;
|
||||
|
||||
for (surf = gl_lms.lightmap_surfaces[i];
|
||||
|
@ -781,9 +782,9 @@ R_RegenAllLightmaps()
|
|||
bottom = surf->light_t + tmax;
|
||||
|
||||
base = gl_lms.lightmap_buffer[i];
|
||||
base += (top * BLOCK_WIDTH + left) * LIGHTMAP_BYTES;
|
||||
base += (top * gl_state.block_width + left) * LIGHTMAP_BYTES;
|
||||
|
||||
R_BuildLightMap(surf, base, BLOCK_WIDTH * LIGHTMAP_BYTES,
|
||||
R_BuildLightMap(surf, base, gl_state.block_width * LIGHTMAP_BYTES,
|
||||
&r_newrefdef, r_modulate->value, r_framecount);
|
||||
R_UpdateSurfCache(surf, map);
|
||||
|
||||
|
@ -811,7 +812,7 @@ R_RegenAllLightmaps()
|
|||
}
|
||||
|
||||
base = gl_lms.lightmap_buffer[i];
|
||||
base += (bt * BLOCK_WIDTH + bl) * LIGHTMAP_BYTES;
|
||||
base += (bt * gl_state.block_width + bl) * LIGHTMAP_BYTES;
|
||||
|
||||
// upload changes
|
||||
R_Bind(gl_state.lightmap_textures + i);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#define TEXNUM_SCRAPS 1152
|
||||
#define TEXNUM_IMAGES 1153
|
||||
#define MAX_SCRAPS 1
|
||||
#define BLOCK_WIDTH 256
|
||||
#define BLOCK_WIDTH 256 // default values; now defined in glstate_t
|
||||
#define BLOCK_HEIGHT 256
|
||||
#define REF_VERSION "Yamagi Quake II OpenGL Refresher"
|
||||
#define MAX_LIGHTMAPS 256
|
||||
|
@ -144,6 +144,7 @@ extern cvar_t *gl1_overbrightbits;
|
|||
extern cvar_t *gl1_palettedtexture;
|
||||
extern cvar_t *gl1_pointparameters;
|
||||
extern cvar_t *gl1_multitexture;
|
||||
extern cvar_t *gl1_biglightmaps;
|
||||
|
||||
extern cvar_t *gl1_particle_min_size;
|
||||
extern cvar_t *gl1_particle_max_size;
|
||||
|
@ -365,6 +366,12 @@ typedef struct
|
|||
enum stereo_modes stereo_mode;
|
||||
|
||||
qboolean stencil;
|
||||
|
||||
int block_width, // replaces BLOCK_WIDTH
|
||||
block_height, // replaces BLOCK_HEIGHT
|
||||
max_lightmaps, // the larger the lightmaps, the fewer the max lightmaps
|
||||
scrap_width, // size for scrap (atlas of 2D elements)
|
||||
scrap_height;
|
||||
} glstate_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -373,7 +380,7 @@ typedef struct
|
|||
|
||||
msurface_t *lightmap_surfaces[MAX_LIGHTMAPS];
|
||||
|
||||
int allocated[BLOCK_WIDTH];
|
||||
int *allocated; // formerly allocated[BLOCK_WIDTH];
|
||||
|
||||
/* the lightmap texture data needs to be kept in
|
||||
main memory so texsubimage can update properly */
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#define GL_POINT_SIZE_MIN 0x8126
|
||||
#define GL_POINT_SIZE_MAX 0x8127
|
||||
#define GL_POINT_DISTANCE_ATTENUATION 0x8129
|
||||
#define GL_GENERATE_MIPMAP 0x8191
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_1_3
|
||||
|
|
|
@ -1747,7 +1747,7 @@ qboolean Pickup_Sphere(edict_t * ent, edict_t * other);
|
|||
* implementation. (-Wmissing-prototypes )
|
||||
*
|
||||
*/
|
||||
#if 1
|
||||
#if 0
|
||||
#include "../savegame/savegame.h"
|
||||
#include "../savegame/tables/gamefunc_decs.h"
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue