void GLSL_ShaderPair::showActiveAttribs ( FILE *fd ) { if ( fd == NULL ) fd = stderr ; GLint maxlen = 0 ; GLint maxattrs = 0 ; glGetObjectParameterivARB ( handle, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &maxattrs ) ; if ( maxattrs == 0 ) { fprintf ( fd, "No Active Attributes.\n" ) ; return ; } glGetObjectParameterivARB ( handle, GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB, &maxlen ) ; char *name = new char [ maxlen+1 ] ; fprintf ( fd, "Active Attributes:\n" ) ; for ( int i = 0 ; i < maxattrs ; i++ ) { GLsizei len ; GLint size ; GLenum vartype ; char *vartypename ; GLint location ; glGetActiveAttribARB ( handle, i, maxlen+1, &len, &size, &vartype, name ) ; location = glGetAttribLocationARB ( handle, name ) ; switch ( vartype ) { case GL_FLOAT : vartypename = "float" ; break ; case GL_FLOAT_VEC2_ARB : vartypename = "vec2 " ; break ; case GL_FLOAT_VEC3_ARB : vartypename = "vec3 " ; break ; case GL_FLOAT_VEC4_ARB : vartypename = "vec4 " ; break ; case GL_FLOAT_MAT2_ARB : vartypename = "mat2 " ; break ; case GL_FLOAT_MAT3_ARB : vartypename = "mat3 " ; break ; case GL_FLOAT_MAT4_ARB : vartypename = "mat4 " ; break ; default : vartypename = "???? " ; break ; } if ( size == 1 ) fprintf ( fd, "%2d) %s %s ; // @%d\n", i, vartypename, name, location ) ; else fprintf ( fd, "%2d) %s %s [ %d ] ; // @%d\n", i, vartypename, name, size, location ) ; } fprintf ( fd, "\n" ) ; delete name ; }
void GPU::Shader::RecoverActiveAttributes() { m_Attributes.clear(); GLint count; GLcharARB nameBuffer[512]; glGetObjectParameterivARB( m_Id, GL_OBJECT_ACTIVE_ATTRIBUTES_ARB, &count ); for( GLint i=0; i<count; ++i ) { GLsizei length; GLint size; GLenum type; glGetActiveAttribARB( m_Id, i, sizeof(nameBuffer), &length, &size, &type, nameBuffer ); GLint attribId = glGetAttribLocationARB( m_Id, nameBuffer ); if( attribId != -1 ) m_Attributes[ std::string(nameBuffer) ] = attribId; } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBVertexShader_nglGetActiveAttribARB(JNIEnv *env, jclass clazz, jint programObj, jint index, jint maxLength, jobject length, jint length_position, jobject size, jint size_position, jobject type, jint type_position, jobject name, jint name_position, jlong function_pointer) { GLsizei *length_address = ((GLsizei *)safeGetBufferAddress(env, length)) + length_position; GLint *size_address = ((GLint *)(*env)->GetDirectBufferAddress(env, size)) + size_position; GLenum *type_address = ((GLenum *)(*env)->GetDirectBufferAddress(env, type)) + type_position; GLcharARB *name_address = ((GLcharARB *)(*env)->GetDirectBufferAddress(env, name)) + name_position; glGetActiveAttribARBPROC glGetActiveAttribARB = (glGetActiveAttribARBPROC)((intptr_t)function_pointer); glGetActiveAttribARB(programObj, index, maxLength, length_address, size_address, type_address, name_address); }