summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoOGL
diff options
context:
space:
mode:
authorRodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com>2009-11-27 19:42:27 +0000
committerRodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com>2009-11-27 19:42:27 +0000
commit5e31f22e50a2dddc0b0a7e5b2fcb515c4e574e60 (patch)
treece9b12f4dc7dfd79170009e3548ed1a76ed7b289 /Source/Plugins/Plugin_VideoOGL
parentf69184b88722cd65364937611a481860f7f7f3c0 (diff)
small code reorganization.
Now efb to ram display correctly but still is misaligned by one pixel please test and give me feedback git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4618 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins/Plugin_VideoOGL')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/BPFunctions.cpp50
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp5
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/Render.cpp76
3 files changed, 85 insertions, 46 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPFunctions.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPFunctions.cpp
index ee663307e5..02cca6592e 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/BPFunctions.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/BPFunctions.cpp
@@ -34,14 +34,6 @@ namespace BPFunctions
// Reference: Yet Another Gamecube Documentation
// ----------------------------------------------
-static const GLenum glCmpFuncs[8] = {
- GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS
-};
-
-static const GLenum glLogicOpCodes[16] = {
- GL_CLEAR, GL_AND, GL_AND_REVERSE, GL_COPY, GL_AND_INVERTED, GL_NOOP, GL_XOR,
- GL_OR, GL_NOR, GL_EQUIV, GL_INVERT, GL_OR_REVERSE, GL_COPY_INVERTED, GL_OR_INVERTED, GL_NAND, GL_SET
-};
void FlushPipeline()
{
@@ -49,17 +41,9 @@ void FlushPipeline()
}
void SetGenerationMode(const BPCmd &bp)
{
- // none, ccw, cw, ccw
- if (bpmem.genMode.cullmode > 0)
- {
- glEnable(GL_CULL_FACE);
- glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
- }
- else
- glDisable(GL_CULL_FACE);
+ Renderer::SetGenerationMode();
}
-
void SetScissor(const BPCmd &bp)
{
if (!Renderer::SetScissorRect())
@@ -68,26 +52,11 @@ void SetScissor(const BPCmd &bp)
}
void SetLineWidth(const BPCmd &bp)
{
- float fratio = xfregs.rawViewport[0] != 0 ? ((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
- if (bpmem.lineptwidth.linesize > 0)
- glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f); // scale by ratio of widths
- if (bpmem.lineptwidth.pointsize > 0)
- glPointSize((float)bpmem.lineptwidth.pointsize * fratio / 6.0f);
+ Renderer::SetLineWidth();
}
void SetDepthMode(const BPCmd &bp)
{
- if (bpmem.zmode.testenable)
- {
- glEnable(GL_DEPTH_TEST);
- glDepthMask(bpmem.zmode.updateenable ? GL_TRUE : GL_FALSE);
- glDepthFunc(glCmpFuncs[bpmem.zmode.func]);
- }
- else
- {
- // if the test is disabled write is disabled too
- glDisable(GL_DEPTH_TEST);
- glDepthMask(GL_FALSE);
- }
+ Renderer::SetDepthMode();
}
void SetBlendMode(const BPCmd &bp)
{
@@ -95,20 +64,11 @@ void SetBlendMode(const BPCmd &bp)
}
void SetDitherMode(const BPCmd &bp)
{
- if (bpmem.blendmode.dither)
- glEnable(GL_DITHER);
- else
- glDisable(GL_DITHER);
+ Renderer::SetDitherMode();
}
void SetLogicOpMode(const BPCmd &bp)
{
- if (bpmem.blendmode.logicopenable)
- {
- glEnable(GL_COLOR_LOGIC_OP);
- glLogicOp(glLogicOpCodes[bpmem.blendmode.logicmode]);
- }
- else
- glDisable(GL_COLOR_LOGIC_OP);
+ Renderer::SetLogicOpMode();
}
void SetColorMask(const BPCmd &bp)
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
index 4bae505087..0539d148be 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp
@@ -118,9 +118,12 @@ void PixelShaderCache::Init()
"TEMP R1;\n"
"TEMP R2;\n"
"PARAM K0 = { 65535.0, 255.0,1.0,16777215.0};\n"
+ "PARAM K1 = { 0.999999940395355224609375, 1.0000000596046483281045155587504,0.0,0.0};\n"
"TEX R2, fragment.texcoord[0], texture[0], RECT;\n"
- "MUL R0, R2.x, K0;\n"
+ "MUL R0, R2.x, K1.x;\n"
+ "MUL R0, R0.x, K0;\n"
"FRC R0, R0;\n"
+ "MUL R0, R0, K1.y;\n"
"DP4 R1.x, R0, program.env[%d];\n"
"DP4 R1.y, R0, program.env[%d];\n"
"DP4 R1.z, R0, program.env[%d];\n"
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
index 6fd6aaa9d4..c573db1daf 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
@@ -154,6 +154,15 @@ static const GLenum glDestFactors[8] = {
GL_ONE_MINUS_DST_ALPHA
};
+static const GLenum glCmpFuncs[8] = {
+ GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL, GL_GREATER, GL_NOTEQUAL, GL_GEQUAL, GL_ALWAYS
+};
+
+static const GLenum glLogicOpCodes[16] = {
+ GL_CLEAR, GL_AND, GL_AND_REVERSE, GL_COPY, GL_AND_INVERTED, GL_NOOP, GL_XOR,
+ GL_OR, GL_NOR, GL_EQUIV, GL_INVERT, GL_OR_REVERSE, GL_COPY_INVERTED, GL_OR_INVERTED, GL_NAND, GL_SET
+};
+
void SetDefaultRectTexParams()
{
// Set some standard texture filter modes.
@@ -1374,3 +1383,70 @@ void UpdateViewport()
glViewport(GLx, GLy, GLWidth, GLHeight);
glDepthRange(GLNear, GLFar);
}
+
+void Renderer::SetGenerationMode()
+{
+ // none, ccw, cw, ccw
+ if (bpmem.genMode.cullmode > 0)
+ {
+ glEnable(GL_CULL_FACE);
+ glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
+ }
+ else
+ glDisable(GL_CULL_FACE);
+}
+
+void Renderer::SetDepthMode()
+{
+ if (bpmem.zmode.testenable)
+ {
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(bpmem.zmode.updateenable ? GL_TRUE : GL_FALSE);
+ glDepthFunc(glCmpFuncs[bpmem.zmode.func]);
+ }
+ else
+ {
+ // if the test is disabled write is disabled too
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(GL_FALSE);
+ }
+}
+
+void Renderer::SetLogicOpMode()
+{
+ if (bpmem.blendmode.logicopenable)
+ {
+ glEnable(GL_COLOR_LOGIC_OP);
+ glLogicOp(glLogicOpCodes[bpmem.blendmode.logicmode]);
+ }
+ else
+ glDisable(GL_COLOR_LOGIC_OP);
+}
+
+void Renderer::SetDitherMode()
+{
+ if (bpmem.blendmode.dither)
+ glEnable(GL_DITHER);
+ else
+ glDisable(GL_DITHER);
+}
+
+
+void Renderer::SetLineWidth()
+{
+ float fratio = xfregs.rawViewport[0] != 0 ? ((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
+ if (bpmem.lineptwidth.linesize > 0)
+ glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f); // scale by ratio of widths
+ if (bpmem.lineptwidth.pointsize > 0)
+ glPointSize((float)bpmem.lineptwidth.pointsize * fratio / 6.0f);
+}
+
+void Renderer::SetSamplerState(int stage,int texindex)
+{
+ // TODO
+}
+
+void Renderer::SetInterlacingMode()
+{
+ // TODO
+}