void PassForward_Indicators::draw()
{
    //return;
    if(!atmGetGame()) { return; }

    i3d::DeviceContext *dc  = atmGetGLDeviceContext();
    VertexArray  *va_grid = atmGetVertexArray(VA_FIELD_GRID);
    AtomicShader *sh_grid = atmGetShader(SH_FILL3D);
    RenderTarget *rt = atmGetBackRenderTarget();

    rt->setDepthStencilBuffer(atmGetRenderTarget(RT_GBUFFER)->getDepthStencilBuffer());
    dc->setBlendState(atmGetBlendState(BS_BLEND_ALPHA));
    dc->setDepthStencilState(atmGetDepthStencilState(DS_DEPTH_ENABLED));
    dc->setRenderTarget(rt);

    sh_grid->bind();
    dc->setVertexArray(va_grid);
    dc->draw(I3D_LINES, 0, 6*6*2);
    dc->setVertexArray(nullptr);
    sh_grid->unbind();

    dc->setDepthStencilState(atmGetDepthStencilState(DS_NO_DEPTH_NO_STENCIL));
    dc->setBlendState(atmGetBlendState(BS_NO_BLEND));
    rt->setDepthStencilBuffer(nullptr);
}
Пример #2
0
void CCPlus::go(const std::string& path, int fps) {
    RenderTarget target;
    target.inputPath = path;
    target.fps = fps;
    go(target);
    target.waitFinish();
}
Пример #3
0
void MainWindow::newRenderTarget(SceneController* scene, char* name)
{
    char buf[256];
    bool ret;

    RenderTarget* renderTarget = new RenderTarget();
    renderTarget->setScene(scene);

    scene->setSceneRect(0, 0, ui->tabWidget->size().width(), ui->tabWidget->size().height());
    scene->setBackgroundBrush(QBrush(QColor(0, 0, 0)));

    renderTarget->setFixedSize(ui->tabWidget->size().width(), ui->tabWidget->size().height());
    renderTarget->setAlignment(Qt::AlignTop);
    renderTarget->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

    if (m_connectedSender) {
        ret = disconnect(m_connectedSender, SIGNAL(statusChanged()), this, SLOT(statusChanged()));
        assert(ret == true);
    }

    ret = connect(scene, SIGNAL(statusChanged()), this, SLOT(statusChanged()), Qt::UniqueConnection);
    assert(ret == true);

    m_connectedSender = scene;

    int idx = ui->tabWidget->addTab(renderTarget, name);
    ui->tabWidget->setCurrentIndex(idx);

    sprintf(buf, "New surface pool: %s", name);
    ui->label->setText(buf);
}
Пример #4
0
void ObjectInterface::drawObjects(RenderTarget &target) {
	if (cb->mapInterface->getTileMap() == 0 && firstFloorObject == 0 && firstObject == 0) {
		// No objects to be drawn
		return;
	}
	target.setAsCurrent();
	//al_hold_bitmap_drawing(true); //Little speed up

	// All objects are drawn at world coordinates.
	target.useWorldCoords(true);

	// Draw floor objects, including map back layer
	CBObject *currentObject = firstFloorObject;
	while (currentObject != 0) {
		currentObject->render(target);
		currentObject = currentObject->afterObj;
	}

	// Draw normal objects
	currentObject = firstObject;
	while (currentObject != 0) {
		currentObject->render(target);
		currentObject = currentObject->afterObj;
	}

	// Draw map over layer
	if (cb->mapInterface->getTileMap()) {
		cb->mapInterface->getTileMap()->drawLayer(1, target);
	}

	//al_hold_bitmap_drawing(false);

	// Reset drawing to screen
	target.useWorldCoords(false);
}
Пример #5
0
  void Graphics::Initialize()
  {

    
    
    WickedSick::Window* window = core_->GetSystem<WickedSick::Window>(ST_Window);
    std::lock_guard<std::mutex> lk(window->GetWindowHandleMutex());

    graphicsAPI->Initialize(options_, window);

    // Setup the projection matrix.
    float fieldOfView = (float)PI / 2.0f;//90 degrees
    float screenAspect = (float)window->GetWindowSize().x / (float)window->GetWindowSize().y;

    // Create the projection matrix for 3D rendering.
    projection_matrix_.DoPerspective(90.0 * PI/180.0, 0.1f, 100000.0f, screenAspect);
    orthographic_matrix_.DoOrthographic(window->GetWindowSize().x, window->GetWindowSize().y, 0.1f, 100000.0f);
    camera_->SetPosition(0.0f, 0.0f, 0.0f);

    mat_stack_->Push(projection_matrix_);
    
    RenderTargetDesc desc;
    desc.size = window->GetWindowSize();
    
    RenderTarget* reflectionTarget = nullptr;
    for(int i = 0; i < ReflectionDirections::Count; ++i)
    {
      reflectionTarget = graphicsAPI->MakeRenderTarget(desc);
      reflectionTarget->Initialize();
      render_targets_.push_back(reflectionTarget);
    }
  }
Пример #6
0
DeferredShadingSystem::~DeferredShadingSystem()
{
	// Delete mini lights
	for(std::set<MLight*>::iterator i=mLights.begin(); i!=mLights.end(); ++i)
	{
		delete (*i);
	}
	// Delete the ambient light
	delete mAmbientLight;

	if (mCurrentMode==DSM_SHOWLIT && mInstance[mCurrentMode]->getEnabled())
	{
		RenderTarget* renderTarget = mInstance[mCurrentMode]->getRenderTarget("mrt_output");
		assert(renderTarget);

		LogManager::getSingleton().logMessage("Removing Listener from:");
		LogManager::getSingleton().logMessage(renderTarget->getName());

		renderTarget->removeListener(this);
	}

	CompositorChain *chain = CompositorManager::getSingleton().getCompositorChain(mViewport);
	for(int i=0; i<DSM_COUNT; ++i)
		chain->_removeInstance(mInstance[i]);

	delete mLightMaterialGenerator;
}
Пример #7
0
void CarReflection::Update()
{
	// update only if we created
	if ( pSet->refl_mode == "single" && iIndex != 0 ) return;
	// static: only 1st frame
	if ( pSet->refl_mode == "static" && bFirstFrame == false ) return;
		
	//  skip frames
	if (++iCounter >= pSet->refl_skip || bFirstFrame)
	{
		iCounter = 0;
		//  cube faces at once
		int fc = bFirstFrame ? 6 : pSet->refl_faces;
		for (int i=0; i < fc; ++i)
		{
			++iCam;  if (iCam > 5)  iCam = 0;  // next

			Camera* cam = pCams[iCam];
			RenderTarget* rt = pRTs[iCam];

			if (cam) cam->setPosition ( camPosition );
				//else  LogO("upd cam 0");
			if (rt)  rt->update();
				//else  LogO("upd rt 0");
		}
	}

	//Image im;
	//cubetex->convertToImage(im);
	//im.save("cube.dds");

	bFirstFrame = false;
}
Пример #8
0
// All threads start execution here.
int main()
{
    void *frameBuffer;
    if (get_current_thread_id() != 0)
        worker_thread();

    // Set up render context
    frameBuffer = init_vga(VGA_MODE_640x480);

    start_all_threads();

    RenderContext *context = new RenderContext();
    RenderTarget *renderTarget = new RenderTarget();
    Surface *colorBuffer = new Surface(kFbWidth, kFbHeight, Surface::RGBA8888,
        frameBuffer);
    renderTarget->setColorBuffer(colorBuffer);
    context->bindTarget(renderTarget);
    context->bindShader(new ColorShader());

    const RenderBuffer kVertices(kSquareVertices, 4, 3 * sizeof(float));
    const RenderBuffer kIndices(kSquareIndices, 6, sizeof(int));
    context->bindVertexAttrs(&kVertices);
    context->drawElements(&kIndices);
    context->finish();
    return 0;
}
Пример #9
0
void WaterRTT::create()
{
	if (!mSceneMgr)  return;
	mCamera = mSceneMgr->createCamera("PlaneReflectionRefraction");
	if (mViewerCamera)
	{
		mCamera->setFarClipDistance(mViewerCamera->getFarClipDistance());
		mCamera->setNearClipDistance(mViewerCamera->getNearClipDistance());
		mCamera->setAspectRatio(mViewerCamera->getAspectRatio());
	}
	
	for (unsigned int i = 0; i < 2; ++i)
	{
		if (i==0 && !mReflect) continue;
		if (i==1 && !mRefract) continue;
		
		TexturePtr tex = TextureManager::getSingleton().createManual(i == 0 ? "PlaneReflection" : "PlaneRefraction",
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_2D, mRTTSize, mRTTSize, 0, PF_R8G8B8, TU_RENDERTARGET);

		RenderTarget* rtt = tex->getBuffer()->getRenderTarget();
		Viewport* vp = rtt->addViewport(mCamera);
		vp->setOverlaysEnabled(false);
		vp->setBackgroundColour(ColourValue(0.8f, 0.9f, 1.0f));
		vp->setShadowsEnabled(false);
		vp->setMaterialScheme ("reflection");
		vp->setVisibilityMask( i == 0 ? RV_WaterReflect : RV_WaterRefract);
		rtt->addListener(this);

		if (i == 0) mReflectionTarget = rtt;
		else mRefractionTarget = rtt;
	}

	sh::Factory::getInstance ().setTextureAlias ("WaterReflection", "PlaneReflection");
	sh::Factory::getInstance ().setTextureAlias ("WaterRefraction", "PlaneRefraction");
}
Пример #10
0
void CompositorRenderPass::Commit(CommitContext& context) {
	
	if (context.rsys->GetTicket() != this->renderSystemTicket)	{
		if (numTextureToResolve == 1) {
			TextureUnit tu;
			RenderTarget* target = context.GetTargetByName(_rtJustOne.name);
			if (target && target->GetRenderTargetType() == RenderTargetType::TEXTURE) {
				tu.texture = static_cast<RenderTexture*>(target);
				parameters.SetData(&tu, _rtJustOne.offset);
			}
		} else {
			for (uint32 i = 0; i < numTextureToResolve; ++i) {
				TextureUnit tu;
				RenderTarget* target = context.GetTargetByName(_rtBunchOf[i].name);
				if (target && target->GetRenderTargetType() == RenderTargetType::TEXTURE) {
					tu.texture = static_cast<RenderTexture*>(target);
					parameters.SetData(&tu, _rtBunchOf[i].offset);
				}
			}
		}
		this->renderSystemTicket = context.rsys->GetTicket();
	}

	BeginRender(context);
	RenderPrimitive(context, (uint32)(ptrdiff_t)this, &primitive);
	EndRender(context);
}
Пример #11
0
// All threads start execution here.
int main()
{
	if (__builtin_nyuzi_read_control_reg(0) != 0)
		workerThread();

	// Start worker threads
	__builtin_nyuzi_write_control_reg(30, 0xffffffff);

	RenderContext *context = new RenderContext();
	RenderTarget *renderTarget = new RenderTarget();
	Surface *colorBuffer = new Surface(kFbWidth, kFbHeight, (void*) 0x200000);
	Surface *depthBuffer = new Surface(kFbWidth, kFbHeight);
	renderTarget->setColorBuffer(colorBuffer);
	renderTarget->setDepthBuffer(depthBuffer);
	context->bindTarget(renderTarget);
	context->enableDepthBuffer(true);
	context->bindShader(new ColorShader());

	const RenderBuffer kVertices(kTriangleVertices, 6, 7 * sizeof(float));
	const RenderBuffer kIndices(kTriangleIndices, 6, sizeof(int));
	context->bindGeometry(&kVertices, &kIndices);
	context->submitDrawCommand();
	context->finish();
	exit(1);	// Stop worker threads
	return 0;
}
Пример #12
0
bool DXDriver::CreateRenderTarget(const unsigned int _id, const RenderTargetInit& _rti, RenderTarget* _renderTargetPtr)
{
	// Id already used
	if (m_pRenderTargets[_id] != nullptr)
		return false;

	RenderTarget* temp = VNEW RenderTarget(std::to_string(_id).c_str());

	// Failed to allocate mem
	if (!temp)
		return false;

	// Failed to initialize, delete allocated mem
	if (!temp->Init(_rti, m_device))
	{
		SAFE_DELETE(temp);
		return false;
	}

	// all is good
	m_pRenderTargets[_id]	= temp;
	_renderTargetPtr		= temp;

	return true;
}
Пример #13
0
	void Renderer::_renderCamera(Camera* cam)
	{
		RenderTarget* rt = cam->GetRenderTarget();
		if (!rt)
			return;
		cameraRendering = cam;

		rt->Bind();

		_setZWrite(true);
		_setZTest(true);
		glClearColor(0, 0, 0, 1);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		std::vector<Renderable*> sorted(renderables.begin(), renderables.end());
		std::sort(sorted.begin(), sorted.end(), renderableCompare());
		std::vector<Renderable*>::iterator rIt;
		for (rIt = sorted.begin(); rIt != sorted.end(); rIt++)
		{
			(*rIt)->Update();
			//_render(cam, (*rIt));
			(*rIt)->Render(cam);
		}

		//Go through post-processes
		_renderPostProcess(rt->GetPostProcess());
	}
Пример #14
0
	void SimpleSurface::applyFilter (Surface *inSrc, const Rect &inRect, ImagePoint inOffset, Filter *inFilter) {
		
		if (!mBase) return;
		FilterList f;
		f.push_back (inFilter);
		
		Rect src_rect (inRect.w, inRect.h);
		Rect dest = GetFilteredObjectRect (f, src_rect);
		
		inSrc->IncRef ();
		Surface *result = FilterBitmap (f, inSrc, src_rect, dest, false, ImagePoint (inRect.x, inRect.y));
		
		dest.Translate (inOffset.x, inOffset.y);
		
		src_rect = Rect (0, 0, result->Width (), result->Height ());
		int dx = dest.x;
		int dy = dest.y;
		dest = dest.Intersect (Rect (0, 0, mWidth, mHeight));
		dest.Translate (-dx, -dy);
		dest = dest.Intersect (src_rect);
		dest.Translate (dx, dy);
		
		int bpp = BytesPP ();
		
		RenderTarget t = BeginRender (dest, false);
		//printf("Copy back @ %d,%d %dx%d  + (%d,%d)\n", dest.x, dest.y, t.Width(), t.Height(), dx, dy);
		for (int y = 0; y < t.Height (); y++)
			memcpy ((void *)(t.Row (y + dest.y) + ((dest.x) * bpp)), result->Row (y - dy) - (dx * bpp), dest.w * bpp);
		
		EndRender ();
		
		result->DecRef ();
		
	}
Пример #15
0
		void render(float delta){
			float ClearColor[4] = { 0.5f, 0.5f, 0.5f, 1.0f }; // red,green,blue,alpha
			float ClearColor2[4] = { 0.1f, 0.2f, 0.3f, 1.0f }; // red,green,blue,alpha
			clearTargetColor(m_pRenderTargetView,ClearColor);
			clearTargetColor(*backTarget->getTarget(),ClearColor2);
			clearTargetDepth(m_depthStencilView,1);
			static float t=0;
			t+=delta;
			m_World = XMMatrixRotationY(t);
			ConstantBuffer cb;
			cb.mWorld = XMMatrixTranspose( m_World );
			cb.mView = XMMatrixTranspose( m_View );
			cb.mProjection = XMMatrixTranspose( m_Projection);
			people->updateConstantbuffer(m_pImmediateContext,0,&cb);
			
			m_pImmediateContext->OMSetRenderTargets(1,backTarget->getTarget(),m_depthStencilView);
			people->draw(m_pImmediateContext);
			clearTargetDepth(m_depthStencilView,1);
			m_pImmediateContext->OMSetRenderTargets(1,&m_pRenderTargetView,m_depthStencilView);
			people->draw(m_pImmediateContext);
			
			view_shader->use(m_pImmediateContext);
			m_pImmediateContext->PSSetShaderResources(0,1,backTarget->getShaderResource());
			view_shader->setConstantBuffer(m_pImmediateContext,0,&quard->s_Matrix);
			//quard->draw(m_pImmediateContext);

			controller->visite(m_pImmediateContext);
           
			//MyLuaManager::getInstance()->doFile("lua/lua_script/render.lua");
			presentDraw();
		}
Пример #16
0
//---------------------------------------------------------------------------------------------
void RenderSystem::attachRenderTarget( RenderTarget &target ) {
  assert( target.getPriority() < OGRE_NUM_RENDERTARGET_GROUPS );

  mRenderTargets.insert( RenderTargetMap::value_type( target.getName(), &target ) );
  mPrioritisedRenderTargets.insert(
    RenderTargetPriorityMap::value_type(target.getPriority(), &target ));
}
Пример #17
0
void CarReflection::Create()
{
	//bFirstFrame = true;
	if (pSet->refl_mode == 1)  cubetexName = "ReflectionCube"; // single: use 1st cubemap
	else if (pSet->refl_mode == 2)
	{
		cubetexName = "ReflectionCube" + toStr(iIndex);
		// first cubemap: no index
		if (cubetexName == "ReflectionCube0")
			cubetexName = "ReflectionCube";
	}
	else /* static */
		cubetexName = "ReflectionCube";
	
	TextureManager* tm = TextureManager::getSingletonPtr();
	int size = ciShadowSizesA[pSet->refl_size];  // /2 ?

	//  create cube render texture
	if ( !(pSet->refl_mode == 1 && iIndex != 0) )
	{
		cubetex = tm->createManual(cubetexName, 
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, TEX_TYPE_CUBE_MAP, 
			size,size, 0/*mips*/, PF_R8G8B8, TU_RENDERTARGET);
			//LogO("created rt cube");

		for (int face = 0; face < 6; face++)
		{
			Camera* mCam = pSceneMgr->createCamera("Reflect_" + toStr(iIndex) + "_" + toStr(face));
			mCam->setAspectRatio(1.0f);  mCam->setFOVy(Degree(90));
			mCam->setNearClipDistance(0.1);
			mCam->setFarClipDistance(pSet->refl_dist * 1.1f);

			RenderTarget* mRT = cubetex->getBuffer(face)->getRenderTarget();
			//LogO( "rt face Name: " + mRT->getName() );
			mRT->removeAllViewports();
			Viewport* vp = mRT->addViewport(mCam);
			vp->setOverlaysEnabled(false);
			vp->setVisibilityMask(RV_MaskReflect);
			vp->setShadowsEnabled(false);
			vp->setMaterialScheme ("reflection");
			mRT->setAutoUpdated(false);
			//mRT->addListener(this);  //-
			mCam->setPosition(Vector3::ZERO);

			Vector3 lookAt(0,0,0), up(0,0,0), right(0,0,0);  switch(face)
			{
				case 0:  lookAt.x =-1;  up.y = 1;  right.z = 1;  break;  // +X
				case 1:  lookAt.x = 1;  up.y = 1;  right.z =-1;  break;	 // -X
				case 2:  lookAt.y =-1;  up.z = 1;  right.x = 1;  break;	 // +Y
				case 3:  lookAt.y = 1;  up.z =-1;  right.x = 1;  break;	 // -Y
				case 4:  lookAt.z = 1;  up.y = 1;  right.x =-1;  break;	 // +Z
				case 5:  lookAt.z =-1;  up.y = 1;  right.x =-1;  break;	 // -Z
			}
			Quaternion orient( right, up, lookAt );  mCam->setOrientation( orient );
			pCams[face] = mCam;
			pRTs[face] = mRT;
		}
	}
}
Пример #18
0
	// 视口更新
	void AxisGridPlugin::postViewportUpdate(const RenderTargetViewportEvent& evt)
	{
		RenderTarget *target = evt.source->getTarget();
		char text[255];
		const RenderTarget::FrameStats& stats = target->getStatistics();
		sprintf(text , "FPS:%.2f TRI:%d BATCH:%d" , stats.avgFPS , stats.triangleCount , stats.batchCount);
		m_statElement->setCaption(text);
	}
Пример #19
0
void HUD::draw(RenderTarget& target, RenderStates states) const // Draws all UI
{
	target.draw(m_RPMSprite);
	target.draw(m_needle);
	target.draw(m_GearText);
	target.draw(m_TimerText);
	target.draw(m_BestTimeText);
}
Пример #20
0
bool OpenGLRenderer::renderModel3DWireframe(Model3D &model3D, const glm::vec4 &color, Camera &camera, RenderTarget &renderTarget)
{
    __(glDepthRangef(camera.getNear(), camera.getFar()));

    /* Enable wireframe mode */
    __(glPolygonMode(GL_FRONT_AND_BACK, GL_LINE));
    __(glEnable(GL_LINE_SMOOTH));
    __(glDisable(GL_CULL_FACE));

    /* Calculate MVP matrix */
    glm::mat4 MVP = camera.getPerspectiveMatrix() * camera.getViewMatrix() * model3D.getModelMatrix();

    /* Cast the model into an internal type */
    OpenGLAsset3D *glObject = static_cast<OpenGLAsset3D *>(model3D.getAsset3D());

    /* Set the color for the wireframe shader */
    _wireframeShader->setColor(color);

    /* Bind the render target */
    renderTarget.bind();
    {
        __(glEnable(GL_MULTISAMPLE));

        __(glEnable(GL_DEPTH_TEST));
        __(glDepthFunc(GL_LEQUAL));
        __(glBlendEquation(GL_FUNC_ADD));
        __(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
        __(glEnable(GL_BLEND));

        /* Bind program to upload the uniform */
        _wireframeShader->attach();

        /* Send our transformation to the currently bound shader, in the "MVP" uniform */
        _wireframeShader->setUniformMat4("u_MVPMatrix", &MVP);

        /* Set the shader custom parameters */
        _wireframeShader->setCustomParams();

        /* Draw the model */
        __(glBindVertexArray(glObject->getVertexArrayID()));
        {
            std::vector<uint32_t> offset = glObject->getIndicesOffsets();
            std::vector<uint32_t> count = glObject->getIndicesCount();

            for (size_t i = 0; i < offset.size(); ++i) {
                __(glDrawElements(GL_TRIANGLES, count[i], GL_UNSIGNED_INT, (void *)(offset[i] * sizeof(GLuint))));
            }
        }
        __(glBindVertexArray(0));

        /* Unbind */
        _wireframeShader->detach();
    }
    renderTarget.unbind();

    return true;
}
Пример #21
0
bool OpenGLRenderer::renderBoundingSphere(const BoundingSphere &sphere, const glm::vec3 &center, const glm::vec3 &color, Camera &camera,
                                          RenderTarget &renderTarget)
{
    /* Calculate MVP matrix, bounding box coordinates are already in world coordinates */
    glm::mat4 MVP = camera.getPerspectiveMatrix() * camera.getViewMatrix();

    /* Bind the render target */
    renderTarget.bind();
    {
        GLuint boxPosVAO, boxPosVBO;

        __(glEnable(GL_DEPTH_TEST));

        //__(glPolygonMode(GL_FRONT_AND_BACK, GL_FILL));
        //__(glEnable(GL_CULL_FACE));

        /* Bind program to upload the uniform */
        _renderBoundingSphere.attach();

        /* Send our transformation to the currently bound _renderBoundingSpheres, in the "MVP" uniform */
        _renderBoundingSphere.setUniformMat4("u_MVPMatrix", &MVP);
        _renderBoundingSphere.setUniformMat4("u_projectionMatrix", &camera.getPerspectiveMatrix());
        _renderBoundingSphere.setUniformVec3("u_boxColor", const_cast<glm::vec3 &>(color));
        _renderBoundingSphere.setUniformFloat("u_radius", sphere.getRadius());

        __(glGenVertexArrays(1, &boxPosVAO));
        __(glBindVertexArray(boxPosVAO));

        __(glGenBuffers(1, &boxPosVBO));

        __(glBindBuffer(GL_ARRAY_BUFFER, boxPosVBO));

        __(glBufferData(GL_ARRAY_BUFFER, sizeof center, &center[0], GL_STATIC_DRAW));

        __(glEnableVertexAttribArray(0));
        __(glVertexAttribPointer(0,  // attribute. No particular reason for 0, but must match the layout in the _renderBoundingSpheres.
                                 3,  // size
                                 GL_FLOAT,  // type
                                 GL_FALSE,  // normalized?
                                 0,         // stride
                                 (void *)0  // array buffer offset
                                 ));

        __(glDrawArrays(GL_POINTS, 0, 1));

        __(glBindVertexArray(0));

        __(glDeleteBuffers(1, &boxPosVBO));
        __(glDeleteVertexArrays(1, &boxPosVAO));

        /* Unbind */
        _renderBoundingSphere.detach();
    }
    renderTarget.unbind();

    return true;
}
Пример #22
0
void CarReflection::Update(bool first)
{
	if (!first)
	{
		// update only if we created
		if (pSet->refl_mode == 1 && iIndex != 0)  return;
		// static: only 1st frame
		if (pSet->refl_mode == 0)  return;
	}
		
	//  skip frames
	if (++iCounter >= pSet->refl_skip || first)
	{
		iCounter = 0;
		//  all cube faces at once
		int fc = first ? 6 : pSet->refl_faces;
		for (int i=0; i < fc; ++i)
		{
			++iCam;  if (iCam > 5)  iCam = 0;  // next

			Camera* cam = pCams[iCam];
			RenderTarget* rt = pRTs[iCam];
			
			Vector3 origScale, origPos;
			
			if (cam)
			{	
				cam->setPosition( camPosition );
				
				// Set skydome position to camera
				if (pApp->ndSky)
				{
					origScale = pApp->ndSky->getScale();
					origPos = pApp->ndSky->getPosition();
					
					pApp->ndSky->setScale(pSet->refl_dist * Vector3::UNIT_SCALE);
					pApp->ndSky->setPosition(camPosition);
				}
			}
				//else  LogO("upd cam 0");
			if (rt)  rt->update();
				//else  LogO("upd rt 0");
				
			// restore previous skydome position
			if (pApp->ndSky)
			{				
				pApp->ndSky->setScale(origScale);
				pApp->ndSky->setPosition(origPos);
			}
		}
	}

	//Image im;
	//cubetex->convertToImage(im);
	//im.save("cube.dds");
}
Пример #23
0
int GL_initializeFrameBuffers()
{
	debug_rendertarget.Create(client_rect.w, client_rect.h, false);
	rt_temp0.Create(client_rect.w, client_rect.h, false);
	rt_temp1.Create(client_rect.w, client_rect.h, false);
	rt_scene.Create(scene_rect.w,scene_rect.h, false);
	rt_back.fbo = 0;

	return 1;
}
Пример #24
0
void Cero::draw(RenderTarget& target, RenderStates states) const
{
	states.transform *= getTransform();
	
	for(int i = 0; i < spirals; i++)
	{
		target.draw(particles[i], (activeSegemnts - 1) * 6, PrimitiveType::Triangles, states);
	}
	target.draw(centerCircle, centerSides + 2, PrimitiveType::TrianglesFan, states);
}
 //-----------------------------------------------------------------------
 void RenderSystem::_notifyCameraRemoved(const Camera* cam)
 {
     RenderTargetMap::iterator i, iend;
     iend = mRenderTargets.end();
     for (i = mRenderTargets.begin(); i != iend; ++i)
     {
         RenderTarget* target = i->second;
         target->_notifyCameraRemoved(cam);
     }
 }
Пример #26
0
void GameWorld::draw(RenderTarget& target, RenderStates states) const
{
	//draw the tiles
	for (auto chunk : Chunks)
	{
		target.draw(*chunk);
	}

	target.draw(*DebugDraw::GetInstance());
	DebugDraw::GetInstance()->clearArray();
}
Пример #27
0
void P_cleanup()
{
	debug_rendertarget.Delete();
	rt_temp0.Delete();
	rt_temp1.Delete();
	rt_scene.Delete();

	glDeleteTextures(1, &texture_sprite);
	glDeleteTextures(1, &texture_tile);
	glDeleteTextures(1, &texture_bg);
}
Пример #28
0
	void PostProcessWater::Process(RenderTarget &destinationTarget, LPDIRECT3DBASETEXTURE9 sourceTexture)
	{
		// Implement your own solution for the Post-process lab
		//return ProcessSolution(destinationTarget, sourceTexture);

		elapsedTime += timer.GetElapsedTime();

		destinationTarget.ActivateTarget(0);
        IDirect3DDevice9 *pDevice = Renderer::theDevicePtr;
		Renderer::theDevicePtr->Clear(0,0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1, 0); 
        
		// Set the vertex and index source and declarion
		pDevice->SetVertexDeclaration(VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexDeclaration());
        pDevice->SetStreamSource(0, VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexBuffer(),
								 0, sizeof(VERTEX_POSTEX));
        pDevice->SetIndices(IndexBuffer::GetReference().GetIndices());

		effectPtr->SetTexture(textureHandle, sourceTexture);
		effectPtr->SetFloat(elapsedTimeHandle, elapsedTime);

		// RTT_Ambient, RTT_Diffuse, RTT_Specular, RTT_Emmisive, RTT_Normal
		effectPtr->SetTexture(reflectionMapTextureHandle, renderMaterialHandle.GetContent()->GetRTCubeMapHandle().GetContent()->GetHandle());
		effectPtr->SetTexture(heightMapTextueHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Diffuse].GetContent()->GetHandle());
		effectPtr->SetTexture(noiseTextureHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Normal].GetContent()->GetHandle());
		effectPtr->SetTexture(foamTextureHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Ambient].GetContent()->GetHandle());
		effectPtr->SetTexture(causticTextureHandle, renderMaterialHandle.GetContent()->GetRTHandles()[RTT_Specular].GetContent()->GetHandle());
		effectPtr->SetValue(surfaceColorHandle, &renderMaterialHandle.GetContent()->GetRenderColors()[RTT_Diffuse], sizeof(RenderColor));
		effectPtr->SetValue(ambientColorHandle, &renderMaterialHandle.GetContent()->GetRenderColors()[RTT_Ambient], sizeof(RenderColor));

		pDevice->SetVertexDeclaration(VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexDeclaration());
		pDevice->SetStreamSource(0, VertexBufferManager::GetReference().GetPositionTexBuffer().GetVertexBuffer(), 0, sizeof(VERTEX_POSTEX));
		pDevice->SetIndices(IndexBuffer::GetReference().GetIndices());

		// Begin the post-process effect
		UINT passes = 0;
		effectPtr->Begin(&passes, 0);

		// Iterate through the post-process passes
		for(UINT pass = 0; pass < passes; ++pass)
		{
			effectPtr->BeginPass(pass);

			Renderer::theDevicePtr->DrawIndexedPrimitive(meshPtr->GetPrimitiveType(), meshPtr->GetStartVertex(), 0, meshPtr->GetVertCount(),
													  meshPtr->GetStartIndex(), meshPtr->GetPrimitiveCount());

			effectPtr->EndPass();
		}

		effectPtr->End();

		destinationTarget.RevertTarget();

		timer.Reset();
	}
RenderTarget InventoryScreenState::GetRenderTarget() const
{
	assert(mPlayer.IsValid());
	
	static const int		kWindowWidth					= ScreenConstants::EViewPortWidth;
	static const int		kWindowHeight					= ScreenConstants::EViewPortHeight;
	
	static const int		kWindowMargin					= 2;
	
	static const int		kCellLeftOffset					= 2;
	static const int		kCellWidth						= (ScreenConstants::EViewPortWidth - (2 * (kWindowMargin + kCellLeftOffset)) - 2) / 2;
	static const int		kCellHeight						= 2;
	static const int		kVerticalSpacingBetweenCells	= 1;

	static const Fragment	kCursor((char) 26, ETextWhite);
	
	auto	armedItem0	= mGameData->mPlayerData.GetItemInSlot( Player::EItemSlot_Slot0 );
	auto	armedItem1	= mGameData->mPlayerData.GetItemInSlot( Player::EItemSlot_Slot1 );
	auto&	items		= mGameData->mPlayerData.mInventory.GetAllItems();

	auto renderItemCell = [&] (ItemBase* inItem)
	{
		RenderTarget target(kCellWidth, kCellHeight);

		std::string itemName = inItem->GetName();
		itemName += (inItem == armedItem0) ? " (Spc)" : "";
		itemName += (inItem == armedItem1) ? " (E)"	: "";

		target.Write(itemName, ETextWhite, 0, 0);
		target.Write(inItem->GetHUDIcon(), 0, 1);

		return target;
	};

	RenderTarget window = BorderedFrame(kWindowWidth, kWindowHeight).Render();
	window.Write( " Inventory ", 3, 0 );
	
	for (size_t i = 0; i < items.size(); ++i)
	{
		RenderTarget renderedCell = renderItemCell( items[i] );

		int col = ((i % 2) == 0) ? (kWindowMargin + kCellLeftOffset) : (kWindowWidth - kWindowMargin - kCellWidth);
		int row = kWindowMargin + ((i / 2) * (kCellHeight + kVerticalSpacingBetweenCells));

		window.Write(renderedCell, col, row);

		if ((int) i == mHighlightedItem)
		{
			window.Write(kCursor, col - kCellLeftOffset, row);
		}
	}

	return window;
}
Пример #30
0
void UIPanel::Render( RenderTarget& target ) const
{
  if (!visibled_)
    return;

  if (!enabled_ && hasDisabledAnim_)
    target.Draw(anims_[DISABLED_ANIM_]);
  else if (hasNormalAnim_)
    target.Draw(anims_[NORMAL_ANIM_]);

  __super::Render(target);
}