Browse Source

Added some matrix uniform setting methods to OpenGLShaderProgram.

tags/2021-05-28
jules 13 years ago
parent
commit
e35e130362
4 changed files with 19 additions and 6 deletions
  1. +5
    -1
      modules/juce_opengl/native/juce_OpenGLExtensions.h
  2. +4
    -5
      modules/juce_opengl/opengl/juce_OpenGLContext.cpp
  3. +4
    -0
      modules/juce_opengl/opengl/juce_OpenGLShaderProgram.cpp
  4. +6
    -0
      modules/juce_opengl/opengl/juce_OpenGLShaderProgram.h

+ 5
- 1
modules/juce_opengl/native/juce_OpenGLExtensions.h View File

@@ -84,7 +84,11 @@
USE_FUNCTION (glUniform3f, void, (GLint p1, GLfloat p2, GLfloat p3, GLfloat p4), (p1, p2, p3, p4))\
USE_FUNCTION (glUniform4f, void, (GLint p1, GLfloat p2, GLfloat p3, GLfloat p4, GLfloat p5), (p1, p2, p3, p4, p5))\
USE_FUNCTION (glUniform4i, void, (GLint p1, GLint p2, GLint p3, GLint p4, GLint p5), (p1, p2, p3, p4, p5))\
USE_FUNCTION (glUniform1fv, void, (GLint p1, GLsizei p2, const GLfloat* p3), (p1, p2, p3))
USE_FUNCTION (glUniform1fv, void, (GLint p1, GLsizei p2, const GLfloat* p3), (p1, p2, p3))\
USE_FUNCTION (glUniformMatrix2fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))\
USE_FUNCTION (glUniformMatrix3fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))\
USE_FUNCTION (glUniformMatrix4fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))
#else
#define JUCE_GL_EXTENSION_FUNCTIONS1(USE_FUNCTION) JUCE_GL_BASIC_EXTENSION_FUNCTIONS(USE_FUNCTION, EXT_FUNCTION)
#endif


+ 4
- 5
modules/juce_opengl/opengl/juce_OpenGLContext.cpp View File

@@ -559,13 +559,12 @@ void OpenGLContext::deactivateCurrentContext() { NativeContext::deactivateC
void OpenGLContext::triggerRepaint()
{
CachedImage* const currentContext
= dynamic_cast <CachedImage*> (Thread::getCurrentThread());
CachedImage* const cachedImage = getCachedImage();
if (currentContext != nullptr)
if (cachedImage != nullptr)
{
currentContext->triggerRepaint();
currentContext->component.repaint();
cachedImage->triggerRepaint();
cachedImage->component.repaint();
}
}


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

@@ -129,4 +129,8 @@ void OpenGLShaderProgram::Uniform::set (GLfloat n1, GLfloat n2, GLfloat n3, floa
void OpenGLShaderProgram::Uniform::set (GLint n1, GLint n2, GLint n3, GLint n4) const noexcept { context.extensions.glUniform4i (uniformID, n1, n2, n3, n4); }
void OpenGLShaderProgram::Uniform::set (const GLfloat* values, GLsizei numValues) const noexcept { context.extensions.glUniform1fv (uniformID, numValues, values); }
void OpenGLShaderProgram::Uniform::setMatrix2 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix2fv (uniformID, num, trns, v); }
void OpenGLShaderProgram::Uniform::setMatrix3 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix3fv (uniformID, num, trns, v); }
void OpenGLShaderProgram::Uniform::setMatrix4 (const GLfloat* v, GLint num, GLboolean trns) const noexcept { context.extensions.glUniformMatrix4fv (uniformID, num, trns, v); }
#endif

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

@@ -105,6 +105,12 @@ public:
void set (GLint n1, GLint n2, GLint n3, GLint n4) const noexcept;
/** Sets a vector float uniform. */
void set (const GLfloat* values, int numValues) const noexcept;
/** Sets a 2x2 matrix float uniform. */
void setMatrix2 (const GLfloat* values, GLint count, GLboolean transpose) const noexcept;
/** Sets a 3x3 matrix float uniform. */
void setMatrix3 (const GLfloat* values, GLint count, GLboolean transpose) const noexcept;
/** Sets a 4x4 matrix float uniform. */
void setMatrix4 (const GLfloat* values, GLint count, GLboolean transpose) const noexcept;
/** The uniform's ID number.
If the uniform couldn't be found, this value will be < 0.


Loading…
Cancel
Save