What can cause glDrawArrays to generate a GL_INVALID_OPERATION error?

I figured out your problem: you are rendering to the same buffer that you’re sourcing your vertex data. glBindVertexArray(vaoPass2); I think you meant vaoPass1 From the spec: Buffers should not be bound or in use for both transform feedback and other purposes in the GL. Specifically, if a buffer object is simultaneously bound to a … Read more

Why would it be beneficial to have a separate projection matrix, yet combine model and view matrix?

Look at it practically. First, the fewer matrices you send, the fewer matrices you have to multiply with positions/normals/etc. And therefore, the faster your vertex shaders. So point 1: fewer matrices is better. However, there are certain things you probably need to do. Unless you’re doing 2D rendering or some simple 3D demo-applications, you are … Read more

In OpenGL is there a way to get a list of all uniforms & attribs used by a shader program?

Variables shared between both examples: GLint i; GLint count; GLint size; // size of the variable GLenum type; // type of the variable (float, vec3 or mat4, etc) const GLsizei bufSize = 16; // maximum name length GLchar name[bufSize]; // variable name in GLSL GLsizei length; // name length Attributes glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &count); printf(“Active Attributes: … Read more

How can I do these image processing tasks using OpenGL ES 2.0 shaders?

I just added filters to my open source GPUImage framework that perform three of the four processing tasks you describe (swirling, sketch filtering, and converting to an oil painting). While I don’t yet have colorspace transforms as filters, I do have the ability to apply a matrix to transform colors. As examples of these filters … Read more

Proper way to delete GLSL shader?

Yes — in fact it is highly desireable to detach and delete your shader objects as soon as possible. That way the driver can free up all the memory it is using to hold a copy of the shader source and unlinked object code, which can be quite substantial. Measurements I have done indicate that … Read more

In OpenGL ES 2.0 / GLSL, where do you need precision specifiers?

You don’t need precision specifiers on constants/literals since those get compile time evaluated to whatever they are being assigned to. In vertex shaders, the following precisions are declared by default: ( 4.5.3 Default Precision Qualifiers) precision highp float; precision highp int; precision lowp sampler2D; precision lowp samplerCube; And in fragment shaders you get: precision mediump … Read more