mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-01 12:57:52 +00:00
OpenGL: Remove ugly and endian-unsafe color pointer casts
This commit is contained in:
parent
ec28f037e6
commit
466e608c19
4 changed files with 13 additions and 9 deletions
|
@ -135,6 +135,7 @@ struct Regs {
|
|||
};
|
||||
|
||||
union {
|
||||
u32 raw;
|
||||
BitField< 0, 8, u32> r;
|
||||
BitField< 8, 8, u32> g;
|
||||
BitField<16, 8, u32> b;
|
||||
|
@ -339,6 +340,7 @@ struct Regs {
|
|||
};
|
||||
|
||||
union {
|
||||
u32 const_color;
|
||||
BitField< 0, 8, u32> const_r;
|
||||
BitField< 8, 8, u32> const_g;
|
||||
BitField<16, 8, u32> const_b;
|
||||
|
@ -389,6 +391,7 @@ struct Regs {
|
|||
TevStageConfig tev_stage5;
|
||||
|
||||
union {
|
||||
u32 raw;
|
||||
BitField< 0, 8, u32> r;
|
||||
BitField< 8, 8, u32> g;
|
||||
BitField<16, 8, u32> b;
|
||||
|
@ -473,6 +476,7 @@ struct Regs {
|
|||
};
|
||||
|
||||
union {
|
||||
u32 raw;
|
||||
BitField< 0, 8, u32> r;
|
||||
BitField< 8, 8, u32> g;
|
||||
BitField<16, 8, u32> b;
|
||||
|
|
|
@ -658,7 +658,7 @@ void RasterizerOpenGL::SyncBlendFuncs() {
|
|||
}
|
||||
|
||||
void RasterizerOpenGL::SyncBlendColor() {
|
||||
auto blend_color = PicaToGL::ColorRGBA8((u8*)&Pica::g_state.regs.output_merger.blend_const.r);
|
||||
auto blend_color = PicaToGL::ColorRGBA8(Pica::g_state.regs.output_merger.blend_const.raw);
|
||||
state.blend.color.red = blend_color[0];
|
||||
state.blend.color.green = blend_color[1];
|
||||
state.blend.color.blue = blend_color[2];
|
||||
|
@ -728,7 +728,7 @@ void RasterizerOpenGL::SyncTevOps(unsigned stage_index, const Pica::Regs::TevSta
|
|||
}
|
||||
|
||||
void RasterizerOpenGL::SyncTevColor(unsigned stage_index, const Pica::Regs::TevStageConfig& config) {
|
||||
auto const_color = PicaToGL::ColorRGBA8((u8*)&config.const_r);
|
||||
auto const_color = PicaToGL::ColorRGBA8(config.const_color);
|
||||
glUniform4fv(uniform_tev_cfgs[stage_index].const_color, 1, const_color.data());
|
||||
}
|
||||
|
||||
|
@ -737,7 +737,7 @@ void RasterizerOpenGL::SyncTevMultipliers(unsigned stage_index, const Pica::Regs
|
|||
}
|
||||
|
||||
void RasterizerOpenGL::SyncCombinerColor() {
|
||||
auto combiner_color = PicaToGL::ColorRGBA8((u8*)&Pica::g_state.regs.tev_combiner_buffer_color.r);
|
||||
auto combiner_color = PicaToGL::ColorRGBA8(Pica::g_state.regs.tev_combiner_buffer_color.raw);
|
||||
glUniform4fv(uniform_tev_combiner_buffer_color, 1, combiner_color.data());
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ void RasterizerCacheOpenGL::LoadAndBindTexture(OpenGLState &state, unsigned text
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t);
|
||||
|
||||
if (wrap_s == GL_CLAMP_TO_BORDER || wrap_t == GL_CLAMP_TO_BORDER) {
|
||||
auto border_color = PicaToGL::ColorRGBA8((u8*)&config.config.border_color.r);
|
||||
auto border_color = PicaToGL::ColorRGBA8(config.config.border_color.raw);
|
||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border_color.data());
|
||||
}
|
||||
|
||||
|
|
|
@ -175,11 +175,11 @@ inline GLenum StencilOp(Pica::Regs::StencilAction action) {
|
|||
return stencil_op_table[(unsigned)action];
|
||||
}
|
||||
|
||||
inline std::array<GLfloat, 4> ColorRGBA8(const u8* bytes) {
|
||||
return { { bytes[0] / 255.0f,
|
||||
bytes[1] / 255.0f,
|
||||
bytes[2] / 255.0f,
|
||||
bytes[3] / 255.0f
|
||||
inline std::array<GLfloat, 4> ColorRGBA8(const u32 color) {
|
||||
return { { (color >> 0 & 0xFF) / 255.0f,
|
||||
(color >> 8 & 0xFF) / 255.0f,
|
||||
(color >> 16 & 0xFF) / 255.0f,
|
||||
(color >> 24 & 0xFF) / 255.0f
|
||||
} };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue