mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Eliminate drawRect that takes int's and make sure everything uses the float version properly, this way everything is rounded the same way
Only round the transforms when setting them on the GPU, to make sure everything is rounded the same, but only at the final moment
This commit is contained in:
parent
5edecef9c8
commit
489d7de096
|
@ -209,7 +209,7 @@ void SystemScreenSaver::renderScreenSaver()
|
|||
{
|
||||
// Render black background
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
||||
// Only render the video if the state requires it
|
||||
if ((int)mState >= STATE_FADE_IN_VIDEO)
|
||||
|
@ -222,7 +222,7 @@ void SystemScreenSaver::renderScreenSaver()
|
|||
{
|
||||
// Render black background
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
||||
// Only render the video if the state requires it
|
||||
if ((int)mState >= STATE_FADE_IN_VIDEO)
|
||||
|
@ -249,7 +249,7 @@ void SystemScreenSaver::renderScreenSaver()
|
|||
{
|
||||
Renderer::setMatrix(Transform4x4f::Identity());
|
||||
unsigned char color = screensaver_behavior == "dim" ? 0x000000A0 : 0x000000FF;
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), color, color);
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), color, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ void AsyncReqComponent::render(const Transform4x4f& /*parentTrans*/)
|
|||
Renderer::setMatrix(trans);
|
||||
|
||||
Vector3f point(Math::cosf(mTime * 0.01f) * 12, Math::sinf(mTime * 0.01f) * 12, 0);
|
||||
Renderer::drawRect((int)point.x(), (int)point.y(), 8, 8, 0x0000FFFF, 0x0000FFFF);
|
||||
Renderer::drawRect(point.x(), point.y(), 8.0f, 8.0f, 0x0000FFFF, 0x0000FFFF);
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> AsyncReqComponent::getHelpPrompts()
|
||||
|
|
|
@ -106,7 +106,6 @@ void RatingComponent::render(const Transform4x4f& parentTrans)
|
|||
return;
|
||||
|
||||
Transform4x4f trans = parentTrans * getTransform();
|
||||
trans.round();
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
mFilledTexture->bind();
|
||||
|
|
|
@ -359,9 +359,7 @@ void ScraperSearchComponent::render(const Transform4x4f& parentTrans)
|
|||
if(mBlockAccept)
|
||||
{
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), 0x00000011, 0x00000011);
|
||||
//Renderer::drawRect((int)mResultList->getPosition().x(), (int)mResultList->getPosition().y(),
|
||||
// (int)mResultList->getSize().x(), (int)mResultList->getSize().y(), 0x0000011, 0x00000011);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0x00000011, 0x00000011);
|
||||
|
||||
mBusyAnim.render(trans);
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ void TextListComponent<T>::render(const Transform4x4f& parentTrans)
|
|||
mSelectorImage.render(trans);
|
||||
} else {
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, (mCursor - startEntry)*entrySize + mSelectorOffsetY, mSize.x(),
|
||||
Renderer::drawRect(0.0f, (mCursor - startEntry)*entrySize + mSelectorOffsetY, mSize.x(),
|
||||
mSelectorHeight, mSelectorColor, mSelectorColorEnd, mSelectorColorGradientHorizontal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
|
|||
Renderer::pushClipRect(Vector2i((int)clipPos.x(), (int)clipPos.y()), Vector2i((int)mCarousel.size.x(), (int)mCarousel.size.y()));
|
||||
|
||||
Renderer::setMatrix(carouselTrans);
|
||||
Renderer::drawRect(0.0, 0.0, mCarousel.size.x(), mCarousel.size.y(), mCarousel.color, mCarousel.colorEnd, mCarousel.colorGradientHorizontal);
|
||||
Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x(), mCarousel.size.y(), mCarousel.color, mCarousel.colorEnd, mCarousel.colorGradientHorizontal);
|
||||
|
||||
// draw logos
|
||||
Vector2f logoSpacing(0.0, 0.0); // NB: logoSpacing will include the size of the logo itself as well!
|
||||
|
|
|
@ -424,7 +424,7 @@ void ViewController::render(const Transform4x4f& parentTrans)
|
|||
{
|
||||
unsigned int fadeColor = 0x00000000 | (unsigned char)(mFadeOpacity * 255);
|
||||
Renderer::setMatrix(parentTrans);
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), fadeColor, fadeColor);
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), fadeColor, fadeColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ void Window::renderLoadingScreen(std::string text)
|
|||
{
|
||||
Transform4x4f trans = Transform4x4f::Identity();
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
Renderer::drawRect(0.0f, 0.0f, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
|
||||
|
||||
ImageComponent splash(this, true);
|
||||
splash.setResize(Renderer::getScreenWidth() * 0.6f, 0.0f);
|
||||
|
|
|
@ -86,14 +86,12 @@ void ButtonComponent::updateImage()
|
|||
void ButtonComponent::render(const Transform4x4f& parentTrans)
|
||||
{
|
||||
Transform4x4f trans = parentTrans * getTransform();
|
||||
trans.round();
|
||||
|
||||
mBox.render(trans);
|
||||
|
||||
if(mTextCache)
|
||||
{
|
||||
Vector3f centerOffset((mSize.x() - mTextCache->metrics.size.x()) / 2, (mSize.y() - mTextCache->metrics.size.y()) / 2, 0);
|
||||
centerOffset.round();
|
||||
trans = trans.translate(centerOffset);
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
|
|
|
@ -161,7 +161,6 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
|||
return;
|
||||
|
||||
Transform4x4f trans = parentTrans * getTransform();
|
||||
trans.round();
|
||||
|
||||
// clip everything to be inside our bounds
|
||||
Vector3f dim(mSize.x(), mSize.y(), 0);
|
||||
|
|
|
@ -146,7 +146,6 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
|||
// vertically center
|
||||
Vector3f off(0, (mSize.y() - mTextCache->metrics.size.y()) / 2, 0);
|
||||
trans.translate(off);
|
||||
trans.round();
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
|
@ -159,8 +158,8 @@ void DateTimeEditComponent::render(const Transform4x4f& parentTrans)
|
|||
{
|
||||
if(mEditIndex >= 0 && (unsigned int)mEditIndex < mCursorBoxes.size())
|
||||
{
|
||||
Renderer::drawRect((int)mCursorBoxes[mEditIndex][0], (int)mCursorBoxes[mEditIndex][1],
|
||||
(int)mCursorBoxes[mEditIndex][2], (int)mCursorBoxes[mEditIndex][3], 0x00000022, 0x00000022);
|
||||
Renderer::drawRect(mCursorBoxes[mEditIndex][0], mCursorBoxes[mEditIndex][1],
|
||||
mCursorBoxes[mEditIndex][2], mCursorBoxes[mEditIndex][3], 0x00000022, 0x00000022);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ void NinePatchComponent::render(const Transform4x4f& parentTrans)
|
|||
return;
|
||||
|
||||
Transform4x4f trans = parentTrans * getTransform();
|
||||
trans.round();
|
||||
|
||||
if(mTexture && mVertices != NULL)
|
||||
{
|
||||
|
|
|
@ -61,7 +61,6 @@ void SliderComponent::update(int deltaTime)
|
|||
void SliderComponent::render(const Transform4x4f& parentTrans)
|
||||
{
|
||||
Transform4x4f trans = parentTrans * getTransform();
|
||||
trans.round();
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
// render suffix
|
||||
|
|
|
@ -102,7 +102,7 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
|||
if (mRenderBackground)
|
||||
{
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), mBgColor, mBgColor);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), mBgColor, mBgColor);
|
||||
}
|
||||
|
||||
if(mTextCache)
|
||||
|
@ -127,11 +127,10 @@ void TextComponent::render(const Transform4x4f& parentTrans)
|
|||
{
|
||||
// draw the "textbox" area, what we are aligned within
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.f, 0.f, mSize.x(), mSize.y(), 0xFF000033, 0xFF000033);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), 0xFF000033, 0xFF000033);
|
||||
}
|
||||
|
||||
trans.translate(off);
|
||||
trans.round();
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
// draw the text area, where the text actually is going
|
||||
|
|
|
@ -254,8 +254,6 @@ void TextEditComponent::render(const Transform4x4f& parentTrans)
|
|||
Renderer::pushClipRect(clipPos, clipDim);
|
||||
|
||||
trans.translate(Vector3f(-mScrollOffset.x(), -mScrollOffset.y(), 0));
|
||||
trans.round();
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
if(mTextCache)
|
||||
|
|
|
@ -238,20 +238,18 @@ namespace Renderer
|
|||
|
||||
void drawRect(const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor)
|
||||
{
|
||||
drawRect((int)Math::round(_x), (int)Math::round(_y), (int)Math::round(_w), (int)Math::round(_h), _color, _colorEnd, horizontalGradient, _srcBlendFactor, _dstBlendFactor);
|
||||
|
||||
} // drawRect
|
||||
|
||||
void drawRect(const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient, const Blend::Factor _srcBlendFactor, const Blend::Factor _dstBlendFactor)
|
||||
{
|
||||
const float x = Math::round(_x);
|
||||
const float y = Math::round(_y);
|
||||
const float w = Math::round(_w);
|
||||
const float h = Math::round(_h);
|
||||
const unsigned int color = convertColor(_color);
|
||||
const unsigned int colorEnd = convertColor(_colorEnd);
|
||||
Vertex vertices[4];
|
||||
|
||||
vertices[0] = { { (float)(_x ), (float)(_y ) }, { 0.0f, 0.0f }, color };
|
||||
vertices[1] = { { (float)(_x ), (float)(_y + _h) }, { 0.0f, 0.0f }, horizontalGradient ? colorEnd : color };
|
||||
vertices[2] = { { (float)(_x + _w), (float)(_y ) }, { 0.0f, 0.0f }, horizontalGradient ? color : colorEnd };
|
||||
vertices[3] = { { (float)(_x + _w), (float)(_y + _h) }, { 0.0f, 0.0f }, colorEnd };
|
||||
vertices[0] = { { _x ,_y }, { 0.0f, 0.0f }, color };
|
||||
vertices[1] = { { _x ,_y + _h }, { 0.0f, 0.0f }, horizontalGradient ? colorEnd : color };
|
||||
vertices[2] = { { _x + _w,_y }, { 0.0f, 0.0f }, horizontalGradient ? color : colorEnd };
|
||||
vertices[3] = { { _x + _w,_y + _h }, { 0.0f, 0.0f }, colorEnd };
|
||||
|
||||
bindTexture(0);
|
||||
drawTriangleStrips(vertices, 4, _srcBlendFactor, _dstBlendFactor);
|
||||
|
|
|
@ -67,7 +67,6 @@ namespace Renderer
|
|||
void pushClipRect (const Vector2i& _pos, const Vector2i& _size);
|
||||
void popClipRect ();
|
||||
void drawRect (const float _x, const float _y, const float _w, const float _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient = false, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||
void drawRect (const int _x, const int _y, const int _w, const int _h, const unsigned int _color, const unsigned int _colorEnd, bool horizontalGradient = false, const Blend::Factor _srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor _dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
SDL_Window* getSDLWindow ();
|
||||
int getWindowWidth ();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#if defined(USE_OPENGL_21)
|
||||
|
||||
#include "renderers/Renderer.h"
|
||||
#include "math/Transform4x4f.h"
|
||||
#include "Log.h"
|
||||
#include "Settings.h"
|
||||
|
||||
|
@ -193,8 +194,10 @@ namespace Renderer
|
|||
|
||||
void setMatrix(const Transform4x4f& _matrix)
|
||||
{
|
||||
Transform4x4f matrix = _matrix;
|
||||
matrix.round();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf((GLfloat*)&_matrix);
|
||||
glLoadMatrixf((GLfloat*)&matrix);
|
||||
|
||||
} // setMatrix
|
||||
|
||||
|
|
|
@ -193,8 +193,10 @@ namespace Renderer
|
|||
|
||||
void setMatrix(const Transform4x4f& _matrix)
|
||||
{
|
||||
Transform4x4f matrix = _matrix;
|
||||
matrix.round();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadMatrixf((GLfloat*)&_matrix);
|
||||
glLoadMatrixf((GLfloat*)&matrix);
|
||||
|
||||
} // setMatrix
|
||||
|
||||
|
|
Loading…
Reference in a new issue