Exemplo n.º 1
0
	void Shader::SendVectorArray(int location, const Vector3d* vectors, unsigned int count) const
	{
		if (location == -1)
			return;

		if (glProgramUniform3dv)
			glProgramUniform3dv(m_program, location, count, reinterpret_cast<const double*>(vectors));
		else
		{
			OpenGL::BindProgram(m_program);
			glUniform3dv(location, count, reinterpret_cast<const double*>(vectors));
		}
	}
Exemplo n.º 2
0
	void Shader::SendVector(int location, const Vector3d& vector) const
	{
		if (location == -1)
			return;

		if (glProgramUniform3dv)
			glProgramUniform3dv(m_program, location, 1, vector);
		else
		{
			OpenGL::BindProgram(m_program);
			glUniform3dv(location, 1, vector);
		}
	}
    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
    }
Exemplo n.º 4
0
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglProgramUniform3dv(JNIEnv *env, jclass clazz, jint program, jint location, jint count, jlong value, jlong function_pointer) {
	const GLdouble *value_address = (const GLdouble *)(intptr_t)value;
	glProgramUniform3dvPROC glProgramUniform3dv = (glProgramUniform3dvPROC)((intptr_t)function_pointer);
	glProgramUniform3dv(program, location, count, value_address);
}
Exemplo n.º 5
0
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
	}
}
Exemplo n.º 6
0
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);
}
Exemplo n.º 7
0
static bool
test_double(const char *version_string)
{
	GLint loc;
	bool pass = true;
	double values[4];
	double got[ARRAY_SIZE(values)];
	GLuint prog;
	static const char subtest_name[] = "double scalar and vectors";
	const char *const shader_strings[] = {
		version_string,
		double_code,
		common_body
	};

	BUILD_SHADER(version_string == NULL);

	/* Try double
	 */
	random_doubles(values, ARRAY_SIZE(values));
	loc = glGetUniformLocation(prog, "v1");
	glProgramUniform1d(prog, loc,
			   values[0]);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 1) && pass;

	random_doubles(values, ARRAY_SIZE(values));
	glProgramUniform1dv(prog, loc, 1, values);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 1) && pass;

	/* Try dvec2
	 */
	random_doubles(values, ARRAY_SIZE(values));
	loc = glGetUniformLocation(prog, "v2");
	glProgramUniform2d(prog, loc,
			   values[0], values[1]);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 2) && pass;

	random_doubles(values, ARRAY_SIZE(values));
	glProgramUniform2dv(prog, loc, 1, values);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 2) && pass;

	/* Try dvec3
	 */
	random_doubles(values, ARRAY_SIZE(values));
	loc = glGetUniformLocation(prog, "v3");
	glProgramUniform3d(prog, loc,
			   values[0], values[1], values[2]);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 3) && pass;

	random_doubles(values, ARRAY_SIZE(values));
	glProgramUniform3dv(prog, loc, 1, values);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 3) && pass;

	/* Try dvec4
	 */
	random_doubles(values, ARRAY_SIZE(values));
	loc = glGetUniformLocation(prog, "v4");
	glProgramUniform4d(prog, loc,
			   values[0], values[1], values[2], values[3]);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 4) && pass;

	random_doubles(values, ARRAY_SIZE(values));
	glProgramUniform4dv(prog, loc, 1, values);
	pass = piglit_check_gl_error(0) && pass;

	glGetUniformdv(prog, loc, got);
	pass = piglit_check_gl_error(0) && pass;

	pass = check_double_values(values, got, 4) && pass;

	piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
				     subtest_name);

	glDeleteProgram(prog);
	return pass;
}