示例#1
0
	//---------------------------------------------------------------------
	String GpuProgramManager::addRenderSystemToName( const String & name )
	{
		// Use the current render system
		RenderSystem* rs = Root::getSingleton().getRenderSystem();

		return rs->getName() + "_" + name;
	}
示例#2
0
void xObjBound::Render(Event * sender)
{
	if (xApp::Instance()->GetSelectedObjSize() == 0)
		return ;

	if (xApp::Instance()->GetSelectedObjSize() == 1 &&
		xApp::Instance()->GetSelectedObj(0)->GetColMesh() != NULL &&
		xApp::Instance()->GetSelectedObj(0)->GetColMesh()->GetPositions().Size() > 0 &&
		xApp::Instance()->GetSelectedObj(0)->GetColMesh()->GetIndices().Size() > 0)
	{
		RenderColMesh();
		return ;
	}

	Aabb box = Aabb::Invalid;

	for (int i = 0; i < xApp::Instance()->GetSelectedObjSize(); ++i)
	{
		xObj * obj = xApp::Instance()->GetSelectedObj(i);
		box = box.Merge(obj->GetBound());
	}

	Vec3 pos = box.GetCenter();
	Vec3 scale = box.GetSize();

	RenderSystem * render = RenderSystem::Instance();

	ShaderParam * uColor = mTech->GetPixelShaderParamTable()->GetParam("gColor");

	uColor->SetUnifom(1, 1, 0, 1);

	mRenderAABB->xform.MakeTransform(pos, Quat::Identity, scale);

	render->Render(mTech, mRenderAABB);
}
示例#3
0
    void UnderWaterCaustics::Render(Texture * colorTex, Texture * depthTex)
    {
        RenderSystem * render = RenderSystem::Instance();
        Camera * cam = World::Instance()->MainCamera();

        ShaderParam * uCornerLeftTop = mTech->GetPixelShaderParamTable()->GetParam("gCornerLeftTop");
        ShaderParam * uCornerRightDir = mTech->GetPixelShaderParamTable()->GetParam("gCornerRightDir");
        ShaderParam * uCornerDownDir = mTech->GetPixelShaderParamTable()->GetParam("gCornerDownDir");
        ShaderParam * uCameraPos = mTech->GetPixelShaderParamTable()->GetParam("gCameraPos");
        ShaderParam * uCausticsParam = mTech->GetPixelShaderParamTable()->GetParam("gCausticsParam");

        const Vec3 * corner = cam->GetWorldCorner();
        const Vec3 & camPos = cam->GetPosition();

        Vec3 cornerLeftTop = corner[4] - camPos;
        Vec3 cornerRightDir = corner[5] - corner[4];
        Vec3 cornerDownDir = corner[6] - corner[4];

        float waterY = 180;
        float depthLimit = 15;
        float uvScale = 0.05f;

        uCornerLeftTop->SetUnifom(cornerLeftTop.x, cornerLeftTop.y, cornerLeftTop.z, 0);
        uCornerRightDir->SetUnifom(cornerRightDir.x, cornerRightDir.y, cornerRightDir.z, 0);
        uCornerDownDir->SetUnifom(cornerDownDir.x, cornerDownDir.y, cornerDownDir.z, 0);
        uCameraPos->SetUnifom(camPos.x, camPos.y, camPos.z, 0);
        uCausticsParam->SetUnifom(waterY, depthLimit, uvScale, 0);

        SamplerState state;
        render->SetTexture(0, state,  depthTex);
        render->SetTexture(1, state,  colorTex);
        render->SetTexture(2, state,  GetTexture());

        RenderHelper::Instance()->DrawScreenQuad(BM_OPATICY, mTech);
    }
示例#4
0
    //-----------------------------------------------------------------------
    void Root::saveConfig(void)
    {
        if (mConfigFileName.empty ())
            return;

		std::ofstream of(mConfigFileName.c_str());

        if (!of)
            OGRE_EXCEPT(Exception::ERR_CANNOT_WRITE_TO_FILE, "Cannot create settings file.",
            "Root::saveConfig");

        if (mActiveRenderer)
        {
            of << "Render System=" << mActiveRenderer->getName() << std::endl;
        }
        else
        {
            of << "Render System=" << std::endl;
        }

        for (RenderSystemList::const_iterator pRend = getAvailableRenderers()->begin(); pRend != getAvailableRenderers()->end(); ++pRend)
        {
            RenderSystem* rs = *pRend;
            of << std::endl;
            of << "[" << rs->getName() << "]" << std::endl;
            const ConfigOptionMap& opts = rs->getConfigOptions();
            for (ConfigOptionMap::const_iterator pOpt = opts.begin(); pOpt != opts.end(); ++pOpt)
            {
				of << pOpt->first << "=" << pOpt->second.currentValue << std::endl;
            }
        }

        of.close();

    }
示例#5
0
	void Shadow::Do(Texture * depthTex)
	{
		RenderSystem * render = RenderSystem::Instance();

		RenderTarget * oldRt = render->GetRenderTarget(0);
		DepthStencil * oldDs = render->GetDepthStencil();

		_updateCamera();

		/*for (int i = 0; i < 4; ++i)
		{
		Mat4 matCrop = _calcuCropMatrix(i);
		mCascadedViewProjMatrix[i] = mLightCamera->GetViewProjMatrix() * matCrop;
		}*/

		_impVisibleCull();

		{
			RS_RenderEvent(ShadowMap);

			for (int i = 0; i < K_NumShadowLayers; ++i)
			{
				_calcuCascadedMatrix(i);
				_renderDepth(i);
				_genShadowMap(i, depthTex);
			}
		}

		render->SetRenderTarget(0, oldRt);
		render->SetDepthStencil(oldDs);
	}
    //---------------------------------------------------------------------
    void Viewport::setOrientationMode(OrientationMode orientationMode, bool setDefault)
    {
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE != 0
        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED,
                    "Setting Viewport orientation mode is not supported",
                    __FUNCTION__);
#endif
        mOrientationMode = orientationMode;

        if (setDefault)
        {
            setDefaultOrientationMode(orientationMode);
        }

        if (mCamera)
        {
            mCamera->setOrientationMode(mOrientationMode);
        }

    // Update the render system config
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
        RenderSystem* rs = Root::getSingleton().getRenderSystem();
        if(mOrientationMode == OR_LANDSCAPELEFT)
            rs->setConfigOption("Orientation", "Landscape Left");
        else if(mOrientationMode == OR_LANDSCAPERIGHT)
            rs->setConfigOption("Orientation", "Landscape Right");
        else if(mOrientationMode == OR_PORTRAIT)
            rs->setConfigOption("Orientation", "Portrait");
#endif
    }
	virtual void execute(SceneManager *sm, RenderSystem *rs)
	{
		// Fire listener
		instance->_fireNotifyMaterialRender(pass_id, mat);

        Rectangle2D * mRectangle=static_cast<Rectangle2D *>(CompositorManager::getSingleton()._getTexturedRectangle2D());
        if (mQuadCornerModified)
        {
            // insure positions are using peculiar render system offsets 
            RenderSystem* rs = Root::getSingleton().getRenderSystem();
            Viewport* vp = rs->_getViewport();
            Real hOffset = rs->getHorizontalTexelOffset() / (0.5 * vp->getActualWidth());
            Real vOffset = rs->getVerticalTexelOffset() / (0.5 * vp->getActualHeight());
            mRectangle->setCorners(mQuadLeft + hOffset, mQuadTop - vOffset, mQuadRight + hOffset, mQuadBottom - vOffset);
        }
        
		// Queue passes from mat
		Technique::PassIterator i = technique->getPassIterator();
		while(i.hasMoreElements())
		{
			sm->_injectRenderWithPass(
				i.getNext(), 
				mRectangle,
				false // don't allow replacement of shadow passes
				);
		}
	}
示例#8
0
 //-----------------------------------------------------------------------------
 const Matrix4& AutoParamDataSource::getProjectionMatrix(void) const
 {
     if (mProjMatrixDirty)
     {
         // NB use API-independent projection matrix since GPU programs
         // bypass the API-specific handedness and use right-handed coords
         if (mCurrentRenderable && mCurrentRenderable->getUseIdentityProjection())
         {
             // Use identity projection matrix, still need to take RS depth into account.
             RenderSystem* rs = Root::getSingleton().getRenderSystem();
             rs->_convertProjectionMatrix(Matrix4::IDENTITY, mProjectionMatrix, true);
         }
         else
         {
             mProjectionMatrix = mCurrentCamera->getProjectionMatrixWithRSDepth();
         }
         if (mCurrentRenderTarget && mCurrentRenderTarget->requiresTextureFlipping())
         {
             // Because we're not using setProjectionMatrix, this needs to be done here
             // Invert transformed y
             mProjectionMatrix[1][0] = -mProjectionMatrix[1][0];
             mProjectionMatrix[1][1] = -mProjectionMatrix[1][1];
             mProjectionMatrix[1][2] = -mProjectionMatrix[1][2];
             mProjectionMatrix[1][3] = -mProjectionMatrix[1][3];
         }
         mProjMatrixDirty = false;
     }
     return mProjectionMatrix;
 }
示例#9
0
void ParticleEmitterSystem::Update(float32 timeElapsed)
{
	uint32 size = emitters.size();
	Vector<ParticleEmitter*> emittersToBeDeleted;

	for(uint32 i = 0; i < size; ++i)
	{
		// Yuri Coder, 2013/05/15. Visible emitters are always updated, "deferred" update
		// is called for invisible ones. See pls issue #DF-1140.
		uint32 flags = emitters[i]->GetFlags();
        if ((flags & RenderObject::VISIBILITY_CRITERIA) == RenderObject::VISIBILITY_CRITERIA)
        {
            emitters[i]->Update(timeElapsed);
        }
		else
		{
			emitters[i]->DeferredUpdate(timeElapsed);
		}

		if (emitters[i]->IsToBeDeleted())
		{
			emittersToBeDeleted.push_back(emitters[i]);
		}
	}

	for(Vector<ParticleEmitter*>::iterator it = emittersToBeDeleted.begin(); it != emittersToBeDeleted.end(); ++it)
	{
		ParticleEmitter* partEmitter = (*it);
		RenderSystem* renderSystem = partEmitter->GetRenderSystem();
	
		renderSystem->RemoveFromRender(partEmitter);
		SafeRelease(partEmitter);
	}
}
示例#10
0
	void BillBoard::renderImpl( Matrix4 const& trans )
	{
		RenderSystem* system = getScene()->_getRenderSystem();

		Matrix4 mat = system->getViewMatrix();

		switch ( mBoardType )
		{
		case BT_CYLINDICAL_X:
			mat[ 0] = trans( 0 , 0 );
			mat[ 1] = trans( 0 , 1 );
			mat[ 2] = trans( 0 , 2 );
			break;
		case BT_CYLINDICAL_Y:
			mat[ 4] = trans( 1 , 0 );
			mat[ 5] = trans( 1 , 1 );
			mat[ 6] = trans( 1 , 2 );
			break;
		case BT_CYLINDICAL_Z:
			mat[ 8] = trans( 2 , 0 );
			mat[ 9] = trans( 2 , 1 );
			mat[10] = trans( 2 , 2 );
			break;
		case BT_SPHERIAL:
			break;
		}

		mat[12] = trans( 3 , 0 );
		mat[13] = trans( 3 , 1 );
		mat[14] = trans( 3 , 2 );
		mat.modifyTranslation( trans.getTranslation() );
		system->setWorldMatrix( mat );
		_renderInternal();
	}
示例#11
0
	void Object::_renderInternal()
	{
		Scene* scene = getScene();
		getScene()->getShaderParamSet()->setCurObject( this );

		RenderSystem* renderSystem = getScene()->_getRenderSystem();

		{
			CF_PROFILE( "SetupObjectRenderState" );
			if ( mUsageRenderOption )
				scene->_setupRenderOption( mRenderOption , mUsageRenderOption );

			renderSystem->setFillMode( mRenderMode );
		}

		for( MeshIterator iter = getElements(); iter.haveMore() ; iter.next() )
		{
			Element* ele = iter.get();

			unsigned restOptionBit = 0;
			float opacity = _evalOpacity( ele->getMaterial() );
			scene->_renderMesh( ele->getMesh() , ele->getMaterial() , mRenderMode , opacity , restOptionBit );

			if ( restOptionBit )
				scene->_setupRenderOption( mRenderOption , restOptionBit );
		}

		if ( mUsageRenderOption )
			scene->_setupDefultRenderOption( mUsageRenderOption );
	}
示例#12
0
bool TextureDemo::Render()
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	MainLoop *ml = MainLoop::Get();
	if (ml)
	{
		RenderSystem *rs = ml->RenderSys();
		if (rs)
		{
			unsigned int w = rs->screenWidth();
			unsigned int h = rs->screenHeight();
			if (w <= h)
				glOrtho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w,
					2.0 * (GLfloat) h / (GLfloat) w, -10.0, 10.0);
			else
				glOrtho(-2.0 * (GLfloat) w / (GLfloat) h,
					2.0 * (GLfloat) w / (GLfloat) h, -2.0, 2.0, -10.0, 10.0);
		}
	}

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glPushAttrib(GL_ALL_ATTRIB_BITS);
	theModel->Draw();
	glPopAttrib();

	return true;
}
/// @brief  Configures the render system ogre uses.
/// @return Returns true if a valid configuration was selected, false otherwise.
bool ServerGraphics::configureRenderer (void)
{
    // Automatically initialise with the config dialog
    //if (mRoot->showConfigDialog())
        //return true;
    //return false;

    // Manually initialise
    RenderSystem* rs = NULL;
    RenderSystemList systems = Root::getSingleton().getAvailableRenderers();

    // Check if any render systems exist
    if (systems.empty())
        return false;
    // Check if OpenGL is one of those rendering systems (should be)
    for (RenderSystemList::iterator itr = systems.begin(); itr != systems.end(); itr++)
        if (!strcmp((*itr)->getName().c_str(), "OpenGL Rendering Subsystem"))
            rs = *itr;
    // If it wasn't, default to the first renderer
    if (rs == NULL)
    {
        //OutputDebugString("OpenGL not found, defaulting to the first item.\n");
        rs = *systems.begin();
    }

    Root::getSingleton().setRenderSystem(rs);
    rs->setConfigOption("Video Mode", "640 x 480");
#ifdef _WIN32
    rs->setConfigOption("Colour Depth", "32");
#endif
    rs->setConfigOption("Full Screen", "No");
    rs->setConfigOption("FSAA", "0");

    return true;
}
示例#14
0
 //---------------------------------------------------------------------
 Viewport::Viewport(RenderTarget* target, Real left, Real top, Real width, Real height)
     : mGlobalIndex( -1 )
     , mTarget(target)
     , mRelLeft(left)
     , mRelTop(top)
     , mRelWidth(width)
     , mRelHeight(height)
     // Actual dimensions will update later
     , mUpdated(false)
     , mShowOverlays(true)
     , mShowSkies(true)
     , mVisibilityMask(0)
     , mRQSequence(0)
     , mMaterialSchemeName(MaterialManager::DEFAULT_SCHEME_NAME)
     , mColourBuffer(CBT_BACK)
 {           
     // Set the default orientation mode
     mOrientationMode = mDefaultOrientationMode;
         
     // Set the default material scheme
     RenderSystem* rs = Root::getSingleton().getRenderSystem();
     mMaterialSchemeName = rs->_getDefaultViewportMaterialScheme();
     
     // Calculate actual dimensions
     _updateDimensions();
 }
	void SDLWindow::copyContentsToMemory(const PixelBox &dst, FrameBuffer buffer)
	{
		if ((dst.left < 0) || (dst.right > mWidth) ||
			(dst.top < 0) || (dst.bottom > mHeight) ||
			(dst.front != 0) || (dst.back != 1))
		{
			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
						"Invalid box.",
						"SDLWindow::copyContentsToMemory" );
		}
	
		if (buffer == FB_AUTO)
		{
			buffer = mIsFullScreen? FB_FRONT : FB_BACK;
		}
	
		GLenum format = Ogre::GLPixelUtil::getGLOriginFormat(dst.format);
		GLenum type = Ogre::GLPixelUtil::getGLOriginDataType(dst.format);
	
		if ((format == GL_NONE) || (type == 0))
		{
			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
						"Unsupported format.",
						"SDLWindow::copyContentsToMemory" );
		}
	
		// Switch context if different from current one
		RenderSystem* rsys = Root::getSingleton().getRenderSystem();
		rsys->_setViewport(this->getViewport(0));
	
		// Must change the packing to ensure no overruns!
		glPixelStorei(GL_PACK_ALIGNMENT, 1);
	
		glReadBuffer((buffer == FB_FRONT)? GL_FRONT : GL_BACK);
		glReadPixels((GLint)dst.left, (GLint)dst.top,
					 (GLsizei)dst.getWidth(), (GLsizei)dst.getHeight(),
					 format, type, dst.data);
	
		// restore default alignment
		glPixelStorei(GL_PACK_ALIGNMENT, 4);
	
		//vertical flip
		{
			size_t rowSpan = dst.getWidth() * PixelUtil::getNumElemBytes(dst.format);
			size_t height = dst.getHeight();
			uchar *tmpData = new uchar[rowSpan * height];
			uchar *srcRow = (uchar *)dst.data, *tmpRow = tmpData + (height - 1) * rowSpan;
	
			while (tmpRow >= tmpData)
			{
				memcpy(tmpRow, srcRow, rowSpan);
				srcRow += rowSpan;
				tmpRow -= rowSpan;
			}
			memcpy(dst.data, tmpData, rowSpan * height);
	
			delete [] tmpData;
		}
	}
示例#16
0
    //---------------------------------------------------------------------
    Viewport::~Viewport()
    {
		RenderSystem* rs = Root::getSingleton().getRenderSystem();
		if ((rs) && (rs->_getViewport() == this))
		{
			rs->_setViewport(NULL);
		}
    }
示例#17
0
    //---------------------------------------------------------------------
    bool GpuProgramManager::canGetCompiledShaderBuffer()
    {
        // Use the current render system
        RenderSystem* rs = Root::getSingleton().getRenderSystem();

        // Check if the supported  
        return rs->getCapabilities()->hasCapability(RSC_CAN_GET_COMPILED_SHADER_BUFFER);
    }
示例#18
0
    //---------------------------------------------------------------------------
		const GpuProgramManager::SyntaxCodes& GpuProgramManager::getSupportedSyntax(void) const
        {
				// Use the current render system
			  RenderSystem* rs = Root::getSingleton().getRenderSystem();

				// Get the supported syntaxed from RenderSystemCapabilities 
				return rs->getCapabilities()->getSupportedShaderProfiles();
        }
示例#19
0
    //---------------------------------------------------------------------------
    bool GpuProgramManager::isSyntaxSupported(const String& syntaxCode) const
    {
        // Use the current render system
        RenderSystem* rs = Root::getSingleton().getRenderSystem();

        // Get the supported syntax from RenderSystemCapabilities 
        return rs->getCapabilities()->isShaderProfileSupported(syntaxCode);
    }
示例#20
0
	void Win32Window::writeContentsToFile(const String& filename)
	{
		ImageCodec::ImageData *imgData = new ImageCodec::ImageData();
		imgData->width = mWidth;
		imgData->height = mHeight;
		imgData->depth = 1;
		imgData->format = PF_BYTE_RGB;

		// Allocate buffer 
		uchar* pBuffer = new uchar[mWidth * mHeight * 3];

		// Switch context if different from current one
		RenderSystem* rsys = Root::getSingleton().getRenderSystem();
		rsys->_setViewport(this->getViewport(0));

		// Must change the packing to ensure no overruns!
		glPixelStorei(GL_PACK_ALIGNMENT, 1);

		// Read pixels
		// I love GL: it does all the locking & colour conversion for us
		if (mIsFullScreen)
			glReadBuffer(GL_FRONT);
		glReadPixels(0,0, mWidth, mHeight, GL_RGB, GL_UNSIGNED_BYTE, pBuffer);

		// restore default alignment
		glPixelStorei(GL_PACK_ALIGNMENT, 4);

		// Wrap buffer in a memory stream
		DataStreamPtr stream(new MemoryDataStream(pBuffer, mWidth * mHeight * 3, false));

		// Need to flip the read data over in Y though
		Image img;
		img.loadRawData(stream, mWidth, mHeight, imgData->format );
		img.flipAroundX();

		MemoryDataStreamPtr streamFlipped(new MemoryDataStream(img.getData(), stream->size(), false));

		// Get codec 
		size_t pos = filename.find_last_of(".");
		String extension;
		if( pos == String::npos )
			OGRE_EXCEPT(
			Exception::ERR_INVALIDPARAMS, 
			"Unable to determine image type for '" + filename + "' - invalid extension.",
			"Win32Window::writeContentsToFile" );

		while( pos != filename.length() - 1 )
			extension += filename[++pos];

		// Get the codec
		Codec * pCodec = Codec::getCodec(extension);

		// Write out
		Codec::CodecDataPtr ptr(imgData);
		pCodec->codeToFile(streamFlipped, filename, ptr);

		delete [] pBuffer;
	}
示例#21
0
    void renderQueueEnded(uint8 queueGroupId, const Ogre::String& invocation,
                          bool& repeatThisInvocation)
    {
        using namespace Ogre;

        if (queueGroupId == RENDER_QUEUE_6)
        {
            MaterialPtr material;
            // Also init full screen quad while we're at it
            if (!mFullScreenQuad)
            {
                mFullScreenQuad = new Rectangle2D();
                mFullScreenQuad->setCorners(-1,1,1,-1);
                material = mFullScreenQuad->getMaterial()->clone(StringConverter::toString((Ogre::ulong)mFullScreenQuad));
                mFullScreenQuad->setMaterial(material->getName());
                Pass* pass = material->getTechnique(0)->getPass(0);
                pass->setDepthCheckEnabled(false);
                pass->setDepthWriteEnabled(false);
                pass->setFog(true, FOG_NONE);
                pass->setLightingEnabled(true);
                pass->setAmbient(ColourValue::ZERO);
                pass->setDiffuse(ColourValue::ZERO);
                pass->setSpecular(ColourValue::ZERO);
                pass->setSelfIllumination(0, 1, 0);
            }
            else
            {
                material = mFullScreenQuad->getMaterial();
            }
            Pass* pass = material->getTechnique(0)->getPass(0);

            SceneManager* sm = Root::getSingleton()._getCurrentSceneManager();
            RenderSystem* rs = Root::getSingleton().getRenderSystem();

            rs->setStencilBufferParams(
                CMPF_EQUAL,
                0xFFFFFFFF, 0xFFFFFFFF,
                SOP_KEEP,
                SOP_INVERT,
                SOP_INVERT,
                false);
            pass->setColourWriteEnabled(false);
            sm->_injectRenderWithPass(pass, mFullScreenQuad, false);

            rs->setStencilBufferParams(
                CMPF_NOT_EQUAL,
                0, 0xFFFFFFFF,
                SOP_KEEP,
                SOP_KEEP,
                SOP_KEEP,
                false);
            pass->setColourWriteEnabled(true);
            sm->_injectRenderWithPass(pass, mFullScreenQuad, false);

            rs->setStencilCheckEnabled(false);
            rs->setStencilBufferParams();
        }
    }
示例#22
0
	//-----------------------------------------------------------------------
	bool D3D10HLSLProgram::isSupported(void) const
	{
		// Use the current render system
		RenderSystem* rs = Root::getSingleton().getRenderSystem();

		// Get the supported syntaxed from RenderSystemCapabilities 
		return rs->getCapabilities()->isShaderProfileSupported(mTarget) && GpuProgram::isSupported();

	}
void CameraSystem::setCurrentCamera(Entity* entity)
{
	_currentCamera = entity;

	RenderSystem* renderSystem = &RenderSystem::getRenderSystem();
	renderSystem->setCurrentCamera(_currentCamera);
	PlayerInputSystem* playerSystem = &PlayerInputSystem::getPlayerInputSystem();
	playerSystem->setCurrentPlayer(_currentCamera);
}
//--------------------------------------------------------------
void testApp::draw(){
    
    RenderSystem * rs = world->getSystemManager()->getSystem<RenderSystem>();
    rs->draw();
    
    ofSetColor(255, 255, 255);
    ofDrawBitmapString(ofToString((int) ofGetFrameRate()) + " fps", 32, 52);

}
示例#25
0
void RenderUpdateSystem::Process(float32 timeElapsed)
{
    TIME_PROFILE("RenderUpdateSystem::Process");

    RenderSystem * renderSystem = GetScene()->GetRenderSystem();
    renderSystem->SetMainCamera(GetScene()->GetCurrentCamera());
    renderSystem->SetDrawCamera(GetScene()->GetDrawCamera());

    GetScene()->GetRenderSystem()->Update(timeElapsed);
}
示例#26
0
文件: viewport.cpp 项目: lhharold/six
Viewport::~Viewport() {
    for (ListenerList::iterator i = mListeners.begin(); i != mListeners.end(); ++i) {
        (*i)->viewportDestroyed(this);
    }

    RenderSystem* rs = Root::get().getRenderSystem();
    if (rs && (rs->getViewport() == this)) {
        rs->setViewport(NULL);
    }
}
示例#27
0
BuildLayer::BuildLayer()
  : mState(STATE_READY),
    mStation(NULL), mCamera(NULL), mPrototype(NULL),
    mPortMesh(NULL), mPortTexture(NULL),
    mFocusMesh(NULL), mFocusTexture(NULL),
    mConnectionMesh(NULL), mConnectionTexture(NULL),
    mMouseOver(MOUSEOVER_BACKGROUND), mMouseOverModule(NULL), mMouseOverPortIndex(-1)
{
  RenderSystem* rSystem = rRenderSystem();

  mPortMesh = rSystem->createMesh(true);
  mPortMesh->load("assets/user_interface/port.shd");
  mPortTexture = rSystem->createTexture();
  mPortTexture->loadSolid(0, 0, 0xcf, 0xff);

  mSelectedMesh = rSystem->createMesh();
  mSelectedMesh->loadCube(10);
  mSelectedTexture = rSystem->createTexture();
  mSelectedTexture->loadSolid(0, 0, 0xcf, 0x5f);

  mFocusMesh = rSystem->createMesh();
  mFocusMesh->load("assets/user_interface/port.shd");
  mFocusTexture = rSystem->createTexture();
  mFocusTexture->loadSolid(0, 0, 0xff, 0xb0);

  mConnectionMesh = rSystem->createMesh();
  mConnectionMesh->load("assets/user_interface/connection_marker.shd");
  mConnectionTexture = rSystem->createTexture();
  mConnectionTexture->loadSolid(0, 0, 0xcf, 0xff);

  setReadyState();
}
示例#28
0
OcclusionQuery::~OcclusionQuery()
{
    mRendering->getScene()->removeRenderObjectListener (this);
    mRendering->getScene()->removeRenderQueueListener(this);

    RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();
    if (mSunTotalAreaQuery)
        renderSystem->destroyHardwareOcclusionQuery(mSunTotalAreaQuery);
    if (mSunVisibleAreaQuery)
        renderSystem->destroyHardwareOcclusionQuery(mSunVisibleAreaQuery);
}
示例#29
0
	//-----------------------------------------------------------------------------------
	PbsMaterial::PbsMaterial() : mAlbedo(1, 1, 1, 0), mF0(0.1f, 0.1f, 0.1f, 1.0f), mRoughness(0.1f), mLightRoughnessOffset(0.0f),
	/*header initial values*/	mMainUvSetIndex(0), mD1UvSetIndex(0), mD2UvSetIndex(0), _hasSamplerListChanged(false), 
								_hasSamplerChanged(false)
	{
		//Header initial values
		mMainOffset = Vector2::ZERO;
		mMainScale = Vector2::UNIT_SCALE;	
		mD1Offset = Vector2::ZERO;
		mD1Scale = Vector2::UNIT_SCALE;
		mD2Offset = Vector2::ZERO;
		mD2Scale = Vector2::UNIT_SCALE;

		_samplers[ST_ENV_MAP].init("environment", false, false, false, false, true, true, TEX_TYPE_CUBE_MAP);

		_samplers[ST_MAIN_ALBEDO].init("main_albedo", true, true, false, true);
		_samplers[ST_MAIN_NORMALR].init("main_normalr", false, true, true);
		_samplers[ST_MAIN_F0].init("main_f0", true, true);

		_samplers[ST_D1_ALBEDO].init("d1_albedo", true, true, false, true);
		_samplers[ST_D1_NORMALR].init("d1_normalr", false, true, true);
		_samplers[ST_D1_F0].init("d1_f0", true, true);

		_samplers[ST_D2_ALBEDO].init("d2_albedo", true, true, false, true);
		_samplers[ST_D2_NORMALR].init("d2_normalr", false, true, true);
		_samplers[ST_D2_F0].init("d2_f0", true, true);


		RenderSystem* rs = Root::getSingleton().getRenderSystem();

		String language = "";
		if (rs->getCapabilities()->isShaderProfileSupported("hlsl"))
		{
			language = "hlsl";
			mVertexDatablock.addProfile("vs_3_0");
			mFragmentDatablock.addProfile("ps_3_0");
		}
		else if (rs->getCapabilities()->isShaderProfileSupported("glsl"))
		{
			language = "glsl";
		}
		else 
		{
			language = "glsles";
		}

		mVertexDatablock.setLanguage(language);
		mFragmentDatablock.setLanguage(language);

		mVertexDatablock.setTemplateName("PBS");
		mFragmentDatablock.setTemplateName("PBS");

		// TODO check if the hardware supports gamma correction "Root::getSingleton().getRenderSystem()->getCapabilities()" doesen't support this check
		mCanHardwareGamma = false;
	}
示例#30
0
OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNode* sunNode) :
    mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0), mActiveQuery(0),
    mDoQuery(0), mSunVisibility(0),
    mWasVisible(false),
    mActive(false),
    mFirstFrame(true)
{
    mRendering = renderer;
    mSunNode = sunNode;

    try {
        RenderSystem* renderSystem = Root::getSingleton().getRenderSystem();

        mSunTotalAreaQuery = renderSystem->createHardwareOcclusionQuery();
        mSunVisibleAreaQuery = renderSystem->createHardwareOcclusionQuery();

        mSupported = (mSunTotalAreaQuery != 0) && (mSunVisibleAreaQuery != 0);
    }
    catch (Ogre::Exception& e)
    {
        mSupported = false;
    }

    if (!mSupported)
    {
        std::cout << "Hardware occlusion queries not supported." << std::endl;
        return;
    }

    mBBNodeReal = mRendering->getScene()->getRootSceneNode()->createChildSceneNode();

    static Ogre::Mesh* plane = MeshManager::getSingleton().createPlane("occlusionbillboard",
                               ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,  Ogre::Plane(Ogre::Vector3(0,0,1), 0), 1, 1, 1, 1, true, 1, 1, 1, Vector3::UNIT_Y).get();
    plane->_setBounds(Ogre::AxisAlignedBox::BOX_INFINITE);

    mBBQueryTotal = mRendering->getScene()->createEntity("occlusionbillboard");
    mBBQueryTotal->setCastShadows(false);
    mBBQueryTotal->setVisibilityFlags(RV_OcclusionQuery);
    mBBQueryTotal->setRenderQueueGroup(RQG_OcclusionQuery+1);
    mBBQueryTotal->setMaterialName("QueryTotalPixels");
    mBBNodeReal->attachObject(mBBQueryTotal);

    mBBQueryVisible = mRendering->getScene()->createEntity("occlusionbillboard");
    mBBQueryVisible->setCastShadows(false);
    mBBQueryVisible->setVisibilityFlags(RV_OcclusionQuery);
    mBBQueryVisible->setRenderQueueGroup(RQG_OcclusionQuery+1);
    mBBQueryVisible->setMaterialName("QueryVisiblePixels");
    mBBNodeReal->attachObject(mBBQueryVisible);

    mRendering->getScene()->addRenderObjectListener(this);
    mRendering->getScene()->addRenderQueueListener(this);
    mDoQuery = true;
}