inline void VL_glBindFragDataLocation(GLuint program, GLuint colorNumber, const GLchar *name)
 {
   if (glBindFragDataLocation)
     glBindFragDataLocation(program, colorNumber, name);
   else
   if (glBindFragDataLocationEXT)
     glBindFragDataLocationEXT(program, colorNumber, name);
   else
     VL_UNSUPPORTED_FUNC();
 }
示例#2
0
//loades the shaders into a program, retruning the programs id
GLuint glslLoadShaderProgram( std::string vertex, std::string fragment ){
	//a quick check
	if( vertex.empty() || fragment.empty() ){
		printf( "ERROR: Unable to load programs, program defined as NULL" );
		return 0;
	}

	printf( "INFO: Loading Shaders %s %s\n", vertex.c_str(), fragment.c_str());

	//temp ids
	GLuint vsID, fsID, program;

	//make the vertex shader
	const char* vertex_data = ReadShaderFile( vertex );
	vsID = glCreateShader( GL_VERTEX_SHADER );
	glShaderSource( vsID, 1, &vertex_data, NULL );
	glCompileShader( vsID );
	printShaderLog( vsID );

	delete [] vertex_data;

	//make the fragment shader
	const char * fragment_data = ReadShaderFile( fragment );
	fsID = glCreateShader( GL_FRAGMENT_SHADER );
	glShaderSource( fsID, 1, &fragment_data, NULL );
	glCompileShader( fsID );
	printShaderLog( fsID );

	delete [] fragment_data;

	//make and link the program
	program = glCreateProgram();
	glAttachShader( program, vsID );
	glAttachShader( program, fsID );

	glBindFragDataLocationEXT( program, 0, "pixelColor" );

	glLinkProgram( program );
	printProgramLog( program );

	//and return, best of luck
	return program;
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGPUShader4_nglBindFragDataLocationEXT(JNIEnv *__env, jclass clazz, jint program, jint color, jlong nameAddress) {
    glBindFragDataLocationEXTPROC glBindFragDataLocationEXT = (glBindFragDataLocationEXTPROC)tlsGetFunction(1744);
    intptr_t name = (intptr_t)nameAddress;
    UNUSED_PARAM(clazz)
    glBindFragDataLocationEXT(program, color, name);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_EXTGpuShader4_nglBindFragDataLocationEXT(JNIEnv *env, jclass clazz, jint program, jint colorNumber, jobject name, jint name_position, jlong function_pointer) {
	const GLchar *name_address = ((const GLchar *)(*env)->GetDirectBufferAddress(env, name)) + name_position;
	glBindFragDataLocationEXTPROC glBindFragDataLocationEXT = (glBindFragDataLocationEXTPROC)((intptr_t)function_pointer);
	glBindFragDataLocationEXT(program, colorNumber, name_address);
}