Removed all glBegin/glEnd references

MD2/MD3 now works, with the exception of WAD textures for some odd reason
This commit is contained in:
Arthur 2018-12-23 17:00:11 -05:00 committed by mazmazz
parent 2f930f1262
commit 1249f37fc5
8 changed files with 386 additions and 777 deletions

View file

@ -63,10 +63,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *ptransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void); EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT INT32 HWRAPI(GetRenderVersion) (void); EXPORT INT32 HWRAPI(GetRenderVersion) (void);
#ifdef SHUFFLE
#define SCREENVERTS 10 #define SCREENVERTS 10
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
#endif
EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(FlushScreenTextures) (void);
EXPORT void HWRAPI(StartScreenWipe) (void); EXPORT void HWRAPI(StartScreenWipe) (void);
EXPORT void HWRAPI(EndScreenWipe) (void); EXPORT void HWRAPI(EndScreenWipe) (void);
@ -105,9 +103,7 @@ struct hwdriver_s
#ifndef HAVE_SDL #ifndef HAVE_SDL
Shutdown pfnShutdown; Shutdown pfnShutdown;
#endif #endif
#ifdef SHUFFLE
PostImgRedraw pfnPostImgRedraw; PostImgRedraw pfnPostImgRedraw;
#endif
FlushScreenTextures pfnFlushScreenTextures; FlushScreenTextures pfnFlushScreenTextures;
StartScreenWipe pfnStartScreenWipe; StartScreenWipe pfnStartScreenWipe;
EndScreenWipe pfnEndScreenWipe; EndScreenWipe pfnEndScreenWipe;

View file

@ -6838,7 +6838,6 @@ void HWR_DoPostProcessor(player_t *player)
if (splitscreen) // Not supported in splitscreen - someone want to add support? if (splitscreen) // Not supported in splitscreen - someone want to add support?
return; return;
#ifdef SHUFFLE
// Drunken vision! WooOOooo~ // Drunken vision! WooOOooo~
if (*type == postimg_water || *type == postimg_heat) if (*type == postimg_water || *type == postimg_heat)
{ {
@ -6881,7 +6880,6 @@ void HWR_DoPostProcessor(player_t *player)
HWD.pfnMakeScreenTexture(); HWD.pfnMakeScreenTexture();
} }
// Flipping of the screen isn't done here anymore // Flipping of the screen isn't done here anymore
#endif // SHUFFLE
} }
void HWR_StartScreenWipe(void) void HWR_StartScreenWipe(void)

View file

@ -233,24 +233,10 @@ typedef struct
// Load the model // Load the model
model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
{ {
useFloat = true;
model_t *retModel = NULL; model_t *retModel = NULL;
md2header_t *header; md2header_t *header;
size_t fileLen;
size_t fileReadLen;
int i, j, t;
size_t namelen;
char *texturefilename, *buffer;
const char *texPos;
const float WUNITS = 1.0f;
float dataScale;
md2triangle_t *tris;
md2texcoord_t *texcoords;
md2frame_t *frames;
FILE *f = fopen(fileName, "rb"); FILE *f = fopen(fileName, "rb");
if (!f) if (!f)
@ -258,7 +244,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0);
texPos = strchr(fileName, '/'); size_t fileLen;
int i, j;
size_t namelen;
char *texturefilename;
const char *texPos = strchr(fileName, '/');
if (texPos) if (texPos)
{ {
@ -284,25 +276,23 @@ 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); char *buffer = malloc(fileLen);
fileReadLen = fread(buffer, fileLen, 1, f); fread(buffer, fileLen, 1, f);
fclose(f); fclose(f);
(void)fileReadLen; // intentionally ignore return value, per buildbot
// get pointer to file header // get pointer to file header
header = (md2header_t*)buffer; header = (md2header_t*)buffer;
retModel->numMeshes = 1; // MD2 only has one mesh retModel->numMeshes = 1; // MD2 only has one mesh
retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0);
retModel->meshes[0].numFrames = header->numFrames; retModel->meshes[0].numFrames = header->numFrames;
const float WUNITS = 1.0f;
dataScale = WUNITS; float dataScale = WUNITS;
// Tris and ST are simple structures that can be straight-copied // Tris and ST are simple structures that can be straight-copied
tris = (md2triangle_t*)&buffer[header->offsetTris]; md2triangle_t *tris = (md2triangle_t*)&buffer[header->offsetTris];
texcoords = (md2texcoord_t*)&buffer[header->offsetST]; md2texcoord_t *texcoords = (md2texcoord_t*)&buffer[header->offsetST];
frames = (md2frame_t*)&buffer[header->offsetFrames]; md2frame_t *frames = (md2frame_t*)&buffer[header->offsetFrames];
// Read in textures // Read in textures
retModel->numMaterials = header->numSkins; retModel->numMaterials = header->numSkins;
@ -312,6 +302,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0);
int t;
for (t = 0; t < retModel->numMaterials; t++) for (t = 0; t < retModel->numMaterials; t++)
{ {
retModel->materials[t].ambient[0] = 0.8f; retModel->materials[t].ambient[0] = 0.8f;
@ -338,7 +329,6 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!systemSucks) if (!systemSucks)
{ {
// Check for a normal map...?? // Check for a normal map...??
Resource::resource_t *res
char openfilename[1024]; char openfilename[1024];
char normalMapName[1024]; char normalMapName[1024];
strcpy(normalMapName, texturefilename); strcpy(normalMapName, texturefilename);
@ -367,7 +357,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
openfilename[k] = '/'; openfilename[k] = '/';
} }
res = Resource::Open(openfilename); Resource::resource_t *res = Resource::Open(openfilename);
if (res) if (res)
{ {
Resource::Close(res); Resource::Close(res);
@ -380,24 +370,15 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
if (!useFloat) // Decompress to MD3 'tinyframe' space if (!useFloat) // Decompress to MD3 'tinyframe' space
{ {
char *ptr = (char*)frames;
md2triangle_t *trisPtr;
unsigned short *indexptr;
float *uvptr;
dataScale = 0.015624f; // 1 / 64.0f dataScale = 0.015624f; // 1 / 64.0f
retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].numVertices = header->numXYZ; retModel->meshes[0].numVertices = header->numXYZ;
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
byte *ptr = (byte*)frames;
for (i = 0; i < header->numFrames; i++, ptr += header->framesize) for (i = 0; i < header->numFrames; i++, ptr += header->framesize)
{ {
short *vertptr;
char *normptr;
//char *tanptr;
md2frame_t *framePtr = (md2frame_t*)ptr; md2frame_t *framePtr = (md2frame_t*)ptr;
md2vertex_t *vertex;
retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0);
retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0);
@ -405,14 +386,14 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
// retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag);
retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0);
vertptr = retModel->meshes[0].tinyframes[i].vertices; short *vertptr = retModel->meshes[0].tinyframes[i].vertices;
normptr = retModel->meshes[0].tinyframes[i].normals; char *normptr = retModel->meshes[0].tinyframes[i].normals;
// tanptr = retModel->meshes[0].tinyframes[i].tangents; // char *tanptr = retModel->meshes[0].tinyframes[i].tangents;
retModel->meshes[0].tinyframes[i].material = &retModel->materials[0]; retModel->meshes[0].tinyframes[i].material = &retModel->materials[0];
framePtr++; // Advance to vertex list framePtr++; // Advance to vertex list
vertex = (md2vertex_t*)framePtr; md2vertex_t *vertex = (md2vertex_t*)framePtr;
framePtr--; framePtr--;
for (j = 0; j < header->numXYZ; j++, vertex++) for (j = 0; j < header->numXYZ; j++, vertex++)
{ {
@ -425,15 +406,15 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
// Normal // Normal
*normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][0] * 127); *normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][0] * 127);
*normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][1] * 127);
*normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][2] * 127); *normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][2] * 127);
*normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][1] * 127);
} }
} }
// This doesn't need to be done every frame! // This doesn't need to be done every frame!
trisPtr = tris; md2triangle_t *trisPtr = tris;
indexptr = retModel->meshes[0].indices; unsigned short *indexptr = retModel->meshes[0].indices;
uvptr = (float*)retModel->meshes[0].uvs; float *uvptr = (float*)retModel->meshes[0].uvs;
for (j = 0; j < header->numTris; j++, trisPtr++) for (j = 0; j < header->numTris; j++, trisPtr++)
{ {
*indexptr = trisPtr->meshIndex[0]; *indexptr = trisPtr->meshIndex[0];
@ -453,15 +434,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
} }
else // Full float loading method else // Full float loading method
{ {
md2triangle_t *trisPtr = tris;
float *uvptr;
char *ptr = (char*)frames;
retModel->meshes[0].numVertices = header->numTris * 3; retModel->meshes[0].numVertices = header->numTris * 3;
retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0);
retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0);
uvptr = retModel->meshes[0].uvs;
md2triangle_t *trisPtr = tris;
float *uvptr = retModel->meshes[0].uvs;
for (i = 0; i < retModel->meshes[0].numTriangles; i++, trisPtr++) for (i = 0; i < retModel->meshes[0].numTriangles; i++, trisPtr++)
{ {
*uvptr++ = texcoords[trisPtr->stIndex[0]].s / (float)header->skinwidth; *uvptr++ = texcoords[trisPtr->stIndex[0]].s / (float)header->skinwidth;
@ -472,16 +450,15 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
*uvptr++ = (texcoords[trisPtr->stIndex[2]].t / (float)header->skinheight); *uvptr++ = (texcoords[trisPtr->stIndex[2]].t / (float)header->skinheight);
} }
byte *ptr = (byte*)frames;
for (i = 0; i < header->numFrames; i++, ptr += header->framesize) for (i = 0; i < header->numFrames; i++, ptr += header->framesize)
{ {
md2vertex_t *vertex;
md2frame_t *framePtr = (md2frame_t*)ptr; md2frame_t *framePtr = (md2frame_t*)ptr;
float *vertptr, *normptr;
retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0);
retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0);
// if (retModel->materials[0].lightmap) // if (retModel->materials[0].lightmap)
// retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag);
float *vertptr, *normptr;
normptr = (float*)retModel->meshes[0].frames[i].normals; normptr = (float*)retModel->meshes[0].frames[i].normals;
vertptr = (float*)retModel->meshes[0].frames[i].vertices; vertptr = (float*)retModel->meshes[0].frames[i].vertices;
trisPtr = tris; trisPtr = tris;
@ -489,7 +466,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
retModel->meshes[0].frames[i].material = &retModel->materials[0]; retModel->meshes[0].frames[i].material = &retModel->materials[0];
framePtr++; // Advance to vertex list framePtr++; // Advance to vertex list
vertex = (md2vertex_t*)framePtr; md2vertex_t *vertex = (md2vertex_t*)framePtr;
framePtr--; framePtr--;
for (j = 0; j < header->numTris; j++, trisPtr++) for (j = 0; j < header->numTris; j++, trisPtr++)
{ {
@ -515,26 +492,17 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat)
vertptr++; vertptr++;
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][0]; *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][0];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][1];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][2]; *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][2];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][1];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][0]; *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][0];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][1];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][2]; *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][2];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][1];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][0]; *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][0];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][1];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][2]; *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][2];
*normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][1];
} }
/*
// Rotate MD2 by 90 degrees in code BLAAHH
vector_t *normVecptr = (vector_t*)retModel->meshes[0].frames[i].normals;
vector_t *vertVecptr = (vector_t*)retModel->meshes[0].frames[i].vertices;
for (j = 0; j < header->numTris * 3; j++, normVecptr++, vertVecptr++)
{
VectorRotate(normVecptr, &vectorYaxis, -90.0f);
VectorRotate(vertVecptr, &vectorYaxis, -90.0f);
}*/
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -37,13 +37,11 @@
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#ifndef MINI_GL_COMPATIBILITY
#ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static #ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#include <GL/glext.h> #include <GL/glext.h>
#endif #endif
#endif #endif
#endif
#define _CREATE_DLL_ // necessary for Unix AND Windows #define _CREATE_DLL_ // necessary for Unix AND Windows
#include "../../doomdef.h" #include "../../doomdef.h"

View file

@ -90,9 +90,7 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DrawModel); GETFUNC(DrawModel);
GETFUNC(SetTransform); GETFUNC(SetTransform);
GETFUNC(GetRenderVersion); GETFUNC(GetRenderVersion);
#ifdef SHUFFLE
GETFUNC(PostImgRedraw); GETFUNC(PostImgRedraw);
#endif //SHUFFLE
GETFUNC(FlushScreenTextures); GETFUNC(FlushScreenTextures);
GETFUNC(StartScreenWipe); GETFUNC(StartScreenWipe);
GETFUNC(EndScreenWipe); GETFUNC(EndScreenWipe);

View file

@ -1549,9 +1549,7 @@ void I_StartupGraphics(void)
HWD.pfnDrawModel = hwSym("DrawModel",NULL); HWD.pfnDrawModel = hwSym("DrawModel",NULL);
HWD.pfnSetTransform = hwSym("SetTransform",NULL); HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL); HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL);
#ifdef SHUFFLE
HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL); HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL);
#endif
HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL); HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL);
HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL); HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL);
HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL); HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL);

View file

@ -108,21 +108,9 @@
<ClCompile Include="..\hardware\hw_md2.c"> <ClCompile Include="..\hardware\hw_md2.c">
<Filter>Hw_Hardware</Filter> <Filter>Hw_Hardware</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\hardware\hw_md2load.c">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\hardware\hw_md3load.c">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClInclude Include="..\hardware\hw_model.c">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClCompile Include="..\hardware\hw_trick.c"> <ClCompile Include="..\hardware\hw_trick.c">
<Filter>Hw_Hardware</Filter> <Filter>Hw_Hardware</Filter>
</ClCompile> </ClCompile>
<ClInclude Include="..\hardware\u_list.c">
<Filter>Hw_Hardware</Filter>
</ClInclude>
<ClCompile Include="..\hardware\hw3sound.c"> <ClCompile Include="..\hardware\hw3sound.c">
<Filter>Hw_Hardware</Filter> <Filter>Hw_Hardware</Filter>
</ClCompile> </ClCompile>
@ -465,6 +453,10 @@
<ClCompile Include="..\string.c"> <ClCompile Include="..\string.c">
<Filter>M_Misc</Filter> <Filter>M_Misc</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\hardware\hw_md2load.c" />
<ClCompile Include="..\hardware\hw_md3load.c" />
<ClCompile Include="..\hardware\hw_model.c" />
<ClCompile Include="..\hardware\u_list.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="afxres.h"> <ClInclude Include="afxres.h">