void program::set_uniform_matrix4x3fv( char const* varname, GLsizei count, GLboolean transpose, GLfloat* value ) const { GLint location = get_uniform_location(varname); if (location >= 0) { #if GPUCAST_GL_DIRECT_STATE_ACCESS glProgramUniformMatrix4x3fv(id_, location, count, transpose, value); #else glUniformMatrix4x3fv(location, count, transpose, value); #endif } }
void GLSLSeparableProgram::updateUniforms(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) { // Iterate through uniform reference list and update uniform values GLUniformReferenceIterator currentUniform = mGLUniformReferences.begin(); GLUniformReferenceIterator endUniform = mGLUniformReferences.end(); // determine if we need to transpose matrices when binding int transpose = GL_TRUE; if ((fromProgType == GPT_FRAGMENT_PROGRAM && mVertexShader && (!mVertexShader->getColumnMajorMatrices())) || (fromProgType == GPT_VERTEX_PROGRAM && mFragmentShader && (!mFragmentShader->getColumnMajorMatrices())) || (fromProgType == GPT_GEOMETRY_PROGRAM && mGeometryShader && (!mGeometryShader->getColumnMajorMatrices())) || (fromProgType == GPT_HULL_PROGRAM && mHullShader && (!mHullShader->getColumnMajorMatrices())) || (fromProgType == GPT_DOMAIN_PROGRAM && mDomainShader && (!mDomainShader->getColumnMajorMatrices())) || (fromProgType == GPT_COMPUTE_PROGRAM && mComputeShader && (!mComputeShader->getColumnMajorMatrices()))) { transpose = GL_FALSE; } GLuint progID = 0; if (fromProgType == GPT_VERTEX_PROGRAM) { progID = mVertexShader->getGLProgramHandle(); } else if (fromProgType == GPT_FRAGMENT_PROGRAM) { progID = mFragmentShader->getGLProgramHandle(); } else if (fromProgType == GPT_GEOMETRY_PROGRAM) { progID = mGeometryShader->getGLProgramHandle(); } else if (fromProgType == GPT_HULL_PROGRAM) { progID = mHullShader->getGLProgramHandle(); } else if (fromProgType == GPT_DOMAIN_PROGRAM) { progID = mDomainShader->getGLProgramHandle(); } else if (fromProgType == GPT_COMPUTE_PROGRAM) { progID = mComputeShader->getGLProgramHandle(); } for (; currentUniform != endUniform; ++currentUniform) { // Only pull values from buffer it's supposed to be in (vertex or fragment) // This method will be called once per shader stage. if (fromProgType == currentUniform->mSourceProgType) { const GpuConstantDefinition* def = currentUniform->mConstantDef; if (def->variability & mask) { GLsizei glArraySize = (GLsizei)def->arraySize; // Get the index in the parameter real list switch (def->constType) { case GCT_FLOAT1: OGRE_CHECK_GL_ERROR(glProgramUniform1fv(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_FLOAT2: OGRE_CHECK_GL_ERROR(glProgramUniform2fv(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_FLOAT3: OGRE_CHECK_GL_ERROR(glProgramUniform3fv(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_FLOAT4: OGRE_CHECK_GL_ERROR(glProgramUniform4fv(progID, currentUniform->mLocation, glArraySize, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_2X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_3X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_4X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_INT1: OGRE_CHECK_GL_ERROR(glProgramUniform1iv(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_INT2: OGRE_CHECK_GL_ERROR(glProgramUniform2iv(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_INT3: OGRE_CHECK_GL_ERROR(glProgramUniform3iv(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_INT4: OGRE_CHECK_GL_ERROR(glProgramUniform4iv(progID, currentUniform->mLocation, glArraySize, params->getIntPointer(def->physicalIndex))); break; case GCT_MATRIX_2X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2x3fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_2X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2x4fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_3X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3x2fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_3X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3x4fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_4X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4x2fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_MATRIX_4X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4x3fv(progID, currentUniform->mLocation, glArraySize, transpose, params->getFloatPointer(def->physicalIndex))); break; case GCT_DOUBLE1: OGRE_CHECK_GL_ERROR(glProgramUniform1dv(progID, currentUniform->mLocation, glArraySize, params->getDoublePointer(def->physicalIndex))); break; case GCT_DOUBLE2: OGRE_CHECK_GL_ERROR(glProgramUniform2dv(progID, currentUniform->mLocation, glArraySize, params->getDoublePointer(def->physicalIndex))); break; case GCT_DOUBLE3: OGRE_CHECK_GL_ERROR(glProgramUniform3dv(progID, currentUniform->mLocation, glArraySize, params->getDoublePointer(def->physicalIndex))); break; case GCT_DOUBLE4: OGRE_CHECK_GL_ERROR(glProgramUniform4dv(progID, currentUniform->mLocation, glArraySize, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_2X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_3X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_4X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_2X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2x3dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_2X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix2x4dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_3X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3x2dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_3X4: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix3x4dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_4X2: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4x2dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_MATRIX_DOUBLE_4X3: OGRE_CHECK_GL_ERROR(glProgramUniformMatrix4x3dv(progID, currentUniform->mLocation, glArraySize, transpose, params->getDoublePointer(def->physicalIndex))); break; case GCT_UINT1: case GCT_BOOL1: OGRE_CHECK_GL_ERROR(glProgramUniform1uiv(progID, currentUniform->mLocation, glArraySize, params->getUnsignedIntPointer(def->physicalIndex))); break; case GCT_UINT2: case GCT_BOOL2: OGRE_CHECK_GL_ERROR(glProgramUniform2uiv(progID, currentUniform->mLocation, glArraySize, params->getUnsignedIntPointer(def->physicalIndex))); break; case GCT_UINT3: case GCT_BOOL3: OGRE_CHECK_GL_ERROR(glProgramUniform3uiv(progID, currentUniform->mLocation, glArraySize, params->getUnsignedIntPointer(def->physicalIndex))); break; case GCT_UINT4: case GCT_BOOL4: OGRE_CHECK_GL_ERROR(glProgramUniform4uiv(progID, currentUniform->mLocation, glArraySize, params->getUnsignedIntPointer(def->physicalIndex))); break; case GCT_SAMPLER1D: case GCT_SAMPLER1DSHADOW: case GCT_SAMPLER2D: case GCT_SAMPLER2DSHADOW: case GCT_SAMPLER2DARRAY: case GCT_SAMPLER3D: case GCT_SAMPLERCUBE: case GCT_SAMPLERRECT: // Samplers handled like 1-element ints OGRE_CHECK_GL_ERROR(glProgramUniform1iv(progID, currentUniform->mLocation, 1, params->getIntPointer(def->physicalIndex))); break; case GCT_UNKNOWN: case GCT_SUBROUTINE: break; } // End switch } // Variability & mask } // fromProgType == currentUniform->mSourceProgType } // End for }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglProgramUniformMatrix4x3fv(JNIEnv *env, jclass clazz, jint program, jint location, jint count, jboolean transpose, jlong value, jlong function_pointer) { const GLfloat *value_address = (const GLfloat *)(intptr_t)value; glProgramUniformMatrix4x3fvPROC glProgramUniformMatrix4x3fv = (glProgramUniformMatrix4x3fvPROC)((intptr_t)function_pointer); glProgramUniformMatrix4x3fv(program, location, count, transpose, value_address); }
void VSShaderLib::setUniform(std::string name, void *value) { myUniforms u = pUniforms[name]; switch (u.type) { // Floats case GL_FLOAT: glProgramUniform1fv(pProgram, u.location, u.size, (const GLfloat *)value); break; case GL_FLOAT_VEC2: glProgramUniform2fv(pProgram, u.location, u.size, (const GLfloat *)value); break; case GL_FLOAT_VEC3: glProgramUniform3fv(pProgram, u.location, u.size, (const GLfloat *)value); break; case GL_FLOAT_VEC4: glProgramUniform4fv(pProgram, u.location, u.size, (const GLfloat *)value); break; #ifndef __ANDROID_API__ // Doubles case GL_DOUBLE: glProgramUniform1dv(pProgram, u.location, u.size, (const GLdouble *)value); break; case GL_DOUBLE_VEC2: glProgramUniform2dv(pProgram, u.location, u.size, (const GLdouble *)value); break; case GL_DOUBLE_VEC3: glProgramUniform3dv(pProgram, u.location, u.size, (const GLdouble *)value); break; case GL_DOUBLE_VEC4: glProgramUniform4dv(pProgram, u.location, u.size, (const GLdouble *)value); break; #endif // Samplers, Ints and Bools #ifndef __ANDROID_API__ case GL_IMAGE_1D : case GL_IMAGE_2D_RECT : case GL_IMAGE_BUFFER : case GL_IMAGE_1D_ARRAY : case GL_IMAGE_CUBE_MAP_ARRAY : case GL_IMAGE_2D_MULTISAMPLE : case GL_IMAGE_2D_MULTISAMPLE_ARRAY : case GL_INT_IMAGE_1D : case GL_INT_IMAGE_2D_RECT : case GL_INT_IMAGE_BUFFER : case GL_INT_IMAGE_1D_ARRAY : case GL_INT_IMAGE_CUBE_MAP_ARRAY : case GL_INT_IMAGE_2D_MULTISAMPLE : case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY : case GL_UNSIGNED_INT_IMAGE_1D : case GL_UNSIGNED_INT_IMAGE_2D_RECT : case GL_UNSIGNED_INT_IMAGE_BUFFER : case GL_UNSIGNED_INT_IMAGE_1D_ARRAY : case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY : case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE : case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY : #endif case GL_IMAGE_2D : case GL_IMAGE_3D : case GL_IMAGE_CUBE : case GL_IMAGE_2D_ARRAY : case GL_INT_IMAGE_2D : case GL_INT_IMAGE_3D : case GL_INT_IMAGE_CUBE : case GL_INT_IMAGE_2D_ARRAY : case GL_UNSIGNED_INT_IMAGE_2D : case GL_UNSIGNED_INT_IMAGE_3D : case GL_UNSIGNED_INT_IMAGE_CUBE : case GL_UNSIGNED_INT_IMAGE_2D_ARRAY : #ifndef __ANDROID_API__ case GL_SAMPLER_1D: case GL_SAMPLER_1D_SHADOW: case GL_SAMPLER_1D_ARRAY: case GL_SAMPLER_1D_ARRAY_SHADOW: case GL_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_SAMPLER_BUFFER: case GL_SAMPLER_2D_RECT: case GL_SAMPLER_2D_RECT_SHADOW: case GL_INT_SAMPLER_1D: case GL_INT_SAMPLER_1D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_INT_SAMPLER_BUFFER: case GL_INT_SAMPLER_2D_RECT: case GL_UNSIGNED_INT_SAMPLER_1D: case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_BUFFER: case GL_UNSIGNED_INT_SAMPLER_2D_RECT: #endif case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_2D_ARRAY_SHADOW: case GL_SAMPLER_2D_MULTISAMPLE: case GL_SAMPLER_CUBE_SHADOW: case GL_INT_SAMPLER_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: case GL_UNSIGNED_INT_SAMPLER_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: case GL_BOOL: case GL_INT : glProgramUniform1iv(pProgram, u.location, u.size, (const GLint *)value); break; case GL_BOOL_VEC2: case GL_INT_VEC2: glProgramUniform2iv(pProgram, u.location, u.size, (const GLint *)value); break; case GL_BOOL_VEC3: case GL_INT_VEC3: glProgramUniform3iv(pProgram, u.location, u.size, (const GLint *)value); break; case GL_BOOL_VEC4: case GL_INT_VEC4: glProgramUniform4iv(pProgram, u.location, u.size, (const GLint *)value); break; // Unsigned ints case GL_UNSIGNED_INT: glProgramUniform1uiv(pProgram, u.location, u.size, (const GLuint *)value); break; case GL_UNSIGNED_INT_VEC2: glProgramUniform2uiv(pProgram, u.location, u.size, (const GLuint *)value); break; case GL_UNSIGNED_INT_VEC3: glProgramUniform3uiv(pProgram, u.location, u.size, (const GLuint *)value); break; case GL_UNSIGNED_INT_VEC4: glProgramUniform4uiv(pProgram, u.location, u.size, (const GLuint *)value); break; // Float Matrices case GL_FLOAT_MAT2: glProgramUniformMatrix2fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT3: glProgramUniformMatrix3fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT4: glProgramUniformMatrix4fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT2x3: glProgramUniformMatrix2x3fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT2x4: glProgramUniformMatrix2x4fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT3x2: glProgramUniformMatrix3x2fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT3x4: glProgramUniformMatrix3x4fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT4x2: glProgramUniformMatrix4x2fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; case GL_FLOAT_MAT4x3: glProgramUniformMatrix4x3fv(pProgram, u.location, u.size, GL_FALSE, (const GLfloat *)value); break; #ifndef __ANDROID_API__ // Double Matrices case GL_DOUBLE_MAT2: glProgramUniformMatrix2dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT3: glProgramUniformMatrix3dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT4: glProgramUniformMatrix4dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT2x3: glProgramUniformMatrix2x3dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT2x4: glProgramUniformMatrix2x4dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT3x2: glProgramUniformMatrix3x2dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT3x4: glProgramUniformMatrix3x4dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT4x2: glProgramUniformMatrix4x2dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; case GL_DOUBLE_MAT4x3: glProgramUniformMatrix4x3dv(pProgram, u.location, u.size, false, (const GLdouble *)value); break; #endif } }
void UniformImplementation_SeparateShaderObjectsARB::set(const Program * program, const GLint location, const std::vector<glm::mat4x3> & value) const { glProgramUniformMatrix4x3fv(program->id(), location, static_cast<GLint>(value.size()), GL_FALSE, reinterpret_cast<const float*>(value.data())); }
void UniformImplementation_SeparateShaderObjectsARB::set(const Program * program, const GLint location, const glm::mat4x3 & value) const { glProgramUniformMatrix4x3fv(program->id(), location, 1, GL_FALSE, glm::value_ptr(value)); }
static bool test_nonsquare_mat(const char *version_string) { GLint loc; bool pass = true; float values[12]; float got[ARRAY_SIZE(values)]; GLuint prog; static const char subtest_name[] = "non-square float matrices"; const char *const shader_strings[] = { version_string, nonsquare_mat_code, }; /* Non-square matrices are only available in GLSL 1.20 or later. */ BUILD_SHADER(strstr(version_string, "110") != NULL); /* Try mat2x3 */ loc = glGetUniformLocation(prog, "m2x3"); random_floats(values, ARRAY_SIZE(values)); glProgramUniformMatrix2x3fv(prog, loc, 1, GL_FALSE, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 6) && pass; /* Try mat2x4 */ loc = glGetUniformLocation(prog, "m2x4"); random_floats(values, ARRAY_SIZE(values)); glProgramUniformMatrix2x4fv(prog, loc, 1, GL_FALSE, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 8) && pass; /* Try mat3x2 */ loc = glGetUniformLocation(prog, "m3x2"); random_floats(values, ARRAY_SIZE(values)); glProgramUniformMatrix3x2fv(prog, loc, 1, GL_FALSE, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 6) && pass; /* Try mat3x4 */ loc = glGetUniformLocation(prog, "m3x4"); random_floats(values, ARRAY_SIZE(values)); glProgramUniformMatrix3x4fv(prog, loc, 1, GL_FALSE, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 12) && pass; /* Try mat4x2 */ loc = glGetUniformLocation(prog, "m4x2"); random_floats(values, ARRAY_SIZE(values)); glProgramUniformMatrix4x2fv(prog, loc, 1, GL_FALSE, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 8) && pass; /* Try mat4x3 */ loc = glGetUniformLocation(prog, "m4x3"); random_floats(values, ARRAY_SIZE(values)); glProgramUniformMatrix4x3fv(prog, loc, 1, GL_FALSE, values); pass = piglit_check_gl_error(0) && pass; glGetUniformfv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_float_values(values, got, 12) && pass; piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, subtest_name); glDeleteProgram(prog); return pass; }