mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
Created a common pixel conversion function for both renderers.
This commit is contained in:
parent
bb3cc4d4a1
commit
0cce86beca
|
@ -163,7 +163,7 @@ void ComponentGrid::updateSeparators()
|
|||
{
|
||||
mLines.clear();
|
||||
|
||||
const unsigned int color = Renderer::convertColor(0xC6C7C6FF);
|
||||
const unsigned int color = Renderer::convertRGBAToABGR(0xC6C7C6FF);
|
||||
bool drawAll = Settings::getInstance()->getBool("DebugGrid");
|
||||
|
||||
Vector2f pos;
|
||||
|
|
|
@ -338,9 +338,9 @@ void ImageComponent::updateVertices()
|
|||
void ImageComponent::updateColors()
|
||||
{
|
||||
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0 : 1.0)) / 255.0;
|
||||
const unsigned int color = Renderer::convertColor((mColorShift & 0xFFFFFF00) |
|
||||
const unsigned int color = Renderer::convertRGBAToABGR((mColorShift & 0xFFFFFF00) |
|
||||
static_cast<unsigned char>((mColorShift & 0xFF) * opacity));
|
||||
const unsigned int colorEnd = Renderer::convertColor((mColorShiftEnd & 0xFFFFFF00) |
|
||||
const unsigned int colorEnd = Renderer::convertRGBAToABGR((mColorShiftEnd & 0xFFFFFF00) |
|
||||
static_cast<unsigned char>((mColorShiftEnd & 0xFF) * opacity));
|
||||
|
||||
mVertices[0].col = color;
|
||||
|
|
|
@ -36,8 +36,8 @@ NinePatchComponent::~NinePatchComponent()
|
|||
|
||||
void NinePatchComponent::updateColors()
|
||||
{
|
||||
const unsigned int edgeColor = Renderer::convertColor(mEdgeColor);
|
||||
const unsigned int centerColor = Renderer::convertColor(mCenterColor);
|
||||
const unsigned int edgeColor = Renderer::convertRGBAToABGR(mEdgeColor);
|
||||
const unsigned int centerColor = Renderer::convertRGBAToABGR(mCenterColor);
|
||||
|
||||
for (int i = 0; i < 6*9; ++i)
|
||||
mVertices[i].col = edgeColor;
|
||||
|
|
|
@ -120,7 +120,7 @@ void RatingComponent::updateVertices()
|
|||
const float h = getSize().y(); // Ss the same as a single star's width.
|
||||
const float w = getSize().y() * mValue * numStars;
|
||||
const float fw = getSize().y() * numStars;
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const unsigned int color = Renderer::convertRGBAToABGR(mColorShift);
|
||||
|
||||
mVertices[0] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, color };
|
||||
mVertices[1] = { { 0.0f, h }, { 0.0f, 0.0f }, color };
|
||||
|
@ -142,7 +142,7 @@ void RatingComponent::updateVertices()
|
|||
|
||||
void RatingComponent::updateColors()
|
||||
{
|
||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||
const unsigned int color = Renderer::convertRGBAToABGR(mColorShift);
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
mVertices[i].col = color;
|
||||
|
@ -165,7 +165,7 @@ void RatingComponent::render(const Transform4x4f& parentTrans)
|
|||
|
||||
if (mUnfilledTexture->bind()) {
|
||||
if (mUnfilledColor != mColorShift) {
|
||||
const unsigned int color = Renderer::convertColor(mUnfilledColor);
|
||||
const unsigned int color = Renderer::convertRGBAToABGR(mUnfilledColor);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
mVertices[i].col = color;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,8 @@ void VideoVlcComponent::render(const Transform4x4f& parentTrans)
|
|||
unsigned int color;
|
||||
if (mFadeIn < 1) {
|
||||
const unsigned int fadeIn = mFadeIn * 255.0f;
|
||||
color = Renderer::convertColor((fadeIn << 24) | (fadeIn << 16) | (fadeIn << 8) | 255);
|
||||
color = Renderer::convertRGBAToABGR((fadeIn << 24) |
|
||||
(fadeIn << 16) | (fadeIn << 8) | 255);
|
||||
}
|
||||
else {
|
||||
color = 0xFFFFFFFF;
|
||||
|
|
|
@ -350,8 +350,8 @@ namespace Renderer
|
|||
const Blend::Factor _srcBlendFactor,
|
||||
const Blend::Factor _dstBlendFactor)
|
||||
{
|
||||
const unsigned int color = convertColor(_color);
|
||||
const unsigned int colorEnd = convertColor(_colorEnd);
|
||||
const unsigned int color = convertRGBAToABGR(_color);
|
||||
const unsigned int colorEnd = convertRGBAToABGR(_colorEnd);
|
||||
Vertex vertices[4];
|
||||
|
||||
vertices[0] = { { _x ,_y }, { 0.0f, 0.0f }, color };
|
||||
|
@ -373,7 +373,7 @@ namespace Renderer
|
|||
drawTriangleStrips(vertices, 4, _trans, _srcBlendFactor, _dstBlendFactor);
|
||||
}
|
||||
|
||||
unsigned int rgbaToABGR(const unsigned int _color)
|
||||
unsigned int convertRGBAToABGR(const unsigned int _color)
|
||||
{
|
||||
unsigned char red = ((_color & 0xff000000) >> 24) & 255;
|
||||
unsigned char green = ((_color & 0x00ff0000) >> 16) & 255;
|
||||
|
@ -383,7 +383,7 @@ namespace Renderer
|
|||
return alpha << 24 | blue << 16 | green << 8 | red;
|
||||
}
|
||||
|
||||
unsigned int abgrToRGBA(const unsigned int _color)
|
||||
unsigned int convertABGRToRGBA(const unsigned int _color)
|
||||
{
|
||||
unsigned char alpha = ((_color & 0xff000000) >> 24) & 255;
|
||||
unsigned char blue = ((_color & 0x00ff0000) >> 16) & 255;
|
||||
|
|
|
@ -157,8 +157,8 @@ namespace Renderer
|
|||
int getScreenOffsetY();
|
||||
int getScreenRotate();
|
||||
|
||||
unsigned int rgbaToABGR(unsigned int color);
|
||||
unsigned int abgrToRGBA(unsigned int color);
|
||||
unsigned int convertRGBAToABGR(unsigned int color);
|
||||
unsigned int convertABGRToRGBA(unsigned int color);
|
||||
|
||||
Shader* getShaderProgram(unsigned int shaderID);
|
||||
const Transform4x4f getProjectionMatrix();
|
||||
|
@ -167,7 +167,6 @@ namespace Renderer
|
|||
unsigned char* textureRGBA = nullptr);
|
||||
|
||||
// API specific.
|
||||
unsigned int convertColor(const unsigned int _color);
|
||||
unsigned int getWindowFlags();
|
||||
void setupWindow();
|
||||
bool createContext();
|
||||
|
|
|
@ -44,17 +44,6 @@ namespace Renderer
|
|||
}
|
||||
}
|
||||
|
||||
unsigned int convertColor(const unsigned int _color)
|
||||
{
|
||||
// Convert from rgba to abgr.
|
||||
unsigned char r = ((_color & 0xff000000) >> 24) & 255;
|
||||
unsigned char g = ((_color & 0x00ff0000) >> 16) & 255;
|
||||
unsigned char b = ((_color & 0x0000ff00) >> 8) & 255;
|
||||
unsigned char a = ((_color & 0x000000ff) ) & 255;
|
||||
|
||||
return ((a << 24) | (b << 16) | (g << 8) | (r));
|
||||
}
|
||||
|
||||
unsigned int getWindowFlags()
|
||||
{
|
||||
return SDL_WINDOW_OPENGL;
|
||||
|
|
|
@ -47,17 +47,6 @@ namespace Renderer
|
|||
}
|
||||
}
|
||||
|
||||
unsigned int convertColor(const unsigned int _color)
|
||||
{
|
||||
// Convert from rgba to abgr.
|
||||
unsigned char r = ((_color & 0xff000000) >> 24) & 255;
|
||||
unsigned char g = ((_color & 0x00ff0000) >> 16) & 255;
|
||||
unsigned char b = ((_color & 0x0000ff00) >> 8) & 255;
|
||||
unsigned char a = ((_color & 0x000000ff) ) & 255;
|
||||
|
||||
return ((a << 24) | (b << 16) | (g << 8) | (r));
|
||||
}
|
||||
|
||||
unsigned int getWindowFlags()
|
||||
{
|
||||
return SDL_WINDOW_OPENGL;
|
||||
|
|
|
@ -585,7 +585,7 @@ TextCache* Font::buildTextCache(
|
|||
|
||||
const float glyphStartX = x + glyph->bearing.x();
|
||||
const Vector2i& textureSize = glyph->texture->textureSize;
|
||||
const unsigned int convertedColor = Renderer::convertColor(color);
|
||||
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
||||
|
||||
vertices[1] = {
|
||||
{ glyphStartX, y - glyph->bearing.y() },
|
||||
|
@ -648,7 +648,7 @@ TextCache* Font::buildTextCache(
|
|||
|
||||
void TextCache::setColor(unsigned int color)
|
||||
{
|
||||
const unsigned int convertedColor = Renderer::convertColor(color);
|
||||
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
||||
|
||||
for (auto it = vertexLists.begin(); it != vertexLists.end(); it++)
|
||||
for (auto it2 = it->verts.begin(); it2 != it->verts.end(); it2++)
|
||||
|
|
Loading…
Reference in a new issue