void Shader::SendVectorArray(int location, const Vector3i* vectors, unsigned int count) const { if (location == -1) return; if (glProgramUniform3iv) glProgramUniform3iv(m_program, location, count, reinterpret_cast<const int*>(vectors)); else { OpenGL::BindProgram(m_program); glUniform3iv(location, count, reinterpret_cast<const int*>(vectors)); } }
void Shader::SendVector(int location, const Vector3i& vector) const { if (location == -1) return; if (glProgramUniform3iv) glProgramUniform3iv(m_program, location, 1, vector); else { OpenGL::BindProgram(m_program); glUniform3iv(location, 1, vector); } }
void program::set_uniform3iv(char const* varname, GLsizei count, GLint* value) const { GLint location = get_uniform_location(varname); if (location >= 0) { #if GPUCAST_GL_DIRECT_STATE_ACCESS glProgramUniform3iv(id_, location, count, value); #else glUniform3iv(location, count, value); #endif } }
void Shader::uniform3i(GLint location, const glm::ivec3& vec) const { glProgramUniform3iv(id_, location, 1, glm::value_ptr(vec)); }
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_nglProgramUniform3iv(JNIEnv *env, jclass clazz, jint program, jint location, jint count, jlong value, jlong function_pointer) { const GLint *value_address = (const GLint *)(intptr_t)value; glProgramUniform3ivPROC glProgramUniform3iv = (glProgramUniform3ivPROC)((intptr_t)function_pointer); glProgramUniform3iv(program, location, count, value_address); }
void GLSeparableProgram::setUniformVector3i( GLint uniformLocation, const Vector3i& v ) { assert( isValid() ); glProgramUniform3iv( id(), uniformLocation, 1, v ); }
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 kore::BindUniform::execute(void) { if(!_componentUniform) { Log::getInstance()->write("[ERROR] Uniform binding undefined"); return; } GLerror::gl_ErrorCheckStart(); switch (_componentUniform->type) { case GL_FLOAT_VEC2: glProgramUniform2fv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_VEC3: glProgramUniform3fv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_VEC4: glProgramUniform4fv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_DOUBLE: glProgramUniform1d(_shaderHandle, _shaderUniform->location, *static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_VEC2: glProgramUniform2dv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_VEC3: glProgramUniform3dv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_VEC4: glProgramUniform4dv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_BOOL: case GL_INT: glProgramUniform1i(_shaderHandle, _shaderUniform->location, *static_cast<GLint*>(_componentUniform->data)); break; case GL_BOOL_VEC2: case GL_INT_VEC2: glProgramUniform2iv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLint*>(_componentUniform->data)); break; case GL_BOOL_VEC3: case GL_INT_VEC3: glProgramUniform3iv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLint*>(_componentUniform->data)); break; case GL_BOOL_VEC4: case GL_INT_VEC4: glProgramUniform4iv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT: glProgramUniform1ui(_shaderHandle, _shaderUniform->location, *static_cast<GLuint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT_VEC2: glProgramUniform2uiv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLuint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT_VEC3: glProgramUniform3uiv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLuint*>(_componentUniform->data)); break; case GL_UNSIGNED_INT_VEC4: glProgramUniform4uiv(_shaderHandle, _shaderUniform->location, 1, static_cast<GLuint*>(_componentUniform->data)); break; case GL_FLOAT_MAT2: glProgramUniformMatrix2fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT3: glProgramUniformMatrix3fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT4: glProgramUniformMatrix4fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT2x3: glProgramUniformMatrix2x3fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT2x4: glProgramUniformMatrix2x4fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT3x2: glProgramUniformMatrix3x2fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT3x4: glProgramUniformMatrix3x4fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT4x2: glProgramUniformMatrix4x2fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_FLOAT_MAT4x3: glProgramUniformMatrix3x4fv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLfloat*>(_componentUniform->data)); break; case GL_DOUBLE_MAT2: glProgramUniformMatrix2dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT3: glProgramUniformMatrix3dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT4: glProgramUniformMatrix4dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT2x3: glProgramUniformMatrix2x3dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT2x4: glProgramUniformMatrix2x4dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT3x2: glProgramUniformMatrix3x2dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT3x4: glProgramUniformMatrix3x4dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT4x2: glProgramUniformMatrix4x2dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; case GL_DOUBLE_MAT4x3: glProgramUniformMatrix4x3dv(_shaderHandle, _shaderUniform->location, 1, GL_FALSE, static_cast<GLdouble*>(_componentUniform->data)); break; // Note(dlazarek): Currently, we handle texture-bindings outside of // Uniform-bindigs for sorting and performance-reasons. case GL_SAMPLER_1D: case GL_SAMPLER_2D: case GL_SAMPLER_3D: case GL_SAMPLER_CUBE: case GL_SAMPLER_1D_SHADOW: case GL_SAMPLER_2D_SHADOW: case GL_SAMPLER_CUBE_SHADOW: case GL_SAMPLER_1D_ARRAY: case GL_SAMPLER_2D_ARRAY: case GL_SAMPLER_1D_ARRAY_SHADOW: case GL_SAMPLER_2D_ARRAY_SHADOW: case GL_SAMPLER_2D_MULTISAMPLE: 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_2D: case GL_INT_SAMPLER_3D: case GL_INT_SAMPLER_CUBE: case GL_INT_SAMPLER_1D_ARRAY: case GL_INT_SAMPLER_2D_ARRAY: case GL_INT_SAMPLER_2D_MULTISAMPLE: 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_2D: case GL_UNSIGNED_INT_SAMPLER_3D: case GL_UNSIGNED_INT_SAMPLER_CUBE: case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE: case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: case GL_UNSIGNED_INT_SAMPLER_BUFFER: case GL_UNSIGNED_INT_SAMPLER_2D_RECT: //glActiveTexture(GL_TEXTURE0 + _componentUniform->texUnit); //glProgramUniform1i(_shaderID, _shaderUniform->location, _componentUniform->texUnit); kore::Log::getInstance()->write("[ERROR] sampler type was adressed" "as uniform"); break; /* break; case GL_IMAGE_1D: break; case GL_IMAGE_2D: break; case GL_IMAGE_3D: break; case GL_IMAGE_2D_RECT: break; case GL_IMAGE_CUBE: break; case GL_IMAGE_BUFFER: break; case GL_IMAGE_1D_ARRAY: break; case GL_IMAGE_2D_ARRAY: break; case GL_IMAGE_2D_MULTISAMPLE: break; case GL_IMAGE_2D_MULTISAMPLE_ARRAY: break; case GL_INT_IMAGE_1D: break; case GL_INT_IMAGE_2D: break; case GL_INT_IMAGE_3D: break; case GL_INT_IMAGE_2D_RECT: break; case GL_INT_IMAGE_CUBE: break; case GL_INT_IMAGE_BUFFER: break; case GL_INT_IMAGE_1D_ARRAY: break; case GL_INT_IMAGE_2D_ARRAY: break; case GL_INT_IMAGE_2D_MULTISAMPLE: break; case GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY: break; case GL_UNSIGNED_INT_IMAGE_1D: break; case GL_UNSIGNED_INT_IMAGE_2D: break; case GL_UNSIGNED_INT_IMAGE_3D: break; case GL_UNSIGNED_INT_IMAGE_2D_RECT: break; case GL_UNSIGNED_INT_IMAGE_CUBE: break; case GL_UNSIGNED_INT_IMAGE_BUFFER: break; case GL_UNSIGNED_INT_IMAGE_1D_ARRAY: break; case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: break; case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE: break; case GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY: break; */ default: kore::Log::getInstance()->write("[ERROR] Unknown uniform binding\n"); break; } GLerror::gl_ErrorCheckFinish("BindUniformOperation: " + _shaderUniform->name); }
void UniformImplementation_SeparateShaderObjectsARB::set(const Program * program, const GLint location, const glm::ivec3 & value) const { glProgramUniform3iv(program->id(), location, 1, glm::value_ptr(value)); }
void UniformImplementation_SeparateShaderObjectsARB::set(const Program * program, const GLint location, const std::vector<glm::ivec3> & value) const { glProgramUniform3iv(program->id(), location, static_cast<GLint>(value.size()), reinterpret_cast<const int*>(value.data())); }
static bool test_int(const char *version_string) { GLint loc; bool pass = true; int values[4]; int got[ARRAY_SIZE(values)]; GLuint prog; static const char subtest_name[] = "integer scalar and vectors"; const char *const shader_strings[] = { version_string, int_code, common_body }; BUILD_SHADER(version_string == NULL); /* Try int */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v1"); glProgramUniform1i(prog, loc, values[0]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 1) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform1iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 1) && pass; /* Try ivec2 */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v2"); glProgramUniform2i(prog, loc, values[0], values[1]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 2) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform2iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 2) && pass; /* Try ivec3 */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v3"); glProgramUniform3i(prog, loc, values[0], values[1], values[2]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 3) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform3iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 3) && pass; /* Try ivec4 */ random_ints(values, ARRAY_SIZE(values)); loc = glGetUniformLocation(prog, "v4"); glProgramUniform4i(prog, loc, values[0], values[1], values[2], values[3]); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 4) && pass; random_ints(values, ARRAY_SIZE(values)); glProgramUniform4iv(prog, loc, 1, values); pass = piglit_check_gl_error(0) && pass; glGetUniformiv(prog, loc, got); pass = piglit_check_gl_error(0) && pass; pass = check_int_values(values, got, 4) && pass; piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL, subtest_name); glDeleteProgram(prog); return pass; }