Browse Source

OpenGL vertex attribute helper.

tags/2021-05-28
jules 14 years ago
parent
commit
df8b3618c2
2 changed files with 24 additions and 0 deletions
  1. +6
    -0
      modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp
  2. +18
    -0
      modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h

+ 6
- 0
modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp View File

@@ -83,6 +83,12 @@ OpenGLShaderProgram::Uniform::Uniform (const OpenGLShaderProgram& program, const
jassert (uniformID >= 0);
}
OpenGLShaderProgram::Attribute::Attribute (const OpenGLShaderProgram& program, const char* name)
: attributeID (glGetAttribLocation (program.programID, name))
{
jassert (attributeID >= 0);
}
void OpenGLShaderProgram::Uniform::set (GLfloat n1) const noexcept { glUniform1f (uniformID, n1); }
void OpenGLShaderProgram::Uniform::set (GLint n1) const noexcept { glUniform1i (uniformID, n1); }
void OpenGLShaderProgram::Uniform::set (GLfloat n1, GLfloat n2) const noexcept { glUniform2f (uniformID, n1, n2); }


+ 18
- 0
modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h View File

@@ -101,6 +101,24 @@ public:
GLint uniformID;
};
/** Represents an openGL vertex attribute value.
After a program has been linked, you can create Attribute objects to let you
set the attributes that your vertex shaders use.
*/
struct Attribute
{
/** Initialises an attribute.
The program must have been successfully linked when this
constructor is called.
*/
Attribute (const OpenGLShaderProgram& program, const char* attributeName);
/** The attribute's ID number.
If the uniform couldn't be found, this value will be < 0.
*/
GLint attributeID;
};
/** The ID number of the compiled program. */
GLuint programID;


Loading…
Cancel
Save