GPU: Fix texture coordinates when rendering paletted textures
This commit is contained in:
parent
e40393fec4
commit
19d9322e67
|
@ -289,7 +289,7 @@ void SDLInterface::RenderDisplay()
|
|||
if (!m_display_texture)
|
||||
return;
|
||||
|
||||
glViewport(0, 0, m_window_width, m_window_height);
|
||||
glViewport(0, 0, m_window_width, m_window_height - 20);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
|
|
@ -409,6 +409,8 @@ bool GPU::HandleRenderCommand()
|
|||
ZeroExtend32(words_per_vertex));
|
||||
|
||||
DispatchRenderCommand(rc, num_vertices);
|
||||
FlushRender();
|
||||
UpdateDisplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ protected:
|
|||
u32 bits;
|
||||
|
||||
BitField<u32, u32, 0, 23> color_for_first_vertex;
|
||||
BitField<u32, bool, 24, 1> texture_blending_raw; // not valid for lines
|
||||
BitField<u32, bool, 24, 1> texture_blend_disable; // not valid for lines
|
||||
BitField<u32, bool, 25, 1> transparency_enable;
|
||||
BitField<u32, bool, 26, 1> texture_enable;
|
||||
BitField<u32, DrawRectangleSize, 27, 2> rectangle_size; // only for rectangles
|
||||
|
@ -91,6 +91,10 @@ protected:
|
|||
BitField<u32, bool, 27, 1> polyline; // only for lines
|
||||
BitField<u32, bool, 28, 1> shading_enable; // 0 - flat, 1 = gouroud
|
||||
BitField<u32, Primitive, 29, 21> primitive;
|
||||
|
||||
// Helper functions.
|
||||
bool IsTextureEnabled() const { return (primitive != Primitive::Line && texture_enable); }
|
||||
bool IsTextureBlendingEnabled() const { return (IsTextureEnabled() && !texture_blend_disable); }
|
||||
};
|
||||
|
||||
// TODO: Use BitField to do sign extending instead
|
||||
|
|
|
@ -166,6 +166,7 @@ in vec2 a_tex0;
|
|||
|
||||
out vec4 v_col0;
|
||||
#if TEXTURED
|
||||
uniform vec2 u_tex_scale;
|
||||
out vec2 v_tex0;
|
||||
#endif
|
||||
|
||||
|
@ -178,7 +179,7 @@ void main()
|
|||
|
||||
v_col0 = a_col0;
|
||||
#if TEXTURED
|
||||
v_tex0 = vec2(a_tex0.x / 4, a_tex0.y);
|
||||
v_tex0 = vec2(a_tex0 * u_tex_scale);
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
|
|
@ -148,12 +148,12 @@ bool GPU_HW_OpenGL::CompileProgram(GL::Program& prog, bool textured, bool blendi
|
|||
if (!prog.Link())
|
||||
return false;
|
||||
|
||||
prog.Bind();
|
||||
|
||||
if (textured)
|
||||
{
|
||||
prog.Bind();
|
||||
prog.RegisterUniform("u_tex_scale");
|
||||
prog.RegisterUniform("samp0");
|
||||
prog.Uniform1i(0, 0);
|
||||
prog.Uniform1i(1, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -163,6 +163,29 @@ void GPU_HW_OpenGL::SetProgram(bool textured, bool blending)
|
|||
{
|
||||
const GL::Program& prog = textured ? (blending ? m_blended_texture_program : m_texture_program) : m_color_program;
|
||||
prog.Bind();
|
||||
|
||||
if (textured)
|
||||
{
|
||||
switch (m_texture_config.color_mode)
|
||||
{
|
||||
case GPU::TextureColorMode::Palette4Bit:
|
||||
prog.Uniform2f(0, 1.0f / 4, 1.0f);
|
||||
break;
|
||||
|
||||
case GPU::TextureColorMode::Palette8Bit:
|
||||
prog.Uniform2f(0, 1.0f / 2, 1.0f);
|
||||
break;
|
||||
|
||||
case GPU::TextureColorMode::Direct16Bit:
|
||||
prog.Uniform2f(0, 1.0f, 1.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_texture_page_texture->Bind();
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_HW_OpenGL::SetViewport()
|
||||
|
@ -337,13 +360,10 @@ void GPU_HW_OpenGL::FlushRender()
|
|||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
SetProgram(m_batch_command.texture_enable, m_batch_command.texture_blending_raw);
|
||||
SetProgram(m_batch_command.IsTextureEnabled(), m_batch_command.IsTextureBlendingEnabled());
|
||||
SetViewport();
|
||||
SetScissor();
|
||||
|
||||
if (m_batch_command.texture_enable)
|
||||
m_texture_page_texture->Bind();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer_fbo_id);
|
||||
glBindVertexArray(m_vao_id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue