수색…


소개

프로그램 개체의 여러 기능을 프로그램 API를 통해 가져올 수 있습니다.

정점 속성 정보

정점 속성에 대한 정보는 OGL 함수 glGetProgram 과 매개 변수 GL_ACTIVE_ATTRIBUTESGL_ACTIVE_ATTRIBUTE_MAX_LENGTH 사용하여 검색 할 수 있습니다.

활성 셰이더 특성의 위치는 OGL 함수 glGetAttribLocation 에 의해 특성 색인에 의해 결정될 수 있습니다.

GLuint shaderProg = ...;
std::map< std::string, GLint > attributeLocation;

GLint maxAttribLen, nAttribs;
glGetProgramiv( shaderProg, GL_ACTIVE_ATTRIBUTES, &nAttribs );
glGetProgramiv( shaderProg, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttribLen 
GLint written, size;
GLenum type;
std::vector< GLchar >attrName( maxAttribLen );
for( int attribInx = 0; attribInx < nAttribs; attribInx++ )
{
    glGetActiveAttrib( shaderProg, attribInx, maxAttribLen, &written, &size, &type, &attrName[0] );
    attributeLocation[attrName] = glGetAttribLocation( shaderProg, attrName.data() );
}

통일 정보

프로그램의 활성 유니폼에 대한 정보는 OGL 함수 glGetProgram 과 매개 변수 GL_ACTIVE_UNIFORMSGL_ACTIVE_UNIFORM_MAX_LENGTH 사용하여 검색 할 수 있습니다.

액티브 셰이더 유니폼 변수의 위치는 OGL 함수 인 glGetActiveUniform 에 의해 속성 색인에 의해 결정될 수 있습니다.

GLuint shaderProg = ...;
std::map< std::string, GLint > unifomLocation;

GLint maxUniformLen, nUniforms;
glGetProgramiv( shaderProg, GL_ACTIVE_UNIFORMS, &nUniforms );
glGetProgramiv( shaderProg, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLen );

GLint written, size;
GLenum type;
std::vector< GLchar >uniformName( maxUniformLen );
for( int uniformInx = 0; uniformInx < nUniforms; uniformInx++ )
{
    glGetActiveUniform( shaderProg, uniformInx, maxUniformLen, &written, &size, &type, &uniformName[0] );
    unifomLocation[uniformName] = glGetUniformLocation( shaderProg, uniformName.data() );
}


Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow