soft: add r_lightmap implementation

This commit is contained in:
Denis Pauk 2022-02-01 21:49:50 +02:00
parent eb979d73ed
commit f1ac7cafbf
3 changed files with 44 additions and 9 deletions

View file

@ -431,6 +431,7 @@ extern cvar_t *r_fullbright;
extern cvar_t *r_lefthand;
extern cvar_t *r_gunfov;
extern cvar_t *r_farsee;
extern cvar_t *r_lightmap;
extern cvar_t *r_drawworld;
extern cvar_t *r_lerpmodels;
extern cvar_t *r_lightlevel;

View file

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "header/local.h"
#define MAX_RIMAGES 1024
static image_t *r_whitetexture_mip = NULL;
static image_t r_images[MAX_RIMAGES];
static int numr_images;
static int image_max = 0;
@ -675,6 +676,12 @@ R_FindImage(char *name, imagetype_t type)
return NULL;
}
/* just return white image if show lighmap only */
if (type == it_wall && r_lightmap->value)
{
return r_whitetexture_mip;
}
ext = COM_FileExtension(name);
if(!ext[0])
{
@ -775,17 +782,12 @@ R_ImageHasFreeSpace(void)
static struct texture_buffer {
image_t image;
byte buffer[4096];
} r_notexture_buffer;
} r_notexture_buffer, r_whitetexture_buffer;
/*
==================
R_InitTextures
==================
*/
static void
R_InitTextures (void)
R_InitNoTexture(void)
{
int x,y, m;
int m;
// create a simple checkerboard texture for the default
r_notexture_mip = &r_notexture_buffer.image;
@ -798,6 +800,7 @@ R_InitTextures (void)
for (m=0 ; m<NUM_MIPS ; m++)
{
int x, y;
byte *dest;
dest = r_notexture_mip->pixels[m];
@ -813,6 +816,35 @@ R_InitTextures (void)
}
}
static void
R_InitWhiteTexture(void)
{
// create a simple white texture for the default
r_whitetexture_mip = &r_whitetexture_buffer.image;
r_whitetexture_mip->width = r_whitetexture_mip->height = 16;
r_whitetexture_mip->asset_width = r_whitetexture_mip->asset_height = 16;
r_whitetexture_mip->pixels[0] = r_whitetexture_buffer.buffer;
R_RestoreImagePointers(r_whitetexture_mip, 0);
memset(r_whitetexture_buffer.buffer, d_16to8table[0xFFFF],
sizeof(r_whitetexture_buffer.buffer));
}
/*
==================
R_InitTextures
==================
*/
static void
R_InitTextures (void)
{
R_InitNoTexture();
/* empty white texture for r_lightmap = 1*/
R_InitWhiteTexture();
}
/*
===============
R_InitImages

View file

@ -134,6 +134,7 @@ float se_time1, se_time2, de_time1, de_time2;
cvar_t *r_lefthand;
cvar_t *r_gunfov;
cvar_t *r_farsee;
cvar_t *r_lightmap;
static cvar_t *sw_aliasstats;
cvar_t *sw_clearcolor;
cvar_t *sw_drawflat;
@ -394,6 +395,7 @@ R_RegisterVariables (void)
r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
r_gunfov = ri.Cvar_Get( "r_gunfov", "80", CVAR_ARCHIVE );
r_farsee = ri.Cvar_Get("r_farsee", "0", CVAR_LATCH | CVAR_ARCHIVE);
r_lightmap = ri.Cvar_Get("r_lightmap", "0", 0);
r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
@ -1341,7 +1343,7 @@ RE_RenderFrame (refdef_t *fd)
// For each dlight_t* passed via r_newrefdef.dlights, mark polygons affected by a light.
R_PushDlights (r_worldmodel);
// TODO: rearange code same as in GL*_DrawWorld?
// TODO: rearrange code same as in GL*_DrawWorld?
/* auto cycle the world frame for texture animation */
memset(&ent, 0, sizeof(ent));
ent.frame = (int)(r_newrefdef.time * 2);