GL Error value 1285: Out of memory

I am trying to make a simple quad row in several ways.

I can do this very easily when everything is stored in one class. But I want to be able to display more than one object on the screen, so I start to separate the code and add different pieces of functionality to separate classes. The problem is, when I put the render functions in the Entity class, I start to get the error.

This is the function that is the VertexArrayObject class:

public void render(){
    glBindVertexArray(vaoID);
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboiID);

    this.exitOnGLError("Before render");
    glDrawElements(GL_TRIANGLES, indicesCount, GL_UNSIGNED_BYTE, 0);
    this.exitOnGLError("After render");

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glBindVertexArray(0);

    this.exitOnGLError("error rendering vao");
}

      

Again, all I did was move this from the main class to a class that manages the VAO and in theory displays it.

This gives me an error value of 1285, and the error causing the error is the "After Rendering" sign. (exitOnGLError () - error checking method).

Error 1285 apparently means "Out of Memory" which is clearly absurd since I'm using a 1MB image file and ... I just can't imagine my four vertex buffers filling all of my VRAMs.

What else could be causing this error?

+3


source to share


3 answers


FYI I had the same error and it was caused by the fact that I was unable to add a glBufferData call where you are actually "sending data" to opengl.

glBufferData (GL_ARRAY_BUFFER, sizeof (GLSL_XYZNDUV_Item) * p-> iNum_verts, p-> pVerts, GL_STATIC_DRAW);



glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (GLushort) * p-> iNum_tris * 2, p-> pIndices, GL_STATIC_DRAW);

+2


source


Share a possible answer for those coming here from Google.

glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData ( GL_ARRAY_BUFFER , sizeof (indices), & indices [0], GL_STATIC_DRAW);


Please note that the copypaste error is in bold. This caused error 1285 and quite a few head scratches for quite some time now.

+2


source


You must first make sure that you are doing all the OpenGL classes in the correct order, eg. you should only bind VBOs when creating a VAO, not when rendering it.

Here's how I order the calls in my VAO class:

    // creation
    array = glGenVertexArrays();
    glBindVertexArray(array);

    vertices = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vertices);
    glBufferData(GL_ARRAY_BUFFER, b, usage);

    for (attributes) {
        glEnableVertexAttribArray(index);
        glVertexAttribPointer(index, dimension, type, false, bytesPerVertex, offset);
    }

    if (indices are used) {
      indices = glGenBuffers();
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices);
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, buffer, usage);
    }

    // render
    glBindVertexArray(array);
    program.use(); // binds shader program and textures
    if (indices == -1)
        glDrawArrays(mode, 0, size);
    else
        glDrawElements(mode, size, indicesType, 0);

      

0


source







All Articles