Fix switching from the different rasterizers

This commit is contained in:
Ryan Houdek 2013-01-19 02:18:39 -06:00
parent ff9ba67773
commit 621204f3e8
2 changed files with 37 additions and 41 deletions

View File

@ -75,22 +75,7 @@ void CreateShaders()
attr_pos = glGetAttribLocation(program, "pos"); attr_pos = glGetAttribLocation(program, "pos");
attr_tex = glGetAttribLocation(program, "TexCoordIn"); attr_tex = glGetAttribLocation(program, "TexCoordIn");
static const GLfloat verts[4][2] = {
{ -1, -1}, // Left top
{ -1, 1}, // left bottom
{ 1, 1}, // right bottom
{ 1, -1} // right top
};
static const GLfloat texverts[4][2] = {
{0, 1},
{0, 0},
{1, 0},
{1, 1}
};
glUniform1i(uni_tex, 0);
glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texverts);
} }
void SWRenderer::Prepare() void SWRenderer::Prepare()
@ -165,8 +150,25 @@ void SWRenderer::DrawTexture(u8 *texture, int width, int height)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glUseProgram(program);
static const GLfloat verts[4][2] = {
{ -1, -1}, // Left top
{ -1, 1}, // left bottom
{ 1, 1}, // right bottom
{ 1, -1} // right top
};
static const GLfloat texverts[4][2] = {
{0, 1},
{0, 0},
{1, 0},
{1, 1}
};
glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texverts);
glEnableVertexAttribArray(attr_pos); glEnableVertexAttribArray(attr_pos);
glEnableVertexAttribArray(attr_tex); glEnableVertexAttribArray(attr_tex);
glUniform1i(uni_tex, 0);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(attr_pos); glDisableVertexAttribArray(attr_pos);

View File

@ -86,9 +86,7 @@ bool VideoSoftware::Initialize(void *&window_handle)
OpcodeDecoder::Init(); OpcodeDecoder::Init();
Clipper::Init(); Clipper::Init();
Rasterizer::Init(); Rasterizer::Init();
if (g_SWVideoConfig.bHwRasterizer)
HwRasterizer::Init(); HwRasterizer::Init();
else
SWRenderer::Init(); SWRenderer::Init();
DebugUtil::Init(); DebugUtil::Init();
@ -134,9 +132,7 @@ void VideoSoftware::EmuStateChange(EMUSTATE_CHANGE newState)
void VideoSoftware::Shutdown() void VideoSoftware::Shutdown()
{ {
if (g_SWVideoConfig.bHwRasterizer)
HwRasterizer::Shutdown(); HwRasterizer::Shutdown();
else
SWRenderer::Shutdown(); SWRenderer::Shutdown();
GLInterface->Shutdown(); GLInterface->Shutdown();
} }
@ -168,9 +164,7 @@ void VideoSoftware::Video_Prepare()
#endif #endif
} }
if (g_SWVideoConfig.bHwRasterizer)
HwRasterizer::Prepare(); HwRasterizer::Prepare();
else
SWRenderer::Prepare(); SWRenderer::Prepare();
INFO_LOG(VIDEO, "Video backend initialized."); INFO_LOG(VIDEO, "Video backend initialized.");