- Remove model GL dependencies except for the matrix classes

This commit is contained in:
Magnus Norddahl 2017-11-25 13:00:44 +01:00
parent 56477c8f89
commit 679f42db78
8 changed files with 38 additions and 31 deletions

View file

@ -137,23 +137,23 @@ void FGLModelRenderer::SetInterpolation(double inter)
gl_RenderState.SetInterpolationFactor((float)inter);
}
void FGLModelRenderer::SetMaterial(FTexture *skin, int clampmode, int translation)
void FGLModelRenderer::SetMaterial(FTexture *skin, bool clampNoFilter, int translation)
{
FMaterial * tex = FMaterial::ValidateTexture(skin, false);
gl_RenderState.SetMaterial(tex, clampmode, translation, -1, false);
gl_RenderState.SetMaterial(tex, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1, false);
gl_RenderState.Apply();
if (modellightindex != -1) gl_RenderState.ApplyLightIndex(modellightindex);
}
void FGLModelRenderer::DrawArrays(int primitiveType, int start, int count)
void FGLModelRenderer::DrawArrays(int start, int count)
{
glDrawArrays(primitiveType, start, count);
glDrawArrays(GL_TRIANGLES, start, count);
}
void FGLModelRenderer::DrawElements(int primitiveType, int numIndices, int elementType, size_t offset)
void FGLModelRenderer::DrawElements(int numIndices, size_t offset)
{
glDrawElements(primitiveType, numIndices, elementType, (void*)(intptr_t)offset);
glDrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_INT, (void*)(intptr_t)offset);
}
double FGLModelRenderer::GetTimeFloat()

View file

@ -41,9 +41,9 @@ public:
void BeginDrawHUDModel(AActor *actor, const VSMatrix &objectToWorldMatrix) override;
void EndDrawHUDModel(AActor *actor) override;
void SetInterpolation(double interpolation) override;
void SetMaterial(FTexture *skin, int clampmode, int translation) override;
void DrawArrays(int primitiveType, int start, int count) override;
void DrawElements(int primitiveType, int numIndices, int elementType, size_t offset) override;
void SetMaterial(FTexture *skin, bool clampNoFilter, int translation) override;
void DrawArrays(int start, int count) override;
void DrawElements(int numIndices, size_t offset) override;
double GetTimeFloat() override;
};

View file

@ -69,9 +69,9 @@ public:
virtual void EndDrawHUDModel(AActor *actor) = 0;
virtual void SetInterpolation(double interpolation) = 0;
virtual void SetMaterial(FTexture *skin, int clampmode, int translation) = 0;
virtual void DrawArrays(int primitiveType, int start, int count) = 0;
virtual void DrawElements(int primitiveType, int numIndices, int elementType, size_t offset) = 0;
virtual void SetMaterial(FTexture *skin, bool clampNoFilter, int translation) = 0;
virtual void DrawArrays(int start, int count) = 0;
virtual void DrawElements(int numIndices, size_t offset) = 0;
virtual double GetTimeFloat() = 0;

View file

@ -26,13 +26,15 @@
**
**/
#include "gl/system/gl_system.h" // for GL_TRIANGLES
#include "w_wad.h"
#include "cmdlib.h"
#include "sc_man.h"
#include "m_crc32.h"
#include "models/models.h"
#include "gl/textures/gl_material.h" // for CLAMP_NONE
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
#endif
static float avertexnormals[NUMVERTEXNORMALS][3] = {
#include "tab_anorms.h"
@ -368,9 +370,9 @@ void FDMDModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
}
renderer->SetInterpolation(inter);
renderer->SetMaterial(skin, CLAMP_NONE, translation);
renderer->SetMaterial(skin, false, translation);
mVBuf->SetupFrame(renderer, frames[frameno].vindex, frames[frameno2].vindex, lodInfo[0].numTriangles * 3);
renderer->DrawArrays(GL_TRIANGLES, 0, lodInfo[0].numTriangles * 3);
renderer->DrawArrays(0, lodInfo[0].numTriangles * 3);
renderer->SetInterpolation(0.f);
}

View file

@ -20,16 +20,18 @@
//--------------------------------------------------------------------------
//
#include "gl/system/gl_system.h" // for GL_TRIANGLES
#include "w_wad.h"
#include "cmdlib.h"
#include "sc_man.h"
#include "m_crc32.h"
#include "models/models.h"
#include "gl/textures/gl_material.h" // for CLAMP_NONE
#define MAX_QPATH 64
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
#endif
//===========================================================================
//
// decode the lat/lng normal to a 3 float normal
@ -362,9 +364,9 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
if (!surfaceSkin) return;
}
renderer->SetMaterial(surfaceSkin, CLAMP_NONE, translation);
renderer->SetMaterial(surfaceSkin, false, translation);
mVBuf->SetupFrame(renderer, surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, surf->numVertices);
renderer->DrawElements(GL_TRIANGLES, surf->numTriangles * 3, GL_UNSIGNED_INT, surf->iindex * sizeof(unsigned int));
renderer->DrawElements(surf->numTriangles * 3, surf->iindex * sizeof(unsigned int));
}
renderer->SetInterpolation(0.f);
}

View file

@ -26,7 +26,6 @@
**
**/
#include "gl/system/gl_system.h" // for GL_TRIANGLES
#include "w_wad.h"
#include "cmdlib.h"
#include "sc_man.h"
@ -39,7 +38,10 @@
#include "textures/bitmap.h"
#include "g_levellocals.h"
#include "models.h"
#include "gl/textures/gl_material.h" // for CLAMP_NONE
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
#endif
//===========================================================================
//
@ -431,8 +433,8 @@ float FVoxelModel::getAspectFactor()
void FVoxelModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation)
{
renderer->SetMaterial(skin, CLAMP_NOFILTER, translation);
renderer->SetMaterial(skin, true, translation);
mVBuf->SetupFrame(renderer, 0, 0, 0);
renderer->DrawElements(GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, 0);
renderer->DrawElements(mNumIndices, 0);
}

View file

@ -31,6 +31,7 @@
#include "polyrenderer/poly_renderthread.h"
#include "r_data/r_vanillatrans.h"
#include "actorinlines.h"
#include "i_time.h"
void PolyRenderModel(PolyRenderThread *thread, const TriMatrix &worldToClip, const PolyClipPlane &clipPlane, uint32_t stencilValue, float x, float y, float z, FSpriteModelFrame *smf, AActor *actor)
{
@ -102,12 +103,12 @@ void PolyModelRenderer::SetInterpolation(double interpolation)
InterpolationFactor = (float)interpolation;
}
void PolyModelRenderer::SetMaterial(FTexture *skin, int clampmode, int translation)
void PolyModelRenderer::SetMaterial(FTexture *skin, bool clampNoFilter, int translation)
{
SkinTexture = skin;
}
void PolyModelRenderer::DrawArrays(int primitiveType, int start, int count)
void PolyModelRenderer::DrawArrays(int start, int count)
{
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
@ -141,7 +142,7 @@ void PolyModelRenderer::DrawArrays(int primitiveType, int start, int count)
args.DrawArray(Thread, VertexBuffer + start, count);
}
void PolyModelRenderer::DrawElements(int primitiveType, int numIndices, int elementType, size_t offset)
void PolyModelRenderer::DrawElements(int numIndices, size_t offset)
{
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
@ -177,7 +178,7 @@ void PolyModelRenderer::DrawElements(int primitiveType, int numIndices, int elem
double PolyModelRenderer::GetTimeFloat()
{
return 0.0f; // (float)gl_frameMS * (float)TICRATE / 1000.0f;
return (float)I_msTime() * (float)TICRATE / 1000.0f;
}
/////////////////////////////////////////////////////////////////////////////

View file

@ -43,9 +43,9 @@ public:
void BeginDrawHUDModel(AActor *actor, const VSMatrix &objectToWorldMatrix) override;
void EndDrawHUDModel(AActor *actor) override;
void SetInterpolation(double interpolation) override;
void SetMaterial(FTexture *skin, int clampmode, int translation) override;
void DrawArrays(int primitiveType, int start, int count) override;
void DrawElements(int primitiveType, int numIndices, int elementType, size_t offset) override;
void SetMaterial(FTexture *skin, bool clampNoFilter, int translation) override;
void DrawArrays(int start, int count) override;
void DrawElements(int numIndices, size_t offset) override;
double GetTimeFloat() override;
PolyRenderThread *Thread = nullptr;