Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
void Drawable::compileGLObjects(RenderInfo& renderInfo) const
{
    if (!_useDisplayList) return;

#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
    // 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 );

    if (_drawCallback.valid())
        _drawCallback->drawImplementation(renderInfo,this);
    else
        drawImplementation(renderInfo);

    glEndList();
#else
    OSG_NOTICE<<"Warning: Drawable::compileGLObjects(RenderInfo&) - not supported."<<std::endl;
#endif
}
Ejemplo n.º 3
0
void PanoDrawable::drawImplementation(RenderInfo& ri) const
{
    if(ComController::instance()->isMaster() && !_renderOnMaster)
    {
	return;
    }

    int context = ri.getContextID();

    _initLock.lock();
    if(badinit)
    {
	if(_doDelete)
	{
	    if(_contextinit[ri.getContextID()] >  0)
	    {
		for(int i = 0; i < rows; i++)
		{
		    for(int j = 0; j < cols; j++)
		    {
			if(_contextinit[ri.getContextID()] & RIGHT)
			{
			    glDeleteTextures(1, rtextures[context][i][j]);
			    delete rtextures[context][i][j];
			}
			if(_contextinit[ri.getContextID()] & LEFT)
			{
			    glDeleteTextures(1, ltextures[context][i][j]);
			    delete ltextures[context][i][j];
			}
		    }
		}
		_contextinit[ri.getContextID()] = -1;
	    }
	    bool tempb = true;
	    for(map<int, int>::iterator it = _contextinit.begin(); it != _contextinit.end(); it++)
	    {
		if(it->second > 0)
		{
		    tempb = false;
		}
	    }
	    _deleteDone = tempb;
	}
	_initLock.unlock();
	return;
    } 

    /*string host;
    int vx, vy, context;

    context = ri.getContextID();
    
    vx = (int)ri.getCurrentCamera()->getViewport()->x();
    vy = (int)ri.getCurrentCamera()->getViewport()->y();

    char hostname[51];
    gethostname(hostname, 50);
    host = hostname;*/

    int eye = 0;

    if(!getNumParents())
    {
	_initLock.unlock();
	return;
    }

    osg::Node::NodeMask nm = getParent(0)->getNodeMask();
    //std::cerr << "Node Mask: " << nm << std::endl;
    if((nm & CULL_MASK) || (nm & CULL_MASK_LEFT) )
    {
	//std::cerr << "LEFT" << std::endl;
	if(ScreenBase::getEyeSeparation() >= 0.0)
	{
	    eye = LEFT;
	}
	else
	{
	    eye = RIGHT;
	}
    }
    else
    {
	//std::cerr << "RIGHT" << std::endl;
	if(ScreenBase::getEyeSeparation() >= 0.0)
	{
	    eye = RIGHT;
	}
	else
	{
	    eye = LEFT;
	}
    }

    if(_contextinit[ri.getContextID()] >= 0)
    {
	if(!(_contextinit[ri.getContextID()] & eye))
	{
	    _initLock.unlock();
	    bool val = initTexture((PanoDrawable::eye)eye, context);
	    _initLock.lock();
	    if(val)
	    {
		_contextinit[ri.getContextID()] |= eye;
	    }
	    else
	    {
		badinit = 1;
		_initLock.unlock();
		return;
	    }
	}
    }

    if(_doDelete)
    {
	if(_contextinit[ri.getContextID()] >  0)
	{
	    for(int i = 0; i < rows; i++)
	    {
		for(int j = 0; j < cols; j++)
		{
		    if(_contextinit[ri.getContextID()] & RIGHT)
		    {
			glDeleteTextures(1, rtextures[context][i][j]);
			delete rtextures[context][i][j];
		    }
		    if(_contextinit[ri.getContextID()] & LEFT)
		    {
			glDeleteTextures(1, ltextures[context][i][j]);
			delete ltextures[context][i][j];
		    }
		}
	    }
	    _contextinit[ri.getContextID()] = -1;
	}
	bool tempb = true;
	for(map<int, int>::iterator it = _contextinit.begin(); it != _contextinit.end(); it++)
	{
	    if(it->second > 0)
	    {
		tempb = false;
	    }
	}
	_deleteDone = tempb;
	_initLock.unlock();
	return;
    }

    _initLock.unlock();

    _rcLock.lock();
    drawShape((PanoDrawable::eye)eye, context);
    _rcLock.unlock();
}
Ejemplo n.º 4
0
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);
    }
}