Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Text Won't Render After glBindVertexArray()  (Read 2290 times)

0 Members and 1 Guest are viewing this topic.

Spirrwell

  • Newbie
  • *
  • Posts: 11
    • View Profile
sf::Text Won't Render After glBindVertexArray()
« on: November 22, 2015, 10:26:08 pm »
Hi there!

This is a question that probably has a really simple answer, as to what I've been reading it has to do with SFML having it's own VBO, VAO, or whatever it is, and I need to use the corresponding glDelete function with it, but I've tried a few different ways with no success.

The way my code is now, the text renders for a second and then goes blank the second that glBindVertexArray(VertexArrayID); is called.

Here is the relevant code:

void AMEngine::Render()
{
        MainWindow->pushGLStates();
        MainWindow->draw(sText);
        MainWindow->popGLStates();

       
        Shader::setShader(&shader, &transform);
       
        GLuint VertexArrayID;
        glGenVertexArrays(1, &VertexArrayID);
        glBindVertexArray(VertexArrayID);
        static const GLfloat g_vertex_buffer_data[] = {
                  - 1.0f, -1.0f, 0.0f,
                    1.0f, -1.0f, 0.0f,
                    0.0f, 1.0f, 0.0f,
                };
       
        // This will identify our vertex buffer
        GLuint vertexbuffer;
        // Generate 1 buffer, put the resulting identifier in vertexbuffer
        glGenBuffers(1, &vertexbuffer);
        // The following commands will talk about our 'vertexbuffer' buffer
        glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
        // Give our vertices to OpenGL.
        glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
        glEnableVertexAttribArray(0);
        glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
        glVertexAttribPointer(
                0,
                3,
                GL_FLOAT,
                GL_FALSE,
                0,
                (void*)0
                );
       
        glDrawArrays(GL_TRIANGLES, 0, 3);
        glDisableVertexAttribArray(0);
        glDeleteVertexArrays(1, &VertexArrayID);
       
}

Again I'm probably missing something simple as understanding what's going on is very difficult for me, so I apologize if it's simple.

 

anything