mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-19 01:50:46 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
This commit is contained in:
commit
086e2a9557
6 changed files with 71 additions and 19 deletions
|
@ -213,6 +213,17 @@ FFlatVertexBuffer::~FFlatVertexBuffer()
|
||||||
map = nullptr;
|
map = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FFlatVertexBuffer::OutputResized(int width, int height)
|
||||||
|
{
|
||||||
|
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
||||||
|
vbo_shadowdata[5].Set(0, (float)height, 0, 0, 0);
|
||||||
|
vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0);
|
||||||
|
vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0);
|
||||||
|
|
||||||
|
Map();
|
||||||
|
memcpy(map, &vbo_shadowdata[4], 4 * sizeof(FFlatVertex));
|
||||||
|
Unmap();
|
||||||
|
}
|
||||||
|
|
||||||
void FFlatVertexBuffer::BindVBO()
|
void FFlatVertexBuffer::BindVBO()
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,6 +131,8 @@ public:
|
||||||
FFlatVertexBuffer(int width, int height);
|
FFlatVertexBuffer(int width, int height);
|
||||||
~FFlatVertexBuffer();
|
~FFlatVertexBuffer();
|
||||||
|
|
||||||
|
void OutputResized(int width, int height);
|
||||||
|
|
||||||
void BindVBO();
|
void BindVBO();
|
||||||
|
|
||||||
void CreateVBO();
|
void CreateVBO();
|
||||||
|
|
|
@ -107,6 +107,44 @@ static const float LARGE_VALUE = 1e19f;
|
||||||
|
|
||||||
void GLSprite::CalculateVertices(FVector3 *v)
|
void GLSprite::CalculateVertices(FVector3 *v)
|
||||||
{
|
{
|
||||||
|
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
||||||
|
{
|
||||||
|
Matrix3x4 mat;
|
||||||
|
mat.MakeIdentity();
|
||||||
|
|
||||||
|
// [MC] Rotate around the center or offsets given to the sprites.
|
||||||
|
// Counteract any existing rotations, then rotate the angle.
|
||||||
|
// Tilt the actor up or down based on pitch (increase 'somersaults' forward).
|
||||||
|
// Then counteract the roll and DO A BARREL ROLL.
|
||||||
|
|
||||||
|
FAngle pitch = (float)-actor->Angles.Pitch.Degrees;
|
||||||
|
pitch.Normalized180();
|
||||||
|
|
||||||
|
mat.Translate(x, z, y);
|
||||||
|
mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees);
|
||||||
|
mat.Rotate(0, 0, 1, pitch.Degrees);
|
||||||
|
|
||||||
|
if (actor->renderflags & RF_ROLLCENTER)
|
||||||
|
{
|
||||||
|
float cx = (x1 + x2) * 0.5;
|
||||||
|
float cy = (y1 + y2) * 0.5;
|
||||||
|
|
||||||
|
mat.Translate(cx - x, 0, cy - y);
|
||||||
|
mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees);
|
||||||
|
mat.Translate(-cx, -z, -cy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees);
|
||||||
|
mat.Translate(-x, -z, -y);
|
||||||
|
}
|
||||||
|
v[0] = mat * FVector3(x1, z, y2);
|
||||||
|
v[1] = mat * FVector3(x2, z, y2);
|
||||||
|
v[2] = mat * FVector3(x1, z, y1);
|
||||||
|
v[3] = mat * FVector3(x2, z, y1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// [BB] Billboard stuff
|
// [BB] Billboard stuff
|
||||||
const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
|
const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
|
||||||
//&& GLRenderer->mViewActor != NULL
|
//&& GLRenderer->mViewActor != NULL
|
||||||
|
@ -363,15 +401,8 @@ void GLSprite::Draw(int pass)
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
|
|
||||||
FVector3 v[4];
|
FVector3 v[4];
|
||||||
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
CalculateVertices(v);
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CalculateVertices(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FQuadDrawer qd;
|
FQuadDrawer qd;
|
||||||
qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt);
|
qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt);
|
||||||
qd.Set(1, v[1][0], v[1][1], v[1][2], ur, vt);
|
qd.Set(1, v[1][0], v[1][1], v[1][2], ur, vt);
|
||||||
|
@ -595,7 +626,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
||||||
sector_t * rendersector;
|
sector_t * rendersector;
|
||||||
|
|
||||||
// Don't waste time projecting sprites that are definitely not visible.
|
// Don't waste time projecting sprites that are definitely not visible.
|
||||||
if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer())
|
if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -728,7 +759,8 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
||||||
|
|
||||||
float rightfac = -r.left;
|
float rightfac = -r.left;
|
||||||
float leftfac = rightfac - r.width;
|
float leftfac = rightfac - r.width;
|
||||||
|
float bottomfac = -r.top;
|
||||||
|
float topfac = bottomfac - r.height;
|
||||||
z1 = z - r.top;
|
z1 = z - r.top;
|
||||||
z2 = z1 - r.height;
|
z2 = z1 - r.height;
|
||||||
|
|
||||||
|
@ -753,11 +785,15 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
||||||
y1 = y + viewvecX*leftfac;
|
y1 = y + viewvecX*leftfac;
|
||||||
y2 = y + viewvecX*rightfac;
|
y2 = y + viewvecX*rightfac;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RF_FLATSPRITE:
|
case RF_FLATSPRITE:
|
||||||
// needs careful rethinking
|
{
|
||||||
return;
|
x1 = x + leftfac;
|
||||||
|
x2 = x + rightfac;
|
||||||
|
y1 = y - topfac;
|
||||||
|
y2 = y - bottomfac;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RF_WALLSPRITE:
|
case RF_WALLSPRITE:
|
||||||
viewvecX = thing->Angles.Yaw.Cos();
|
viewvecX = thing->Angles.Yaw.Cos();
|
||||||
viewvecY = thing->Angles.Yaw.Sin();
|
viewvecY = thing->Angles.Yaw.Sin();
|
||||||
|
|
|
@ -192,6 +192,7 @@ void OpenGLFrameBuffer::Update()
|
||||||
{
|
{
|
||||||
Resize(clientWidth, clientHeight);
|
Resize(clientWidth, clientHeight);
|
||||||
V_OutputResized(Width, Height);
|
V_OutputResized(Width, Height);
|
||||||
|
GLRenderer->mVBO->OutputResized(Width, Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@ vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
vec2 texCoord = vTexCoord.st;
|
vec2 texCoord = vTexCoord.st;
|
||||||
vec4 basicColor = getTexel(texCoord);
|
vec4 basicColor = getTexel(texCoord);
|
||||||
|
ivec2 texSize = textureSize(tex, 0);
|
||||||
|
|
||||||
texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0;
|
texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x;
|
||||||
texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0;
|
texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y;
|
||||||
|
|
||||||
float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0;
|
float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0;
|
||||||
float texY = cos(mod(texCoord.y * 100.0 + timer*5.0, 3.489)) + texCoord.y / 4.0;
|
float texY = cos(mod(texCoord.y * 100.0 + timer*5.0, 3.489)) + texCoord.y / 4.0;
|
||||||
|
|
|
@ -5,9 +5,10 @@ vec4 ProcessTexel()
|
||||||
{
|
{
|
||||||
vec2 texCoord = vTexCoord.st;
|
vec2 texCoord = vTexCoord.st;
|
||||||
vec4 basicColor = getTexel(texCoord);
|
vec4 basicColor = getTexel(texCoord);
|
||||||
|
ivec2 texSize = textureSize(tex, 0);
|
||||||
|
|
||||||
texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0;
|
texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x;
|
||||||
texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0;
|
texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y;
|
||||||
|
|
||||||
float texX = texCoord.x / 3.0 + 0.66;
|
float texX = texCoord.x / 3.0 + 0.66;
|
||||||
float texY = 0.34 - texCoord.y / 3.0;
|
float texY = 0.34 - texCoord.y / 3.0;
|
||||||
|
|
Loading…
Reference in a new issue