• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GutGetGraphicsDeviceDX9函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GutGetGraphicsDeviceDX9函数的典型用法代码示例。如果您正苦于以下问题:C++ GutGetGraphicsDeviceDX9函数的具体用法?C++ GutGetGraphicsDeviceDX9怎么用?C++ GutGetGraphicsDeviceDX9使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GutGetGraphicsDeviceDX9函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: InitResourceDX9

bool InitResourceDX9(void)
{
	g_orient_matrix.Identity();

	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	if ( !ReInitResourceDX9() )
		return false;

	g_pPostEffect = GutLoadFXShaderDX9("../../shaders/Posteffect.fx");
	if ( NULL==g_pPostEffect )
		return false;

	g_pWaterEffect = GutLoadFXShaderDX9("../../shaders/Watereffect.fx");
	if ( NULL==g_pWaterEffect )
		return false;

	g_pWaterTexture = GutLoadTexture_DX9("../../textures/lena.tga");
	if ( NULL==g_pWaterTexture )
		return false;

	g_Model_DX9.ConvertToDX9Model(&g_Model);

	return true;
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:25,代码来源:render_dx9.cpp


示例2: InitResourceDX9

bool InitResourceDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	Matrix4x4 projection_matrix = GutMatrixPerspectiveRH_DirectX(90.0f, 1.0f, 0.1f, 100.0f);
	// 設定視角轉換矩陣
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &projection_matrix);
	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 改變三角形正面的面向
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);

	int num_vertices = sizeof(g_pyramid_vertices)/sizeof(Vertex_VC);

	// 把RGBA的顏色資料轉換成DX9 BGRA格式
	for ( int i=0; i<num_vertices; i++ )
	{
		unsigned char temp = g_pyramid_vertices[i].m_RGBA[0];
		g_pyramid_vertices[i].m_RGBA[0] = g_pyramid_vertices[i].m_RGBA[2];
		g_pyramid_vertices[i].m_RGBA[2] = temp;
	}

	num_vertices = sizeof(g_road_vertices)/sizeof(Vertex_VC);
	for ( int i=0; i<num_vertices; i++ )
	{
		unsigned char temp = g_road_vertices[i].m_RGBA[0];
		g_road_vertices[i].m_RGBA[0] = g_road_vertices[i].m_RGBA[2];
		g_road_vertices[i].m_RGBA[2] = temp;
	}

	return true;
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:33,代码来源:render_dx9.cpp


示例3: RenderFrameDX9

// `使用Direct3D9來繪圖`
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// `消除畫面`
	device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
	// `開始下繪圖指令`
	device->BeginScene(); 
	// `計算出一個可以轉換到鏡頭座標系的矩陣`
	Matrix4x4 view_matrix = GutMatrixLookAtRH(g_eye, g_lookat, g_up);
	device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);

	// `設定資料格式`
	// D3DFVF_XYZ = `使用3個浮點數來記錄位置`
	// D3DFVF_DIFFUSE = `使用32bits整數型態來記錄BGRA顏色`
	device->SetFVF(D3DFVF_XYZ|D3DFVF_DIFFUSE); 

	// `太陽`
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_sun_matrix);
	device->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, g_iNumSphereVertices, g_iNumSphereTriangles, 
		g_pSphereIndices, D3DFMT_INDEX16, g_pSunVertices, sizeof(Vertex_VC) );
	// `地球`
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_earth_matrix);
	device->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, g_iNumSphereVertices, g_iNumSphereTriangles, 
		g_pSphereIndices, D3DFMT_INDEX16, g_pEarthVertices, sizeof(Vertex_VC) );
	// `月亮`
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_moon_matrix);
	device->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, g_iNumSphereVertices, g_iNumSphereTriangles, 
		g_pSphereIndices, D3DFMT_INDEX16, g_pMoonVertices, sizeof(Vertex_VC) );

	// `宣告所有的繪圖指令都下完了`
	device->EndScene(); 

	// `把背景backbuffer的畫面呈現出來`
	device->Present( NULL, NULL, NULL, NULL );
}
开发者ID:as2120,项目名称:ZNginx,代码行数:36,代码来源:render_dx9.cpp


示例4: InitResourceDX9

bool InitResourceDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// 設定視角轉換矩陣
	int w, h;
	GutGetWindowSize(w, h);
	float aspect = (float) h / (float) w;
	Matrix4x4 projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFovW, aspect, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &projection_matrix);
	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 畫出正向跟反向的三角形
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	// 載入貼圖
	g_pTexture = GutLoadTexture_DX9("../../textures/lena_rgb.tga");
	if ( NULL==g_pTexture )
		return false;
	// trilinear
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

	return true;
}
开发者ID:as2120,项目名称:ZNginx,代码行数:25,代码来源:render_dx9_.cpp


示例5: RenderFrameDX9

// 使用Direct3D9來繪圖
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	device->SetRenderState( D3DRS_LIGHTING, FALSE );
	device->Clear(
		0, NULL, // 清除整個畫面 
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, // 清除顏色跟Z Buffer
		D3DCOLOR_ARGB(0, 0, 0, 0), // 設定要把顏色清成黑色
		1.0f, // 設定要把Z值清為1, 也就是離鏡頭最遠.
		0 // 設定要把Stencil buffer清為0, 在這沒差.
		);

	// 計算出一個可以轉換到鏡頭座標系的矩陣
	Matrix4x4 view_matrix = GutMatrixLookAtRH(g_eye, g_lookat, g_up);
	// 計算出一個使用非平行投影的矩陣
	Matrix4x4 perspective_matrix = GutMatrixPerspectiveRH_DirectX(90.0f, 1.0f, 1.0f, 100.0f);
	// 把這兩個矩陣相乘
	Matrix4x4 view_perspective_matrix = view_matrix * perspective_matrix;
	// 把空間中的座標點轉換到螢幕座標系上
	Vector4 vertices[16];
	for ( int i=0; i<16; i++ )
	{
		vertices[i] = g_vertices[i] * view_perspective_matrix;
		vertices[i] /= vertices[i].GetW();
	}

	device->BeginScene(); // 開始下繪圖指令
	device->SetFVF(D3DFVF_XYZ); // 設定資料格式
	// 畫出金字塔的8條邊線
	device->DrawPrimitiveUP(D3DPT_LINELIST, 8, vertices, sizeof(Vector4)); 
	device->EndScene(); // 宣告所有的繪圖指令都下完了

	// 把背景backbuffer的畫面呈現出來
	device->Present( NULL, NULL, NULL, NULL );
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:36,代码来源:perspective_view.cpp


示例6: ResizeWindowDX9

void ResizeWindowDX9(int width, int height)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// Reset Device
	GutResetGraphicsDeviceDX9();
	// 設定視角轉換矩陣
	int w, h;
	GutGetWindowSize(w, h);
	float aspect = (float) h / (float) w;
	Matrix4x4 projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFovW, aspect, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &projection_matrix);
	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 畫出正向跟反向的三角形
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	// trilinear
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

	// trilinear
	device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:27,代码来源:render_dx9.cpp


示例7: RenderFrameDX9

// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	if ( g_bWireframe )
	{
		device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
	}
	else
	{
		device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
	}

	switch(g_iMode)
	{
	default:
	case 1:
		Antialiasing_None();
		break;
	case 2:
		Antialiasing_MultiSampling();
		break;
	case 3:
		Antialiasing_SuperSampling();
		break;
	}
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:28,代码来源:render_dx9.cpp


示例8: DrawScreenQuad

void DrawScreenQuad(sImageInfo *pInfo, float x0, float y0, float width, float height)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	int w = pInfo->m_iWidth;
	int h = pInfo->m_iHeight;

	float fTexelW = 1.0f/(float)w;
	float fTexelH = 1.0f/(float)h;

	Vertex_VT quad[4];
	memcpy(quad, g_FullScreenQuad, sizeof(quad));

	quad[0].m_Position[0] = x0;
	quad[0].m_Position[1] = y0;

	quad[1].m_Position[0] = x0 + width;
	quad[1].m_Position[1] = y0;

	quad[2].m_Position[0] = x0;
	quad[2].m_Position[1] = y0 + height;

	quad[3].m_Position[0] = x0 + width;
	quad[3].m_Position[1] = y0 + height;

	for ( int i=0; i<4; i++ )
	{
		quad[i].m_Texcoord[0] += fTexelW*0.5f;
		quad[i].m_Texcoord[1] += fTexelH*0.5f;
	}

	device->SetFVF(D3DFVF_XYZ|D3DFVF_TEX1);
	device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(Vertex_VT));
}
开发者ID:as2120,项目名称:ZNginx,代码行数:34,代码来源:render_dx9.cpp


示例9: AutoExposure

void AutoExposure(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	D3DXHANDLE shader = g_pExposureEffect->GetTechniqueByName("AutoExposure");
	g_pExposureEffect->SetTechnique(shader);

	Vector4 vMiddleGray(0.5f);
	Vector4 vMultiplierClamp(0.2f, 3.0f, 0.0f, 0.0f);

	D3DXHANDLE middlegray_var = g_pExposureEffect->GetParameterByName(NULL, "vMiddleGray");
	D3DXHANDLE clamp_var = g_pExposureEffect->GetParameterByName(NULL, "vMultiplierClamp");
	D3DXHANDLE image0_var = g_pExposureEffect->GetParameterByName(NULL, "Image");
	D3DXHANDLE image1_var = g_pExposureEffect->GetParameterByName(NULL, "Image2");

	g_pExposureEffect->SetVector(middlegray_var, (D3DXVECTOR4*)&vMiddleGray);
	g_pExposureEffect->SetVector(clamp_var, (D3DXVECTOR4*)&vMultiplierClamp);

	g_pExposureEffect->SetTexture(image0_var, g_pFrameBuffer[FULLSIZE]);
	g_pExposureEffect->SetTexture(image1_var, g_pFrameBuffer[LUMINANCE_TEMP]);

	g_pExposureEffect->Begin(NULL, 0);
	g_pExposureEffect->BeginPass(0);

	DrawFullScreenQuad(&g_ImageInfo);

	g_pExposureEffect->EndPass();
	g_pExposureEffect->End();
}
开发者ID:as2120,项目名称:ZNginx,代码行数:29,代码来源:render_dx9.cpp


示例10: RenderFrameDX9

// `使用Direct3D9來繪圖`
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// `消除畫面`
	device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
	// `開始下繪圖指令`
	device->BeginScene(); 
	// `設定資料格式`
	device->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL);
	// `套用shader`
	device->SetVertexShader(g_pSelected_VS);
	device->SetPixelShader(g_pVertexColor_PS);
	// `設定光源`
	SetupLightingDX9();
	// `設定轉換矩陣`
	Matrix4x4 world_view_proj_matrix = g_world_matrix * g_view_proj_matrix;
	device->SetVertexShaderConstantF(0, &world_view_proj_matrix[0][0], 4);
	device->SetVertexShaderConstantF(4, &g_world_matrix[0][0], 4);
	// `鏡頭位置, 計算Specular會用到.`
	device->SetVertexShaderConstantF(8, &g_eye[0], 1);
	// `畫出格子`
	device->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, g_iNumGridVertices, g_iNumGridTriangles, 
		g_pGridIndices, D3DFMT_INDEX16, g_pGridVertices, sizeof(Vertex_V3N3) );
	// `宣告所有的繪圖指令都下完了`
	device->EndScene(); 
	// `把背景backbuffer的畫面呈現出來`
	device->Present( NULL, NULL, NULL, NULL );
}
开发者ID:as2120,项目名称:ZNginx,代码行数:29,代码来源:render_dx9.cpp


示例11: InitResourceDX9

bool InitResourceDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// 設定視角轉換矩陣
	g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, 1.0f, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);

	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 改變三角形正面的面向
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	device->CreateTexture(512, 512, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexture, NULL);
	device->CreateDepthStencilSurface(512, 512, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &g_pDepthStencil, NULL);

	CGutModel::SetTexturePath("../../textures/");
	g_Model_DX9.ConvertToDX9Model(&g_Model);

	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

	device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

	device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);

	return true;
}
开发者ID:as2120,项目名称:ZNginx,代码行数:31,代码来源:render_dx9.cpp


示例12: InitResourceDX9

bool InitResourceDX9(void)
{
	// `取得Direct3D9裝置`
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// `載入Pixel Shader`
	g_pVertexColor_PS = GutLoadPixelShaderDX9_HLSL("../../shaders/vertex_lighting_directional.shader", "PS", "ps_2_0");
	if ( g_pVertexColor_PS==NULL )
		return false;
	// `載入Directional Light Vertex Shader`
	g_pDirLight_VS = GutLoadVertexShaderDX9_HLSL("../../shaders/vertex_lighting_directional.shader", "VS", "vs_1_1");
	if ( g_pDirLight_VS==NULL )
		return false;
	// `載入Point Light Vertex Shader`
	g_pPointLight_VS = GutLoadVertexShaderDX9_HLSL("../../shaders/vertex_lighting_point.shader", "VS", "vs_1_1");
	if ( g_pPointLight_VS==NULL )
		return false;
	// `載入Spot Light Vertex Shader`
	g_pSpotLight_VS = GutLoadVertexShaderDX9_HLSL("../../shaders/vertex_lighting_spot.shader", "VS", "vs_1_1");
	if ( g_pSpotLight_VS==NULL )
		return false;

	// `視角轉換矩陣`
	g_proj_matrix = GutMatrixPerspectiveRH_DirectX(g_fFovW, 1.0f, 0.1f, 100.0f);
	// `鏡頭轉換矩陣`
	g_view_matrix = GutMatrixLookAtRH(g_eye, g_lookat, g_up);
	// `事先把view_matrix跟proj_matrix相乘`
	g_view_proj_matrix = g_view_matrix * g_proj_matrix;

	// `畫出正向跟反向的三角形`
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	return true;
}
开发者ID:as2120,项目名称:ZNginx,代码行数:33,代码来源:render_dx9.cpp


示例13: DrawObject

void DrawObject(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	Matrix4x4 view_matrix = g_Control.GetViewMatrix();
	
	Matrix4x4 scale_matrix; 
	scale_matrix.Scale_Replace(g_fRippleSize, g_fRippleSize, 1.0f);
	
	Matrix4x4 world_matrix = g_orient_matrix * scale_matrix;
	world_matrix[3] = g_vPosition;

	device->SetVertexShader(NULL);
	device->SetPixelShader(NULL);

	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*) &g_proj_matrix);
	device->SetTransform(D3DTS_VIEW, (D3DMATRIX*) &view_matrix);
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX*) &world_matrix);

	device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS);
	device->SetRenderState(D3DRS_ZENABLE, TRUE);
	device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);

	g_Model_DX9.Render();

	device->SetRenderState(D3DRS_LIGHTING, FALSE);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:27,代码来源:render_dx9.cpp


示例14: WaterSimulation

static void WaterSimulation(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	device->SetRenderTarget(0, g_pSurfaces[TEX_HEIGHT2]);
	device->SetDepthStencilSurface(NULL);

	D3DXHANDLE shader = g_pWaterEffect->GetTechniqueByName("WaterSimulation");
	D3DXHANDLE heightmap_current_var = g_pWaterEffect->GetParameterByName(NULL, "heightmap_current");
	D3DXHANDLE heightmap_prev_var = g_pWaterEffect->GetParameterByName(NULL, "heightmap_prev");
	D3DXHANDLE texturesize_var = g_pWaterEffect->GetParameterByName(NULL, "texture_size");
	D3DXHANDLE damping_var = g_pWaterEffect->GetParameterByName(NULL, "fDamping");
	
	Vector4 texturesize;
	texturesize[0] = 1.0f/(float)g_ImageInfo.m_iWidth;
	texturesize[1] = 1.0f/(float)g_ImageInfo.m_iHeight;
	texturesize[2] = (float)g_ImageInfo.m_iWidth;
	texturesize[3] = (float)g_ImageInfo.m_iHeight;

	g_pWaterEffect->SetTechnique(shader);
	g_pWaterEffect->SetTexture(heightmap_prev_var, g_pTextures[TEX_HEIGHT0]);
	g_pWaterEffect->SetTexture(heightmap_current_var, g_pTextures[TEX_HEIGHT1]);
	g_pWaterEffect->SetFloat(damping_var, 0.99f);
	g_pWaterEffect->SetVector(texturesize_var, (D3DXVECTOR4*)&texturesize);

	g_pWaterEffect->Begin(NULL,0);
	g_pWaterEffect->BeginPass(0);
		GutDrawFullScreenQuad_DX9(&g_ImageInfo);
	g_pWaterEffect->EndPass();
	g_pWaterEffect->End();
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:31,代码来源:render_dx9.cpp


示例15: SetupLightingDX9

void SetupLightingDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	device->SetRenderState(D3DRS_LIGHTING, TRUE);
	// 設定環境光
	device->SetRenderState(D3DRS_AMBIENT, ConvertToD3DCOLOR(g_vAmbientLight));
	// 設定光源
	device->LightEnable(0, TRUE);

	D3DLIGHT9 light;
	ZeroMemory( &light, sizeof(light) );

	light.Type = D3DLIGHT_POINT;

	light.Position = *(D3DVECTOR *) &g_Light.m_Position;
	light.Diffuse = *(D3DCOLORVALUE*) &g_Light.m_Diffuse;
	light.Specular = *(D3DCOLORVALUE*) &g_Light.m_Specular;
	light.Range = 100.0f;

	light.Attenuation0 = 1.0f;
	light.Attenuation1 = 0.0f;
	light.Attenuation2 = 0.0f;

	device->SetLight(0, &light);

}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:28,代码来源:render_dx9.cpp


示例16: ConverToLogLuminance

void ConverToLogLuminance(LPDIRECT3DTEXTURE9 pSource, sImageInfo *pInfo)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	device->SetRenderTarget(0, g_pFrameSurface[DOWNSAMPLED_256x256]);
	device->SetDepthStencilSurface(NULL);

	D3DXHANDLE shader = g_pExposureEffect->GetTechniqueByName("LogLuminance");
	g_pExposureEffect->SetTechnique(shader);

	D3DXHANDLE tablevar = g_pExposureEffect->GetParameterByName(NULL, "vLuminanceTable");
	D3DXHANDLE imagevar = g_pExposureEffect->GetParameterByName(NULL, "Image");

	Vector4 vTable(0.21f, 0.71f, 0.072f);
	g_pExposureEffect->SetVector(tablevar, (D3DXVECTOR4*)&vTable);
	g_pExposureEffect->SetTexture(imagevar, pSource);

	g_pExposureEffect->Begin(NULL, 0);
	g_pExposureEffect->BeginPass(0);

	DrawFullScreenQuad(pInfo);

	g_pExposureEffect->EndPass();
	g_pExposureEffect->End();
}
开发者ID:as2120,项目名称:ZNginx,代码行数:25,代码来源:render_dx9.cpp


示例17: ResizeWindowDX9

void ResizeWindowDX9(int width, int height)
{
	// Reset Device
	GutResetGraphicsDeviceDX9();
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// 投影矩陣, 重設水平跟垂直方向的視角.
	float aspect = (float) height / (float) width;
	g_projection_matrix = GutMatrixPerspectiveRH_DirectX(g_fFOV, aspect, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 改變三角形正面的面向
	//device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	// 使用自動normalize功能
	device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);

	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

	device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:26,代码来源:render_dx9.cpp


示例18: RenderFrameDX9

void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	device->BeginScene(); 

	Matrix4x4 view_matrix = g_Control.GetViewMatrix();
	Matrix4x4 world_matrix = g_Control.GetObjectMatrix();

	// normal pass
	if ( g_bPosteffect )
	{
		device->SetRenderTarget(0, g_pFrameSurface[FULLSIZE]);
		device->SetDepthStencilSurface(NULL);
	}
	else
	{
		device->SetRenderTarget(0, g_pMainSurface);
		device->SetDepthStencilSurface(NULL);
	}

	device->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 1.0f, 0);

	device->SetVertexShader(NULL);
	device->SetPixelShader(NULL);

	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	device->SetRenderState(D3DRS_ZENABLE, FALSE);
	device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);

	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&g_proj_matrix);
	device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&view_matrix);
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&world_matrix);

	g_Model_DX9.Render();

	if ( g_bPosteffect )
	{
		ConverToLogLuminance(g_pFrameBuffer[FULLSIZE], &g_ImageInfo);
		// ExpLuminance(g_pFrameSurface[FULLSIZE], g_pFrameBuffer[DOWNSAMPLED_256x256], &g_Image256x256);

		AverageLuminance(g_pFrameBuffer[DOWNSAMPLED_256x256]);
		ExpLuminance();
		AdaptiveLuminance();

		device->SetRenderTarget(0, g_pMainSurface);
		device->SetDepthStencilSurface(NULL);
		//device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0x0, 1.0f, 0);
		
		AutoExposure();

		if ( g_iMode & 0x01 )
		{
			DrawImage(g_pFrameBuffer[LUMINANCE_TEMP], &g_Image1x1, -1.0f, -1.0f, 0.1f, 0.1f);
			DrawImage(g_pFrameBuffer[LUMINANCE_CURRENT], &g_Image1x1, -0.9f, -1.0f, 0.1f, 0.1f);
		}
	}

	device->EndScene();
	device->Present( NULL, NULL, NULL, NULL );
}
开发者ID:as2120,项目名称:ZNginx,代码行数:60,代码来源:render_dx9.cpp


示例19: InitStateDX9

void InitStateDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 使用trilinear
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	//
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	//
	device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);

	device->GetRenderTarget(0, &g_pMainFrameBuffer);
	device->GetDepthStencilSurface(&g_pMainDepthBuffer);

	int width, height;
	GutGetWindowSize(width, height);

	g_iFrameBufferWidth = width * 2;
	g_iFrameBufferHeight = height * 2;

	device->CreateTexture(g_iFrameBufferWidth, g_iFrameBufferHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexture, NULL);
	device->CreateDepthStencilSurface(g_iFrameBufferWidth, g_iFrameBufferHeight, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, FALSE, &g_pDepthStencil, NULL);
	g_pTexture->GetSurfaceLevel(0, &g_pFrameBuffer);
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:29,代码来源:render_dx9.cpp


示例20: InitResourceDX9

bool InitResourceDX9(void)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	// 設定視角轉換矩陣
	g_projection_matrix = GutMatrixOrthoRH_DirectX(g_fOrthoWidth, g_fOrthoHeight, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);

	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);

	// 畫出正向跟反向的三角形
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	// 載入貼圖
	g_pTexture0 = GutLoadTexture_DX9("../../textures/brickwall.tga");
	g_pTexture1 = GutLoadTexture_DX9("../../textures/spotlight_effect.tga");

	// trilinear
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

	// trilinear
	device->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

	return true;
}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:31,代码来源:render_dx9.cpp



注:本文中的GutGetGraphicsDeviceDX9函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GvNAME函数代码示例发布时间:2022-05-30
下一篇:
C++ Gura_Symbol函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap