mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 14:41:40 +00:00
- moved vertex creation for skybox sector to backend independent code.
This commit is contained in:
parent
34ee04f2ce
commit
6b92b95068
4 changed files with 51 additions and 35 deletions
|
@ -23,6 +23,10 @@ public:
|
|||
p = GLRenderer->mVBO->Alloc(4, &ndx);
|
||||
}
|
||||
}
|
||||
FFlatVertex *Pointer()
|
||||
{
|
||||
return p;
|
||||
}
|
||||
void Set(int ndx, float x, float y, float z, float s, float t)
|
||||
{
|
||||
p[ndx].Set(x, y, z, s, t);
|
||||
|
|
|
@ -279,46 +279,14 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
|
|||
|
||||
//==========================================================================
|
||||
//
|
||||
// special handling for skyboxes which need texture clamping.
|
||||
// This will find the bounding rectangle of the sector and just
|
||||
// draw one single polygon filling that rectangle with a clamped
|
||||
// texture.
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDrawInfo::DrawSkyboxSector(GLFlat *flat, int pass, bool processlights)
|
||||
{
|
||||
|
||||
float minx = FLT_MAX, miny = FLT_MAX;
|
||||
float maxx = -FLT_MAX, maxy = -FLT_MAX;
|
||||
|
||||
for (auto ln : flat->sector->Lines)
|
||||
{
|
||||
float x = ln->v1->fX();
|
||||
float y = ln->v1->fY();
|
||||
if (x < minx) minx = x;
|
||||
if (y < miny) miny = y;
|
||||
if (x > maxx) maxx = x;
|
||||
if (y > maxy) maxy = y;
|
||||
x = ln->v2->fX();
|
||||
y = ln->v2->fY();
|
||||
if (x < minx) minx = x;
|
||||
if (y < miny) miny = y;
|
||||
if (x > maxx) maxx = x;
|
||||
if (y > maxy) maxy = y;
|
||||
}
|
||||
|
||||
float z = flat->plane.plane.ZatPoint(0., 0.) + flat->dz;
|
||||
static float uvals[] = { 0, 0, 1, 1 };
|
||||
static float vvals[] = { 1, 0, 0, 1 };
|
||||
int rot = -xs_FloorToInt(flat->plane.Angle / 90.f);
|
||||
|
||||
FQuadDrawer qd;
|
||||
|
||||
qd.Set(0, minx, z, miny, uvals[rot & 3], vvals[rot & 3]);
|
||||
qd.Set(1, minx, z, maxy, uvals[(rot + 1) & 3], vvals[(rot + 1) & 3]);
|
||||
qd.Set(2, maxx, z, maxy, uvals[(rot + 2) & 3], vvals[(rot + 2) & 3]);
|
||||
qd.Set(3, maxx, z, miny, uvals[(rot + 3) & 3], vvals[(rot + 3) & 3]);
|
||||
flat->CreateSkyboxVertices(qd.Pointer());
|
||||
qd.Render(GL_TRIANGLE_FAN);
|
||||
|
||||
flatvertices += 4;
|
||||
|
|
|
@ -314,6 +314,7 @@ public:
|
|||
|
||||
int dynlightindex;
|
||||
|
||||
void CreateSkyboxVertices(FFlatVertex *buffer);
|
||||
bool SetupLights(int pass, FLightNode *head, FDynLightData &lightdata, int portalgroup);
|
||||
bool SetupSubsectorLights(int pass, subsector_t * sub, FDynLightData &lightdata);
|
||||
bool SetupSectorLights(int pass, sector_t * sec, FDynLightData &lightdata);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "hwrenderer/utility/hw_lighting.h"
|
||||
#include "hwrenderer/textures/hw_material.h"
|
||||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "hwrenderer/data/flatvertices.h"
|
||||
#include "hw_drawstructs.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
@ -86,9 +87,51 @@ bool hw_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Flats
|
||||
// special handling for skyboxes which need texture clamping.
|
||||
// This will find the bounding rectangle of the sector and just
|
||||
// draw one single polygon filling that rectangle with a clamped
|
||||
// texture.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void GLFlat::CreateSkyboxVertices(FFlatVertex *vert)
|
||||
{
|
||||
float minx = FLT_MAX, miny = FLT_MAX;
|
||||
float maxx = -FLT_MAX, maxy = -FLT_MAX;
|
||||
|
||||
for (auto ln : sector->Lines)
|
||||
{
|
||||
float x = ln->v1->fX();
|
||||
float y = ln->v1->fY();
|
||||
if (x < minx) minx = x;
|
||||
if (y < miny) miny = y;
|
||||
if (x > maxx) maxx = x;
|
||||
if (y > maxy) maxy = y;
|
||||
x = ln->v2->fX();
|
||||
y = ln->v2->fY();
|
||||
if (x < minx) minx = x;
|
||||
if (y < miny) miny = y;
|
||||
if (x > maxx) maxx = x;
|
||||
if (y > maxy) maxy = y;
|
||||
}
|
||||
|
||||
float z = plane.plane.ZatPoint(0., 0.) + dz;
|
||||
static float uvals[] = { 0, 0, 1, 1 };
|
||||
static float vvals[] = { 1, 0, 0, 1 };
|
||||
int rot = -xs_FloorToInt(plane.Angle / 90.f);
|
||||
|
||||
vert[0].Set(minx, z, miny, uvals[rot & 3], vvals[rot & 3]);
|
||||
vert[1].Set(minx, z, maxy, uvals[(rot + 1) & 3], vvals[(rot + 1) & 3]);
|
||||
vert[2].Set(maxx, z, maxy, uvals[(rot + 2) & 3], vvals[(rot + 2) & 3]);
|
||||
vert[3].Set(maxx, z, miny, uvals[(rot + 3) & 3], vvals[(rot + 3) & 3]);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
|
|
Loading…
Reference in a new issue