1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

OpenGL vertex attribute helper.

This commit is contained in:
jules 2011-12-18 11:45:00 +00:00
parent 3995ef255f
commit df8b3618c2
2 changed files with 24 additions and 0 deletions

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); }

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;