Exemple #1
0
void OBS::DrawPreview(const Vect2 &renderFrameSize, const Vect2 &renderFrameOffset, const Vect2 &renderFrameCtrlSize, int curRenderTarget, PreviewDrawType type)
{
    LoadVertexShader(mainVertexShader);
    LoadPixelShader(mainPixelShader);

    Ortho(0.0f, renderFrameCtrlSize.x, renderFrameCtrlSize.y, 0.0f, -100.0f, 100.0f);
    if(type != Preview_Projector
       && (renderFrameCtrlSize.x != oldRenderFrameCtrlWidth
           || renderFrameCtrlSize.y != oldRenderFrameCtrlHeight))
    {
        // User is drag resizing the window. We don't recreate the swap chains so our coordinates are wrong
        SetViewport(0.0f, 0.0f, (float)oldRenderFrameCtrlWidth, (float)oldRenderFrameCtrlHeight);
    }
    else
        SetViewport(0.0f, 0.0f, renderFrameCtrlSize.x, renderFrameCtrlSize.y);

    // Draw background (Black if fullscreen/projector, window colour otherwise)
    if(type == Preview_Fullscreen || type == Preview_Projector)
        ClearColorBuffer(0x000000);
    else
        ClearColorBuffer(GetSysColor(COLOR_BTNFACE));

    if(bTransitioning)
    {
        BlendFunction(GS_BLEND_ONE, GS_BLEND_ZERO);
        DrawSprite(transitionTexture, 0xFFFFFFFF,
                renderFrameOffset.x, renderFrameOffset.y,
                renderFrameOffset.x + renderFrameSize.x, renderFrameOffset.y + renderFrameSize.y);
        BlendFunction(GS_BLEND_FACTOR, GS_BLEND_INVFACTOR, transitionAlpha);
    }

    DrawSprite(mainRenderTextures[curRenderTarget], 0xFFFFFFFF,
            renderFrameOffset.x, renderFrameOffset.y,
            renderFrameOffset.x + renderFrameSize.x, renderFrameOffset.y + renderFrameSize.y);
}
	int KungFuPOC::ProcessApplication()
	{
		if (WaitForSingleObject(kinectController.DepthStreamEvent(), 0) == WAIT_OBJECT_0)
			UpdateKinectDepthData();

		if (WaitForSingleObject(kinectController.ColorStreamEvent(), 0) == WAIT_OBJECT_0)
			UpdateKinectColorData();

		deviceContext->OMSetRenderTargets(1, &backBufferView, depthStencilView);
		SetViewport(0, 0, (float)windowWidth, (float)windowHeight);

		deviceContext->ClearRenderTargetView(backBufferView, backgroundColor);
		deviceContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0, 0);
		deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

		if (WaitForSingleObject(kinectController.SkeletonStreamEvent(), 0) == WAIT_OBJECT_0)
			UpdateKinectSkeletonData();		

		deviceContext->OMSetRenderTargets(1, &backBufferView, depthStencilView);
		SetViewport(0, 0, (float)windowWidth, (float)windowHeight);

		jointMaterial->SetProjectionMatrix(projection);
		painting->SetProjectionMatrix(projection);

		colorDisplay->Draw();
		depthDisplay->Draw();
		painting->Render(deviceContext);		
		meshInstance->Render(deviceContext);

		swapChain->Present(0, 0);
	
		return 0;
	}
Exemple #3
0
void RenderFrameDX10(void)
{
	Matrix4x4 view_matrix = g_Control.GetViewMatrix();
	Matrix4x4 world_matrix = g_Control.GetObjectMatrix();

	Vector4 vClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	UINT stride = sizeof(Vertex_VT);
	UINT offset = 0;

	ID3D10RenderTargetView *pRenderTargetView = GutGetDX10RenderTargetView();
	ID3D10DepthStencilView *pDepthStencilView = GutGetDX10DepthStencilView();

	g_pDevice->OMSetRenderTargets(1, &g_pRTView[FULLSIZE], pDepthStencilView);
	g_pDevice->ClearRenderTargetView(g_pRTView[FULLSIZE], &vClearColor[0]);
	g_pDevice->ClearDepthStencilView(pDepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);

	SetViewport(FULLSIZE);

	CGutModel_DX10::SetViewMatrix(view_matrix);
	CGutModel_DX10::SetWorldMatrix(world_matrix);
	CGutModel_DX10::SetProjectionMatrix(g_proj_matrix);
	CGutModel_DX10::UpdateMatrix();

	g_Model_DX10.Render();

	ConvertToLuminance();
	Average();

	AdaptiveLuminance();
	AutoExposure();

	if ( g_iMode & 0x01 )
	{
		g_pDevice->OMSetRenderTargets(1, &pRenderTargetView, pDepthStencilView);
		SetViewport(FULLSIZE);

		float x = -1.0f;
		float y = -1.0f;
		float w = 0.2f;
		float h = 0.2f;

		DrawImage(g_pSRView[LUMINANCE_CURRENT], x, y, w, h);
		x+=w;
		DrawImage(g_pSRView[LUMINANCE_PREVIOUS], x, y, w, h);
		x+=w;
	}

	// 等待硬體掃結束, 然後才更新畫面
	IDXGISwapChain *pSwapChain = GutGetDX10SwapChain();
	pSwapChain->Present(1, 0);
}
Exemple #4
0
void RenderDynamic()
{
	static float t = 0.0;
	SetWindow(-1.0,1.0,-1.0,1.0);
	/*SetViewport(0,100,0,100);
	RenderPoly(Tree,11);
	SetViewport(500,600,0,100);
	RenderPoly(F,11);*/
	/*for(float t = 0.0; t<= 1.0; t+= 0.1)
	{
	SetViewport(t*1000,(t+0.1)*1000,0,100);
	RenderTween(Tree,F,11,t);
	}*/
	SetViewport(0,480,0,480);
	RenderTween(Tree,F,11,t);
	static bool down = false;
	if(t>=1.0)
	{
		down = true;

	}else if(t<=0.0)
	{
		down = false;
	}
	if(down)
		t -= 0.001;
	else 
		t += 0.001;
}
Exemple #5
0
void RenderInOrOuter()
{
	SetWindow(-2.0,2.0,-2.0,2.0);
	SetViewport(0,480,0,480);
	DrawPolygon();
	testQ();
}
Exemple #6
0
void ShaderPass::BeginGraphics()
{
    if (Viewport.Width == 0 || Viewport.Height == 0)
    {
        // Reset based on RenderTarget
        SetViewport(nullptr);
    }

    Context->OMSetRenderTargets(_countof(RenderTargets), RenderTargets, DepthBuffer.Get());

    Context->OMSetDepthStencilState(DepthState.Get(), 0);
    Context->RSSetViewports(1, &Viewport);

    Context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    Context->IASetInputLayout(InputLayouts[(uint32_t)CurrentInputBinding].Get());

    Context->VSSetShader(VertexShader.Get(), nullptr, 0);
    Context->VSSetConstantBuffers(0, _countof(VSCSConstants), VSCSConstants);
    Context->VSSetShaderResources(0, _countof(VSCSResources), VSCSResources);
    Context->VSSetSamplers(0, _countof(VSSamplers), VSSamplers);

    Context->PSSetShader(PixelShader.Get(), nullptr, 0);
    if (PixelShader)
    {
        Context->PSSetConstantBuffers(0, _countof(PSConstants), PSConstants);
        Context->PSSetShaderResources(0, _countof(PSResources), PSResources);
        Context->PSSetSamplers(0, _countof(PSSamplers), PSSamplers);
    }

    Context->CSSetShader(nullptr, nullptr, 0);
}
Exemple #7
0
void RenderDynamic()
{
    static float t = 0.0;
    SetWindow(-1.0,1.0,-1.0,1.0);
    SetViewport(0,480,0,480);

}
void RenderSystem_GL30::UpdateViewport()
{
	DisplayManager *dm = DisplayManager::GetSingleton();
	SetViewport(dm->GetViewport());
	glm::vec4 view = GetViewport();
	glViewport((GLsizei)view.x, (GLsizei)view.y, (GLsizei)view.z, (GLsizei)view.w);
}
	void KungFuPOC::UpdateKinectSkeletonData()
	{
		float3 offset(0.0, 0.0, 0.0);
		
		SkeletonData data;
		kinectController.GetSkeletonData(&data);
		int skeletonIndex = GetActiveSkeleton(data.skeletonData);
		if (skeletonIndex < 0) return;

		NUI_SKELETON_DATA skeleton = data.skeletonData[skeletonIndex];
		Vector4* positions = skeleton.SkeletonPositions;
		
		float dz = 0.0;
		for (int i = 0; i != NUI_SKELETON_POSITION_COUNT; ++i) {			
			Vector4& pos = positions[i];
			pos.z = -pos.z;
			// don't let player come too close to the painting!
			if (i == 0) {
				if (pos.z > PAINTING_Z - MINIMUM_PLAYER_DISTANCE) {
					dz = pos.z - (PAINTING_Z - MINIMUM_PLAYER_DISTANCE);
				}
			}
			pos.z -= dz;
		}

		stickFigureMesh->Update(deviceContext, positions);

		matrix4x4 projectionMtx = XMLoadFloat4x4(&projection);
		for (auto it = paintLogics.begin(); it != paintLogics.end(); ++it) {
			deviceContext->OMSetRenderTargets(1, &backBufferView, depthStencilView);
			SetViewport(0, 0, (float)windowWidth, (float)windowHeight);
			(*it)->Update(projectionMtx, deviceContext, positions);
		}
	}
Exemple #10
0
void
LayerManagerD3D10::SetupPipeline()
{
  VerifyBufferSize();
  UpdateRenderTarget();

  nsIntRect rect;
  mWidget->GetClientBounds(rect);

  HRESULT hr;

  hr = mEffect->GetVariableByName("vTextureCoords")->AsVector()->
    SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f));

  if (FAILED(hr)) {
    NS_WARNING("Failed to set Texture Coordinates.");
    return;
  }

  ID3D10RenderTargetView *view = mRTView;
  mDevice->OMSetRenderTargets(1, &view, NULL);
  mDevice->IASetInputLayout(mInputLayout);

  UINT stride = sizeof(Vertex);
  UINT offset = 0;
  ID3D10Buffer *buffer = mVertexBuffer;
  mDevice->IASetVertexBuffers(0, 1, &buffer, &stride, &offset);
  mDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);

  SetViewport(nsIntSize(rect.width, rect.height));
}
Exemple #11
0
void nuiGLPainter::StartRendering()
{
  BeginSession();
  //NUI_RETURN_IF_RENDERING_DISABLED;
  nuiCheckForGLErrors();

  mScissorX = -1;
  mScissorY = -1;
  mScissorW = -1;
  mScissorH = -1;
  mScissorOn = false;
  
  nuiPainter::StartRendering();
  
  SetViewport();
  glLoadIdentity();

  glDisable(GL_DEPTH_TEST);
  glDisable(GL_SCISSOR_TEST);
  glDisable(GL_TEXTURE_2D);

#ifndef _OPENGL_ES_
  if (mCanRectangleTexture == 2)
  {
    glDisable(GL_TEXTURE_RECTANGLE_ARB);
  }
#endif

  glDisable(GL_STENCIL_TEST);
  glDisable(GL_BLEND);
  glDisable(GL_ALPHA_TEST);
  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
  BlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
  nuiCheckForGLErrors();
}
Exemple #12
0
void nuiGLPainter::PopProjectionMatrix()
{
  NUI_RETURN_IF_RENDERING_DISABLED;
  
  nuiPainter::PopProjectionMatrix();
  SetViewport();
}
HRESULT CBRenderer::SetViewport(RECT* Rect)
{
    return SetViewport(	Rect->left + m_DrawOffsetX,
                        Rect->top + m_DrawOffsetY,
                        Rect->right + m_DrawOffsetX,
                        Rect->bottom + m_DrawOffsetY);
}
Exemple #14
0
void wxGLCanvas::MacUpdateView()
{
    if (m_glContext)
    {
        SetViewport();
    }
}
Exemple #15
0
void gld_Viewport_DX7(
	struct gl_context *ctx,
	GLint x,
	GLint y,
	GLsizei w,
	GLsizei h)
{
	GLD_context		*gldCtx	= GLD_GET_CONTEXT(ctx);
	GLD_driver_dx7	*gld	= GLD_GET_DX7_DRIVER(gldCtx);

	D3DVIEWPORT7	d3dvp;

	if (!gld || !gld->pDev)
		return;

	// This is a hack. When the app is minimized, Mesa passes
	// w=1 and h=1 for viewport dimensions. Without this test
	// we get a GPF in gld_wgl_resize_buffers().
	if ((w==1) && (h==1))
		return;

	// Call ResizeBuffersMESA. This function will early-out
	// if no resize is needed.
	//ctx->Driver.ResizeBuffersMESA(ctx);
	// Mesa 5: Changed parameters
	ctx->Driver.ResizeBuffers(gldCtx->glBuffer);

#if 0
	ddlogPrintf(GLDLOG_SYSTEM, ">> Viewport x=%d y=%d w=%d h=%d", x,y,w,h);
#endif

	// ** D3D viewport must not be outside the render target surface **
	// Sanity check the GL viewport dimensions
	if (x < 0) x = 0;
	if (y < 0) y = 0;
	if (w > gldCtx->dwWidth) 		w = gldCtx->dwWidth;
	if (h > gldCtx->dwHeight) 		h = gldCtx->dwHeight;
	// Ditto for D3D viewport dimensions
	if (w+x > gldCtx->dwWidth) 		w = gldCtx->dwWidth-x;
	if (h+y > gldCtx->dwHeight) 	h = gldCtx->dwHeight-y;

	d3dvp.dwX		= x;
	d3dvp.dwY		= gldCtx->dwHeight - (y + h);
	d3dvp.dwWidth	= w;
	d3dvp.dwHeight	= h;
	if (ctx->Viewport.Near <= ctx->Viewport.Far) {
		d3dvp.dvMinZ	= ctx->Viewport.Near;
		d3dvp.dvMaxZ	= ctx->Viewport.Far;
	} else {
		d3dvp.dvMinZ	= ctx->Viewport.Far;
		d3dvp.dvMaxZ	= ctx->Viewport.Near;
	}

	// TODO: DEBUGGING
//	d3dvp.MinZ		= 0.0f;
//	d3dvp.MaxZ		= 1.0f;

	_GLD_DX7_DEV(SetViewport(gld->pDev, &d3dvp));

}
void UOpenALAudioSubsystem::Destroy()
{
	guard(UOpenALAudioSubsystem::Destroy);

	if( Initialized )
	{
		// Unhook.
		USound::Audio = NULL;
		UMusic::Audio = NULL;

		// Shut down viewport.
		SetViewport( NULL );

		// Cleanup.
		MikMod_Exit();
		alDeleteSources( 1, &MusicSource );
		for( INT i=0; i<NumSources; i++ )
			alDeleteSources( 1, &Sources[i].Id );
		alureShutdownDevice();
	}

	Super::Destroy();

	unguard;
}
Exemple #17
0
void SetUpCameraAsymmetric(Eye eye, const Camera& camera)
{
    // http://paulbourke.net/stereographics/stereorender/

    const int windowwidth = Screen::X();
    const int windowheight = Screen::Y();

    float aspectratio = (float)windowwidth / (float)windowheight / 2.0f;
    // Dividing by 2 for side-by-side stereo

    float aperture = camera.fovx();
    float widthdiv2   = camera.m_neardist * tan(aperture / 2.0f);
    // aperture in radians
    Vec3f cameraright = CrossProduct(camera.m_dir,camera.m_up);  // Each unit vectors
    cameraright *= camera.m_eyeSep / 2.0f;

    AmjuGL::SetMatrixMode(AmjuGL::AMJU_PROJECTION_MATRIX);
    AmjuGL::SetIdentity();

    SetViewport(eye, camera.m_vpXOffset * windowwidth, camera.m_vpYOffset * windowheight);

    if (eye == LEFT)
    {
        float top    =   widthdiv2;
        float bottom = - widthdiv2;
        float left   = - aspectratio * widthdiv2 + 0.5f * camera.m_eyeSep * camera.m_neardist / camera.m_fo;
        float right  =   aspectratio * widthdiv2 + 0.5f * camera.m_eyeSep * camera.m_neardist / camera.m_fo;
        MultFrustum(left, right, bottom, top, camera.m_neardist, camera.m_fardist);

        AmjuGL::SetMatrixMode(AmjuGL::AMJU_MODELVIEW_MATRIX);
        AmjuGL::SetIdentity();
        AmjuGL::LookAt(
            camera.m_pos.x - cameraright.x,
            camera.m_pos.y - cameraright.y,
            camera.m_pos.z - cameraright.z,
            camera.m_pos.x - cameraright.x + camera.m_dir.x,
            camera.m_pos.y - cameraright.y + camera.m_dir.y,
            camera.m_pos.z - cameraright.z + camera.m_dir.z,
            camera.m_up.x,camera.m_up.y,camera.m_up.z);
    }
    else
    {
        float top    =   widthdiv2;
        float bottom = - widthdiv2;
        float left   = - aspectratio * widthdiv2 - 0.5f * camera.m_eyeSep * camera.m_neardist / camera.m_fo;
        float right  =   aspectratio * widthdiv2 - 0.5f * camera.m_eyeSep * camera.m_neardist / camera.m_fo;
        MultFrustum(left, right, bottom, top, camera.m_neardist, camera.m_fardist);

        AmjuGL::SetMatrixMode(AmjuGL::AMJU_MODELVIEW_MATRIX);
        AmjuGL::SetIdentity();
        AmjuGL::LookAt(
            camera.m_pos.x + cameraright.x,
            camera.m_pos.y + cameraright.y,
            camera.m_pos.z + cameraright.z,
            camera.m_pos.x + cameraright.x + camera.m_dir.x,
            camera.m_pos.y + cameraright.y + camera.m_dir.y,
            camera.m_pos.z + cameraright.z + camera.m_dir.z,
            camera.m_up.x,camera.m_up.y,camera.m_up.z);
    }
}
RendererLegacy::RendererLegacy(WindowSDL *window, const Graphics::Settings &vs)
: Renderer(window, window->GetWidth(), window->GetHeight())
, m_numDirLights(0)
, m_minZNear(10.f)
, m_maxZFar(1000000.0f)
, m_useCompressedTextures(false)
{
	const bool useDXTnTextures = vs.useTextureCompression && glewIsSupported("GL_EXT_texture_compression_s3tc");
	m_useCompressedTextures = useDXTnTextures;

	glShadeModel(GL_SMOOTH);
	glCullFace(GL_BACK);
	glFrontFace(GL_CCW);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glAlphaFunc(GL_GREATER, 0.5f);

	SetClearColor(Color(0.f));
	SetViewport(0, 0, m_width, m_height);

	if (vs.enableDebugMessages)
		GLDebug::Enable();
}
		ErrorMessage DirectXEngine::Initialize(Jamgine::Data_Send p_data)
		{
			ErrorMessage l_errorMessage = J_OK;

			m_hInstance		= p_data.hInstance;
			m_clientWidth	= p_data.clientWidth;
			m_clientHeight	= p_data.clientHeight;
			
			// Register window
			l_errorMessage  = RegisterWindow(p_data);
				if(l_errorMessage != J_OK)
				return J_FAIL; 

			// Init swapchain and device
			l_errorMessage = InitializeSwapChain();
			if(l_errorMessage != J_OK)
				return J_FAIL; 

			// Create texturemanger
			l_errorMessage = Texture2DManager::CreateTexture2DManager(&m_texture2DManager);
			m_texture2DManager->Initialize(m_device);
			if(l_errorMessage != J_OK)
				return J_FAIL; 

			CreateDepthBuffer();
			InitializeRenderTarget();
			LoadShaders();
			CreateBuffer();
			SetViewport();
			CreateRasterizers();
			SetBlendState();

			return l_errorMessage;
		}
void DisplayManager::EnsureRectVisible (WebRect* r)
{
	WebRect rect(*r);
	DISPLAY_INT left = mViewRect.left;
	DISPLAY_INT top  = mViewRect.top;

	if (rect.bottom > mViewRect.bottom)
	{
		top = rect.bottom - mViewRect.Height();
	}

	if (rect.top < top)
	{
		top = rect.top;
	}

	if (rect.right > mViewRect.right)
	{
		left = rect.right - mViewRect.Width();
	}

	if (rect.left < left)
	{
		left = rect.left;
	}

	rect.Set(&mViewRect);
	rect.MoveTo(left, top);
	SetViewport(&rect);
}
Exemple #21
0
void App::RenderText(const std::wstring& text, Float2 pos)
{
    ID3D11DeviceContext* context = deviceManager.ImmediateContext();

    // Set the backbuffer and viewport
    ID3D11RenderTargetView* rtvs[1] = { deviceManager.BackBuffer() };
    context->OMSetRenderTargets(1, rtvs, NULL);

    float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
    context->ClearRenderTargetView(rtvs[0], clearColor);

    SetViewport(context, deviceManager.BackBufferWidth(), deviceManager.BackBufferHeight());

    // Draw the text
    Float4x4 transform;
    transform.SetTranslation(Float3(pos.x, pos.y,0.0f));
    spriteRenderer.Begin(context, SpriteRenderer::Point);
    spriteRenderer.RenderText(font, text.c_str(), transform.ToSIMD());
    spriteRenderer.End();

    // Present
    deviceManager.SwapChain()->Present(0, 0);

    // Pump the message loop
    window.MessageLoop();
}
Exemple #22
0
void nuiGLPainter::LoadProjectionMatrix(const nuiRect& rViewport, const nuiMatrix& rMatrix)
{
  NUI_RETURN_IF_RENDERING_DISABLED;
  
  nuiPainter::LoadProjectionMatrix(rViewport, rMatrix);

  SetViewport();
}
BitmapImage::BitmapImage( vgui::VPANEL parent, const char *filename )
{
	m_nTextureId = -1;
	m_clr.SetColor( 255, 255, 255, 255 );
	m_pos[ 0 ] = m_pos[ 1 ]  = 0;
	Init( parent, filename );
	SetViewport( false, 0.0f, 0.0f, 0.0f, 0.0f );
}
Exemple #24
0
void nuiGLPainter::MultProjectionMatrix(const nuiMatrix& rMatrix)
{
  NUI_RETURN_IF_RENDERING_DISABLED;
  
  nuiPainter::MultProjectionMatrix(rMatrix);

  SetViewport();
}
void RenderTerrain(ID3D11DeviceContext* pContext, const D3DXMATRIX& mProj, const D3D11_VIEWPORT& vp, const char* passOverride=NULL)
{
	
	SetMatrices(GetApp()->ActiveCam_, mProj);

	g_HwTessellation = false;
	

	if (g_HwTessellation)
	{
		pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_4_CONTROL_POINT_PATCHLIST);
		pContext->IASetIndexBuffer(g_TileQuadListIB, DXGI_FORMAT_R32_UINT, 0);
	}
	else
	{
		pContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
		pContext->IASetIndexBuffer(g_TileTriStripIB, DXGI_FORMAT_R32_UINT, 0);
	}

	const char* passName = "ShadedTriStrip";

	const bool wire = true;
	if (wire)
		passName = "Wireframe";
	if (g_HwTessellation)
	{
		if (wire)
			passName = "HwTessellatedWireframe";
		else
			passName = "HwTessellated";
	}
	if (passOverride != NULL)
		passName = passOverride;

	ID3DX11EffectPass* pPass = g_pTesselationTechnique->GetPassByName(passName);
	if (!pPass)
		return;		// Shouldn't happen unless the FX file is broken (like wrong pass name).

	SetViewport(pContext, vp);

	for (int i=0; i!=g_nRings ; ++i)
	{
		const TileRing* pRing = g_pTileRings[i];
		pRing->SetRenderingState(pContext);

		g_HeightMapVar->SetResource(g_pHeightMapSRV);
		g_GradientMapVar->SetResource(g_pGradientMapSRV);
		g_pTileSizeVar->SetFloat(pRing->tileSize());

		// Need to apply the pass after setting its vars.
		pPass->Apply(0, pContext);

		// Instancing is used: one tiles is one instance and the index buffer describes all the 
		// NxN patches within one tile.
		const int nIndices = (g_HwTessellation)? QUAD_LIST_INDEX_COUNT: TRI_STRIP_INDEX_COUNT;
		pContext->DrawIndexedInstanced(nIndices, pRing->nTiles(), 0, 0, 0);
	}
}
Exemple #26
0
/*  CDirect3D::ResetDevice
resets the device
called if surface was lost or the settings/display size require a device reset
-----
returns true if successful, false otherwise
*/
bool CDirect3D::ResetDevice()
{
	if(!init_done) return false;

	HRESULT hr;

	//release prior to reset
	DestroyDrawSurface();

	if(cgAvailable) {
		cgShader->OnLostDevice();
		cgD3D9SetDevice(NULL);
	}

	//zero or unknown values result in the current window size/display settings
	dPresentParams.BackBufferWidth = 0;
	dPresentParams.BackBufferHeight = 0;
	dPresentParams.BackBufferCount = GUI.DoubleBuffered?2:1;
	dPresentParams.BackBufferFormat = D3DFMT_UNKNOWN;
	dPresentParams.FullScreen_RefreshRateInHz = 0;
	dPresentParams.Windowed = true;
	dPresentParams.PresentationInterval = GUI.Vsync?D3DPRESENT_INTERVAL_ONE:D3DPRESENT_INTERVAL_IMMEDIATE;
	dPresentParams.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

	if(fullscreen) {
		dPresentParams.BackBufferWidth = GUI.FullscreenMode.width;
		dPresentParams.BackBufferHeight = GUI.FullscreenMode.height;
		dPresentParams.BackBufferCount = GUI.DoubleBuffered?2:1;
		dPresentParams.Windowed = false;
		if(GUI.FullscreenMode.depth == 32)
			dPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8;
		else
			dPresentParams.BackBufferFormat = D3DFMT_R5G6B5;
		dPresentParams.FullScreen_RefreshRateInHz = GUI.FullscreenMode.rate;
	}

	if(FAILED(hr = pDevice->Reset(&dPresentParams))) {
		DXTRACE_ERR(TEXT("Unable to reset device"), hr);
		return false;
	}

	if(cgAvailable) {
		cgD3D9SetDevice(pDevice);
		cgShader->OnResetDevice();
	}

	pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

	pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
	
	//recreate the surface
	CreateDrawSurface();

	SetViewport();

	return true;
}
//-----------------------------------------------------------------------------
// Purpose: Check box image
//-----------------------------------------------------------------------------
BitmapImage::BitmapImage()
{
	m_clr.SetColor( 255, 255, 255, 255 );
	m_pos[ 0 ] = m_pos[ 1 ]  = 0;
	m_pPanelSize = NULL;
	m_nTextureId = -1;

	SetViewport( false, 0.0f, 0.0f, 0.0f, 0.0f );
}
Exemple #28
0
void wxGLCanvas::MacUpdateView()
{
    if (m_glContext)
    {
        UpdateContext();
        m_glContext->SetCurrent();
        SetViewport();
    }
}
Exemple #29
0
    void Graphics::SetUpViewport()
    {
        if (currentFbo_)
        {
            auto width = currentFbo_->GetWidth();
            auto height = currentFbo_->GetHeight();
            SetViewport(Recti(0, 0, width, height), false);
        }
        else if (activeWindow_)
        {
            auto width = activeWindow_->GetWidth();
            auto height = activeWindow_->GetHeight();
            SetViewport(Recti(0, 0, width, height), false);
        }
        else
            SetViewport(Recti(0, 0, 0, 0), false);

    }
CRenderingContext::CRenderingContext(CRenderer* pRenderer, bool bInherit)
{
	m_pRenderer = pRenderer;

	m_clrRender = ::Color(255, 255, 255, 255);

	s_aContexts.push_back();

	if (bInherit && s_aContexts.size() > 1)
	{
		CRenderContext& oLastContext = s_aContexts[s_aContexts.size()-2];
		CRenderContext& oThisContext = GetContext();

		oThisContext.m_mProjection = oLastContext.m_mProjection;
		oThisContext.m_mView = oLastContext.m_mView;
		oThisContext.m_mTransformations = oLastContext.m_mTransformations;

		oThisContext.m_hMaterial = oLastContext.m_hMaterial;
		oThisContext.m_pFrameBuffer = oLastContext.m_pFrameBuffer;
		tstrncpy(oThisContext.m_szProgram, PROGRAM_LEN, oLastContext.m_szProgram, PROGRAM_LEN);
		oThisContext.m_pShader = oLastContext.m_pShader;

		oThisContext.m_rViewport = oLastContext.m_rViewport;
		oThisContext.m_eBlend = oLastContext.m_eBlend;
		oThisContext.m_flAlpha = oLastContext.m_flAlpha;
		oThisContext.m_bDepthMask = oLastContext.m_bDepthMask;
		oThisContext.m_bDepthTest = oLastContext.m_bDepthTest;
		oThisContext.m_eDepthFunction = oLastContext.m_eDepthFunction;
		oThisContext.m_bCull = oLastContext.m_bCull;
		oThisContext.m_bWinding = oLastContext.m_bWinding;

		m_pShader = oThisContext.m_pShader;

		if (m_pShader)
			m_iProgram = m_pShader->m_iProgram;
		else
			m_iProgram = 0;
	}
	else
	{
		m_pShader = NULL;

		BindTexture(0);
		UseMaterial(CMaterialHandle());
		UseFrameBuffer(NULL);
		UseProgram("");

		SetViewport(Rect(0, 0, Application()->GetWindowWidth(), Application()->GetWindowHeight()));
		SetBlend(BLEND_NONE);
		SetAlpha(1);
		SetDepthMask(true);
		SetDepthTest(true);
		SetDepthFunction(DF_LESS);
		SetBackCulling(true);
		SetWinding(true);
	}
}