MenuStateGraphicInfo::MenuStateGraphicInfo(Program *program, MainMenu *mainMenu): MenuState(program, mainMenu, "info") { Lang &lang= Lang::getInstance(); containerName = "GraphicInfo"; buttonReturn.registerGraphicComponent(containerName,"buttonReturn"); buttonReturn.init(100, 540, 125); buttonReturn.setText(lang.getString("Return")); labelInfo.registerGraphicComponent(containerName,"labelInfo"); labelInfo.init(0, 730); labelMoreInfo.registerGraphicComponent(containerName,"labelMoreInfo"); labelMoreInfo.init(0, 520); labelMoreInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelMoreInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); labelInternalInfo.registerGraphicComponent(containerName,"labelInternalInfo"); labelInternalInfo.init(300, 730); labelInternalInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelInternalInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); GraphicComponent::applyAllCustomProperties(containerName); Renderer &renderer= Renderer::getInstance(); string glInfo= renderer.getGlInfo(); string glMoreInfo= renderer.getGlMoreInfo(); labelInfo.setText(glInfo); labelMoreInfo.setText(glMoreInfo); string strInternalInfo = ""; strInternalInfo += "VBOSupported: " + boolToStr(getVBOSupported()); if(getenv("MEGAGLEST_FONT") != NULL) { char *tryFont = getenv("MEGAGLEST_FONT"); strInternalInfo += "\nMEGAGLEST_FONT: " + string(tryFont); } strInternalInfo += "\nforceLegacyFonts: " + boolToStr(Font::forceLegacyFonts); strInternalInfo += "\nrenderText3DEnabled: " + boolToStr(Renderer::renderText3DEnabled); strInternalInfo += "\nuseTextureCompression: " + boolToStr(Texture::useTextureCompression); strInternalInfo += "\nfontIsRightToLeft: " + boolToStr(Font::fontIsRightToLeft); strInternalInfo += "\nscaleFontValue: " + floatToStr(Font::scaleFontValue); strInternalInfo += "\nscaleFontValueCenterHFactor: " + floatToStr(Font::scaleFontValueCenterHFactor); strInternalInfo += "\nlangHeightText: " + Font::langHeightText; strInternalInfo += "\nAllowAltEnterFullscreenToggle: " + boolToStr(Window::getAllowAltEnterFullscreenToggle()); strInternalInfo += "\nTryVSynch: " + boolToStr(Window::getTryVSynch()); strInternalInfo += "\nVERBOSE_MODE_ENABLED: " + boolToStr(SystemFlags::VERBOSE_MODE_ENABLED); labelInternalInfo.setText(strInternalInfo); }
void ModelRendererGl::renderMeshNormals(Mesh *mesh) { if(getVBOSupported() == true && mesh->getFrameCount() == 1) { if(mesh->hasBuiltVBOEntities() == false) { mesh->BuildVBOs(); } //printf("Rendering Mesh Normals with VBO's\n"); //vertices glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBOVertices() ); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL ); // Set The Vertex Pointer To The Vertex Buffer //glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); //normals glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBONormals() ); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, (char *) NULL); //glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); //misc vars uint32 vertexCount= mesh->getVertexCount(); uint32 indexCount= mesh->getIndexCount(); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mesh->getVBOIndexes() ); glDrawRangeElements(GL_TRIANGLES, 0, vertexCount-1, indexCount, GL_UNSIGNED_INT, (char *)NULL); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } else { //printf("Rendering Mesh Normals WITHOUT VBO's\n"); glBegin(GL_LINES); for(unsigned int i = 0; i < mesh->getIndexCount(); ++i) { const Vec3f &vertex= mesh->getInterpolationData()->getVertices()[mesh->getIndices()[i]]; const Vec3f &normal= vertex + mesh->getInterpolationData()->getNormals()[mesh->getIndices()[i]]; glVertex3fv(vertex.ptr()); glVertex3fv(normal.ptr()); } glEnd(); } }
void MenuStateGraphicInfo::reloadUI() { Lang &lang= Lang::getInstance(); console.resetFonts(); buttonReturn.setText(lang.getString("Return")); labelMoreInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelMoreInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); labelInternalInfo.setFont(CoreData::getInstance().getDisplayFontSmall()); labelInternalInfo.setFont3D(CoreData::getInstance().getDisplayFontSmall3D()); Renderer &renderer= Renderer::getInstance(); string glInfo= renderer.getGlInfo(); string glMoreInfo= renderer.getGlMoreInfo(); labelInfo.setText(glInfo); labelMoreInfo.setText(glMoreInfo); string strInternalInfo = ""; strInternalInfo += "VBOSupported: " + boolToStr(getVBOSupported()); if(getenv("MEGAGLEST_FONT") != NULL) { char *tryFont = getenv("MEGAGLEST_FONT"); strInternalInfo += "\nMEGAGLEST_FONT: " + string(tryFont); } strInternalInfo += "\nforceLegacyFonts: " + boolToStr(Font::forceLegacyFonts); strInternalInfo += "\nrenderText3DEnabled: " + boolToStr(Renderer::renderText3DEnabled); strInternalInfo += "\nuseTextureCompression: " + boolToStr(Texture::useTextureCompression); strInternalInfo += "\nfontIsRightToLeft: " + boolToStr(Font::fontIsRightToLeft); strInternalInfo += "\nscaleFontValue: " + floatToStr(Font::scaleFontValue); strInternalInfo += "\nscaleFontValueCenterHFactor: " + floatToStr(Font::scaleFontValueCenterHFactor); strInternalInfo += "\nlangHeightText: " + Font::langHeightText; strInternalInfo += "\nAllowAltEnterFullscreenToggle: " + boolToStr(Window::getAllowAltEnterFullscreenToggle()); strInternalInfo += "\nTryVSynch: " + boolToStr(Window::getTryVSynch()); strInternalInfo += "\nVERBOSE_MODE_ENABLED: " + boolToStr(SystemFlags::VERBOSE_MODE_ENABLED); labelInternalInfo.setText(strInternalInfo); GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName); }
void ModelRendererGl::renderMesh(Mesh *mesh,int renderMode) { if(renderMode==rmSelection && mesh->getNoSelect()==true) {// don't render this and do nothing return; } //assertions assertGl(); //glPolygonOffset(0.05f, 0.0f); //set cull face if(mesh->getTwoSided()) { glDisable(GL_CULL_FACE); } else{ glEnable(GL_CULL_FACE); } if(this->colorPickingMode == false) { //set color if(renderColors) { Vec4f color(mesh->getDiffuseColor(), mesh->getOpacity()); glColor4fv(color.ptr()); } //texture state const Texture2DGl *texture= static_cast<const Texture2DGl*>(mesh->getTexture(mtDiffuse)); if(texture != NULL && renderTextures) { if(lastTexture != texture->getHandle()){ //assert(glIsTexture(texture->getHandle())); //throw megaglest_runtime_error("glIsTexture(texture->getHandle()) == false for texture: " + texture->getPath()); if(glIsTexture(texture->getHandle()) == GL_TRUE) { glBindTexture(GL_TEXTURE_2D, texture->getHandle()); lastTexture= texture->getHandle(); } else { glBindTexture(GL_TEXTURE_2D, 0); lastTexture= 0; } } } else{ glBindTexture(GL_TEXTURE_2D, 0); lastTexture= 0; } if(meshCallback != NULL) { meshCallback->execute(mesh); } } //misc vars uint32 vertexCount= mesh->getVertexCount(); uint32 indexCount= mesh->getIndexCount(); //assertions assertGl(); if(getVBOSupported() == true && mesh->getFrameCount() == 1) { if(mesh->hasBuiltVBOEntities() == false) { mesh->BuildVBOs(); } //printf("Rendering Mesh with VBO's\n"); //vertices glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBOVertices() ); glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL ); // Set The Vertex Pointer To The Vertex Buffer //glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); //normals if(renderNormals) { glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBONormals() ); glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, (char *) NULL); //glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } else{ glDisableClientState(GL_NORMAL_ARRAY); } //tex coords if(renderTextures && mesh->getTexture(mtDiffuse) != NULL ) { if(duplicateTexCoords) { glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit); glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBOTexCoords() ); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // Set The TexCoord Pointer To The TexCoord Buffer //glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } glActiveTexture(GL_TEXTURE0); glBindBufferARB( GL_ARRAY_BUFFER_ARB, mesh->getVBOTexCoords() ); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL ); // Set The TexCoord Pointer To The TexCoord Buffer //glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } else { if(duplicateTexCoords) { glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } glActiveTexture(GL_TEXTURE0); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } else { //printf("Rendering Mesh WITHOUT VBO's\n"); //vertices glVertexPointer(3, GL_FLOAT, 0, mesh->getInterpolationData()->getVertices()); //normals if(renderNormals) { glEnableClientState(GL_NORMAL_ARRAY); glNormalPointer(GL_FLOAT, 0, mesh->getInterpolationData()->getNormals()); } else{ glDisableClientState(GL_NORMAL_ARRAY); } //tex coords if(renderTextures && mesh->getTexture(mtDiffuse)!=NULL ) { if(duplicateTexCoords) { glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, mesh->getTexCoords()); } glActiveTexture(GL_TEXTURE0); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, mesh->getTexCoords()); } else { if(duplicateTexCoords) { glActiveTexture(GL_TEXTURE0 + secondaryTexCoordUnit); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } glActiveTexture(GL_TEXTURE0); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } } if(getVBOSupported() == true && mesh->getFrameCount() == 1) { glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mesh->getVBOIndexes() ); glDrawRangeElements(GL_TRIANGLES, 0, vertexCount-1, indexCount, GL_UNSIGNED_INT, (char *)NULL); glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); //glDrawRangeElements(GL_TRIANGLES, 0, vertexCount-1, indexCount, GL_UNSIGNED_INT, mesh->getIndices()); } else { //draw model glDrawRangeElements(GL_TRIANGLES, 0, vertexCount-1, indexCount, GL_UNSIGNED_INT, mesh->getIndices()); } //assertions assertGl(); }