Beispiel #1
0
	void Shader::SendDouble(int location, double value) const
	{
		if (location == -1)
			return;

		if (glProgramUniform1d)
			glProgramUniform1d(m_program, location, value);
		else
		{
			OpenGL::BindProgram(m_program);
			glUniform1d(location, value);
		}
	}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL41_nglProgramUniform1d(JNIEnv *env, jclass clazz, jint program, jint location, jdouble v0, jlong function_pointer) {
	glProgramUniform1dPROC glProgramUniform1d = (glProgramUniform1dPROC)((intptr_t)function_pointer);
	glProgramUniform1d(program, location, v0);
}
Beispiel #3
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);
}
Beispiel #4
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;
}