summaryrefslogtreecommitdiff
path: root/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2013-03-24 21:06:34 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2013-03-24 21:06:34 -0500
commit7034c79ab9cede868bf324091b7394b75d350976 (patch)
tree90b3b5176316262d5321c4bb6159a354635f6ac2 /Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
parentd11679a06e6a992216148fd2ce1730c9912c8564 (diff)
Big commit. Fix running the APK, I had missed a view in the manifest. Clean up the Android EGL context creation to fit more in line with how Dolphin works. This breaks input at the moment as well. Change the memarena from 768MB to 64MB to allow 1GB phones to potentially run it. Rename EGL_X11 back to EGL since this merge brings in some of soreau's changes to more easily allow different platforms like Wayland and Android. Not quite all of the code because some needs to be cleaned up still.
Diffstat (limited to 'Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp')
-rw-r--r--Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp118
1 files changed, 57 insertions, 61 deletions
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
index e81fb99206..e41d6402ff 100644
--- a/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
+++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWRenderer.cpp
@@ -77,10 +77,13 @@ void CreateShaders()
uni_tex = glGetUniformLocation(program, "Texture");
attr_pos = glGetAttribLocation(program, "pos");
attr_tex = glGetAttribLocation(program, "TexCoordIn");
+
+
}
-#include <EGL/egl.h>
-void PrepareShit()
+
+void SWRenderer::Prepare()
{
+ glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment
glGenTextures(1, &s_RenderTarget);
@@ -94,9 +97,6 @@ void PrepareShit()
#endif
GL_REPORT_ERRORD();
}
-void SWRenderer::Prepare()
-{
-}
void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
{
@@ -135,71 +135,66 @@ void SWRenderer::DrawDebugText()
p+=sprintf(p,"Rasterized Pix: %i\n",swstats.thisFrame.rasterizedPixels);
p+=sprintf(p,"TEV Pix In: %i\n",swstats.thisFrame.tevPixelsIn);
p+=sprintf(p,"TEV Pix Out: %i\n",swstats.thisFrame.tevPixelsOut);
- }
+}
// Render a shadow, and then the text.
SWRenderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
SWRenderer::RenderText(debugtext_buffer, 20, 20, 0xFFFFFF00);
}
-u8 image[1024*1024*4];
+#ifdef ANDROID
float ButtonCoords[8 * 2];
-int gW, gH;
-bool once = false;
-std::recursive_mutex section;
void SetButtonCoords(float *Coords)
{
- memcpy(ButtonCoords, Coords, sizeof(float) * 8 * 2);
+ memcpy(ButtonCoords, Coords, sizeof(float) * 8 * 2);
}
void DrawButton(int tex, int ID)
{
- //Texture rectangle uses pixel coordinates
+ //Texture rectangle uses pixel coordinates
#ifndef USE_GLES
- GLfloat u_max = (GLfloat)width;
- GLfloat v_max = (GLfloat)height;
-
- static const GLfloat texverts[4][2] = {
- {0, v_max},
- {0, 0},
- {u_max, 0},
- {u_max, v_max}
- };
+ GLfloat u_max = (GLfloat)width;
+ GLfloat v_max = (GLfloat)height;
+
+ static const GLfloat texverts[4][2] = {
+ {0, v_max},
+ {0, 0},
+ {u_max, 0},
+ {u_max, v_max}
+ };
#else
- static const GLfloat texverts[4][2] = {
- {0, 1},
- {0, 0},
- {1, 0},
- {1, 1}
- };
+ static const GLfloat texverts[4][2] = {
+ {0, 1},
+ {0, 0},
+ {1, 0},
+ {1, 1}
+ };
#endif
- glBindTexture(TEX2D, tex);
-
- glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, &ButtonCoords[ID * 8]);
- glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texverts);
- glEnableVertexAttribArray(attr_pos);
- glEnableVertexAttribArray(attr_tex);
- glActiveTexture(GL_TEXTURE0);
- glUniform1i(uni_tex, 0);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableVertexAttribArray(attr_pos);
- glDisableVertexAttribArray(attr_tex);
-
- glBindTexture(TEX2D, 0);
-
+ glBindTexture(TEX2D, tex);
+
+ glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, &ButtonCoords[ID * 8]);
+ glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, texverts);
+ glEnableVertexAttribArray(attr_pos);
+ glEnableVertexAttribArray(attr_tex);
+ glActiveTexture(GL_TEXTURE0);
+ glUniform1i(uni_tex, 0);
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ glDisableVertexAttribArray(attr_pos);
+ glDisableVertexAttribArray(attr_tex);
+
+ glBindTexture(TEX2D, 0);
}
-void DrawReal()
+#endif
+void SWRenderer::DrawTexture(u8 *texture, int width, int height)
{
- section.lock();
- if (!once)
- {
- section.unlock();
- return;
- }
- int width = gW;
- int height = gH;
+ GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();
+ GLsizei glHeight = (GLsizei)GLInterface->GetBackBufferHeight();
+
+ // Update GLViewPort
+ glViewport(0, 0, glWidth, glHeight);
+ glScissor(0, 0, glWidth, glHeight);
glBindTexture(GL_TEXTURE_2D, s_RenderTarget);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -228,19 +223,20 @@ void DrawReal()
glDisableVertexAttribArray(attr_tex);
glBindTexture(GL_TEXTURE_2D, 0);
- section.unlock();
GL_REPORT_ERRORD();
}
-void SWRenderer::DrawTexture(u8 *texture, int width, int height)
-{
- section.lock();
- memcpy(image, texture, width * height * 4);
- gW = width;
- gH = height;
- once = true;
- section.unlock();
-}
void SWRenderer::SwapBuffer()
{
+ DrawDebugText();
+
+ glFlush();
+
+ GLInterface->Swap();
+
+ swstats.ResetFrame();
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ GL_REPORT_ERRORD();
}