summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2012-12-08 00:54:38 +0100
committerRyan Houdek <Sonicadvance1@gmail.com>2012-12-13 15:27:56 -0600
commitd44228f1b7ec13db032ff558a6e3bc87e5789216 (patch)
treeddd6eded9722554bd2e9b8c1485aaa8b6d8ae3b8 /Source
parent6b3125728be4041e44cc2805e561737ac0d28375 (diff)
TextureCache::TCacheEntry::FromRenderTarget as vbo
Signed-off-by: Ryan Houdek <Sonicadvance1@gmail.com>
Diffstat (limited to 'Source')
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp47
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h1
2 files changed, 31 insertions, 17 deletions
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
index 5441a65901..30b67119df 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp
@@ -57,6 +57,7 @@ namespace OGL
{
static u32 s_TempFramebuffer = 0;
+static GLuint s_VBO = 0;
static const GLint c_MinLinearFilter[8] = {
GL_NEAREST,
@@ -306,19 +307,20 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect);
GL_REPORT_ERRORD();
- GLfloat tex1[] = {
- (GLfloat)targetSource.left, (GLfloat)targetSource.bottom,
- (GLfloat)targetSource.left, (GLfloat)targetSource.top,
- (GLfloat)targetSource.right, (GLfloat)targetSource.top,
- (GLfloat)targetSource.right, (GLfloat)targetSource.bottom
- };
- GLfloat vtx1[] = {
- -1.f, 1.f,
- -1.f, -1.f,
- 1.f, -1.f,
- 1.f, 1.f
+ GLfloat vertices[] = {
+ -1.f, 1.f,
+ (GLfloat)targetSource.left, (GLfloat)targetSource.bottom,
+ -1.f, -1.f,
+ (GLfloat)targetSource.left, (GLfloat)targetSource.top,
+ 1.f, -1.f,
+ (GLfloat)targetSource.right, (GLfloat)targetSource.top,
+ 1.f, 1.f,
+ (GLfloat)targetSource.right, (GLfloat)targetSource.bottom
};
+ glBindBuffer(GL_ARRAY_BUFFER, s_VBO);
+ glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
+
// disable all pointer, TODO: use VAO
glEnableClientState(GL_VERTEX_ARRAY);
glDisableVertexAttribArray(SHADER_POSMTX_ATTRIB);
@@ -335,9 +337,12 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo
}
glClientActiveTexture(GL_TEXTURE0);
- glTexCoordPointer(2, GL_FLOAT, 0, tex1);
- glVertexPointer(2, GL_FLOAT, 0, vtx1);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL + 2);
+ glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, 0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+ // TODO: this should be removed if we use vbo everywhere
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
GL_REPORT_ERRORD();
@@ -415,13 +420,21 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co
(float)(1 << g_ActiveConfig.iMaxAnisotropy));
}
+TextureCache::TextureCache()
+{
+ glGenBuffers(1, &s_VBO);
+}
+
+
TextureCache::~TextureCache()
{
- if (s_TempFramebuffer)
+ glDeleteBuffers(1, &s_VBO);
+
+ if (s_TempFramebuffer)
{
- glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer);
- s_TempFramebuffer = 0;
- }
+ glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer);
+ s_TempFramebuffer = 0;
+ }
}
void TextureCache::DisableStage(unsigned int stage)
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h
index 30f44b797d..91245237d9 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h
@@ -32,6 +32,7 @@ namespace OGL
class TextureCache : public ::TextureCache
{
public:
+ TextureCache();
static void DisableStage(unsigned int stage);
private: