summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/GLUtil.cpp
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2014-12-14 14:42:07 +1100
committerskidau <skidau@gmail.com>2014-12-14 14:42:07 +1100
commit15f7e63cc20690f3a65100a7053821e1d935f1ac (patch)
tree6c541ca187265e51566133aefadc426a3c364c46 /Source/Core/VideoBackends/OGL/GLUtil.cpp
parent45dedfcb8ea71e85b4cea43256532265362e8adb (diff)
parent029f8c3c3f065de723a1a334f70d2882208b7cdf (diff)
Merge pull request #1650 from unknownbrackets/attributeless-fix
OGL: Unbind the active VAO before attributeless rendering
Diffstat (limited to 'Source/Core/VideoBackends/OGL/GLUtil.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/GLUtil.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/OGL/GLUtil.cpp b/Source/Core/VideoBackends/OGL/GLUtil.cpp
index bfd6170839..dddc299fb9 100644
--- a/Source/Core/VideoBackends/OGL/GLUtil.cpp
+++ b/Source/Core/VideoBackends/OGL/GLUtil.cpp
@@ -16,6 +16,8 @@
#include "VideoCommon/VideoConfig.h"
cInterfaceBase *GLInterface;
+static GLuint attributelessVAO = 0;
+static GLuint attributelessVBO = 0;
namespace OGL
{
@@ -113,3 +115,38 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
return programID;
}
+void OpenGL_CreateAttributelessVAO()
+{
+ glGenVertexArrays(1, &attributelessVAO);
+ _dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have been created successfully.")
+
+ // In a compatibility context, we require a valid, bound array buffer.
+ glGenBuffers(1, &attributelessVBO);
+ _dbg_assert_msg_(VIDEO, attributelessVBO != 0, "Attributeless VBO should have been created successfully.")
+
+ // Initialize the buffer with nothing.
+ glBindBuffer(GL_ARRAY_BUFFER, attributelessVBO);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat), nullptr, GL_STATIC_DRAW);
+
+ // We must also define vertex attribute 0.
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
+}
+
+void OpenGL_BindAttributelessVAO()
+{
+ _dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have already been created.")
+ glBindVertexArray(attributelessVAO);
+}
+
+void OpenGL_DeleteAttributelessVAO()
+{
+ _dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have already been created.")
+ if (attributelessVAO != 0)
+ {
+ glDeleteVertexArrays(1, &attributelessVAO);
+ glDeleteBuffers(1, &attributelessVBO);
+
+ attributelessVAO = 0;
+ attributelessVBO = 0;
+ }
+}