Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix switching from the different rasterizers
  • Loading branch information
Sonicadvance1 committed Jan 19, 2013
1 parent ff9ba67 commit 621204f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 41 deletions.
34 changes: 18 additions & 16 deletions Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
Expand Up @@ -75,22 +75,7 @@ void CreateShaders()
attr_pos = glGetAttribLocation(program, "pos");
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()
Expand Down Expand Up @@ -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_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_tex);
glUniform1i(uni_tex, 0);
glActiveTexture(GL_TEXTURE0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glDisableVertexAttribArray(attr_pos);
Expand Down
44 changes: 19 additions & 25 deletions Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp
Expand Up @@ -70,7 +70,7 @@ void VideoSoftware::ShowConfig(void *_hParent)

bool VideoSoftware::Initialize(void *&window_handle)
{
g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str());
g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str());
InitInterface();

if (!GLInterface->Create(window_handle))
Expand All @@ -79,18 +79,16 @@ bool VideoSoftware::Initialize(void *&window_handle)
return false;
}

InitBPMemory();
InitXFMemory();
SWCommandProcessor::Init();
SWPixelEngine::Init();
OpcodeDecoder::Init();
Clipper::Init();
Rasterizer::Init();
if (g_SWVideoConfig.bHwRasterizer)
HwRasterizer::Init();
else
SWRenderer::Init();
DebugUtil::Init();
InitBPMemory();
InitXFMemory();
SWCommandProcessor::Init();
SWPixelEngine::Init();
OpcodeDecoder::Init();
Clipper::Init();
Rasterizer::Init();
HwRasterizer::Init();
SWRenderer::Init();
DebugUtil::Init();

return true;
}
Expand Down Expand Up @@ -134,10 +132,8 @@ void VideoSoftware::EmuStateChange(EMUSTATE_CHANGE newState)

void VideoSoftware::Shutdown()
{
if (g_SWVideoConfig.bHwRasterizer)
HwRasterizer::Shutdown();
else
SWRenderer::Shutdown();
HwRasterizer::Shutdown();
SWRenderer::Shutdown();
GLInterface->Shutdown();
}

Expand All @@ -149,9 +145,9 @@ void VideoSoftware::Video_Prepare()
{
#ifndef USE_GLES
if (glewInit() != GLEW_OK) {
ERROR_LOG(VIDEO, "glewInit() failed!Does your video card support OpenGL 2.x?");
return;
}
ERROR_LOG(VIDEO, "glewInit() failed!Does your video card support OpenGL 2.x?");
return;
}

// Handle VSync on/off
#ifdef _WIN32
Expand All @@ -168,12 +164,10 @@ void VideoSoftware::Video_Prepare()
#endif
}

if (g_SWVideoConfig.bHwRasterizer)
HwRasterizer::Prepare();
else
SWRenderer::Prepare();
HwRasterizer::Prepare();
SWRenderer::Prepare();

INFO_LOG(VIDEO, "Video backend initialized.");
INFO_LOG(VIDEO, "Video backend initialized.");
}

// Run from the CPU thread (from VideoInterface.cpp)
Expand Down

0 comments on commit 621204f

Please sign in to comment.