JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL40_nglUniformMatrix4x3dv(JNIEnv *__env, jclass clazz, jint location, jint count, jboolean transpose, jlong valueAddress, jlong __functionAddress) {
	const GLdouble *value = (const GLdouble *)(intptr_t)valueAddress;
	glUniformMatrix4x3dvPROC glUniformMatrix4x3dv = (glUniformMatrix4x3dvPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	glUniformMatrix4x3dv(location, count, transpose, value);
}
Example #2
0
void kore::BindUniform::doExecute(void) const {
  if(!_componentUniform) {
    Log::getInstance()->write("[ERROR] Uniform binding undefined");
    return;
  }

  GLerror::gl_ErrorCheckStart();
  _renderManager->
    useShaderProgram(_shaderUniform->shader->getProgramLocation());

  switch (_componentUniform->type) {
    case GL_FLOAT:
      glUniform1fv(_shaderUniform->location, _componentUniform->size,
                  static_cast<GLfloat*>(_componentUniform->data));
    break;

    case GL_FLOAT_VEC2:
      glUniform2fv(_shaderUniform->location, _componentUniform->size,
                          static_cast<GLfloat*>(_componentUniform->data));
      break;
    case GL_FLOAT_VEC3:
      glUniform3fv(_shaderUniform->location, _componentUniform->size,
                    static_cast<GLfloat*>(_componentUniform->data));
      break;
    case GL_FLOAT_VEC4:
        glUniform4fv(_shaderUniform->location, _componentUniform->size,
                     static_cast<GLfloat*>(_componentUniform->data));
      break;
    case GL_DOUBLE: 
      glUniform1d(_shaderUniform->location,
                  *static_cast<GLdouble*>(_componentUniform->data));
    break;
    case GL_DOUBLE_VEC2: 
      glUniform2dv(_shaderUniform->location, _componentUniform->size,
                  static_cast<GLdouble*>(_componentUniform->data));
    break;
    case GL_DOUBLE_VEC3: 
      glUniform3dv(_shaderUniform->location, _componentUniform->size,
                  static_cast<GLdouble*>(_componentUniform->data));
    break;
    case GL_DOUBLE_VEC4: 
      glUniform4dv(_shaderUniform->location, _componentUniform->size,
                   static_cast<GLdouble*>(_componentUniform->data));
    break;
    case GL_BOOL: 
    case GL_INT: 
      glUniform1i(_shaderUniform->location,
                  *static_cast<GLint*>(_componentUniform->data));
    break;
    case GL_BOOL_VEC2:
    case GL_INT_VEC2: 
      glUniform2iv(_shaderUniform->location, _componentUniform->size,
                   static_cast<GLint*>(_componentUniform->data));
    break;
    case GL_BOOL_VEC3:
    case GL_INT_VEC3: 
      glUniform3iv(_shaderUniform->location, _componentUniform->size,
                    static_cast<GLint*>(_componentUniform->data));
    break;
    case GL_BOOL_VEC4:
    case GL_INT_VEC4:
      glUniform4iv(_shaderUniform->location, _componentUniform->size,
                   static_cast<GLint*>(_componentUniform->data));
    break;
  case GL_UNSIGNED_INT:
      glUniform1ui(_shaderUniform->location,
                  *static_cast<GLuint*>(_componentUniform->data));
  break;
  case GL_UNSIGNED_INT_VEC2:
      glUniform2uiv(_shaderUniform->location, _componentUniform->size,
                   static_cast<GLuint*>(_componentUniform->data));
  break;
  case GL_UNSIGNED_INT_VEC3:
    glUniform3uiv(_shaderUniform->location, _componentUniform->size,
                  static_cast<GLuint*>(_componentUniform->data));
  break;
  case GL_UNSIGNED_INT_VEC4:
    glUniform4uiv(_shaderUniform->location, _componentUniform->size,
                  static_cast<GLuint*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT2:
    glUniformMatrix2fv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT3: 
    glUniformMatrix3fv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT4:
    glUniformMatrix4fv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT2x3: 
    glUniformMatrix2x3fv(_shaderUniform->location, _componentUniform->size,
     GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT2x4: 
     glUniformMatrix2x4fv(_shaderUniform->location, _componentUniform->size,
                          GL_FALSE,
                          static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT3x2: 
    glUniformMatrix3x2fv(_shaderUniform->location, _componentUniform->size,
                          GL_FALSE,
                          static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT3x4: 
    glUniformMatrix3x4fv(_shaderUniform->location, _componentUniform->size,
                     GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT4x2: 
    glUniformMatrix4x2fv(_shaderUniform->location, _componentUniform->size,
                    GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_FLOAT_MAT4x3: 
      glUniformMatrix3x4fv(_shaderUniform->location, _componentUniform->size,
        GL_FALSE, static_cast<GLfloat*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT2: 
    glUniformMatrix2dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT3: 
    glUniformMatrix3dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT4: 
    glUniformMatrix4dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT2x3: 
    glUniformMatrix2x3dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT2x4:
    glUniformMatrix2x4dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT3x2:
    glUniformMatrix3x2dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT3x4:
    glUniformMatrix3x4dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT4x2:
    glUniformMatrix4x2dv(_shaderUniform->location, _componentUniform->size,
      GL_FALSE, static_cast<GLdouble*>(_componentUniform->data));
  break;
  case GL_DOUBLE_MAT4x3:
    glUniformMatrix4x3dv(_shaderUniform->location, _componentUniform->size,
      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 GLSLLinkProgram::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 && mVertexProgram && (!mVertexProgram->getGLSLProgram()->getColumnMajorMatrices())) ||
            (fromProgType == GPT_VERTEX_PROGRAM && mFragmentProgram && (!mFragmentProgram->getGLSLProgram()->getColumnMajorMatrices())) ||
            (fromProgType == GPT_GEOMETRY_PROGRAM && mGeometryProgram && (!mGeometryProgram->getGLSLProgram()->getColumnMajorMatrices())) ||
            (fromProgType == GPT_HULL_PROGRAM && mHullProgram && (!mHullProgram->getGLSLProgram()->getColumnMajorMatrices())) ||
            (fromProgType == GPT_DOMAIN_PROGRAM && mDomainProgram && (!mDomainProgram->getGLSLProgram()->getColumnMajorMatrices())) ||
            (fromProgType == GPT_COMPUTE_PROGRAM && mComputeProgram && (!mComputeProgram->getGLSLProgram()->getColumnMajorMatrices())))
        {
            transpose = GL_FALSE;
        }

		for (;currentUniform != endUniform; ++currentUniform)
		{
			// Only pull values from buffer it's supposed to be in (vertex or fragment)
			// This method will be called twice, once for vertex program params, 
			// and once for fragment program params.
			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(glUniform1fv(currentUniform->mLocation, glArraySize, 
                                                         params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_FLOAT2:
						OGRE_CHECK_GL_ERROR(glUniform2fv(currentUniform->mLocation, glArraySize, 
                                                         params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_FLOAT3:
						OGRE_CHECK_GL_ERROR(glUniform3fv(currentUniform->mLocation, glArraySize, 
                                                         params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_FLOAT4:
						OGRE_CHECK_GL_ERROR(glUniform4fv(currentUniform->mLocation, glArraySize, 
                                                         params->getFloatPointer(def->physicalIndex)));
						break;
                    case GCT_DOUBLE1:
                        OGRE_CHECK_GL_ERROR(glUniform1dv(currentUniform->mLocation, glArraySize,
                                                         params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_DOUBLE2:
                        OGRE_CHECK_GL_ERROR(glUniform2dv(currentUniform->mLocation, glArraySize,
                                                         params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_DOUBLE3:
                        OGRE_CHECK_GL_ERROR(glUniform3dv(currentUniform->mLocation, glArraySize,
                                                         params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_DOUBLE4:
                        OGRE_CHECK_GL_ERROR(glUniform4dv(currentUniform->mLocation, glArraySize,
                                                         params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_2X2:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix2dv(currentUniform->mLocation, glArraySize,
                                                               transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_2X3:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix2x3dv(currentUniform->mLocation, glArraySize,
                                                                 transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_2X4:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix2x4dv(currentUniform->mLocation, glArraySize,
                                                                 transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_3X2:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix3x2dv(currentUniform->mLocation, glArraySize,
                                                                 transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_3X3:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix3dv(currentUniform->mLocation, glArraySize,
                                                               transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_3X4:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix3x4dv(currentUniform->mLocation, glArraySize,
                                                                 transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_4X2:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix4x2dv(currentUniform->mLocation, glArraySize,
                                                                 transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_4X3:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix4x3dv(currentUniform->mLocation, glArraySize,
                                                                 transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
                    case GCT_MATRIX_DOUBLE_4X4:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix4dv(currentUniform->mLocation, glArraySize,
                                                               transpose, params->getDoublePointer(def->physicalIndex)));
                        break;
					case GCT_MATRIX_2X2:
						OGRE_CHECK_GL_ERROR(glUniformMatrix2fv(currentUniform->mLocation, glArraySize,
                                                               transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_2X3:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix2x3fv(currentUniform->mLocation, glArraySize, 
                                                                 transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_2X4:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix2x4fv(currentUniform->mLocation, glArraySize, 
                                                                 transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_3X2:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix3x2fv(currentUniform->mLocation, glArraySize, 
                                                                 transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_3X3:
						OGRE_CHECK_GL_ERROR(glUniformMatrix3fv(currentUniform->mLocation, glArraySize, 
                                                               transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_3X4:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix3x4fv(currentUniform->mLocation, glArraySize, 
                                                                 transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_4X2:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix4x2fv(currentUniform->mLocation, glArraySize, 
                                                                 transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_4X3:
                        OGRE_CHECK_GL_ERROR(glUniformMatrix4x3fv(currentUniform->mLocation, glArraySize, 
                                                                 transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_MATRIX_4X4:
						OGRE_CHECK_GL_ERROR(glUniformMatrix4fv(currentUniform->mLocation, glArraySize, 
                                                               transpose, params->getFloatPointer(def->physicalIndex)));
						break;
					case GCT_INT1:
						OGRE_CHECK_GL_ERROR(glUniform1iv(currentUniform->mLocation, glArraySize, 
                                                         (GLint*)params->getIntPointer(def->physicalIndex)));
						break;
					case GCT_INT2:
						OGRE_CHECK_GL_ERROR(glUniform2iv(currentUniform->mLocation, glArraySize, 
                                                         (GLint*)params->getIntPointer(def->physicalIndex)));
						break;
					case GCT_INT3:
						OGRE_CHECK_GL_ERROR(glUniform3iv(currentUniform->mLocation, glArraySize, 
                                                         (GLint*)params->getIntPointer(def->physicalIndex)));
						break;
					case GCT_INT4:
						OGRE_CHECK_GL_ERROR(glUniform4iv(currentUniform->mLocation, glArraySize, 
                                                         (GLint*)params->getIntPointer(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(glUniform1iv(currentUniform->mLocation, 1, 
                                                         (GLint*)params->getIntPointer(def->physicalIndex)));
						break;
                    case GCT_SUBROUTINE:
                    case GCT_UNKNOWN:
                        break;

					} // End switch

				} // Variability & mask
			} // fromProgType == currentUniform->mSourceProgType

  		} // End for
	}