Removed gr_voodoocompatibility as even low-power mobile devices do not have this limitation

No longer using byte2float in DrawPolygon -- use the surface color data directly
Vertex Buffer Objects for non-interpolated model frames
Removed some old unused paletted texture stuff
This commit is contained in:
Arthur 2018-12-26 10:58:37 -05:00 committed by mazmazz
parent a812acc3d4
commit 587ffa9ada
16 changed files with 276 additions and 281 deletions

View File

@ -533,9 +533,6 @@ void D_SRB2Loop(void)
if (dedicated)
server = true;
if (M_CheckParm("-voodoo")) // 256x256 Texture Limiter
COM_BufAddText("gr_voodoocompatibility on\n");
// Pushing of + parameters is now done back in D_SRB2Main, not here.
CONS_Printf("I_StartupKeyboard()...\n");

View File

@ -366,16 +366,18 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
/* Miscellaneous types that don't fit anywhere else (Can this be changed?) */
typedef struct
{
UINT8 red;
UINT8 green;
UINT8 blue;
UINT8 alpha;
} byteColor_t;
union FColorRGBA
{
UINT32 rgba;
struct
{
UINT8 red;
UINT8 green;
UINT8 blue;
UINT8 alpha;
} s;
byteColor_t s;
} ATTRPACK;
typedef union FColorRGBA RGBA_t;

View File

@ -241,43 +241,6 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight,
if (blockheight < 1)
I_Error("3D GenerateTexture : too small");
}
else if (cv_voodoocompatibility.value)
{
if (originalwidth > 256 || originalheight > 256)
{
blockwidth = 256;
while (originalwidth < blockwidth)
blockwidth >>= 1;
if (blockwidth < 1)
I_Error("3D GenerateTexture : too small");
blockheight = 256;
while (originalheight < blockheight)
blockheight >>= 1;
if (blockheight < 1)
I_Error("3D GenerateTexture : too small");
}
else
{
//size up to nearest power of 2
blockwidth = 1;
while (blockwidth < originalwidth)
blockwidth <<= 1;
// scale down the original graphics to fit in 256
if (blockwidth > 256)
blockwidth = 256;
//I_Error("3D GenerateTexture : too big");
//size up to nearest power of 2
blockheight = 1;
while (blockheight < originalheight)
blockheight <<= 1;
// scale down the original graphics to fit in 256
if (blockheight > 256)
blockheight = 255;
//I_Error("3D GenerateTexture : too big");
}
}
else
{
//size up to nearest power of 2
@ -508,18 +471,6 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
newwidth = blockwidth;
newheight = blockheight;
}
else if (cv_voodoocompatibility.value) // Only scales down textures that exceed 256x256.
{
// no rounddown, do not size up patches, so they don't look 'scaled'
newwidth = min(grPatch->width, blockwidth);
newheight = min(grPatch->height, blockheight);
if (newwidth > 256 || newheight > 256)
{
newwidth = blockwidth;
newheight = blockheight;
}
}
else
{
// no rounddown, do not size up patches, so they don't look 'scaled'
@ -935,18 +886,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
newwidth = blockwidth;
newheight = blockheight;
}
else if (cv_voodoocompatibility.value) // Only scales down textures that exceed 256x256.
{
// no rounddown, do not size up patches, so they don't look 'scaled'
newwidth = min(SHORT(pic->width),blockwidth);
newheight = min(SHORT(pic->height),blockheight);
if (newwidth > 256 || newheight > 256)
{
newwidth = blockwidth;
newheight = blockheight;
}
}
else
{
// no rounddown, do not size up patches, so they don't look 'scaled'

View File

@ -224,8 +224,6 @@ enum hwdsetspecialstate
HWD_SET_FOG_COLOR,
HWD_SET_FOG_DENSITY,
HWD_SET_FOV,
HWD_SET_POLYGON_SMOOTH,
HWD_SET_PALETTECOLOR,
HWD_SET_TEXTUREFILTERMODE,
HWD_SET_TEXTUREANISOTROPICMODE,
HWD_NUMSTATE

View File

@ -59,6 +59,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 *color);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *ptransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT INT32 HWRAPI(GetRenderVersion) (void);
@ -94,6 +95,7 @@ struct hwdriver_s
ClearMipMapCache pfnClearMipMapCache;
SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility
DrawModel pfnDrawModel;
CreateModelVBOs pfnCreateModelVBOs;
SetTransform pfnSetTransform;
GetTextureUsed pfnGetTextureUsed;
GetRenderVersion pfnGetRenderVersion;

View File

@ -6606,11 +6606,6 @@ static void HWR_RenderWall(wallVert3D *wallVerts, FSurfaceInfo *pSurf, FBITFIE
#endif
}
void HWR_SetPaletteColor(INT32 palcolor)
{
HWD.pfnSetSpecialState(HWD_SET_PALETTECOLOR, palcolor);
}
INT32 HWR_GetTextureUsed(void)
{
return HWD.pfnGetTextureUsed();

View File

@ -58,7 +58,6 @@ void HWR_AddCommands(void);
void HWR_CorrectSWTricks(void);
void transform(float *cx, float *cy, float *cz);
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
void HWR_SetPaletteColor(INT32 palcolor);
INT32 HWR_GetTextureUsed(void);
void HWR_DoPostProcessor(player_t *player);
void HWR_StartScreenWipe(void);
@ -92,7 +91,6 @@ extern consvar_t cv_grgammablue;
extern consvar_t cv_grfiltermode;
extern consvar_t cv_granisotropicmode;
extern consvar_t cv_grcorrecttricks;
extern consvar_t cv_voodoocompatibility;
extern consvar_t cv_grfovchange;
extern consvar_t cv_grsolvetjoin;

View File

@ -981,6 +981,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
if (md2->model)
{
md2_printModelInfo(md2->model);
HWD.pfnCreateModelVBOs(md2->model);
}
else
{

View File

@ -49,117 +49,6 @@ void VectorRotate(vector_t *rotVec, const vector_t *axisVec, float angle)
rotVec->z = axisVec->z*(ux + vy + wz) + (rotVec->z*(axisVec->x*axisVec->x + axisVec->y*axisVec->y) - axisVec->z*(ux + vy))*ca + (-vx + uy)*sa;
}
void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame)
{
(void)mesh;
(void)frame;
return;
/* int bufferSize = sizeof(VBO::vbotiny_t)*mesh->numTriangles*3;
VBO::vbotiny_t *buffer = (VBO::vbotiny_t*)Z_Malloc(bufferSize, PU_STATIC, 0);
VBO::vbotiny_t *bufPtr = buffer;
short *vertPtr = frame->vertices;
char *normPtr = frame->normals;
float *uvPtr = mesh->uvs;
char *tanPtr = frame->tangents;
int i;
for (i = 0; i < mesh->numTriangles*3; i++)
{
bufPtr->x = *vertPtr++;
bufPtr->y = *vertPtr++;
bufPtr->z = *vertPtr++;
bufPtr->nx = (*normPtr++) * 127;
bufPtr->ny = (*normPtr++) * 127;
bufPtr->nz = (*normPtr++) * 127;
bufPtr->s0 = *uvPtr++;
bufPtr->t0 = *uvPtr++;
if (tanPtr)
{
bufPtr->tanx = *tanPtr++;
bufPtr->tany = *tanPtr++;
bufPtr->tanz = *tanPtr++;
}
bufPtr++;
}
bglGenBuffers(1, &frame->vboID);
bglBindBuffer(BGL_ARRAY_BUFFER, frame->vboID);
bglBufferData(BGL_ARRAY_BUFFER, bufferSize, buffer, BGL_STATIC_DRAW);
Z_Free(buffer);*/
}
void CreateVBO(mesh_t *mesh, mdlframe_t *frame)
{
(void)mesh;
(void)frame;
return;
/* int bufferSize = sizeof(VBO::vbo64_t)*mesh->numTriangles*3;
VBO::vbo64_t *buffer = (VBO::vbo64_t*)Z_Malloc(bufferSize, PU_STATIC, 0);
VBO::vbo64_t *bufPtr = buffer;
float *vertPtr = frame->vertices;
float *normPtr = frame->normals;
float *tanPtr = frame->tangents;
float *uvPtr = mesh->uvs;
float *lightPtr = mesh->lightuvs;
char *colorPtr = frame->colors;
int i;
for (i = 0; i < mesh->numTriangles*3; i++)
{
bufPtr->x = *vertPtr++;
bufPtr->y = *vertPtr++;
bufPtr->z = *vertPtr++;
bufPtr->nx = *normPtr++;
bufPtr->ny = *normPtr++;
bufPtr->nz = *normPtr++;
bufPtr->s0 = *uvPtr++;
bufPtr->t0 = *uvPtr++;
if (tanPtr != NULL)
{
bufPtr->tan0 = *tanPtr++;
bufPtr->tan1 = *tanPtr++;
bufPtr->tan2 = *tanPtr++;
}
if (lightPtr != NULL)
{
bufPtr->s1 = *lightPtr++;
bufPtr->t1 = *lightPtr++;
}
if (colorPtr)
{
bufPtr->r = *colorPtr++;
bufPtr->g = *colorPtr++;
bufPtr->b = *colorPtr++;
bufPtr->a = *colorPtr++;
}
else
{
bufPtr->r = 255;
bufPtr->g = 255;
bufPtr->b = 255;
bufPtr->a = 255;
}
bufPtr++;
}
bglGenBuffers(1, &frame->vboID);
bglBindBuffer(BGL_ARRAY_BUFFER, frame->vboID);
bglBufferData(BGL_ARRAY_BUFFER, bufferSize, buffer, BGL_STATIC_DRAW);
Z_Free(buffer);*/
}
void UnloadModel(model_t *model)
{
// Wouldn't it be great if C just had destructors?
@ -326,33 +215,6 @@ model_t *LoadModel(const char *filename, int ztag)
material->shininess = 25.0f;
}
// CONS_Printf("Generating VBOs for %s\n", filename);
for (i = 0; i < model->numMeshes; i++)
{
mesh_t *mesh = &model->meshes[i];
if (mesh->frames)
{
int j;
for (j = 0; j < model->meshes[i].numFrames; j++)
{
mdlframe_t *frame = &mesh->frames[j];
frame->vboID = 0;
CreateVBO(mesh, frame);
}
}
else if (mesh->tinyframes)
{
int j;
for (j = 0; j < model->meshes[i].numFrames; j++)
{
tinyframe_t *frame = &mesh->tinyframes[j];
frame->vboID = 0;
CreateVBOTiny(mesh, frame);
}
}
}
return model;
}

View File

@ -30,6 +30,7 @@
#include <stdarg.h>
#include <math.h>
#include "r_opengl.h"
#include "r_vbo.h"
#if defined (HWRENDER) && !defined (NOROPENGL)
// for KOS: GL_TEXTURE_ENV, glAlphaFunc, glColorMask, glPolygonOffset, glReadPixels, GL_ALPHA_TEST, GL_POLYGON_OFFSET_FILL
@ -42,7 +43,7 @@ struct GLRGBAFloat
GLfloat alpha;
};
typedef struct GLRGBAFloat GLRGBAFloat;
static const float white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
static const GLubyte white[4] = { 255, 255, 255, 255 };
// ==========================================================================
// CONSTANTS
@ -227,6 +228,8 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#define pglNormal3bv glNormal3bv
#define pglColor4f glColor4f
#define pglColor4fv glColor4fv
#define pglColor4ub glColor4ub
#define pglColor4ubv glColor4ubv
#define pglTexCoord2f glTexCoord2f
#define pglTexCoord2fv glTexCoord2fv
#define pglVertexPointer glVertexPointer
@ -237,6 +240,10 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
#define pglEnableClientState glEnableClientState
#define pglDisableClientState glDisableClientState
#define pglClientActiveTexture glClientActiveTexture
#define pglGenBuffers glGenBuffers
#define pglBindBuffer glBindBuffer
#define pglBufferData glBufferData
#define pglDeleteBuffers glDeleteBuffers
/* Lighting */
#define pglShadeModel glShadeModel
@ -346,6 +353,10 @@ typedef void (APIENTRY * PFNglColor4f) (GLfloat red, GLfloat green, GLfloat blue
static PFNglColor4f pglColor4f;
typedef void (APIENTRY * PFNglColor4fv) (const GLfloat *v);
static PFNglColor4fv pglColor4fv;
typedef void (APIENTRY * PFNglColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
static PFNglColor4ub pglColor4ub;
typedef void (APIENTRY * PFNglColor4ubv) (const GLubyte *v);
static PFNglColor4ubv pglColor4ubv;
typedef void (APIENTRY * PFNglTexCoord2f) (GLfloat s, GLfloat t);
static PFNglTexCoord2f pglTexCoord2f;
typedef void (APIENTRY * PFNglTexCoord2fv) (const GLfloat *v);
@ -364,6 +375,15 @@ typedef void (APIENTRY * PFNglEnableClientState) (GLenum cap);
static PFNglEnableClientState pglEnableClientState;
typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap);
static PFNglDisableClientState pglDisableClientState;
typedef void (APIENTRY * PFNglGenBuffers) (GLsizei n, GLuint *buffers);
static PFNglGenBuffers pglGenBuffers;
typedef void (APIENTRY * PFNglBindBuffer) (GLenum target, GLuint buffer);
static PFNglBindBuffer pglBindBuffer;
typedef void (APIENTRY * PFNglBufferData) (GLenum target, GLsizei size, const GLvoid *data, GLenum usage);
static PFNglBufferData pglBufferData;
typedef void (APIENTRY * PFNglDeleteBuffers) (GLsizei n, const GLuint *buffers);
static PFNglDeleteBuffers pglDeleteBuffers;
/* Lighting */
typedef void (APIENTRY * PFNglShadeModel) (GLenum mode);
@ -492,6 +512,8 @@ boolean SetupGLfunc(void)
GETOPENGLFUNC(pglNormal3bv, glNormal3bv)
GETOPENGLFUNC(pglColor4f , glColor4f)
GETOPENGLFUNC(pglColor4fv , glColor4fv)
GETOPENGLFUNC(pglColor4ub, glColor4ub)
GETOPENGLFUNC(pglColor4ubv, glColor4ubv)
GETOPENGLFUNC(pglTexCoord2f , glTexCoord2f)
GETOPENGLFUNC(pglTexCoord2fv, glTexCoord2fv)
GETOPENGLFUNC(pglVertexPointer, glVertexPointer)
@ -501,9 +523,6 @@ boolean SetupGLfunc(void)
GETOPENGLFUNC(pglDrawElements, glDrawElements)
GETOPENGLFUNC(pglEnableClientState, glEnableClientState)
GETOPENGLFUNC(pglDisableClientState, glDisableClientState)
GETOPENGLFUNC(pglClientActiveTexture, glClientActiveTexture)
if (!pglClientActiveTexture)
GETOPENGLFUNC(pglClientActiveTexture, glClientActiveTextureARB)
GETOPENGLFUNC(pglShadeModel , glShadeModel)
GETOPENGLFUNC(pglLightfv, glLightfv)
@ -542,6 +561,10 @@ boolean SetupGLFunc13(void)
pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2f");
pglClientActiveTexture = GetGLFunc("glClientActiveTexture");
pglMultiTexCoord2fv = GetGLFunc("glMultiTexCoord2fv");
pglGenBuffers = GetGLFunc("glGenBuffers");
pglBindBuffer = GetGLFunc("glBindBuffer");
pglBufferData = GetGLFunc("glBufferData");
pglDeleteBuffers = GetGLFunc("glDeleteBuffers");
return true;
}
@ -950,8 +973,6 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1,
F2DCoord * v2,
RGBA_t Color)
{
GLRGBAFloat c;
// DBG_Printf ("DrawLine() (%f %f %f) %d\n", v1->x, -v1->y, -v1->z, v1->argb);
GLfloat p[12];
GLfloat dx, dy;
@ -962,11 +983,6 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1,
pglDisable(GL_TEXTURE_2D);
c.red = byte2float[Color.s.red];
c.green = byte2float[Color.s.green];
c.blue = byte2float[Color.s.blue];
c.alpha = byte2float[Color.s.alpha];
// This is the preferred, 'modern' way of rendering lines -- creating a polygon.
if (fabsf(v2->x - v1->x) > FLT_EPSILON)
angle = (float)atan((v2->y-v1->y)/(v2->x-v1->x));
@ -981,7 +997,7 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1,
p[9] = v1->x + dx; p[10] = -(v1->y - dy); p[11] = 1;
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
pglColor4fv(&c.red); // is in RGBA float format
pglColor4ubv((GLbyte*)&Color);
pglVertexPointer(3, GL_FLOAT, 0, p);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@ -1098,7 +1114,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
if (oglflags & GLF_NOTEXENV)
{
if (!(PolyFlags & PF_Modulated))
pglColor4fv(white);
pglColor4ubv(white);
}
else
#endif
@ -1379,7 +1395,6 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
{
FUINT i;
FUINT j;
GLRGBAFloat c = {0,0,0,0};
if ((PolyFlags & PF_Corona) && (oglflags & GLF_NOZBUFREAD))
PolyFlags &= ~(PF_NoDepthTest|PF_Corona);
@ -1388,24 +1403,7 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
// If Modulated, mix the surface colour to the texture
if ((CurrentPolyFlags & PF_Modulated) && pSurf)
{
if (pal_col)
{ // hack for non-palettized mode
c.red = (const_pal_col.red +byte2float[pSurf->FlatColor.s.red]) /2.0f;
c.green = (const_pal_col.green+byte2float[pSurf->FlatColor.s.green])/2.0f;
c.blue = (const_pal_col.blue +byte2float[pSurf->FlatColor.s.blue]) /2.0f;
c.alpha = byte2float[pSurf->FlatColor.s.alpha];
}
else
{
c.red = byte2float[pSurf->FlatColor.s.red];
c.green = byte2float[pSurf->FlatColor.s.green];
c.blue = byte2float[pSurf->FlatColor.s.blue];
c.alpha = byte2float[pSurf->FlatColor.s.alpha];
}
pglColor4fv(&c.red); // is in RGBA float format
}
pglColor4ubv(&pSurf->FlatColor.s);
// this test is added for new coronas' code (without depth buffer)
// I think I should do a separate function for drawing coronas, so it will be a little faster
@ -1452,8 +1450,15 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf,
if (scalef < 0.05f)
return;
c.alpha *= scalef; // change the alpha value (it seems better than changing the size of the corona)
pglColor4fv(&c.red);
GLubyte c[4];
c[0] = pSurf->FlatColor.s.red;
c[1] = pSurf->FlatColor.s.green;
c[2] = pSurf->FlatColor.s.blue;
float alpha = byte2float[pSurf->FlatColor.s.alpha];
alpha *= scalef; // change the alpha value (it seems better than changing the size of the corona)
c[3] = (unsigned char)(alpha * 255);
pglColor4ubv(c);
}
pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x);
@ -1489,15 +1494,6 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
}
#endif
case HWD_SET_PALETTECOLOR:
{
pal_col = Value;
const_pal_col.blue = byte2float[((Value>>16)&0xff)];
const_pal_col.green = byte2float[((Value>>8)&0xff)];
const_pal_col.red = byte2float[((Value)&0xff)];
break;
}
case HWD_SET_FOG_COLOR:
{
GLfloat fogcolor[4];
@ -1539,13 +1535,6 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
pglDisable(GL_FOG);
break;
case HWD_SET_POLYGON_SMOOTH:
if (Value)
pglEnable(GL_POLYGON_SMOOTH);
else
pglDisable(GL_POLYGON_SMOOTH);
break;
case HWD_SET_TEXTUREFILTERMODE:
switch (Value)
{
@ -1643,6 +1632,155 @@ static void AllocLerpTinyBuffer(size_t size)
normTinyBuffer = malloc(lerpTinyBufferSize / 2);
}
#ifndef GL_STATIC_DRAW
#define GL_STATIC_DRAW 0x88E4
#endif
#ifndef GL_ARRAY_BUFFER
#define GL_ARRAY_BUFFER 0x8892
#endif
static void CreateModelVBO(mesh_t *mesh, mdlframe_t *frame)
{
int bufferSize = sizeof(vbo64_t)*mesh->numTriangles * 3;
vbo64_t *buffer = (vbo64_t*)malloc(bufferSize);
vbo64_t *bufPtr = buffer;
float *vertPtr = frame->vertices;
float *normPtr = frame->normals;
float *tanPtr = frame->tangents;
float *uvPtr = mesh->uvs;
float *lightPtr = mesh->lightuvs;
char *colorPtr = frame->colors;
int i;
for (i = 0; i < mesh->numTriangles * 3; i++)
{
bufPtr->x = *vertPtr++;
bufPtr->y = *vertPtr++;
bufPtr->z = *vertPtr++;
bufPtr->nx = *normPtr++;
bufPtr->ny = *normPtr++;
bufPtr->nz = *normPtr++;
bufPtr->s0 = *uvPtr++;
bufPtr->t0 = *uvPtr++;
if (tanPtr != NULL)
{
bufPtr->tan0 = *tanPtr++;
bufPtr->tan1 = *tanPtr++;
bufPtr->tan2 = *tanPtr++;
}
if (lightPtr != NULL)
{
bufPtr->s1 = *lightPtr++;
bufPtr->t1 = *lightPtr++;
}
if (colorPtr)
{
bufPtr->r = *colorPtr++;
bufPtr->g = *colorPtr++;
bufPtr->b = *colorPtr++;
bufPtr->a = *colorPtr++;
}
else
{
bufPtr->r = 255;
bufPtr->g = 255;
bufPtr->b = 255;
bufPtr->a = 255;
}
bufPtr++;
}
pglGenBuffers(1, &frame->vboID);
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW);
free(buffer);
}
static void CreateModelVBOTiny(mesh_t *mesh, tinyframe_t *frame)
{
int bufferSize = sizeof(vbotiny_t)*mesh->numTriangles * 3;
vbotiny_t *buffer = (vbotiny_t*)malloc(bufferSize);
vbotiny_t *bufPtr = buffer;
short *vertPtr = frame->vertices;
char *normPtr = frame->normals;
float *uvPtr = mesh->uvs;
char *tanPtr = frame->tangents;
int i;
for (i = 0; i < mesh->numVertices; i++)
{
bufPtr->x = *vertPtr++;
bufPtr->y = *vertPtr++;
bufPtr->z = *vertPtr++;
bufPtr->nx = *normPtr++;
bufPtr->ny = *normPtr++;
bufPtr->nz = *normPtr++;
bufPtr->s0 = *uvPtr++;
bufPtr->t0 = *uvPtr++;
if (tanPtr)
{
bufPtr->tanx = *tanPtr++;
bufPtr->tany = *tanPtr++;
bufPtr->tanz = *tanPtr++;
}
bufPtr++;
}
pglGenBuffers(1, &frame->vboID);
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW);
free(buffer);
}
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model)
{
int i;
for (i = 0; i < model->numMeshes; i++)
{
mesh_t *mesh = &model->meshes[i];
if (mesh->frames)
{
int j;
for (j = 0; j < model->meshes[i].numFrames; j++)
{
mdlframe_t *frame = &mesh->frames[j];
if (frame->vboID)
pglDeleteBuffers(1, &frame->vboID);
frame->vboID = 0;
CreateModelVBO(mesh, frame);
}
}
else if (mesh->tinyframes)
{
int j;
for (j = 0; j < model->meshes[i].numFrames; j++)
{
tinyframe_t *frame = &mesh->tinyframes[j];
if (frame->vboID)
pglDeleteBuffers(1, &frame->vboID);
frame->vboID = 0;
CreateModelVBOTiny(mesh, frame);
}
}
}
}
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 *color)
{
GLfloat ambient[4];
@ -1773,10 +1911,13 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
if (!nextframe || fpclassify(pol) == FP_ZERO)
{
pglVertexPointer(3, GL_SHORT, 0, frame->vertices);
pglNormalPointer(GL_BYTE, 0, frame->normals);
pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs);
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglVertexPointer(3, GL_SHORT, sizeof(vbotiny_t), BUFFER_OFFSET(0));
pglNormalPointer(GL_BYTE, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short)*3));
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short) * 3 + sizeof(byte) * 6));
pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
}
else
{
@ -1814,10 +1955,18 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32
if (!nextframe || fpclassify(pol) == FP_ZERO)
{
// Zoom! Take advantage of just shoving the entire arrays to the GPU.
pglVertexPointer(3, GL_FLOAT, 0, frame->vertices);
/* pglVertexPointer(3, GL_FLOAT, 0, frame->vertices);
pglNormalPointer(GL_FLOAT, 0, frame->normals);
pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs);
pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);
pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);*/
pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID);
pglVertexPointer(3, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(0));
pglNormalPointer(GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 3));
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 6));
pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
}
else
{
@ -1971,7 +2120,7 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2])
// Draw a black square behind the screen texture,
// so nothing shows through the edges
pglColor4fv(white);
pglColor4ubv(white);
pglVertexPointer(3, GL_FLOAT, 0, blackBack);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@ -2143,7 +2292,7 @@ EXPORT void HWRAPI(DrawIntermissionBG)(void)
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
pglBindTexture(GL_TEXTURE_2D, screentexture);
pglColor4fv(white);
pglColor4ubv(white);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
@ -2208,7 +2357,7 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha)
// Draw the original screen
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
pglColor4fv(white);
pglColor4ubv(white);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
@ -2366,7 +2515,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
ClearBuffer(true, false, &clearColour);
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
pglColor4fv(white);
pglColor4ubv(white);
pglTexCoordPointer(2, GL_FLOAT, 0, fix);
pglVertexPointer(3, GL_FLOAT, 0, off);

View File

@ -0,0 +1,52 @@
/*
From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com )
An experimental work-in-progress.
Donated to Sonic Team Junior and adapted to work with
Sonic Robo Blast 2. The license of this code matches whatever
the licensing is for Sonic Robo Blast 2.
*/
#ifndef _R_VBO_H_
#define _R_VBO_H_
typedef struct
{
float x, y, z; // Vertex
float nx, ny, nz; // Normal
float s0, t0; // Texcoord0
} vbo32_t;
typedef struct
{
float x, y, z; // Vertex
float s0, t0; // Texcoord0
unsigned char r, g, b, a; // Color
float pad[2]; // Pad
} vbo2d32_t;
typedef struct
{
float x, y; // Vertex
float s0, t0; // Texcoord0
} vbofont_t;
typedef struct
{
short x, y, z; // Vertex
char nx, ny, nz; // Normal
char tanx, tany, tanz; // Tangent
float s0, t0; // Texcoord0
} vbotiny_t;
typedef struct
{
float x, y, z; // Vertex
float nx, ny, nz; // Normal
float s0, t0; // Texcoord0
float s1, t1; // Texcoord1
float s2, t2; // Texcoord2
float tan0, tan1, tan2; // Tangent
unsigned char r, g, b, a; // Color
} vbo64_t;
#endif

View File

@ -1397,7 +1397,6 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_grgammared);
CV_RegisterVar(&cv_grfovchange);
CV_RegisterVar(&cv_grfog);
CV_RegisterVar(&cv_voodoocompatibility);
CV_RegisterVar(&cv_grfogcolor);
CV_RegisterVar(&cv_grsoftwarefog);
#ifdef ALAM_LIGHTING

View File

@ -88,6 +88,7 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(SetSpecialState);
GETFUNC(GetTextureUsed);
GETFUNC(DrawModel);
GETFUNC(CreateModelVBOs);
GETFUNC(SetTransform);
GETFUNC(GetRenderVersion);
GETFUNC(PostImgRedraw);

View File

@ -1489,6 +1489,7 @@ void I_StartupGraphics(void)
HWD.pfnSetPalette = hwSym("SetPalette",NULL);
HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL);
HWD.pfnDrawModel = hwSym("DrawModel",NULL);
HWD.pfnCreateModelVBOs = hwSym("CreateModelVBOs",NULL);
HWD.pfnSetTransform = hwSym("SetTransform",NULL);
HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL);
HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL);

View File

@ -60,7 +60,6 @@ static void CV_Gammaxxx_ONChange(void);
static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}};
static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "LightPlanes"}, {0, NULL}};
consvar_t cv_voodoocompatibility = {"gr_voodoocompatibility", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grfog = {"gr_fog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grfogcolor = {"gr_fogcolor", "AAAAAA", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};

View File

@ -1572,12 +1572,12 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5)
{
char actualmd5text[2*MD5_LEN+1];
PrintMD5String(wadfiles[wadfilenum]->md5sum, actualmd5text);
#ifdef _DEBUG
/*#ifdef _DEBUG
CONS_Printf
#else
I_Error
#endif
(M_GetText("File is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n"), wadfiles[wadfilenum]->filename, actualmd5text, matchmd5);
(M_GetText("File is corrupt or has been modified: %s (found md5: %s, wanted: %s)\n"), wadfiles[wadfilenum]->filename, actualmd5text, matchmd5);*/
}
#endif
}