VertexBufferObject with glDrawArrays INVALID_OPERATION

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

VertexBufferObject with glDrawArrays INVALID_OPERATION

Postby mrdlink » Thu Mar 08, 2018 11:46 am

I wanted to use the VertexBufferObject class only for drawing stuff. I just wanted to see how the class works under the hood. But every frame I try to call glDrawArrays I get an INVALID_OPERATION error. Creating a VBO from ground up using GL calls works fine. I'm using the latest LibGDX 1.9.8. Here is how I setup and render:

Code: Select all
    ShaderProgram shader = new ShaderProgram(Gdx.files.internalFile("default.vert"), Gdx.files.internalFile("default.frag"));

    VertexBufferObject vbo = new VertexBufferObject(true, 3,
            VertexAttribute(Usage.Position, 2, "a_position"));

    public void show() {
        Matrix4 proj = new Matrix4().idt().setToOrtho2D(0f, 0f, 600f, 600f);
        shader.setUniformMatrix("u_projTrans", proj);

        vbo.setVertices(new float[]{
                0f, 0f,
                100f, 0f,
                0f, 100f
        }, 0, 6);

    public void render(delta: Float) {

        gl20.glDrawArrays(GL20.GL_TRIANGLES, 0, 3);

And here are my shader files:

Code: Select all
attribute vec2 a_position;

uniform mat4 u_projTrans;

void main() {
    gl_Position = u_projTrans * vec4(a_position, 0f, 1f);

Code: Select all
void main() {
    gl_FragColor = vec4(1f, 1f, 1f, 1f);
Posts: 1
Joined: Thu Mar 08, 2018 11:37 am

Return to General Development

Who is online

Users browsing this forum: No registered users and 1 guest