//------------------------------------------------------------------------ void TBuilder_Model_Ogre::Build() { mFGI = TModuleLogic::Get()->GetFGI(); int cntPart = mPatternModel->mMngNode_Collection.GetCountPart(); for( int iPart = 0 ; iPart < cntPart ; iPart++ ) { std::string namePart = mPatternModel->mMngNode_Collection.GetNamePart(iPart); int cntVariant = mPatternModel->mMngNode_Collection.GetCountVariant(namePart); for( int iVariant = 0 ; iVariant < cntVariant ; iVariant++ ) { std::string nameVariant = mPatternModel->mMngNode_Collection.GetNameVariant(namePart, iVariant); TBaseNode_Model* pNode = mPatternModel->mMngNode_Collection.Get(namePart, nameVariant); if( pNode==NULL ) continue; if( mPatternModel->GetTypeContent()==TModelItem::eModel ) { TModelNode_Model* pModelNode = (TModelNode_Model*)pNode; pModelNode->mPtrModel->BuildByModule_Graphic(); } else { TShapeNode_Model* pShapeNode = (TShapeNode_Model*)pNode; BuildShape(pShapeNode); } } } PostBuild(); }
bool CRhGLShaderProgram::BuildProgram(const GLchar* VertexShader, const GLchar* FragmentShader) { // Shaders MUST consist of both a vertex AND a fragment shader in 2.0... if ( (VertexShader == NULL) || (FragmentShader == NULL) ) return false; PreBuild(); GLuint hVsh = BuildShader( VertexShader, GL_VERTEX_SHADER ); GLuint hFsh = BuildShader( FragmentShader, GL_FRAGMENT_SHADER ); if ( (hVsh == 0) || (hFsh == 0) ) return false; m_hProgram = glCreateProgram(); if ( m_hProgram == 0 ) return false; glAttachShader( m_hProgram, hVsh ); glAttachShader( m_hProgram, hFsh ); // These bindings are forced here so that mesh drawing can enable the // appropriate vertex array based on the same binding values. // Note: These must be done before we attempt to link the program... // Note2: Rhino supports multiple textures but for now we'll only // provide for a single set of texture coordinates. glBindAttribLocation( m_hProgram, ATTRIB_VERTEX, "rglVertex" ); glBindAttribLocation( m_hProgram, ATTRIB_NORMAL, "rglNormal" ); glBindAttribLocation( m_hProgram, ATTRIB_TEXCOORD0, "rglTexCoord0" ); glBindAttribLocation( m_hProgram, ATTRIB_COLOR, "rglColor" ); glLinkProgram( m_hProgram ); GLint Success; glGetProgramiv( m_hProgram, GL_LINK_STATUS, &Success ); if ( Success == GL_FALSE ) { #if defined(_DEBUG) GLint logLength; glGetProgramiv( m_hProgram, GL_INFO_LOG_LENGTH, &logLength ); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetProgramInfoLog( m_hProgram, logLength, &logLength, log); std::cout << "Program link log:\n" << log; free(log); } #endif glDetachShader( m_hProgram, hVsh ); glDetachShader( m_hProgram, hFsh ); glDeleteProgram( m_hProgram ); m_hProgram = 0; } glDeleteShader( hVsh ); glDeleteShader( hFsh ); if ( m_hProgram == 0 ) return false; PostBuild(); return true; }