mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-08 09:51:45 +00:00
Convert legacy GL files to C++
This commit is contained in:
parent
8a5f548f87
commit
4a9d1927c4
16 changed files with 205 additions and 202 deletions
|
|
@ -1474,7 +1474,7 @@ consvar_t cv_voice_allowservervoice = NetVar("voice_allowservervoice", "Off")
|
||||||
consvar_t cv_glshaders = OpenGL("gr_shaders", "On").values(glshaders_cons_t);
|
consvar_t cv_glshaders = OpenGL("gr_shaders", "On").values(glshaders_cons_t);
|
||||||
|
|
||||||
extern CV_PossibleValue_t glanisotropicmode_cons_t[];
|
extern CV_PossibleValue_t glanisotropicmode_cons_t[];
|
||||||
void CV_glanisotropic_OnChange(void);
|
extern "C" void CV_glanisotropic_OnChange(void);
|
||||||
consvar_t cv_glanisotropicmode = OpenGL("gr_anisotropicmode", "1").values(glanisotropicmode_cons_t).onchange(CV_glanisotropic_OnChange);
|
consvar_t cv_glanisotropicmode = OpenGL("gr_anisotropicmode", "1").values(glanisotropicmode_cons_t).onchange(CV_glanisotropic_OnChange);
|
||||||
|
|
||||||
consvar_t cv_glbatching = OpenGL("gr_batching", "On").on_off().dont_save();
|
consvar_t cv_glbatching = OpenGL("gr_batching", "On").on_off().dont_save();
|
||||||
|
|
@ -1487,7 +1487,7 @@ consvar_t cv_voice_allowservervoice = NetVar("voice_allowservervoice", "Off")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern CV_PossibleValue_t glfiltermode_cons_t[];
|
extern CV_PossibleValue_t glfiltermode_cons_t[];
|
||||||
void CV_glfiltermode_OnChange(void);
|
extern "C" void CV_glfiltermode_OnChange(void);
|
||||||
consvar_t cv_glfiltermode = OpenGL("gr_filtermode", "Nearest").values(glfiltermode_cons_t).onchange(CV_glfiltermode_OnChange);
|
consvar_t cv_glfiltermode = OpenGL("gr_filtermode", "Nearest").values(glfiltermode_cons_t).onchange(CV_glfiltermode_OnChange);
|
||||||
|
|
||||||
#ifdef BAD_MODEL_OPTIONS
|
#ifdef BAD_MODEL_OPTIONS
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
target_sources(SRB2SDL2 PRIVATE
|
target_sources(SRB2SDL2 PRIVATE
|
||||||
hw_bsp.c
|
hw_bsp.cpp
|
||||||
hw_draw.c
|
hw_draw.cpp
|
||||||
hw_light.c
|
hw_light.cpp
|
||||||
hw_main.c
|
hw_main.cpp
|
||||||
hw_clip.c
|
hw_clip.cpp
|
||||||
hw_md2.c
|
hw_md2.cpp
|
||||||
hw_cache.c
|
hw_cache.cpp
|
||||||
hw_md2load.c
|
hw_md2load.cpp
|
||||||
hw_md3load.c
|
hw_md3load.cpp
|
||||||
hw_model.c
|
hw_model.cpp
|
||||||
u_list.c
|
u_list.cpp
|
||||||
hw_batching.c
|
hw_batching.cpp
|
||||||
r_opengl/r_opengl.c
|
r_opengl/r_opengl.cpp
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,11 @@ void HWR_StartBatching(void)
|
||||||
// init arrays if that has not been done yet
|
// init arrays if that has not been done yet
|
||||||
if (!finalVertexArray)
|
if (!finalVertexArray)
|
||||||
{
|
{
|
||||||
finalVertexArray = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
finalVertexArray = (FOutVector *)malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
finalVertexIndexArray = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
finalVertexIndexArray = (UINT32 *)malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
||||||
polygonArray = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
polygonArray = (PolygonArrayEntry *)malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
||||||
polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32));
|
polygonIndexArray = (UINT32 *)malloc(polygonArrayAllocSize * sizeof(UINT32));
|
||||||
unsortedVertexArray = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
unsortedVertexArray = (FOutVector *)malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
}
|
}
|
||||||
|
|
||||||
currently_batching = true;
|
currently_batching = true;
|
||||||
|
|
@ -104,13 +104,13 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
||||||
PolygonArrayEntry* new_array;
|
PolygonArrayEntry* new_array;
|
||||||
// ran out of space, make new array double the size
|
// ran out of space, make new array double the size
|
||||||
polygonArrayAllocSize *= 2;
|
polygonArrayAllocSize *= 2;
|
||||||
new_array = malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
new_array = (PolygonArrayEntry *)malloc(polygonArrayAllocSize * sizeof(PolygonArrayEntry));
|
||||||
memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry));
|
memcpy(new_array, polygonArray, polygonArraySize * sizeof(PolygonArrayEntry));
|
||||||
free(polygonArray);
|
free(polygonArray);
|
||||||
polygonArray = new_array;
|
polygonArray = new_array;
|
||||||
// also need to redo the index array, dont need to copy it though
|
// also need to redo the index array, dont need to copy it though
|
||||||
free(polygonIndexArray);
|
free(polygonIndexArray);
|
||||||
polygonIndexArray = malloc(polygonArrayAllocSize * sizeof(UINT32));
|
polygonIndexArray = (UINT32 *)malloc(polygonArrayAllocSize * sizeof(UINT32));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize)
|
while (unsortedVertexArraySize + (int)iNumPts > unsortedVertexArrayAllocSize)
|
||||||
|
|
@ -118,7 +118,7 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt
|
||||||
FOutVector* new_array;
|
FOutVector* new_array;
|
||||||
// need more space for vertices in unsortedVertexArray
|
// need more space for vertices in unsortedVertexArray
|
||||||
unsortedVertexArrayAllocSize *= 2;
|
unsortedVertexArrayAllocSize *= 2;
|
||||||
new_array = malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
new_array = (FOutVector *)malloc(unsortedVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
memcpy(new_array, unsortedVertexArray, unsortedVertexArraySize * sizeof(FOutVector));
|
memcpy(new_array, unsortedVertexArray, unsortedVertexArraySize * sizeof(FOutVector));
|
||||||
free(unsortedVertexArray);
|
free(unsortedVertexArray);
|
||||||
unsortedVertexArray = new_array;
|
unsortedVertexArray = new_array;
|
||||||
|
|
@ -368,13 +368,13 @@ void HWR_RenderBatches(void)
|
||||||
FOutVector* new_array;
|
FOutVector* new_array;
|
||||||
unsigned int* new_index_array;
|
unsigned int* new_index_array;
|
||||||
finalVertexArrayAllocSize *= 2;
|
finalVertexArrayAllocSize *= 2;
|
||||||
new_array = malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
new_array = (FOutVector *)malloc(finalVertexArrayAllocSize * sizeof(FOutVector));
|
||||||
memcpy(new_array, finalVertexArray, finalVertexWritePos * sizeof(FOutVector));
|
memcpy(new_array, finalVertexArray, finalVertexWritePos * sizeof(FOutVector));
|
||||||
free(finalVertexArray);
|
free(finalVertexArray);
|
||||||
finalVertexArray = new_array;
|
finalVertexArray = new_array;
|
||||||
// also increase size of index array, 3x of vertex array since
|
// also increase size of index array, 3x of vertex array since
|
||||||
// going from fans to triangles increases vertex count to 3x
|
// going from fans to triangles increases vertex count to 3x
|
||||||
new_index_array = malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
new_index_array = (UINT32 *)malloc(finalVertexArrayAllocSize * 3 * sizeof(UINT32));
|
||||||
memcpy(new_index_array, finalVertexIndexArray, finalIndexWritePos * sizeof(UINT32));
|
memcpy(new_index_array, finalVertexIndexArray, finalIndexWritePos * sizeof(UINT32));
|
||||||
free(finalVertexIndexArray);
|
free(finalVertexIndexArray);
|
||||||
finalVertexIndexArray = new_index_array;
|
finalVertexIndexArray = new_index_array;
|
||||||
|
|
@ -88,7 +88,7 @@ void HWR_InitPolyPool(void)
|
||||||
POLYPOOLSIZE = atoi(myargv[pnum+1])*1024; // (in kb)
|
POLYPOOLSIZE = atoi(myargv[pnum+1])*1024; // (in kb)
|
||||||
|
|
||||||
CONS_Debug(DBG_RENDER, "HWR_InitPolyPool(): allocating %d bytes\n", POLYPOOLSIZE);
|
CONS_Debug(DBG_RENDER, "HWR_InitPolyPool(): allocating %d bytes\n", POLYPOOLSIZE);
|
||||||
gl_polypool = malloc(POLYPOOLSIZE);
|
gl_polypool = (UINT8 *)malloc(POLYPOOLSIZE);
|
||||||
if (!gl_polypool)
|
if (!gl_polypool)
|
||||||
I_Error("HWR_InitPolyPool(): couldn't malloc polypool\n");
|
I_Error("HWR_InitPolyPool(): couldn't malloc polypool\n");
|
||||||
HWR_ClearPolys();
|
HWR_ClearPolys();
|
||||||
|
|
@ -109,7 +109,7 @@ static poly_t *HWR_AllocPoly(INT32 numpts)
|
||||||
poly_t *p;
|
poly_t *p;
|
||||||
size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * numpts;
|
size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * numpts;
|
||||||
#ifdef ZPLANALLOC
|
#ifdef ZPLANALLOC
|
||||||
p = Z_Malloc(size, PU_HWRPLANE, NULL);
|
p = (poly_t *)Z_Malloc(size, PU_HWRPLANE, NULL);
|
||||||
#else
|
#else
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
if (!gl_polypool)
|
if (!gl_polypool)
|
||||||
|
|
@ -135,7 +135,7 @@ static polyvertex_t *HWR_AllocVertex(void)
|
||||||
polyvertex_t *p;
|
polyvertex_t *p;
|
||||||
size_t size = sizeof (polyvertex_t);
|
size_t size = sizeof (polyvertex_t);
|
||||||
#ifdef ZPLANALLOC
|
#ifdef ZPLANALLOC
|
||||||
p = Z_Malloc(size, PU_HWRPLANE, NULL);
|
p = (polyvertex_t *)Z_Malloc(size, PU_HWRPLANE, NULL);
|
||||||
#else
|
#else
|
||||||
if (gl_ppfree < size)
|
if (gl_ppfree < size)
|
||||||
I_Error("HWR_AllocVertex(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
|
I_Error("HWR_AllocVertex(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
|
||||||
|
|
@ -715,8 +715,8 @@ void HWR_FreeExtraSubsectors(void)
|
||||||
//#define MOVEVERTEX
|
//#define MOVEVERTEX
|
||||||
static boolean PointInSeg(polyvertex_t *a,polyvertex_t *v1,polyvertex_t *v2)
|
static boolean PointInSeg(polyvertex_t *a,polyvertex_t *v1,polyvertex_t *v2)
|
||||||
{
|
{
|
||||||
register float ax,ay,bx,by,cx,cy,d,norm;
|
float ax,ay,bx,by,cx,cy,d,norm;
|
||||||
register polyvertex_t *p;
|
polyvertex_t *p;
|
||||||
|
|
||||||
// check bbox of the seg first
|
// check bbox of the seg first
|
||||||
if (v1->x > v2->x)
|
if (v1->x > v2->x)
|
||||||
|
|
@ -985,7 +985,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
|
||||||
HWR_FreeExtraSubsectors();
|
HWR_FreeExtraSubsectors();
|
||||||
// allocate extra data for each subsector present in map
|
// allocate extra data for each subsector present in map
|
||||||
totsubsectors = numsubsectors + NEWSUBSECTORS;
|
totsubsectors = numsubsectors + NEWSUBSECTORS;
|
||||||
extrasubsectors = calloc(totsubsectors, sizeof (*extrasubsectors));
|
extrasubsectors = (extrasubsector_t *)calloc(totsubsectors, sizeof (*extrasubsectors));
|
||||||
if (extrasubsectors == NULL)
|
if (extrasubsectors == NULL)
|
||||||
I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors));
|
I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors));
|
||||||
|
|
||||||
|
|
@ -283,7 +283,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
|
||||||
fixed_t xfrac, xfracstep;
|
fixed_t xfrac, xfracstep;
|
||||||
fixed_t yfracstep, scale_y;
|
fixed_t yfracstep, scale_y;
|
||||||
const column_t *patchcol;
|
const column_t *patchcol;
|
||||||
UINT8 *block = mipmap->data;
|
UINT8 *block = (UINT8 *)mipmap->data;
|
||||||
INT32 bpp;
|
INT32 bpp;
|
||||||
INT32 blockmodulo;
|
INT32 blockmodulo;
|
||||||
|
|
||||||
|
|
@ -330,7 +330,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
|
||||||
fixed_t xfrac, xfracstep;
|
fixed_t xfrac, xfracstep;
|
||||||
fixed_t yfracstep, scale_y;
|
fixed_t yfracstep, scale_y;
|
||||||
const column_t *patchcol;
|
const column_t *patchcol;
|
||||||
UINT8 *block = mipmap->data;
|
UINT8 *block = (UINT8 *)mipmap->data;
|
||||||
INT32 bpp;
|
INT32 bpp;
|
||||||
INT32 blockmodulo;
|
INT32 blockmodulo;
|
||||||
INT32 width, height;
|
INT32 width, height;
|
||||||
|
|
@ -423,7 +423,7 @@ static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
|
||||||
INT32 blocksize = (grMipmap->width * grMipmap->height);
|
INT32 blocksize = (grMipmap->width * grMipmap->height);
|
||||||
|
|
||||||
bpp = format2bpp(grMipmap->format);
|
bpp = format2bpp(grMipmap->format);
|
||||||
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));
|
block = (UINT8 *)Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));
|
||||||
|
|
||||||
switch (bpp)
|
switch (bpp)
|
||||||
{
|
{
|
||||||
|
|
@ -476,12 +476,12 @@ static void HWR_GenerateTexture(GLMapTexture_t *grtex, INT32 texnum, boolean noe
|
||||||
|
|
||||||
grtex->mipmap.width = (UINT16)texture->width;
|
grtex->mipmap.width = (UINT16)texture->width;
|
||||||
grtex->mipmap.height = (UINT16)texture->height;
|
grtex->mipmap.height = (UINT16)texture->height;
|
||||||
grtex->mipmap.format = textureformat;
|
grtex->mipmap.format = (GLTextureFormat_t)textureformat;
|
||||||
|
|
||||||
if (!noencoremap && encoremap)
|
if (!noencoremap && encoremap)
|
||||||
colormap += COLORMAP_REMAPOFFSET;
|
colormap += COLORMAP_REMAPOFFSET;
|
||||||
|
|
||||||
grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
grtex->mipmap.colormap = (GLColormap_t *)Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
||||||
grtex->mipmap.colormap->source = colormap;
|
grtex->mipmap.colormap->source = colormap;
|
||||||
M_Memcpy(grtex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
|
M_Memcpy(grtex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
|
||||||
|
|
||||||
|
|
@ -513,17 +513,17 @@ static void HWR_GenerateTexture(GLMapTexture_t *grtex, INT32 texnum, boolean noe
|
||||||
{
|
{
|
||||||
boolean dealloc = true;
|
boolean dealloc = true;
|
||||||
size_t lumplength = W_LumpLengthPwad(patch->wad, patch->lump);
|
size_t lumplength = W_LumpLengthPwad(patch->wad, patch->lump);
|
||||||
pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
|
pdata = (uint8_t*)W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE);
|
||||||
realpatch = (softwarepatch_t *)pdata;
|
realpatch = (softwarepatch_t *)pdata;
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
if (Picture_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||||
realpatch = (softwarepatch_t *)Picture_PNGConvert(pdata, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, lumplength, NULL, 0);
|
realpatch = (softwarepatch_t *)Picture_PNGConvert(pdata, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, lumplength, NULL, (pictureflags_t)0);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef WALLFLATS
|
#ifdef WALLFLATS
|
||||||
if (texture->type == TEXTURETYPE_FLAT)
|
if (texture->type == TEXTURETYPE_FLAT)
|
||||||
realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0);
|
realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, (pictureflags_t)0);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
@ -566,7 +566,7 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||||
grMipmap->flags = 0;
|
grMipmap->flags = 0;
|
||||||
|
|
||||||
// setup the texture info
|
// setup the texture info
|
||||||
grMipmap->format = patchformat;
|
grMipmap->format = (GLTextureFormat_t)patchformat;
|
||||||
|
|
||||||
grPatch->max_s = (float)patch->width / (float)grMipmap->width;
|
grPatch->max_s = (float)patch->width / (float)grMipmap->width;
|
||||||
grPatch->max_t = (float)patch->height / (float)grMipmap->height;
|
grPatch->max_t = (float)patch->height / (float)grMipmap->height;
|
||||||
|
|
@ -601,7 +601,7 @@ void HWR_FreeTextureData(patch_t *patch)
|
||||||
if (!patch || !patch->hardware)
|
if (!patch || !patch->hardware)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
grPatch = patch->hardware;
|
grPatch = (GLPatch_t*)patch->hardware;
|
||||||
|
|
||||||
if (vid.glstate == VID_GL_LIBRARY_LOADED)
|
if (vid.glstate == VID_GL_LIBRARY_LOADED)
|
||||||
HWD.pfnDeleteTexture(grPatch->mipmap);
|
HWD.pfnDeleteTexture(grPatch->mipmap);
|
||||||
|
|
@ -616,7 +616,7 @@ void HWR_FreeTexture(patch_t *patch)
|
||||||
|
|
||||||
if (patch->hardware)
|
if (patch->hardware)
|
||||||
{
|
{
|
||||||
GLPatch_t *grPatch = patch->hardware;
|
GLPatch_t *grPatch = (GLPatch_t*)patch->hardware;
|
||||||
|
|
||||||
HWR_FreeTextureColormaps(patch);
|
HWR_FreeTextureColormaps(patch);
|
||||||
|
|
||||||
|
|
@ -641,7 +641,7 @@ void HWR_FreeTextureColormaps(patch_t *patch)
|
||||||
if (!patch)
|
if (!patch)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pat = patch->hardware;
|
pat = (GLPatch_t*)patch->hardware;
|
||||||
if (!pat)
|
if (!pat)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -759,8 +759,8 @@ void HWR_LoadMapTextures(size_t pnumtextures)
|
||||||
HWR_FreeMapTextures();
|
HWR_FreeMapTextures();
|
||||||
|
|
||||||
gl_numtextures = pnumtextures;
|
gl_numtextures = pnumtextures;
|
||||||
gl_textures = calloc(gl_numtextures, sizeof(*gl_textures));
|
gl_textures = (GLMapTexture_t *)calloc(gl_numtextures, sizeof(*gl_textures));
|
||||||
gl_flats = calloc(gl_numtextures, sizeof(*gl_flats));
|
gl_flats = (GLMapTexture_t *)calloc(gl_numtextures, sizeof(*gl_flats));
|
||||||
|
|
||||||
if ((gl_textures == NULL) || (gl_flats == NULL))
|
if ((gl_textures == NULL) || (gl_flats == NULL))
|
||||||
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures");
|
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures");
|
||||||
|
|
@ -879,7 +879,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||||
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
||||||
PU_HWRCACHE, &grMipmap->data));
|
PU_HWRCACHE, &grMipmap->data));
|
||||||
|
|
||||||
flat = grMipmap->data;
|
flat = (UINT8*)grMipmap->data;
|
||||||
for (steppy = 0; steppy < size; steppy++)
|
for (steppy = 0; steppy < size; steppy++)
|
||||||
if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
||||||
flat[steppy] = grMipmap->colormap->source[flat[steppy]];
|
flat[steppy] = grMipmap->colormap->source[flat[steppy]];
|
||||||
|
|
@ -906,7 +906,7 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum, boole
|
||||||
grMipmap->height = (UINT16)textures[texturenum]->height;
|
grMipmap->height = (UINT16)textures[texturenum]->height;
|
||||||
size = (grMipmap->width * grMipmap->height);
|
size = (grMipmap->width * grMipmap->height);
|
||||||
|
|
||||||
flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data);
|
flat = (UINT8 *)Z_Malloc(size, PU_HWRCACHE, &grMipmap->data);
|
||||||
converted = (UINT8 *)Picture_TextureToFlat(texturenum);
|
converted = (UINT8 *)Picture_TextureToFlat(texturenum);
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -934,7 +934,7 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||||
if (!noencoremap && encoremap)
|
if (!noencoremap && encoremap)
|
||||||
colormap += COLORMAP_REMAPOFFSET;
|
colormap += COLORMAP_REMAPOFFSET;
|
||||||
|
|
||||||
grmip->colormap = Z_Calloc(sizeof(*grmip->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
grmip->colormap = (GLColormap_t *)Z_Calloc(sizeof(*grmip->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
||||||
grmip->colormap->source = colormap;
|
grmip->colormap->source = colormap;
|
||||||
M_Memcpy(grmip->colormap->data, colormap, 256 * sizeof(UINT8));
|
M_Memcpy(grmip->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||||
}
|
}
|
||||||
|
|
@ -1013,7 +1013,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap)
|
||||||
}
|
}
|
||||||
else if (levelflat->type == LEVELFLAT_PATCH)
|
else if (levelflat->type == LEVELFLAT_PATCH)
|
||||||
{
|
{
|
||||||
patch_t *patch = W_CachePatchNum(levelflat->u.flat.lumpnum, PU_CACHE);
|
patch_t *patch = (patch_t *)W_CachePatchNum(levelflat->u.flat.lumpnum, PU_CACHE);
|
||||||
levelflat->width = (UINT16)(patch->width);
|
levelflat->width = (UINT16)(patch->width);
|
||||||
levelflat->height = (UINT16)(patch->height);
|
levelflat->height = (UINT16)(patch->height);
|
||||||
HWR_GetPatch(patch);
|
HWR_GetPatch(patch);
|
||||||
|
|
@ -1021,13 +1021,13 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap)
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
else if (levelflat->type == LEVELFLAT_PNG)
|
else if (levelflat->type == LEVELFLAT_PNG)
|
||||||
{
|
{
|
||||||
GLMipmap_t *mipmap = levelflat->mipmap;
|
GLMipmap_t *mipmap = (GLMipmap_t *)levelflat->mipmap;
|
||||||
|
|
||||||
// Cache the picture.
|
// Cache the picture.
|
||||||
if (!levelflat->mippic)
|
if (!levelflat->mippic)
|
||||||
{
|
{
|
||||||
INT32 pngwidth = 0, pngheight = 0;
|
INT32 pngwidth = 0, pngheight = 0;
|
||||||
void *pic = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
|
void *pic = Picture_PNGConvert((const UINT8*)W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, (pictureflags_t)0);
|
||||||
|
|
||||||
Z_ChangeTag(pic, PU_LEVEL);
|
Z_ChangeTag(pic, PU_LEVEL);
|
||||||
Z_SetUser(pic, &levelflat->mippic);
|
Z_SetUser(pic, &levelflat->mippic);
|
||||||
|
|
@ -1039,7 +1039,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap)
|
||||||
// Make the mipmap.
|
// Make the mipmap.
|
||||||
if (mipmap == NULL)
|
if (mipmap == NULL)
|
||||||
{
|
{
|
||||||
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_STATIC, NULL);
|
mipmap = (GLMipmap_t *)Z_Calloc(sizeof(GLMipmap_t), PU_STATIC, NULL);
|
||||||
mipmap->format = GL_TEXFMT_P_8;
|
mipmap->format = GL_TEXFMT_P_8;
|
||||||
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
||||||
levelflat->mipmap = mipmap;
|
levelflat->mipmap = mipmap;
|
||||||
|
|
@ -1057,7 +1057,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap)
|
||||||
mipmap->height = levelflat->height;
|
mipmap->height = levelflat->height;
|
||||||
|
|
||||||
size = (mipmap->width * mipmap->height);
|
size = (mipmap->width * mipmap->height);
|
||||||
flat = Z_Malloc(size, PU_LEVEL, &mipmap->data);
|
flat = (UINT8 *)Z_Malloc(size, PU_LEVEL, &mipmap->data);
|
||||||
M_Memcpy(flat, levelflat->mippic, size);
|
M_Memcpy(flat, levelflat->mippic, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1074,7 +1074,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat, boolean noencoremap)
|
||||||
// --------------------+
|
// --------------------+
|
||||||
static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap)
|
static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap)
|
||||||
{
|
{
|
||||||
GLPatch_t *grPatch = patch->hardware;
|
GLPatch_t *grPatch = (GLPatch_t *)patch->hardware;
|
||||||
if (!grMipmap->downloaded && !grMipmap->data)
|
if (!grMipmap->downloaded && !grMipmap->data)
|
||||||
HWR_MakePatch(patch, grPatch, grMipmap, true);
|
HWR_MakePatch(patch, grPatch, grMipmap, true);
|
||||||
|
|
||||||
|
|
@ -1092,7 +1092,7 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap)
|
||||||
// ----------------------+
|
// ----------------------+
|
||||||
static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *grMipmap)
|
static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *grMipmap)
|
||||||
{
|
{
|
||||||
GLPatch_t *grPatch = patch->hardware;
|
GLPatch_t *grPatch = (GLPatch_t *)patch->hardware;
|
||||||
HWR_MakePatch(patch, grPatch, grMipmap, true);
|
HWR_MakePatch(patch, grPatch, grMipmap, true);
|
||||||
|
|
||||||
// If hardware does not have the texture, then call pfnSetTexture to upload it
|
// If hardware does not have the texture, then call pfnSetTexture to upload it
|
||||||
|
|
@ -1127,7 +1127,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
|
||||||
|
|
||||||
if (!patch->hardware)
|
if (!patch->hardware)
|
||||||
Patch_CreateGL(patch);
|
Patch_CreateGL(patch);
|
||||||
grPatch = patch->hardware;
|
grPatch = (GLPatch_t *)patch->hardware;
|
||||||
|
|
||||||
// Blatant hack for encore colormapping aside...
|
// Blatant hack for encore colormapping aside...
|
||||||
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
|
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
|
||||||
|
|
@ -1161,12 +1161,12 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
|
||||||
// (it have a liste of mipmap)
|
// (it have a liste of mipmap)
|
||||||
// this malloc is cleared in HWR_FreeColormapCache
|
// this malloc is cleared in HWR_FreeColormapCache
|
||||||
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
||||||
newMipmap = calloc(1, sizeof (*newMipmap));
|
newMipmap = (GLMipmap_t *)calloc(1, sizeof (*newMipmap));
|
||||||
if (newMipmap == NULL)
|
if (newMipmap == NULL)
|
||||||
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
|
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
|
||||||
grMipmap->nextcolormap = newMipmap;
|
grMipmap->nextcolormap = newMipmap;
|
||||||
|
|
||||||
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
newMipmap->colormap = (GLColormap_t *)Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
||||||
newMipmap->colormap->source = colormap;
|
newMipmap->colormap->source = colormap;
|
||||||
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||||
|
|
||||||
|
|
@ -1202,7 +1202,7 @@ static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheig
|
||||||
|
|
||||||
stepy = ((INT32)SHORT(pic->height)<<FRACBITS)/pblockheight;
|
stepy = ((INT32)SHORT(pic->height)<<FRACBITS)/pblockheight;
|
||||||
stepx = ((INT32)SHORT(pic->width)<<FRACBITS)/pblockwidth;
|
stepx = ((INT32)SHORT(pic->width)<<FRACBITS)/pblockwidth;
|
||||||
picbpp = format2bpp(picmode2GR[pic->mode]);
|
picbpp = format2bpp((GLTextureFormat_t)picmode2GR[pic->mode]);
|
||||||
posy = 0;
|
posy = 0;
|
||||||
for (j = 0; j < pblockheight; j++)
|
for (j = 0; j < pblockheight; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -1270,7 +1270,7 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum)
|
||||||
UINT8 *block;
|
UINT8 *block;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
pic = W_CacheLumpNum(lumpnum, PU_CACHE);
|
pic = (pic_t*)W_CacheLumpNum(lumpnum, PU_CACHE);
|
||||||
patch->width = SHORT(pic->width);
|
patch->width = SHORT(pic->width);
|
||||||
patch->height = SHORT(pic->height);
|
patch->height = SHORT(pic->height);
|
||||||
len = W_LumpLength(lumpnum) - sizeof (pic_t);
|
len = W_LumpLength(lumpnum) - sizeof (pic_t);
|
||||||
|
|
@ -1279,9 +1279,9 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum)
|
||||||
grPatch->mipmap->height = (UINT16)patch->height;
|
grPatch->mipmap->height = (UINT16)patch->height;
|
||||||
|
|
||||||
if (pic->mode == PALETTE)
|
if (pic->mode == PALETTE)
|
||||||
grPatch->mipmap->format = textureformat; // can be set by driver
|
grPatch->mipmap->format = (GLTextureFormat_t)textureformat; // can be set by driver
|
||||||
else
|
else
|
||||||
grPatch->mipmap->format = picmode2GR[pic->mode];
|
grPatch->mipmap->format = (GLTextureFormat_t)picmode2GR[pic->mode];
|
||||||
|
|
||||||
Z_Free(grPatch->mipmap->data);
|
Z_Free(grPatch->mipmap->data);
|
||||||
|
|
||||||
|
|
@ -1290,7 +1290,7 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum)
|
||||||
|
|
||||||
if (patch->width == SHORT(pic->width) &&
|
if (patch->width == SHORT(pic->width) &&
|
||||||
patch->height == SHORT(pic->height) &&
|
patch->height == SHORT(pic->height) &&
|
||||||
format2bpp(grPatch->mipmap->format) == format2bpp(picmode2GR[pic->mode]))
|
format2bpp(grPatch->mipmap->format) == format2bpp((GLTextureFormat_t)picmode2GR[pic->mode]))
|
||||||
{
|
{
|
||||||
// no conversion needed
|
// no conversion needed
|
||||||
M_Memcpy(grPatch->mipmap->data, pic->data,len);
|
M_Memcpy(grPatch->mipmap->data, pic->data,len);
|
||||||
|
|
@ -1318,7 +1318,7 @@ patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||||
lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache;
|
lumpcache_t *lumpcache = wadfiles[wadnum]->patchcache;
|
||||||
if (!lumpcache[lumpnum])
|
if (!lumpcache[lumpnum])
|
||||||
{
|
{
|
||||||
void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]);
|
patch_t *ptr = (patch_t *)Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]);
|
||||||
Patch_Create(NULL, 0, ptr);
|
Patch_Create(NULL, 0, ptr);
|
||||||
Patch_AllocateHardwarePatch(ptr);
|
Patch_AllocateHardwarePatch(ptr);
|
||||||
}
|
}
|
||||||
|
|
@ -1336,7 +1336,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
|
||||||
{
|
{
|
||||||
INT32 i,j;
|
INT32 i,j;
|
||||||
fixed_t posx, posy, stepx, stepy;
|
fixed_t posx, posy, stepx, stepy;
|
||||||
UINT8 *block = mipmap->data; // places the data directly into here
|
UINT8 *block = (UINT8 *)mipmap->data; // places the data directly into here
|
||||||
UINT8 *flat;
|
UINT8 *flat;
|
||||||
UINT8 *dest, *src, texel;
|
UINT8 *dest, *src, texel;
|
||||||
RGBA_t col;
|
RGBA_t col;
|
||||||
|
|
@ -881,7 +881,7 @@ void HWR_DrawViewBorder(INT32 clearlines)
|
||||||
// top edge
|
// top edge
|
||||||
if (clearlines > basewindowy - 8)
|
if (clearlines > basewindowy - 8)
|
||||||
{
|
{
|
||||||
patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH);
|
patch = (patch_t*)W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH);
|
||||||
for (x = 0; x < baseviewwidth; x += 8)
|
for (x = 0; x < baseviewwidth; x += 8)
|
||||||
HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8,
|
HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8,
|
||||||
0);
|
0);
|
||||||
|
|
@ -890,7 +890,7 @@ void HWR_DrawViewBorder(INT32 clearlines)
|
||||||
// bottom edge
|
// bottom edge
|
||||||
if (clearlines > basewindowy + baseviewheight)
|
if (clearlines > basewindowy + baseviewheight)
|
||||||
{
|
{
|
||||||
patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH);
|
patch = (patch_t*)W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH);
|
||||||
for (x = 0; x < baseviewwidth; x += 8)
|
for (x = 0; x < baseviewwidth; x += 8)
|
||||||
HWR_DrawPatch(patch, basewindowx + x,
|
HWR_DrawPatch(patch, basewindowx + x,
|
||||||
basewindowy + baseviewheight, 0);
|
basewindowy + baseviewheight, 0);
|
||||||
|
|
@ -899,7 +899,7 @@ void HWR_DrawViewBorder(INT32 clearlines)
|
||||||
// left edge
|
// left edge
|
||||||
if (clearlines > basewindowy)
|
if (clearlines > basewindowy)
|
||||||
{
|
{
|
||||||
patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH);
|
patch = (patch_t*)W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH);
|
||||||
for (y = 0; y < baseviewheight && basewindowy + y < clearlines;
|
for (y = 0; y < baseviewheight && basewindowy + y < clearlines;
|
||||||
y += 8)
|
y += 8)
|
||||||
{
|
{
|
||||||
|
|
@ -911,7 +911,7 @@ void HWR_DrawViewBorder(INT32 clearlines)
|
||||||
// right edge
|
// right edge
|
||||||
if (clearlines > basewindowy)
|
if (clearlines > basewindowy)
|
||||||
{
|
{
|
||||||
patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH);
|
patch = (patch_t*)W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH);
|
||||||
for (y = 0; y < baseviewheight && basewindowy+y < clearlines;
|
for (y = 0; y < baseviewheight && basewindowy+y < clearlines;
|
||||||
y += 8)
|
y += 8)
|
||||||
{
|
{
|
||||||
|
|
@ -922,22 +922,22 @@ void HWR_DrawViewBorder(INT32 clearlines)
|
||||||
|
|
||||||
// Draw beveled corners.
|
// Draw beveled corners.
|
||||||
if (clearlines > basewindowy - 8)
|
if (clearlines > basewindowy - 8)
|
||||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TL],
|
HWR_DrawPatch((patch_t*)W_CachePatchNum(viewborderlump[BRDR_TL],
|
||||||
PU_PATCH),
|
PU_PATCH),
|
||||||
basewindowx - 8, basewindowy - 8, 0);
|
basewindowx - 8, basewindowy - 8, 0);
|
||||||
|
|
||||||
if (clearlines > basewindowy - 8)
|
if (clearlines > basewindowy - 8)
|
||||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TR],
|
HWR_DrawPatch((patch_t*)W_CachePatchNum(viewborderlump[BRDR_TR],
|
||||||
PU_PATCH),
|
PU_PATCH),
|
||||||
basewindowx + baseviewwidth, basewindowy - 8, 0);
|
basewindowx + baseviewwidth, basewindowy - 8, 0);
|
||||||
|
|
||||||
if (clearlines > basewindowy+baseviewheight)
|
if (clearlines > basewindowy+baseviewheight)
|
||||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BL],
|
HWR_DrawPatch((patch_t*)W_CachePatchNum(viewborderlump[BRDR_BL],
|
||||||
PU_PATCH),
|
PU_PATCH),
|
||||||
basewindowx - 8, basewindowy + baseviewheight, 0);
|
basewindowx - 8, basewindowy + baseviewheight, 0);
|
||||||
|
|
||||||
if (clearlines > basewindowy + baseviewheight)
|
if (clearlines > basewindowy + baseviewheight)
|
||||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BR],
|
HWR_DrawPatch((patch_t*)W_CachePatchNum(viewborderlump[BRDR_BR],
|
||||||
PU_PATCH),
|
PU_PATCH),
|
||||||
basewindowx + baseviewwidth,
|
basewindowx + baseviewwidth,
|
||||||
basewindowy + baseviewheight, 0);
|
basewindowy + baseviewheight, 0);
|
||||||
|
|
@ -1297,19 +1297,19 @@ static inline boolean saveTGA(const char *file_name, void *buffer,
|
||||||
|
|
||||||
UINT8 *HWR_GetScreenshot(void)
|
UINT8 *HWR_GetScreenshot(void)
|
||||||
{
|
{
|
||||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
UINT8 *buf = (UINT8 *)malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
// returns 24bit 888 RGB
|
// returns 24bit 888 RGB
|
||||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (UINT16 *)buf);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean HWR_Screenshot(const char *pathname)
|
boolean HWR_Screenshot(const char *pathname)
|
||||||
{
|
{
|
||||||
boolean ret;
|
boolean ret;
|
||||||
UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
UINT8 *buf = (UINT8 *)malloc(vid.width * vid.height * 3 * sizeof (*buf));
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
|
|
@ -1318,7 +1318,7 @@ boolean HWR_Screenshot(const char *pathname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns 24bit 888 RGB
|
// returns 24bit 888 RGB
|
||||||
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf);
|
HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (UINT16 *)buf);
|
||||||
|
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL);
|
||||||
|
|
@ -1233,7 +1233,7 @@ static void HWR_SetLight(void)
|
||||||
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data)
|
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data)
|
||||||
{
|
{
|
||||||
|
|
||||||
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data);
|
UINT16 *Data = (UINT16 *)Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data);
|
||||||
|
|
||||||
for (i = 0; i < 128; i++)
|
for (i = 0; i < 128; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1285,7 +1285,7 @@ static inline void HWR_BuildWallLightmaps(FVector *p1, FVector *p2, int lighnum,
|
||||||
(void)lighnum;
|
(void)lighnum;
|
||||||
(void)p1;
|
(void)p1;
|
||||||
(void)p2;
|
(void)p2;
|
||||||
lp = malloc(sizeof (*lp));
|
lp = (lightmap_t *)malloc(sizeof (*lp));
|
||||||
lp->next = line->lightmaps;
|
lp->next = line->lightmaps;
|
||||||
line->lightmaps = lp;
|
line->lightmaps = lp;
|
||||||
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
/// \file hw_main.c
|
/// \file hw_main.c
|
||||||
/// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2
|
/// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "../doomstat.h"
|
#include "../doomstat.h"
|
||||||
|
|
@ -226,7 +227,7 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32
|
||||||
);
|
);
|
||||||
|
|
||||||
// Less change in contrast in dark sectors
|
// Less change in contrast in dark sectors
|
||||||
extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255);
|
extralight = FixedMul(extralight, std::min(std::max(0, *lightlevel), 255) * FRACUNIT / 255);
|
||||||
|
|
||||||
if (papersprite)
|
if (papersprite)
|
||||||
{
|
{
|
||||||
|
|
@ -241,7 +242,7 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32
|
||||||
|
|
||||||
// Less change in contrast at further distances, to counteract DOOM diminished light
|
// Less change in contrast at further distances, to counteract DOOM diminished light
|
||||||
fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT));
|
fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT));
|
||||||
extralight = FixedMul(extralight, min(n, FRACUNIT));
|
extralight = FixedMul(extralight, std::min(n, FRACUNIT));
|
||||||
|
|
||||||
// Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance
|
// Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance
|
||||||
*lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT;
|
*lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT;
|
||||||
|
|
@ -290,8 +291,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
|
||||||
fade_alpha = (float)(sqrt(255-light_level) * 12) / 255.0f;
|
fade_alpha = (float)(sqrt(255-light_level) * 12) / 255.0f;
|
||||||
|
|
||||||
// Clamp the alpha values
|
// Clamp the alpha values
|
||||||
tint_alpha = min(max(tint_alpha, 0.0f), 1.0f);
|
tint_alpha = std::min(std::max(tint_alpha, 0.0f), 1.0f);
|
||||||
fade_alpha = min(max(fade_alpha, 0.0f), 1.0f);
|
fade_alpha = std::min(std::max(fade_alpha, 0.0f), 1.0f);
|
||||||
|
|
||||||
red = (tint_color.s.red * tint_alpha) + (red * (1.0f - tint_alpha));
|
red = (tint_color.s.red * tint_alpha) + (red * (1.0f - tint_alpha));
|
||||||
green = (tint_color.s.green * tint_alpha) + (green * (1.0f - tint_alpha));
|
green = (tint_color.s.green * tint_alpha) + (green * (1.0f - tint_alpha));
|
||||||
|
|
@ -307,7 +308,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clamp the light level, since it can sometimes go out of the 0-255 range from animations
|
// Clamp the light level, since it can sometimes go out of the 0-255 range from animations
|
||||||
light_level = min(max(light_level, 0), 255);
|
light_level = std::min(std::max(light_level, 0), 255);
|
||||||
|
|
||||||
Surface->PolyColor.rgba = poly_color.rgba;
|
Surface->PolyColor.rgba = poly_color.rgba;
|
||||||
Surface->TintColor.rgba = tint_color.rgba;
|
Surface->TintColor.rgba = tint_color.rgba;
|
||||||
|
|
@ -737,7 +738,7 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast)
|
||||||
|
|
||||||
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
|
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
|
||||||
{
|
{
|
||||||
transtablenum = max(min(transtablenum, tr_trans90), 0);
|
transtablenum = std::max(std::min(transtablenum, (INT32)tr_trans90), 0);
|
||||||
|
|
||||||
switch (transtablenum)
|
switch (transtablenum)
|
||||||
{
|
{
|
||||||
|
|
@ -1332,20 +1333,20 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
popentop = min(worldtop, worldhigh);
|
popentop = std::min(worldtop, worldhigh);
|
||||||
popenbottom = max(worldbottom, worldlow);
|
popenbottom = std::max(worldbottom, worldlow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl_linedef->flags & ML_NOSKEW)
|
if (gl_linedef->flags & ML_NOSKEW)
|
||||||
{
|
{
|
||||||
if (gl_linedef->flags & ML_MIDPEG)
|
if (gl_linedef->flags & ML_MIDPEG)
|
||||||
{
|
{
|
||||||
polybottom = max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset;
|
polybottom = std::max(front->floorheight, back->floorheight) + gl_sidedef->rowoffset;
|
||||||
polytop = polybottom + textureheight[gl_midtexture]*repeats;
|
polytop = polybottom + textureheight[gl_midtexture]*repeats;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
polytop = min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset;
|
polytop = std::min(front->ceilingheight, back->ceilingheight) + gl_sidedef->rowoffset;
|
||||||
polybottom = polytop - textureheight[gl_midtexture]*repeats;
|
polybottom = polytop - textureheight[gl_midtexture]*repeats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1374,8 +1375,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
highcut = popentop;
|
highcut = popentop;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = min(highcut, polytop);
|
h = std::min(highcut, polytop);
|
||||||
l = max(polybottom, lowcut);
|
l = std::max(polybottom, lowcut);
|
||||||
|
|
||||||
{
|
{
|
||||||
// PEGGING
|
// PEGGING
|
||||||
|
|
@ -1434,8 +1435,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
: worldlowslope-worldlow;
|
: worldlowslope-worldlow;
|
||||||
|
|
||||||
// Texture stuff
|
// Texture stuff
|
||||||
h = min(highcut, polytop);
|
h = std::min(highcut, polytop);
|
||||||
l = max(polybottom, lowcut);
|
l = std::max(polybottom, lowcut);
|
||||||
|
|
||||||
{
|
{
|
||||||
// PEGGING
|
// PEGGING
|
||||||
|
|
@ -1443,7 +1444,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
texturevpeg = textureheight[gl_sidedef->midtexture]*repeats - h + polybottom;
|
texturevpeg = textureheight[gl_sidedef->midtexture]*repeats - h + polybottom;
|
||||||
else
|
else
|
||||||
texturevpeg = polytop - h;
|
texturevpeg = polytop - h;
|
||||||
|
|
||||||
// Apply tripwire flipping for slope correction as well
|
// Apply tripwire flipping for slope correction as well
|
||||||
if (R_ShouldFlipTripWire(gl_linedef))
|
if (R_ShouldFlipTripWire(gl_linedef))
|
||||||
{
|
{
|
||||||
|
|
@ -1643,10 +1644,10 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
INT32 texnum, basetexnum;
|
INT32 texnum, basetexnum;
|
||||||
line_t * newline = NULL; // Multi-Property FOF
|
line_t * newline = NULL; // Multi-Property FOF
|
||||||
|
|
||||||
lowcut = max(worldbottom, worldlow);
|
lowcut = std::max(worldbottom, worldlow);
|
||||||
highcut = min(worldtop, worldhigh);
|
highcut = std::min(worldtop, worldhigh);
|
||||||
lowcutslope = max(worldbottomslope, worldlowslope);
|
lowcutslope = std::max(worldbottomslope, worldlowslope);
|
||||||
highcutslope = min(worldtopslope, worldhighslope);
|
highcutslope = std::min(worldtopslope, worldhighslope);
|
||||||
|
|
||||||
if (gl_backsector->ffloors)
|
if (gl_backsector->ffloors)
|
||||||
{
|
{
|
||||||
|
|
@ -1793,7 +1794,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
if (rover->alpha < 256 || rover->blend)
|
if (rover->alpha < 256 || rover->blend)
|
||||||
{
|
{
|
||||||
blendmode = HWR_GetBlendModeFlag(rover->blend);
|
blendmode = HWR_GetBlendModeFlag(rover->blend);
|
||||||
Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255));
|
Surf.PolyColor.s.alpha = std::max(0, std::min(rover->alpha, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1922,7 +1923,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||||
if (rover->alpha < 256 || rover->blend)
|
if (rover->alpha < 256 || rover->blend)
|
||||||
{
|
{
|
||||||
blendmode = HWR_GetBlendModeFlag(rover->blend);
|
blendmode = HWR_GetBlendModeFlag(rover->blend);
|
||||||
Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255));
|
Surf.PolyColor.s.alpha = std::max(0, std::min(rover->alpha, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2168,9 +2169,9 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord)
|
||||||
static inline void HWR_AddPolyObjectSegs(void)
|
static inline void HWR_AddPolyObjectSegs(void)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
seg_t *gl_fakeline = Z_Calloc(sizeof(seg_t), PU_STATIC, NULL);
|
seg_t *gl_fakeline = (seg_t *)Z_Calloc(sizeof(seg_t), PU_STATIC, NULL);
|
||||||
polyvertex_t *pv1 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL);
|
polyvertex_t *pv1 = (polyvertex_t *)Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL);
|
||||||
polyvertex_t *pv2 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL);
|
polyvertex_t *pv2 = (polyvertex_t *)Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL);
|
||||||
|
|
||||||
// Sort through all the polyobjects
|
// Sort through all the polyobjects
|
||||||
for (i = 0; i < numpolys; ++i)
|
for (i = 0; i < numpolys; ++i)
|
||||||
|
|
@ -2551,12 +2552,12 @@ static void HWR_Subsector(size_t num)
|
||||||
|
|
||||||
light = R_GetPlaneLight(gl_frontsector, locFloorHeight, false);
|
light = R_GetPlaneLight(gl_frontsector, locFloorHeight, false);
|
||||||
if (gl_frontsector->floorlightsec == -1 && !gl_frontsector->floorlightabsolute)
|
if (gl_frontsector->floorlightsec == -1 && !gl_frontsector->floorlightabsolute)
|
||||||
floorlightlevel = max(0, min(255, *gl_frontsector->lightlist[light].lightlevel + gl_frontsector->floorlightlevel));
|
floorlightlevel = std::max(0, std::min(255, *gl_frontsector->lightlist[light].lightlevel + gl_frontsector->floorlightlevel));
|
||||||
floorcolormap = *gl_frontsector->lightlist[light].extra_colormap;
|
floorcolormap = *gl_frontsector->lightlist[light].extra_colormap;
|
||||||
|
|
||||||
light = R_GetPlaneLight(gl_frontsector, locCeilingHeight, false);
|
light = R_GetPlaneLight(gl_frontsector, locCeilingHeight, false);
|
||||||
if (gl_frontsector->ceilinglightsec == -1 && !gl_frontsector->ceilinglightabsolute)
|
if (gl_frontsector->ceilinglightsec == -1 && !gl_frontsector->ceilinglightabsolute)
|
||||||
ceilinglightlevel = max(0, min(255, *gl_frontsector->lightlist[light].lightlevel + gl_frontsector->ceilinglightlevel));
|
ceilinglightlevel = std::max(0, std::min(255, *gl_frontsector->lightlist[light].lightlevel + gl_frontsector->ceilinglightlevel));
|
||||||
ceilingcolormap = *gl_frontsector->lightlist[light].extra_colormap;
|
ceilingcolormap = *gl_frontsector->lightlist[light].extra_colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2667,7 +2668,7 @@ static void HWR_Subsector(size_t num)
|
||||||
false,
|
false,
|
||||||
*rover->bottomheight,
|
*rover->bottomheight,
|
||||||
*gl_frontsector->lightlist[light].lightlevel,
|
*gl_frontsector->lightlist[light].lightlevel,
|
||||||
max(0, min(rover->alpha, 255)), rover->master->frontsector, blendmode,
|
std::max(0, std::min(rover->alpha, 255)), rover->master->frontsector, blendmode,
|
||||||
false, *gl_frontsector->lightlist[light].extra_colormap);
|
false, *gl_frontsector->lightlist[light].extra_colormap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2715,7 +2716,7 @@ static void HWR_Subsector(size_t num)
|
||||||
true,
|
true,
|
||||||
*rover->topheight,
|
*rover->topheight,
|
||||||
*gl_frontsector->lightlist[light].lightlevel,
|
*gl_frontsector->lightlist[light].lightlevel,
|
||||||
max(0, min(rover->alpha, 255)), rover->master->frontsector, blendmode,
|
std::max(0, std::min(rover->alpha, 255)), rover->master->frontsector, blendmode,
|
||||||
false, *gl_frontsector->lightlist[light].extra_colormap);
|
false, *gl_frontsector->lightlist[light].extra_colormap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -4390,14 +4391,14 @@ static void HWR_CreateDrawNodes(void)
|
||||||
// Dump EVERYTHING into a huge drawnode list. Then we'll sort it!
|
// Dump EVERYTHING into a huge drawnode list. Then we'll sort it!
|
||||||
// Could this be optimized into _AddTransparentWall/_AddTransparentPlane?
|
// Could this be optimized into _AddTransparentWall/_AddTransparentPlane?
|
||||||
// Hell yes! But sort algorithm must be modified to use a linked list.
|
// Hell yes! But sort algorithm must be modified to use a linked list.
|
||||||
sortnode = Z_Calloc((sizeof(planeinfo_t)*numplanes)
|
sortnode = (gl_drawnode_t *)Z_Calloc((sizeof(planeinfo_t)*numplanes)
|
||||||
+ (sizeof(polyplaneinfo_t)*numpolyplanes)
|
+ (sizeof(polyplaneinfo_t)*numpolyplanes)
|
||||||
+ (sizeof(wallinfo_t)*numwalls)
|
+ (sizeof(wallinfo_t)*numwalls)
|
||||||
,PU_STATIC, NULL);
|
,PU_STATIC, NULL);
|
||||||
// todo:
|
// todo:
|
||||||
// However, in reality we shouldn't be re-copying and shifting all this information
|
// However, in reality we shouldn't be re-copying and shifting all this information
|
||||||
// that is already lying around. This should all be in some sort of linked list or lists.
|
// that is already lying around. This should all be in some sort of linked list or lists.
|
||||||
sortindex = Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL);
|
sortindex = (size_t *)Z_Calloc(sizeof(size_t) * (numplanes + numpolyplanes + numwalls), PU_STATIC, NULL);
|
||||||
|
|
||||||
ps_hw_nodesorttime = I_GetPreciseTime();
|
ps_hw_nodesorttime = I_GetPreciseTime();
|
||||||
|
|
||||||
|
|
@ -4740,7 +4741,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
fixed_t jitters = HITLAGJITTERS;
|
fixed_t jitters = HITLAGJITTERS;
|
||||||
if (R_UsingFrameInterpolation() && !paused)
|
if (R_UsingFrameInterpolation() && !paused)
|
||||||
jitters += (rendertimefrac / HITLAGDIV);
|
jitters += (rendertimefrac / HITLAGDIV);
|
||||||
|
|
||||||
fixed_t mul = thing->hitlag * jitters;
|
fixed_t mul = thing->hitlag * jitters;
|
||||||
|
|
||||||
if (leveltime & 1)
|
if (leveltime & 1)
|
||||||
|
|
@ -5175,16 +5176,16 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
// Hide not-yet-unlocked characters in replays from other people
|
// Hide not-yet-unlocked characters in replays from other people
|
||||||
if (skinnum >= 0 && !R_CanShowSkinInDemo(skinnum))
|
if (skinnum >= 0 && !R_CanShowSkinInDemo(skinnum))
|
||||||
{
|
{
|
||||||
vis->colormap = R_GetTranslationColormap(TC_BLINK, thing->color, GTC_CACHE);
|
vis->colormap = R_GetTranslationColormap(TC_BLINK, (skincolornum_t)thing->color, GTC_CACHE);
|
||||||
}
|
}
|
||||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||||
else if (R_ThingIsFlashing(vis->mobj))
|
else if (R_ThingIsFlashing(vis->mobj))
|
||||||
{
|
{
|
||||||
vis->colormap = R_GetTranslationColormap(TC_HITLAG, 0, GTC_CACHE);
|
vis->colormap = R_GetTranslationColormap(TC_HITLAG, (skincolornum_t)0, GTC_CACHE);
|
||||||
}
|
}
|
||||||
else if (thing->color)
|
else if (thing->color)
|
||||||
{
|
{
|
||||||
vis->colormap = R_GetTranslationColormap(thing->colorized ? TC_RAINBOW : skinnum, thing->color, GTC_CACHE);
|
vis->colormap = R_GetTranslationColormap(thing->colorized ? TC_RAINBOW : skinnum, (skincolornum_t)thing->color, GTC_CACHE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -5484,11 +5485,11 @@ void HWR_BuildSkyDome(void)
|
||||||
sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2;
|
sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2;
|
||||||
|
|
||||||
if (!sky->loops)
|
if (!sky->loops)
|
||||||
sky->loops = malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]));
|
sky->loops = (gl_skyloopdef_t *)malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]));
|
||||||
|
|
||||||
// create vertex array
|
// create vertex array
|
||||||
if (!sky->data)
|
if (!sky->data)
|
||||||
sky->data = malloc(sky->vertex_count * sizeof(sky->data[0]));
|
sky->data = (gl_skyvertex_t *)malloc(sky->vertex_count * sizeof(sky->data[0]));
|
||||||
|
|
||||||
sky->texture = texturetranslation[skytexture];
|
sky->texture = texturetranslation[skytexture];
|
||||||
sky->width = texture->width;
|
sky->width = texture->width;
|
||||||
|
|
@ -5620,7 +5621,7 @@ static void HWR_DrawSkyBackground(player_t *player)
|
||||||
|
|
||||||
dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f);
|
dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f);
|
||||||
|
|
||||||
v[0].s = v[3].s = (-1.0f * angle) / ((ANGLE_90-1)*dimensionmultiply); // left
|
v[0].s = v[3].s = (-1.0f * angle) / ((ANGLE_90-1.0f)*dimensionmultiply); // left
|
||||||
v[2].s = v[1].s = v[0].s + (1.0f/dimensionmultiply); // right (or left + 1.0f)
|
v[2].s = v[1].s = v[0].s + (1.0f/dimensionmultiply); // right (or left + 1.0f)
|
||||||
// use +angle and -1.0f above instead if you wanted old backwards behavior
|
// use +angle and -1.0f above instead if you wanted old backwards behavior
|
||||||
|
|
||||||
|
|
@ -5782,10 +5783,10 @@ static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean
|
||||||
//
|
//
|
||||||
static void HWR_SetShaderState(void)
|
static void HWR_SetShaderState(void)
|
||||||
{
|
{
|
||||||
hwdshaderoption_t state = cv_glshaders.value;
|
hwdshaderoption_t state = (hwdshaderoption_t)cv_glshaders.value;
|
||||||
|
|
||||||
if (!cv_glallowshaders.value)
|
if (!cv_glallowshaders.value)
|
||||||
state = (cv_glshaders.value == HWD_SHADEROPTION_ON ? HWD_SHADEROPTION_NOCUSTOM : cv_glshaders.value);
|
state = (hwdshaderoption_t)(cv_glshaders.value == HWD_SHADEROPTION_ON ? HWD_SHADEROPTION_NOCUSTOM : cv_glshaders.value);
|
||||||
|
|
||||||
HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)state);
|
HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)state);
|
||||||
HWD.pfnSetShader(SHADER_DEFAULT);
|
HWD.pfnSetShader(SHADER_DEFAULT);
|
||||||
|
|
@ -6067,14 +6068,14 @@ CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED,
|
||||||
|
|
||||||
CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
|
CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
|
||||||
|
|
||||||
void CV_glfiltermode_OnChange(void);
|
extern "C" void CV_glfiltermode_OnChange(void);
|
||||||
void CV_glfiltermode_OnChange(void)
|
void CV_glfiltermode_OnChange(void)
|
||||||
{
|
{
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
|
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CV_glanisotropic_OnChange(void);
|
extern "C" void CV_glanisotropic_OnChange(void);
|
||||||
void CV_glanisotropic_OnChange(void)
|
void CV_glanisotropic_OnChange(void)
|
||||||
{
|
{
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
|
|
@ -6466,10 +6467,10 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
|
||||||
if (lump == INT16_MAX)
|
if (lump == INT16_MAX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shaderdef = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
|
shaderdef = (char *)W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
|
||||||
size = W_LumpLengthPwad(wadnum, lump);
|
size = W_LumpLengthPwad(wadnum, lump);
|
||||||
|
|
||||||
line = Z_Malloc(size+1, PU_STATIC, NULL);
|
line = (char *)Z_Malloc(size+1, PU_STATIC, NULL);
|
||||||
M_Memcpy(line, shaderdef, size);
|
M_Memcpy(line, shaderdef, size);
|
||||||
line[size] = '\0';
|
line[size] = '\0';
|
||||||
|
|
||||||
|
|
@ -6530,14 +6531,14 @@ skip_lump:
|
||||||
|
|
||||||
if (PK3)
|
if (PK3)
|
||||||
{
|
{
|
||||||
shader_lumpname = Z_Malloc(strlen(value) + 12, PU_STATIC, NULL);
|
shader_lumpname = (char *)Z_Malloc(strlen(value) + 12, PU_STATIC, NULL);
|
||||||
strcpy(shader_lumpname, "Shaders/sh_");
|
strcpy(shader_lumpname, "Shaders/sh_");
|
||||||
strcat(shader_lumpname, value);
|
strcat(shader_lumpname, value);
|
||||||
shader_lumpnum = W_CheckNumForFullNamePK3(shader_lumpname, wadnum, 0);
|
shader_lumpnum = W_CheckNumForFullNamePK3(shader_lumpname, wadnum, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shader_lumpname = Z_Malloc(strlen(value) + 4, PU_STATIC, NULL);
|
shader_lumpname = (char *)Z_Malloc(strlen(value) + 4, PU_STATIC, NULL);
|
||||||
strcpy(shader_lumpname, "SH_");
|
strcpy(shader_lumpname, "SH_");
|
||||||
strcat(shader_lumpname, value);
|
strcat(shader_lumpname, value);
|
||||||
shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0);
|
shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0);
|
||||||
|
|
@ -6551,7 +6552,7 @@ skip_lump:
|
||||||
}
|
}
|
||||||
|
|
||||||
shader_size = W_LumpLengthPwad(wadnum, shader_lumpnum);
|
shader_size = W_LumpLengthPwad(wadnum, shader_lumpnum);
|
||||||
shader_source = Z_Malloc(shader_size, PU_STATIC, NULL);
|
shader_source = (char *)Z_Malloc(shader_size, PU_STATIC, NULL);
|
||||||
W_ReadLumpPwad(wadnum, shader_lumpnum, shader_source);
|
W_ReadLumpPwad(wadnum, shader_lumpnum, shader_source);
|
||||||
|
|
||||||
HWD.pfnLoadCustomShader(shaderxlat[i].id, shader_source, shader_size, (shadertype == 2));
|
HWD.pfnLoadCustomShader(shaderxlat[i].id, shader_source, shader_size, (shadertype == 2));
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -100,11 +101,11 @@ static void md2_freeModel (model_t *model)
|
||||||
static model_t *md2_readModel(const char *filename)
|
static model_t *md2_readModel(const char *filename)
|
||||||
{
|
{
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
if (FIL_FileExists(va("%s"PATHSEP"%s", srb2home, filename)))
|
if (FIL_FileExists(va("%s" PATHSEP "%s", srb2home, filename)))
|
||||||
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC);
|
return LoadModel(va("%s" PATHSEP "%s", srb2home, filename), PU_STATIC);
|
||||||
|
|
||||||
if (FIL_FileExists(va("%s"PATHSEP"%s", srb2path, filename)))
|
if (FIL_FileExists(va("%s" PATHSEP "%s", srb2path, filename)))
|
||||||
return LoadModel(va("%s"PATHSEP"%s", srb2path, filename), PU_STATIC);
|
return LoadModel(va("%s" PATHSEP "%s", srb2path, filename), PU_STATIC);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -168,18 +169,18 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||||
#endif
|
#endif
|
||||||
volatile png_FILE_p png_FILE;
|
volatile png_FILE_p png_FILE;
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
char *pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2home, filename);
|
char *pngfilename = va("%s" PATHSEP "models" PATHSEP "%s", srb2home, filename);
|
||||||
|
|
||||||
FIL_ForceExtension(pngfilename, ".png");
|
FIL_ForceExtension(pngfilename, ".png");
|
||||||
png_FILE = fopen(pngfilename, "rb");
|
png_FILE = fopen(pngfilename, "rb");
|
||||||
if (!png_FILE)
|
if (!png_FILE)
|
||||||
{
|
{
|
||||||
pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename);
|
pngfilename = va("%s" PATHSEP "models" PATHSEP "%s", srb2path, filename);
|
||||||
FIL_ForceExtension(pngfilename, ".png");
|
FIL_ForceExtension(pngfilename, ".png");
|
||||||
png_FILE = fopen(pngfilename, "rb");
|
png_FILE = fopen(pngfilename, "rb");
|
||||||
//CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename);
|
//CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename);
|
||||||
if (!png_FILE)
|
if (!png_FILE)
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
|
||||||
|
|
@ -188,7 +189,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_RENDER, "PNG_Load: Error on initialize libpng\n");
|
CONS_Debug(DBG_RENDER, "PNG_Load: Error on initialize libpng\n");
|
||||||
fclose(png_FILE);
|
fclose(png_FILE);
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
png_info_ptr = png_create_info_struct(png_ptr);
|
png_info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
@ -197,7 +198,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||||
CONS_Debug(DBG_RENDER, "PNG_Load: Error on allocate for libpng\n");
|
CONS_Debug(DBG_RENDER, "PNG_Load: Error on allocate for libpng\n");
|
||||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||||
fclose(png_FILE);
|
fclose(png_FILE);
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
|
|
@ -210,7 +211,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||||
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
|
||||||
fclose(png_FILE);
|
fclose(png_FILE);
|
||||||
Z_Free(grpatch->mipmap->data);
|
Z_Free(grpatch->mipmap->data);
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
#ifdef USE_FAR_KEYWORD
|
#ifdef USE_FAR_KEYWORD
|
||||||
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf);
|
png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf);
|
||||||
|
|
@ -250,8 +251,8 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
|
||||||
|
|
||||||
{
|
{
|
||||||
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
|
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
|
||||||
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
|
png_bytep PNG_image = (png_bytep)Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
|
||||||
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
|
png_bytepp row_pointers = (png_bytepp)png_malloc(png_ptr, height * sizeof (png_bytep));
|
||||||
for (i = 0; i < height; i++)
|
for (i = 0; i < height; i++)
|
||||||
row_pointers[i] = PNG_image + i*pitch;
|
row_pointers[i] = PNG_image + i*pitch;
|
||||||
png_read_image(png_ptr, row_pointers);
|
png_read_image(png_ptr, row_pointers);
|
||||||
|
|
@ -301,42 +302,42 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
|
||||||
INT32 ch, rep;
|
INT32 ch, rep;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
char *pcxfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2home, filename);
|
char *pcxfilename = va("%s" PATHSEP "models" PATHSEP "%s", srb2home, filename);
|
||||||
|
|
||||||
FIL_ForceExtension(pcxfilename, ".pcx");
|
FIL_ForceExtension(pcxfilename, ".pcx");
|
||||||
file = fopen(pcxfilename, "rb");
|
file = fopen(pcxfilename, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
pcxfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2path, filename);
|
pcxfilename = va("%s" PATHSEP "models" PATHSEP "%s", srb2path, filename);
|
||||||
FIL_ForceExtension(pcxfilename, ".pcx");
|
FIL_ForceExtension(pcxfilename, ".pcx");
|
||||||
file = fopen(pcxfilename, "rb");
|
file = fopen(pcxfilename, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fread(&header, sizeof (PcxHeader), 1, file) != 1)
|
if (fread(&header, sizeof (PcxHeader), 1, file) != 1)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header.bitsPerPixel != 8)
|
if (header.bitsPerPixel != 8)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(file, -PALSIZE, SEEK_END);
|
fseek(file, -PALSIZE, SEEK_END);
|
||||||
|
|
||||||
pw = *w = header.xmax - header.xmin + 1;
|
pw = *w = header.xmax - header.xmin + 1;
|
||||||
ph = *h = header.ymax - header.ymin + 1;
|
ph = *h = header.ymax - header.ymin + 1;
|
||||||
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
|
image = (RGBA_t *)Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
|
||||||
|
|
||||||
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
|
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
|
||||||
{
|
{
|
||||||
Z_Free(image);
|
Z_Free(image);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return (GLTextureFormat_t)0;
|
||||||
}
|
}
|
||||||
fseek(file, sizeof (PcxHeader), SEEK_SET);
|
fseek(file, sizeof (PcxHeader), SEEK_SET);
|
||||||
|
|
||||||
|
|
@ -378,7 +379,7 @@ static void md2_loadTexture(md2_t *model)
|
||||||
|
|
||||||
if (model->grpatch)
|
if (model->grpatch)
|
||||||
{
|
{
|
||||||
patch = model->grpatch;
|
patch = (patch_t*)(model->grpatch);
|
||||||
grPatch = (GLPatch_t *)(patch->hardware);
|
grPatch = (GLPatch_t *)(patch->hardware);
|
||||||
if (grPatch)
|
if (grPatch)
|
||||||
Z_Free(grPatch->mipmap->data);
|
Z_Free(grPatch->mipmap->data);
|
||||||
|
|
@ -418,7 +419,7 @@ static void md2_loadTexture(md2_t *model)
|
||||||
grPatch->mipmap->height = (UINT16)h;
|
grPatch->mipmap->height = (UINT16)h;
|
||||||
|
|
||||||
// Lactozilla: Apply colour cube
|
// Lactozilla: Apply colour cube
|
||||||
image = grPatch->mipmap->data;
|
image = (RGBA_t*)(grPatch->mipmap->data);
|
||||||
size = w*h;
|
size = w*h;
|
||||||
while (size--)
|
while (size--)
|
||||||
{
|
{
|
||||||
|
|
@ -437,14 +438,14 @@ static void md2_loadBlendTexture(md2_t *model)
|
||||||
{
|
{
|
||||||
patch_t *patch;
|
patch_t *patch;
|
||||||
GLPatch_t *grPatch = NULL;
|
GLPatch_t *grPatch = NULL;
|
||||||
char *filename = Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL);
|
char *filename = (char *)Z_Malloc(strlen(model->filename)+7, PU_STATIC, NULL);
|
||||||
|
|
||||||
strcpy(filename, model->filename);
|
strcpy(filename, model->filename);
|
||||||
FIL_ForceExtension(filename, "_blend.png");
|
FIL_ForceExtension(filename, "_blend.png");
|
||||||
|
|
||||||
if (model->blendgrpatch)
|
if (model->blendgrpatch)
|
||||||
{
|
{
|
||||||
patch = model->blendgrpatch;
|
patch = (patch_t*)(model->blendgrpatch);
|
||||||
grPatch = (GLPatch_t *)(patch->hardware);
|
grPatch = (GLPatch_t *)(patch->hardware);
|
||||||
if (grPatch)
|
if (grPatch)
|
||||||
Z_Free(grPatch->mipmap->data);
|
Z_Free(grPatch->mipmap->data);
|
||||||
|
|
@ -495,10 +496,10 @@ void HWR_InitModels(void)
|
||||||
size_t i;
|
size_t i;
|
||||||
INT32 s;
|
INT32 s;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char name[26], filename[32];
|
char name[24], filename[32];
|
||||||
// name[24] is used to check for names in the models.dat file that match with sprites or player skins
|
// name[24] is used to check for names in the models.dat file that match with sprites or player skins
|
||||||
// sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long
|
// sprite names are always 4 characters long, and names is for player skins can be up to 16+1 characters long
|
||||||
// PLAYERMODELPREFIX is 6 characters long
|
// PLAYERMODELPREFIX is 6 characters long - 24 fits in (16 + 6) + 1
|
||||||
float scale, offset;
|
float scale, offset;
|
||||||
size_t prefixlen;
|
size_t prefixlen;
|
||||||
|
|
||||||
|
|
@ -528,11 +529,11 @@ void HWR_InitModels(void)
|
||||||
|
|
||||||
// read the models.dat file
|
// read the models.dat file
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2home, "models.dat"), "rt");
|
f = fopen(va("%s" PATHSEP "%s", srb2home, "models.dat"), "rt");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
f = fopen(va("%s" PATHSEP "%s", srb2path, "models.dat"), "rt");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||||
|
|
@ -544,7 +545,7 @@ void HWR_InitModels(void)
|
||||||
// length of the player model prefix
|
// length of the player model prefix
|
||||||
prefixlen = strlen(PLAYERMODELPREFIX);
|
prefixlen = strlen(PLAYERMODELPREFIX);
|
||||||
|
|
||||||
while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4)
|
while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4)
|
||||||
{
|
{
|
||||||
char *skinname = name;
|
char *skinname = name;
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
|
|
@ -609,11 +610,11 @@ void HWR_AddPlayerModel(INT32 skin) // For skins that were added after startup
|
||||||
|
|
||||||
// read the models.dat file
|
// read the models.dat file
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2home, "models.dat"), "rt");
|
f = fopen(va("%s" PATHSEP "%s", srb2home, "models.dat"), "rt");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
f = fopen(va("%s" PATHSEP "%s", srb2path, "models.dat"), "rt");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||||
|
|
@ -626,7 +627,7 @@ void HWR_AddPlayerModel(INT32 skin) // For skins that were added after startup
|
||||||
prefixlen = strlen(PLAYERMODELPREFIX);
|
prefixlen = strlen(PLAYERMODELPREFIX);
|
||||||
|
|
||||||
// Check for any models that match the names of player skins!
|
// Check for any models that match the names of player skins!
|
||||||
while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4)
|
while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4)
|
||||||
{
|
{
|
||||||
char *skinname = name;
|
char *skinname = name;
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
|
|
@ -655,8 +656,8 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
// name[24] is used to check for names in the models.dat file that match with sprites or player skins
|
// name[24] is used to check for names in the models.dat file that match with sprites or player skins
|
||||||
// sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long
|
// sprite names are always 4 characters long, and names is for player skins can be up to 16+1 characters long
|
||||||
// PLAYERMODELPREFIX is 6 characters long
|
// PLAYERMODELPREFIX is 6 characters long - 24 fits in (16 + 6) + 1
|
||||||
char name[24], filename[32];
|
char name[24], filename[32];
|
||||||
float scale, offset;
|
float scale, offset;
|
||||||
|
|
||||||
|
|
@ -668,11 +669,11 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s
|
||||||
|
|
||||||
// Read the models.dat file
|
// Read the models.dat file
|
||||||
//Filename checking fixed ~Monster Iestyn and Golden
|
//Filename checking fixed ~Monster Iestyn and Golden
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2home, "models.dat"), "rt");
|
f = fopen(va("%s" PATHSEP" %s", srb2home, "models.dat"), "rt");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "models.dat"), "rt");
|
f = fopen(va("%s" PATHSEP" %s", srb2path, "models.dat"), "rt");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno));
|
||||||
|
|
@ -682,7 +683,7 @@ void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for any models that match the names of sprite names!
|
// Check for any models that match the names of sprite names!
|
||||||
while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4)
|
while (fscanf(f, "%23s %31s %f %f", name, filename, &scale, &offset) == 4)
|
||||||
{
|
{
|
||||||
// length of the sprite name
|
// length of the sprite name
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
|
|
@ -713,8 +714,8 @@ spritemodelfound:
|
||||||
|
|
||||||
static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *grMipmap, INT32 skinnum, skincolornum_t color)
|
static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *grMipmap, INT32 skinnum, skincolornum_t color)
|
||||||
{
|
{
|
||||||
GLPatch_t *hwrPatch = gpatch->hardware;
|
GLPatch_t *hwrPatch = (GLPatch_t*)(gpatch->hardware);
|
||||||
GLPatch_t *hwrBlendPatch = blendgpatch->hardware;
|
GLPatch_t *hwrBlendPatch = (GLPatch_t*)(blendgpatch->hardware);
|
||||||
UINT16 w = gpatch->width, h = gpatch->height;
|
UINT16 w = gpatch->width, h = gpatch->height;
|
||||||
UINT32 size = w*h;
|
UINT32 size = w*h;
|
||||||
RGBA_t *image, *blendimage, *cur, blendcolor;
|
RGBA_t *image, *blendimage, *cur, blendcolor;
|
||||||
|
|
@ -747,11 +748,11 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
|
||||||
grMipmap->data = NULL;
|
grMipmap->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grMipmap->data);
|
cur = (RGBA_t *)Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grMipmap->data);
|
||||||
memset(cur, 0x00, size*4);
|
memset(cur, 0x00, size*4);
|
||||||
|
|
||||||
image = hwrPatch->mipmap->data;
|
image = (RGBA_t*)(hwrPatch->mipmap->data);
|
||||||
blendimage = hwrBlendPatch->mipmap->data;
|
blendimage = (RGBA_t*)(hwrBlendPatch->mipmap->data);
|
||||||
|
|
||||||
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
|
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
|
||||||
if (skinnum == TC_METALSONIC)
|
if (skinnum == TC_METALSONIC)
|
||||||
|
|
@ -1068,15 +1069,15 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
|
||||||
}
|
}
|
||||||
|
|
||||||
tempcolor = (brightness * blendcolor.s.red) / colorbright;
|
tempcolor = (brightness * blendcolor.s.red) / colorbright;
|
||||||
tempcolor = min(255, tempcolor);
|
tempcolor = std::min<UINT32>(255, tempcolor);
|
||||||
cur->s.red = (UINT8)tempcolor;
|
cur->s.red = (UINT8)tempcolor;
|
||||||
|
|
||||||
tempcolor = (brightness * blendcolor.s.green) / colorbright;
|
tempcolor = (brightness * blendcolor.s.green) / colorbright;
|
||||||
tempcolor = min(255, tempcolor);
|
tempcolor = std::min<UINT32>(255, tempcolor);
|
||||||
cur->s.green = (UINT8)tempcolor;
|
cur->s.green = (UINT8)tempcolor;
|
||||||
|
|
||||||
tempcolor = (brightness * blendcolor.s.blue) / colorbright;
|
tempcolor = (brightness * blendcolor.s.blue) / colorbright;
|
||||||
tempcolor = min(255, tempcolor);
|
tempcolor = std::min<UINT32>(255, tempcolor);
|
||||||
cur->s.blue = (UINT8)tempcolor;
|
cur->s.blue = (UINT8)tempcolor;
|
||||||
cur->s.alpha = image->s.alpha;
|
cur->s.alpha = image->s.alpha;
|
||||||
}
|
}
|
||||||
|
|
@ -1086,15 +1087,15 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
|
||||||
INT32 tempcolor;
|
INT32 tempcolor;
|
||||||
|
|
||||||
tempcolor = ((image->s.red * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.red * blendimage->s.alpha) / 255);
|
tempcolor = ((image->s.red * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.red * blendimage->s.alpha) / 255);
|
||||||
tempcolor = min(255, tempcolor);
|
tempcolor = std::min(255, tempcolor);
|
||||||
cur->s.red = (UINT8)tempcolor;
|
cur->s.red = (UINT8)tempcolor;
|
||||||
|
|
||||||
tempcolor = ((image->s.green * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.green * blendimage->s.alpha) / 255);
|
tempcolor = ((image->s.green * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.green * blendimage->s.alpha) / 255);
|
||||||
tempcolor = min(255, tempcolor);
|
tempcolor = std::min(255, tempcolor);
|
||||||
cur->s.green = (UINT8)tempcolor;
|
cur->s.green = (UINT8)tempcolor;
|
||||||
|
|
||||||
tempcolor = ((image->s.blue * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.blue * blendimage->s.alpha) / 255);
|
tempcolor = ((image->s.blue * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.blue * blendimage->s.alpha) / 255);
|
||||||
tempcolor = min(255, tempcolor);
|
tempcolor = std::min(255, tempcolor);
|
||||||
cur->s.blue = (UINT8)tempcolor;
|
cur->s.blue = (UINT8)tempcolor;
|
||||||
cur->s.alpha = image->s.alpha;
|
cur->s.alpha = image->s.alpha;
|
||||||
}
|
}
|
||||||
|
|
@ -1129,7 +1130,7 @@ skippixel:
|
||||||
static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 skinnum, const UINT8 *colormap, skincolornum_t color)
|
static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 skinnum, const UINT8 *colormap, skincolornum_t color)
|
||||||
{
|
{
|
||||||
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
|
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
|
||||||
GLPatch_t *grPatch = patch->hardware;
|
GLPatch_t *grPatch = (GLPatch_t*)(patch->hardware);
|
||||||
GLPatch_t *grBlendPatch = NULL;
|
GLPatch_t *grBlendPatch = NULL;
|
||||||
GLMipmap_t *grMipmap, *newMipmap;
|
GLMipmap_t *grMipmap, *newMipmap;
|
||||||
|
|
||||||
|
|
@ -1140,7 +1141,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((blendpatch && (grBlendPatch = blendpatch->hardware) && grBlendPatch->mipmap->format)
|
if ((blendpatch && (grBlendPatch = (GLPatch_t*)blendpatch->hardware) && grBlendPatch->mipmap->format)
|
||||||
&& (patch->width != blendpatch->width || patch->height != blendpatch->height))
|
&& (patch->width != blendpatch->width || patch->height != blendpatch->height))
|
||||||
{
|
{
|
||||||
// Blend image exists, but it's bad.
|
// Blend image exists, but it's bad.
|
||||||
|
|
@ -1179,12 +1180,12 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
|
||||||
// (it have a liste of mipmap)
|
// (it have a liste of mipmap)
|
||||||
// this malloc is cleared in HWR_FreeColormapCache
|
// this malloc is cleared in HWR_FreeColormapCache
|
||||||
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
||||||
newMipmap = calloc(1, sizeof (*newMipmap));
|
newMipmap = (GLMipmap_t *)calloc(1, sizeof (*newMipmap));
|
||||||
if (newMipmap == NULL)
|
if (newMipmap == NULL)
|
||||||
I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
|
I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
|
||||||
grMipmap->nextcolormap = newMipmap;
|
grMipmap->nextcolormap = newMipmap;
|
||||||
|
|
||||||
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
newMipmap->colormap = (GLColormap_t*) Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
||||||
newMipmap->colormap->source = colormap;
|
newMipmap->colormap->source = colormap;
|
||||||
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||||
|
|
||||||
|
|
@ -1297,7 +1298,7 @@ static void adjustTextureCoords(model_t *model, patch_t *patch)
|
||||||
// if originaluvs points to uvs, we need to allocate new memory for adjusted uvs
|
// if originaluvs points to uvs, we need to allocate new memory for adjusted uvs
|
||||||
// the old uvs are kept around for use in possible readjustments
|
// the old uvs are kept around for use in possible readjustments
|
||||||
if (mesh->uvs == mesh->originaluvs)
|
if (mesh->uvs == mesh->originaluvs)
|
||||||
mesh->uvs = Z_Malloc(numVertices * 2 * sizeof(float), PU_STATIC, NULL);
|
mesh->uvs = (float *)Z_Malloc(numVertices * 2 * sizeof(float), PU_STATIC, NULL);
|
||||||
|
|
||||||
uvWritePtr = mesh->uvs;
|
uvWritePtr = mesh->uvs;
|
||||||
|
|
||||||
|
|
@ -1465,7 +1466,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
|
|
||||||
// texture loading before model init, so it knows if sprite graphics are used, which
|
// texture loading before model init, so it knows if sprite graphics are used, which
|
||||||
// means that texture coordinates have to be adjusted
|
// means that texture coordinates have to be adjusted
|
||||||
gpatch = md2->grpatch;
|
gpatch = (patch_t*)(md2->grpatch);
|
||||||
if (gpatch)
|
if (gpatch)
|
||||||
hwrPatch = ((GLPatch_t *)gpatch->hardware);
|
hwrPatch = ((GLPatch_t *)gpatch->hardware);
|
||||||
|
|
||||||
|
|
@ -1474,12 +1475,12 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
md2_loadTexture(md2);
|
md2_loadTexture(md2);
|
||||||
|
|
||||||
// Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
|
// Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
|
||||||
gpatch = md2->grpatch;
|
gpatch = (patch_t*)(md2->grpatch);
|
||||||
if (gpatch)
|
if (gpatch)
|
||||||
hwrPatch = ((GLPatch_t *)gpatch->hardware);
|
hwrPatch = ((GLPatch_t *)gpatch->hardware);
|
||||||
|
|
||||||
// Load blend texture
|
// Load blend texture
|
||||||
blendgpatch = md2->blendgrpatch;
|
blendgpatch = (patch_t*)(md2->blendgrpatch);
|
||||||
if (blendgpatch)
|
if (blendgpatch)
|
||||||
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
|
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
|
||||||
|
|
||||||
|
|
@ -1489,7 +1490,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
md2_loadBlendTexture(md2);
|
md2_loadBlendTexture(md2);
|
||||||
|
|
||||||
// Load it again, because it isn't being loaded into blendgpatch after md2_loadblendtexture...
|
// Load it again, because it isn't being loaded into blendgpatch after md2_loadblendtexture...
|
||||||
blendgpatch = md2->blendgrpatch;
|
blendgpatch = (patch_t*)(md2->blendgrpatch);
|
||||||
if (blendgpatch)
|
if (blendgpatch)
|
||||||
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
|
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
|
||||||
|
|
||||||
|
|
@ -1573,7 +1574,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
frame = (spr->mobj->frame & FF_FRAMEMASK);
|
frame = (spr->mobj->frame & FF_FRAMEMASK);
|
||||||
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && md2->model->spr2frames)
|
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && md2->model->spr2frames)
|
||||||
{
|
{
|
||||||
spr2 = HWR_GetModelSprite2(md2, spr->mobj->skin, spr->mobj->sprite2, spr->mobj->player);
|
spr2 = HWR_GetModelSprite2(md2, (skin_t*)spr->mobj->skin, spr->mobj->sprite2, spr->mobj->player);
|
||||||
mod = md2->model->spr2frames[spr2].numframes;
|
mod = md2->model->spr2frames[spr2].numframes;
|
||||||
#ifndef DONTHIDEDIFFANIMLENGTH // by default, different anim length is masked by the mod
|
#ifndef DONTHIDEDIFFANIMLENGTH // by default, different anim length is masked by the mod
|
||||||
if (mod > (INT32)((skin_t *)spr->mobj->skin)->sprites[spr2].numframes)
|
if (mod > (INT32)((skin_t *)spr->mobj->skin)->sprites[spr2].numframes)
|
||||||
|
|
@ -1610,7 +1611,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
&& (spr->mobj->frame & FF_ANIMATE
|
&& (spr->mobj->frame & FF_ANIMATE
|
||||||
|| (spr->mobj->state->nextstate != S_NULL
|
|| (spr->mobj->state->nextstate != S_NULL
|
||||||
&& states[spr->mobj->state->nextstate].sprite == SPR_PLAY
|
&& states[spr->mobj->state->nextstate].sprite == SPR_PLAY
|
||||||
&& ((P_GetSkinSprite2(spr->mobj->skin, (states[spr->mobj->state->nextstate].frame) & FF_FRAMEMASK, spr->mobj->player) == spr->mobj->sprite2)))))
|
&& ((P_GetSkinSprite2((skin_t*)spr->mobj->skin, (states[spr->mobj->state->nextstate].frame) & FF_FRAMEMASK, spr->mobj->player) == spr->mobj->sprite2)))))
|
||||||
{
|
{
|
||||||
nextFrame = (spr->mobj->frame & FF_FRAMEMASK) + 1;
|
nextFrame = (spr->mobj->frame & FF_FRAMEMASK) + 1;
|
||||||
if (nextFrame >= mod)
|
if (nextFrame >= mod)
|
||||||
|
|
@ -1780,7 +1781,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
// x offset
|
// x offset
|
||||||
xx = FIXED_TO_FLOAT(FixedMul(FixedMul(
|
xx = FIXED_TO_FLOAT(FixedMul(FixedMul(
|
||||||
FixedMul(xoffs,spr->mobj->spritexscale),
|
FixedMul(xoffs,spr->mobj->spritexscale),
|
||||||
hflipmul),
|
hflipmul),
|
||||||
FINECOSINE(pitchR >> ANGLETOFINESHIFT)
|
FINECOSINE(pitchR >> ANGLETOFINESHIFT)
|
||||||
));
|
));
|
||||||
xy = FIXED_TO_FLOAT(FixedMul(FixedMul(
|
xy = FIXED_TO_FLOAT(FixedMul(FixedMul(
|
||||||
|
|
@ -1792,7 +1793,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
// y offset
|
// y offset
|
||||||
yx = FIXED_TO_FLOAT(FixedMul(FixedMul(
|
yx = FIXED_TO_FLOAT(FixedMul(FixedMul(
|
||||||
FixedMul(yoffs,spr->mobj->spritexscale),
|
FixedMul(yoffs,spr->mobj->spritexscale),
|
||||||
hflipmul),
|
hflipmul),
|
||||||
FINECOSINE(rollR >> ANGLETOFINESHIFT)
|
FINECOSINE(rollR >> ANGLETOFINESHIFT)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -320,7 +320,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
// read in file
|
// read in file
|
||||||
buffer = malloc(fileLen);
|
buffer = (char *)malloc(fileLen);
|
||||||
if (fread(buffer, fileLen, 1, f)) { } // squash ignored fread error
|
if (fread(buffer, fileLen, 1, f)) { } // squash ignored fread error
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
|
@ -188,7 +188,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat)
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
// read in file
|
// read in file
|
||||||
buffer = malloc(fileLen);
|
buffer = (char *)malloc(fileLen);
|
||||||
fileReadLen = fread(buffer, fileLen, 1, f);
|
fileReadLen = fread(buffer, fileLen, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
|
@ -429,7 +429,7 @@ EXPORT void HWRAPI(GetModeList) (vmode_t** pvidmodes, INT32 *numvidmodes)
|
||||||
video_modes[iMode].pnext = &video_modes[iMode+1];
|
video_modes[iMode].pnext = &video_modes[iMode+1];
|
||||||
video_modes[iMode].windowed = 0; // fullscreen is the default
|
video_modes[iMode].windowed = 0; // fullscreen is the default
|
||||||
video_modes[iMode].misc = 0;
|
video_modes[iMode].misc = 0;
|
||||||
video_modes[iMode].name = malloc(12 * sizeof (CHAR));
|
video_modes[iMode].name = (char *)malloc(12 * sizeof (CHAR));
|
||||||
sprintf(video_modes[iMode].name, "%dx%d", (INT32)Tmp.dmPelsWidth, (INT32)Tmp.dmPelsHeight);
|
sprintf(video_modes[iMode].name, "%dx%d", (INT32)Tmp.dmPelsWidth, (INT32)Tmp.dmPelsHeight);
|
||||||
GL_DBG_Printf ("Mode: %s\n", video_modes[iMode].name);
|
GL_DBG_Printf ("Mode: %s\n", video_modes[iMode].name);
|
||||||
video_modes[iMode].width = Tmp.dmPelsWidth;
|
video_modes[iMode].width = Tmp.dmPelsWidth;
|
||||||
|
|
@ -482,7 +482,7 @@ EXPORT void HWRAPI(GetModeList) (vmode_t** pvidmodes, INT32 *numvidmodes)
|
||||||
video_modes[i].pnext = &video_modes[i+1];
|
video_modes[i].pnext = &video_modes[i+1];
|
||||||
video_modes[i].windowed = 0; // fullscreen is the default
|
video_modes[i].windowed = 0; // fullscreen is the default
|
||||||
video_modes[i].misc = 0;
|
video_modes[i].misc = 0;
|
||||||
video_modes[i].name = malloc(12 * sizeof (CHAR));
|
video_modes[i].name = (char *)malloc(12 * sizeof (CHAR));
|
||||||
sprintf(video_modes[i].name, "%dx%d", res[i][0], res[i][1]);
|
sprintf(video_modes[i].name, "%dx%d", res[i][0], res[i][1]);
|
||||||
GL_DBG_Printf ("Mode: %s\n", video_modes[i].name);
|
GL_DBG_Printf ("Mode: %s\n", video_modes[i].name);
|
||||||
video_modes[i].width = res[i][0];
|
video_modes[i].width = res[i][0];
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "r_opengl.h"
|
#include "r_opengl.h"
|
||||||
|
|
@ -1107,7 +1108,7 @@ EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boole
|
||||||
#define COPYSHADER(source) { \
|
#define COPYSHADER(source) { \
|
||||||
if (shader->source) \
|
if (shader->source) \
|
||||||
free(shader->source); \
|
free(shader->source); \
|
||||||
shader->source = malloc(size+1); \
|
shader->source = (char *)malloc(size+1); \
|
||||||
strncpy(shader->source, code, size); \
|
strncpy(shader->source, code, size); \
|
||||||
shader->source[size] = 0; \
|
shader->source[size] = 0; \
|
||||||
}
|
}
|
||||||
|
|
@ -1516,8 +1517,8 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height,
|
||||||
// GL_DBG_Printf ("ReadRect()\n");
|
// GL_DBG_Printf ("ReadRect()\n");
|
||||||
if (dst_stride == width*3)
|
if (dst_stride == width*3)
|
||||||
{
|
{
|
||||||
GLubyte*top = (GLvoid*)dst_data, *bottom = top + dst_stride * (height - 1);
|
GLubyte*top = (GLubyte*)dst_data, *bottom = top + dst_stride * (height - 1);
|
||||||
GLubyte *row = malloc(dst_stride);
|
GLubyte *row = (GLubyte *)malloc(dst_stride);
|
||||||
if (!row) return;
|
if (!row) return;
|
||||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, dst_data);
|
pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, dst_data);
|
||||||
|
|
@ -1535,7 +1536,7 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
INT32 j;
|
INT32 j;
|
||||||
GLubyte *image = malloc(width*height*3*sizeof (*image));
|
GLubyte *image = (GLubyte *)malloc(width*height*3*sizeof (*image));
|
||||||
if (!image) return;
|
if (!image) return;
|
||||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, image);
|
pglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, image);
|
||||||
|
|
@ -1870,7 +1871,7 @@ static void AllocTextureBuffer(GLMipmap_t *pTexInfo)
|
||||||
size_t size = pTexInfo->width * pTexInfo->height;
|
size_t size = pTexInfo->width * pTexInfo->height;
|
||||||
if (size > textureBufferSize)
|
if (size > textureBufferSize)
|
||||||
{
|
{
|
||||||
textureBuffer = realloc(textureBuffer, size * sizeof(RGBA_t));
|
textureBuffer = (RGBA_t *)realloc(textureBuffer, size * sizeof(RGBA_t));
|
||||||
if (textureBuffer == NULL)
|
if (textureBuffer == NULL)
|
||||||
I_Error("AllocTextureBuffer: out of memory allocating %s bytes", sizeu1(size * sizeof(RGBA_t)));
|
I_Error("AllocTextureBuffer: out of memory allocating %s bytes", sizeu1(size * sizeof(RGBA_t)));
|
||||||
textureBufferSize = size;
|
textureBufferSize = size;
|
||||||
|
|
@ -2112,7 +2113,7 @@ EXPORT void HWRAPI(SetTexture) (GLMipmap_t *pTexInfo)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FTextureInfo *newTex = calloc(1, sizeof (*newTex));
|
FTextureInfo *newTex = (FTextureInfo *)calloc(1, sizeof (*newTex));
|
||||||
|
|
||||||
UpdateTexture(pTexInfo);
|
UpdateTexture(pTexInfo);
|
||||||
|
|
||||||
|
|
@ -2334,7 +2335,7 @@ static void Shader_CompileError(const char *message, GLuint program, INT32 shade
|
||||||
|
|
||||||
if (logLength)
|
if (logLength)
|
||||||
{
|
{
|
||||||
infoLog = malloc(logLength);
|
infoLog = (GLchar *)malloc(logLength);
|
||||||
pglGetShaderInfoLog(program, logLength, NULL, infoLog);
|
pglGetShaderInfoLog(program, logLength, NULL, infoLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2635,7 +2636,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HWD_SET_TEXTUREANISOTROPICMODE:
|
case HWD_SET_TEXTUREANISOTROPICMODE:
|
||||||
anisotropic_filter = min(Value,maximumAnisotropy);
|
anisotropic_filter = std::min(Value,maximumAnisotropy);
|
||||||
if (maximumAnisotropy)
|
if (maximumAnisotropy)
|
||||||
Flush(); //??? if we want to change filter mode by texture, remove this
|
Flush(); //??? if we want to change filter mode by texture, remove this
|
||||||
break;
|
break;
|
||||||
|
|
@ -2666,8 +2667,8 @@ static void AllocLerpBuffer(size_t size)
|
||||||
free(normBuffer);
|
free(normBuffer);
|
||||||
|
|
||||||
lerpBufferSize = size;
|
lerpBufferSize = size;
|
||||||
vertBuffer = malloc(lerpBufferSize);
|
vertBuffer = (float *)malloc(lerpBufferSize);
|
||||||
normBuffer = malloc(lerpBufferSize);
|
normBuffer = (float *)malloc(lerpBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static temporary buffer for doing frame interpolation
|
// Static temporary buffer for doing frame interpolation
|
||||||
|
|
@ -2684,8 +2685,8 @@ static void AllocLerpTinyBuffer(size_t size)
|
||||||
free(normTinyBuffer);
|
free(normTinyBuffer);
|
||||||
|
|
||||||
lerpTinyBufferSize = size;
|
lerpTinyBufferSize = size;
|
||||||
vertTinyBuffer = malloc(lerpTinyBufferSize);
|
vertTinyBuffer = (short *)malloc(lerpTinyBufferSize);
|
||||||
normTinyBuffer = malloc(lerpTinyBufferSize / 2);
|
normTinyBuffer = (char *)malloc(lerpTinyBufferSize / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GL_STATIC_DRAW
|
#ifndef GL_STATIC_DRAW
|
||||||
Loading…
Add table
Reference in a new issue