mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 14:34:34 +00:00
remove immediate mode from quad rendering. breaks a couple rendering details too. WIP.
This commit is contained in:
parent
a4ea66761b
commit
b33080b0ea
4 changed files with 25 additions and 28 deletions
|
@ -116,29 +116,18 @@ void Quad::_renderBorder(const RenderState& rs, Vector color, float borderalpha)
|
|||
{
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glColor4f(color.x, color.y, color.z, borderalpha*alpha.x*alphaMod);
|
||||
|
||||
core->getDefaultQuadBorderBuf()->apply();
|
||||
|
||||
if (rs.forceRenderCenter || renderCenter)
|
||||
{
|
||||
glColor4f(color.x, color.y, color.z, borderalpha*alpha.x*alphaMod);
|
||||
glPointSize(16);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex2f(0,0);
|
||||
glEnd();
|
||||
glDrawArrays(GL_POINTS, 4, 1);
|
||||
}
|
||||
|
||||
glColor4f(color.x, color.y, color.z, alpha.x*alphaMod);
|
||||
glLineWidth(2);
|
||||
const float _w2 = width*0.5f;
|
||||
const float _h2 = height*0.5f;
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-_w2, _h2);
|
||||
glVertex2f(_w2, _h2);
|
||||
glVertex2f(_w2, -_h2);
|
||||
glVertex2f(_w2, _h2);
|
||||
glVertex2f(-_w2, -_h2);
|
||||
glVertex2f(-_w2, _h2);
|
||||
glVertex2f(-_w2, -_h2);
|
||||
glVertex2f(_w2, -_h2);
|
||||
glEnd();
|
||||
glDrawArrays(GL_LINE_LOOP, 0, 4);
|
||||
RenderObject::lastTextureApplied = 0;
|
||||
}
|
||||
|
||||
|
@ -266,11 +255,13 @@ void Quad::refreshRepeatTextureToFill()
|
|||
texcoords.v1 = texOff.y;
|
||||
texcoords.u2 = (width*scale.x*repeatToFillScale.x)/texture->width + texOff.x;
|
||||
texcoords.v2 = (height*scale.y*repeatToFillScale.y)/texture->height + texOff.y;
|
||||
//texcoords.fixflip();
|
||||
|
||||
if(!grid)
|
||||
{
|
||||
createGrid(2, 2)->gridType = GRID_UNDEFINED;
|
||||
}
|
||||
grid->setTexCoords(texcoords);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -43,6 +43,20 @@ void TexCoordBox::setStandard()
|
|||
v2 = 1;
|
||||
}
|
||||
|
||||
void TexCoordBox::fixflip()
|
||||
{
|
||||
// HACK: partially repeated textures have a weird Y axis. assuming a repeat factor of 0.4,
|
||||
// instead of texcoords from 0 -> 0.4 everything is biased towards the opposite end, ie. 0.6 -> 1.
|
||||
// This is especially true for partial repeats, we always need to bias towards the other end.
|
||||
// I have no idea why this has to be like this for tiles, but this is NOT the case for fonts.
|
||||
// And NOTE: without this, maps may look deceivingly correct, but they really are not.
|
||||
const float percentY = v2 - v1;
|
||||
const float remainder = 1.0f - fmodf(percentY, 1.0f);
|
||||
v1 += remainder; // bias towards next int
|
||||
v2 += remainder;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Texture::Texture()
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@ struct TexCoordBox
|
|||
|
||||
bool isStandard() const;
|
||||
void setStandard();
|
||||
void fixflip(); // call this after setting up, in case flip is desired
|
||||
};
|
||||
|
||||
enum TextureLoadResult
|
||||
|
|
|
@ -168,7 +168,7 @@ void TileStorage::deleteSome(const size_t* indices, size_t n)
|
|||
|
||||
for(size_t i = 0; i < tmp.size(); ++i)
|
||||
{
|
||||
for(size_t k = 0; k < n; ++i) // not particularly efficient, could be much better by sorting first but eh
|
||||
for(size_t k = 0; k < n; ++k) // not particularly efficient, could be much better by sorting first but eh
|
||||
if(indices[k] == i)
|
||||
{
|
||||
dropAll(tmp[i]);
|
||||
|
@ -630,16 +630,7 @@ TexCoordBox TileRepeatData::calcTexCoords(const TileData& t) const
|
|||
tc.v1 = texOffY;
|
||||
tc.u2 = (et.w*t.scalex*texscaleX)/tw + texOffX;
|
||||
tc.v2 = (et.h*t.scaley*texscaleY)/th + texOffY;
|
||||
|
||||
// HACK: partially repeated textures have a weird Y axis. assuming a repeat factor of 0.4,
|
||||
// instead of texcoords from 0 -> 0.4 everything is biased towards the opposite end, ie. 0.6 -> 1.
|
||||
// This is especially true for partial repeats, we always need to bias towards the other end.
|
||||
// I have no idea why this has to be like this for tiles, but this is NOT the case for fonts.
|
||||
// And NOTE: without this, maps may look deceivingly correct, but they really are not.
|
||||
const float percentY = tc.v2 - tc.v1;
|
||||
const float remainder = 1.0f - fmodf(percentY, 1.0f);
|
||||
tc.v1 += remainder; // bias towards next int
|
||||
tc.v2 += remainder;
|
||||
//tc.fixflip();
|
||||
|
||||
return tc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue