Code cleanup and added glPolygonOffset

This commit is contained in:
raven02 2014-05-22 00:20:13 +08:00
parent e569de73d6
commit b95667563f
3 changed files with 33 additions and 9 deletions

View file

@ -581,7 +581,7 @@ void GLGSRender::WriteColourBufferD()
checkForGlError("glReadPixels(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)"); checkForGlError("glReadPixels(GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)");
} }
void GLGSRender::WriteBuffers() void GLGSRender::WriteColorBuffers()
{ {
glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_ALIGNMENT, 4); glPixelStorei(GL_PACK_ALIGNMENT, 4);
@ -641,7 +641,6 @@ void GLGSRender::OnInitThread()
InitProcTable(); InitProcTable();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_SCISSOR_TEST);
#ifdef _WIN32 #ifdef _WIN32
glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0); glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0);
@ -773,8 +772,10 @@ void GLGSRender::ExecCMD()
} }
m_fbo.Bind(); m_fbo.Bind();
if(Ini.GSDumpDepthBuffer.GetValue()) if(Ini.GSDumpDepthBuffer.GetValue())
WriteDepthBuffer(); WriteDepthBuffer();
static const GLenum draw_buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; static const GLenum draw_buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
switch(m_surface_colour_target) switch(m_surface_colour_target)
@ -813,8 +814,6 @@ void GLGSRender::ExecCMD()
checkForGlError("glColorMask"); checkForGlError("glColorMask");
} }
//glFrontFace(m_front_face);
if(m_set_viewport_horizontal && m_set_viewport_vertical) if(m_set_viewport_horizontal && m_set_viewport_vertical)
{ {
//glViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h); //glViewport(m_viewport_x, m_viewport_y, m_viewport_w, m_viewport_h);
@ -859,6 +858,7 @@ void GLGSRender::ExecCMD()
Enable(m_set_blend, GL_BLEND); Enable(m_set_blend, GL_BLEND);
Enable(m_set_logic_op, GL_LOGIC_OP); Enable(m_set_logic_op, GL_LOGIC_OP);
Enable(m_set_cull_face_enable, GL_CULL_FACE); Enable(m_set_cull_face_enable, GL_CULL_FACE);
//Enable(m_set_front_face, GL_FRONT_FACE); // glEnable : OpenGL error 0x0500
Enable(m_set_dither, GL_DITHER); Enable(m_set_dither, GL_DITHER);
Enable(m_set_stencil_test, GL_STENCIL_TEST); Enable(m_set_stencil_test, GL_STENCIL_TEST);
Enable(m_set_scissor_horizontal && m_set_scissor_vertical, GL_SCISSOR_TEST); Enable(m_set_scissor_horizontal && m_set_scissor_vertical, GL_SCISSOR_TEST);
@ -896,6 +896,12 @@ void GLGSRender::ExecCMD()
checkForGlError("glPolygonMode(Back)"); checkForGlError("glPolygonMode(Back)");
} }
if (m_set_poly_offset_scale_factor && m_set_poly_offset_bias)
{
glPolygonOffset(m_set_poly_offset_scale_factor, m_set_poly_offset_bias);
checkForGlError("glPolygonOffset");
}
if (m_set_logic_op) if (m_set_logic_op)
{ {
glLogicOp(m_logic_op); glLogicOp(m_logic_op);
@ -907,6 +913,7 @@ void GLGSRender::ExecCMD()
glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h); glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h);
checkForGlError("glScissor"); checkForGlError("glScissor");
} }
if(m_set_two_sided_stencil_test_enable) if(m_set_two_sided_stencil_test_enable)
{ {
if(m_set_stencil_fail && m_set_stencil_zfail && m_set_stencil_zpass) if(m_set_stencil_fail && m_set_stencil_zfail && m_set_stencil_zpass)
@ -1029,6 +1036,12 @@ void GLGSRender::ExecCMD()
checkForGlError("glCullFace"); checkForGlError("glCullFace");
} }
if (m_set_front_face)
{
//glFrontFace(m_front_face); // glFrontFace : OpenGL error 0x0500
checkForGlError("glFrontFace");
}
if(m_set_alpha_func && m_set_alpha_ref) if(m_set_alpha_func && m_set_alpha_ref)
{ {
glAlphaFunc(m_alpha_func, m_alpha_ref/255.0f); glAlphaFunc(m_alpha_func, m_alpha_ref/255.0f);
@ -1118,7 +1131,7 @@ void GLGSRender::ExecCMD()
} }
if (Ini.GSDumpColorBuffers.GetValue()) if (Ini.GSDumpColorBuffers.GetValue())
WriteBuffers(); WriteColorBuffers();
} }
void GLGSRender::Flip() void GLGSRender::Flip()

View file

@ -827,11 +827,11 @@ private:
virtual void Close(); virtual void Close();
bool LoadProgram(); bool LoadProgram();
void WriteDepthBuffer(); void WriteDepthBuffer();
void WriteColorBuffers();
void WriteColourBufferA(); void WriteColourBufferA();
void WriteColourBufferB(); void WriteColourBufferB();
void WriteColourBufferC(); void WriteColourBufferC();
void WriteColourBufferD(); void WriteColourBufferD();
void WriteBuffers();
void DrawObjects(); void DrawObjects();

View file

@ -175,6 +175,11 @@ public:
bool m_set_poly_offset_line; bool m_set_poly_offset_line;
bool m_set_poly_offset_point; bool m_set_poly_offset_point;
bool m_set_poly_offset_scale_factor;
u32 m_poly_offset_scale_factor;
bool m_set_poly_offset_bias;
u32 m_poly_offset_bias;
bool m_set_restart_index; bool m_set_restart_index;
u32 m_restart_index; u32 m_restart_index;
@ -384,6 +389,7 @@ public:
u32 m_surface_colour_target; u32 m_surface_colour_target;
bool m_set_front_face;
u32 m_front_face; u32 m_front_face;
u8 m_begin_end; u8 m_begin_end;
@ -428,6 +434,9 @@ protected:
m_clear_z = 0xffffff; m_clear_z = 0xffffff;
m_clear_s = 0; m_clear_s = 0;
m_poly_offset_scale_factor = 0;
m_poly_offset_bias = 0;
m_depth_bounds_min = 0.0; m_depth_bounds_min = 0.0;
m_depth_bounds_max = 1.0; m_depth_bounds_max = 1.0;
m_restart_index = 0xffffffff; m_restart_index = 0xffffffff;
@ -500,6 +509,8 @@ protected:
m_set_poly_offset_fill = false; m_set_poly_offset_fill = false;
m_set_poly_offset_line = false; m_set_poly_offset_line = false;
m_set_poly_offset_point = false; m_set_poly_offset_point = false;
m_set_poly_offset_scale_factor = false;
m_set_poly_offset_bias = false;
m_set_restart_index = false; m_set_restart_index = false;
m_clear_surface_mask = 0; m_clear_surface_mask = 0;