OGL: Move attributeless VAO creation to Init.
This way we won't trash an existing bound VBO by mistake.
This commit is contained in:
parent
290fd545e6
commit
de2abbed17
|
@ -115,12 +115,14 @@ GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShade
|
||||||
return programID;
|
return programID;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateAttributelessVAO()
|
void OpenGL_CreateAttributelessVAO()
|
||||||
{
|
{
|
||||||
glGenVertexArrays(1, &attributelessVAO);
|
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.
|
// In a compatibility context, we require a valid, bound array buffer.
|
||||||
glGenBuffers(1, &attributelessVBO);
|
glGenBuffers(1, &attributelessVBO);
|
||||||
|
_dbg_assert_msg_(VIDEO, attributelessVBO != 0, "Attributeless VBO should have been created successfully.")
|
||||||
|
|
||||||
// Initialize the buffer with nothing.
|
// Initialize the buffer with nothing.
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, attributelessVBO);
|
glBindBuffer(GL_ARRAY_BUFFER, attributelessVBO);
|
||||||
|
@ -132,16 +134,14 @@ static void CreateAttributelessVAO()
|
||||||
|
|
||||||
void OpenGL_BindAttributelessVAO()
|
void OpenGL_BindAttributelessVAO()
|
||||||
{
|
{
|
||||||
if (attributelessVAO == 0)
|
_dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have already been created.")
|
||||||
CreateAttributelessVAO();
|
|
||||||
|
|
||||||
glBindVertexArray(attributelessVAO);
|
glBindVertexArray(attributelessVAO);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, attributelessVBO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGL_DeleteAttributelessVAO()
|
void OpenGL_DeleteAttributelessVAO()
|
||||||
{
|
{
|
||||||
if (attributelessVAO)
|
_dbg_assert_msg_(VIDEO, attributelessVAO != 0, "Attributeless VAO should have already been created.")
|
||||||
|
if (attributelessVAO != 0)
|
||||||
{
|
{
|
||||||
glDeleteVertexArrays(1, &attributelessVAO);
|
glDeleteVertexArrays(1, &attributelessVAO);
|
||||||
glDeleteBuffers(1, &attributelessVBO);
|
glDeleteBuffers(1, &attributelessVBO);
|
||||||
|
|
|
@ -18,11 +18,14 @@ void InitInterface();
|
||||||
// Helpers
|
// Helpers
|
||||||
GLuint OpenGL_CompileProgram(const char *vertexShader, const char *fragmentShader);
|
GLuint OpenGL_CompileProgram(const char *vertexShader, const char *fragmentShader);
|
||||||
|
|
||||||
// Binds (and creates, if necessary) a VAO and VBO suitable for attributeless rendering.
|
// Creates and deletes a VAO and VBO suitable for attributeless rendering.
|
||||||
void OpenGL_BindAttributelessVAO();
|
// Called by the Renderer.
|
||||||
// Deletes any existing VAO / VBO that has been created.
|
void OpenGL_CreateAttributelessVAO();
|
||||||
void OpenGL_DeleteAttributelessVAO();
|
void OpenGL_DeleteAttributelessVAO();
|
||||||
|
|
||||||
|
// Binds the VAO suitable for attributeless rendering.
|
||||||
|
void OpenGL_BindAttributelessVAO();
|
||||||
|
|
||||||
// this should be removed in future, but as long as glsl is unstable, we should really read this messages
|
// this should be removed in future, but as long as glsl is unstable, we should really read this messages
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
#define DEBUG_GLSL 1
|
#define DEBUG_GLSL 1
|
||||||
|
|
|
@ -714,6 +714,8 @@ void Renderer::Init()
|
||||||
" ocol0 = c;\n"
|
" ocol0 = c;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
|
|
||||||
|
OpenGL_CreateAttributelessVAO();
|
||||||
|
|
||||||
// creating buffers
|
// creating buffers
|
||||||
glGenBuffers(1, &s_ShowEFBCopyRegions_VBO);
|
glGenBuffers(1, &s_ShowEFBCopyRegions_VBO);
|
||||||
glGenVertexArrays(1, &s_ShowEFBCopyRegions_VAO);
|
glGenVertexArrays(1, &s_ShowEFBCopyRegions_VAO);
|
||||||
|
|
Loading…
Reference in New Issue