void Drawable::compileGLObjects(RenderInfo& renderInfo) const { #ifdef OSG_GL_DISPLAYLISTS_AVAILABLE if (!renderInfo.getState()->useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects) && _useDisplayList) { // get the contextID (user defined ID of 0 upwards) for the // current OpenGL context. unsigned int contextID = renderInfo.getContextID(); // get the globj for the current contextID. GLuint& globj = _globjList[contextID]; // call the globj if already set otherwise compile and execute. if( globj != 0 ) { glDeleteLists( globj, 1 ); } globj = generateDisplayList(contextID, getGLObjectSizeHint()); glNewList( globj, GL_COMPILE ); drawInner(renderInfo); glEndList(); } #endif }
void ComputeDispatch::drawImplementation(RenderInfo& renderInfo) const { renderInfo.getState()->get<GLExtensions>()->glDispatchCompute(_numGroupsX, _numGroupsY, _numGroupsZ); }
void Drawable::draw(RenderInfo& renderInfo) const { State& state = *renderInfo.getState(); bool useVertexArrayObject = state.useVertexArrayObject(_useVertexArrayObject); if (useVertexArrayObject) { unsigned int contextID = renderInfo.getContextID(); VertexArrayState* vas = _vertexArrayStateList[contextID].get(); if (!vas) { _vertexArrayStateList[contextID] = vas = createVertexArrayState(renderInfo, true); // OSG_NOTICE<<" Geometry::draw() "<<this<<", assigned _vertexArrayStateList[renderInfo.getContextID()]="<<_vertexArrayStateList[renderInfo.getContextID()].get()<<", vas="<<vas<< std::endl; } else { // vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC); // OSG_NOTICE<<" Geometry::draw() "<<this<<", reusing _vertexArrayStateList[renderInfo.getContextID()]="<<_vertexArrayStateList[renderInfo.getContextID()].get()<<", vas="<<vas<< std::endl; } State::SetCurrentVertexArrayStateProxy setVASProxy(state, vas); vas->bindVertexArrayObject(); drawInner(renderInfo); vas->setRequiresSetArrays(getDataVariance()==osg::Object::DYNAMIC); return; } // TODO, add check against whether VAO is active and supported if (state.getCurrentVertexArrayState()) state.getCurrentVertexArrayState()->bindVertexArrayObject(); #ifdef OSG_GL_DISPLAYLISTS_AVAILABLE if (!state.useVertexBufferObject(_supportsVertexBufferObjects && _useVertexBufferObjects) && _useDisplayList) { // get the contextID (user defined ID of 0 upwards) for the // current OpenGL context. unsigned int contextID = renderInfo.getContextID(); // get the globj for the current contextID. GLuint& globj = _globjList[contextID]; if( globj == 0 ) { // compile the display list globj = generateDisplayList(contextID, getGLObjectSizeHint()); glNewList( globj, GL_COMPILE ); drawInner(renderInfo); glEndList(); } // call the display list glCallList( globj); } else #endif { // if state.previousVertexArrayState() is different than currentVertexArrayState bind current // OSG_NOTICE<<"Fallback drawInner()........................"<<std::endl; drawInner(renderInfo); } }
void coVolumeDrawable::drawImplementation(RenderInfo &renderInfo) const { vvDebugMsg::msg(3, "coVolumeDrawable::drawImplementation()"); const unsigned ctx = renderInfo.getState()->getContextID(); while (ctx >= contextState.size()) { // this will delete the old renderer contextState.resize(ctx+1); ContextState *nc = new ContextState; contextState.push_back(nc); } vvRenderer *&renderer = contextState[ctx]->renderer; if (vd && !renderer) { // Debug level value may be either [NO_MESSAGES|FEW_MESSAGES|MOST_MESSAGES|ALL_MESSAGES] // Or, in the same order and meaning the same as the string equivalents [0|1|2|3] bool debugLevelExists = false; const int debugLevelInt = covise::coCoviseConfig::getInt("COVER.Plugin.Volume.DebugLevel", 0, &debugLevelExists); if (debugLevelExists) { if ((debugLevelInt >= 0) && (debugLevelInt <= 9)) { vvDebugMsg::setDebugLevel(debugLevelInt); } else { // In that case, the debug level was specified as a string literal std::string debugLevelStr = covise::coCoviseConfig::getEntry("COVER.Plugin.Volume.DebugLevel"); if (!debugLevelStr.empty()) { if (strcasecmp(debugLevelStr.c_str(), "NO_MESSAGES") == 0) { vvDebugMsg::setDebugLevel(vvDebugMsg::NO_MESSAGES); } else if (strcasecmp(debugLevelStr.c_str(), "FEW_MESSAGES") == 0) { vvDebugMsg::setDebugLevel(vvDebugMsg::FEW_MESSAGES); } else if (strcasecmp(debugLevelStr.c_str(), "MOST_MESSAGES") == 0) { vvDebugMsg::setDebugLevel(vvDebugMsg::MOST_MESSAGES); } else if (strcasecmp(debugLevelStr.c_str(), "ALL_MESSAGES") == 0) { vvDebugMsg::setDebugLevel(vvDebugMsg::ALL_MESSAGES); } } } } bool imageScalingExists = false; const bool useOffscreenBuffer = covise::coCoviseConfig::isOn("imageScaling", "COVER.Plugin.Volume.Renderer", false, &imageScalingExists); bool numGPUSlavesExists = false; const char **displayNames = NULL; virvo::BufferPrecision multiGpuPrecision = virvo::Short; const int numGPUSlaves = covise::coCoviseConfig::getInt("COVER.Plugin.Volume.MultiGPU.NumSlaves", -1, &numGPUSlavesExists); std::vector<const char *> hostnames; std::vector<int> ports; std::vector<const char *> alternativeFilenames; const bool useMultiGPU = numGPUSlavesExists; if (useMultiGPU) { // Buffer precision for multi gpu rendering slaves. // As with debug level. May either be [BYTE|SHORT|FLOAT] // or equivalently [8|16|32] bool bufferPrecisionExists; const int precisionInt = covise::coCoviseConfig::getInt("COVER.Plugin.Volume.MultiGPU.BufferPrecision", 16, &bufferPrecisionExists); if (bufferPrecisionExists) { if ((precisionInt == 8) || (precisionInt == 16) || (precisionInt == 32)) { if (precisionInt == 8) multiGpuPrecision = virvo::Byte; else if (precisionInt == 16) multiGpuPrecision = virvo::Short; else multiGpuPrecision = virvo::Float; } else { // In that case, the buffer precision was specified as a string literal std::string precisionStr = covise::coCoviseConfig::getEntry("COVER.Plugin.Volume.MultiGPU.BufferPrecision"); if (strcasecmp(precisionStr.c_str(), "BYTE") == 0) { multiGpuPrecision = virvo::Byte; } else if (strcasecmp(precisionStr.c_str(), "SHORT") == 0) { multiGpuPrecision = virvo::Short; } else if (strcasecmp(precisionStr.c_str(), "FLOAT") == 0) { multiGpuPrecision = virvo::Float; } } } displayNames = new const char *[numGPUSlaves]; for (int i = 0; i < numGPUSlaves; ++i) { std::stringstream disp; disp << "COVER.Plugin.Volume.MultiGPU.GPU:"; disp << i; std::string entry = covise::coCoviseConfig::getEntry("display", disp.str()); #ifdef VERBOSE cerr << "Use additional GPU for rendering on display: " << entry << endl; #endif char *cstr = new char[strlen(entry.c_str()) + 1]; strncpy(cstr, entry.c_str(), strlen(entry.c_str())); displayNames[i] = cstr; } } renderer = vvRendererFactory::create(vd, renderState, geoType.c_str(), voxType.c_str()); if (renderer) { renderer->setParameter(vvRenderer::VV_OFFSCREENBUFFER, useOffscreenBuffer); } } // if a renderer exists, process regular rendering procedure if (renderer) { for (std::vector<vvRenderState::ParameterType>::iterator it = contextState[ctx]->parameterChanges.begin(); it != contextState[ctx]->parameterChanges.end(); ++it) { renderer->setParameter(*it, renderState.getParameter(*it)); } contextState[ctx]->parameterChanges.clear(); if (contextState[ctx]->applyTF) { renderer->updateTransferFunction(); contextState[ctx]->applyTF = false; } ref_ptr<StateSet> currentState = new StateSet; renderInfo.getState()->captureCurrentState(*currentState); renderInfo.getState()->pushStateSet(currentState.get()); renderer->setCurrentFrame(currentFrame); //renderer->setQuality(quality); renderer->setViewingDirection(viewDir); renderer->setObjectDirection(objDir); renderer->renderFrame(); renderInfo.getState()->popStateSet(); } else { //cerr << "vd==NULL" << endl; } }