Example #1
0
//============================================================
//	描画処理
//============================================================
void DrawFade(void){
	LPDIRECT3DDEVICE9 pDevice = GetDevice();

	//頂点フォーマット設定
	pDevice->SetFVF(FVF_VERTEX_2D);
	
	//テクスチャの設定
	pDevice->SetTexture(0, g_pTextureFade);
	//ポリゴン描画
	pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 
									NUM_POLYGON,
									&g_aFadeVertex[0],
									sizeof(VERTEX_2D));
}
Example #2
0
int gamePicture::render(LPDIRECT3DDEVICE9 d3dDevice)
{

	struct RocketVertex *pVtx;
	static float seedx = 0.0;
	static float seedy = 0.0;
	static float step = 3;
	int i;
//	float rad;
	D3DXMATRIX matTransform, matScale, matTranslate,  matRotation;


	D3DXMatrixTranslation(&matTranslate, position.x, position.y, position.z);

	D3DXMatrixScaling(&matScale, size.x,size.y,1);
	//rad = D3DXToRadian(orient);
	D3DXMatrixRotationZ(&matRotation, D3DXToRadian(orient));
	matTransform = matScale * matRotation * matTranslate ;

    // Obtain the vertex buffer and update the coordinates
    // buffer may be in device memory.
    if( FAILED(pVtxBuf->Lock( 0, sizeof(RocketVertex) * ROCKET_VTX/2, ( void** )&pVtx, 0 ) ) )
        return E_FAIL;

	// copy the records
	memcpy( pVtx, vtx, sizeof(RocketVertex) * ROCKET_VTX/2 );
	// update the coordinates
	for (i = 0; i < ROCKET_VTX/2; i++) {
		D3DXVec3TransformCoord(&pVtx[i].pos, &vtx[i].pos, &matTransform);
	}
    pVtxBuf->Unlock();
	
	d3dDevice->SetStreamSource( 0, pVtxBuf, 0, sizeof(RocketVertex) );
    d3dDevice->SetFVF(D3DFVF_VERTEX);
	//d3dDevice->SetRenderState(D3DRS_COLORVERTEX, true);
	d3dDevice->SetRenderState(D3DRS_FOGCOLOR , D3DBLEND_ZERO);
	d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); 
	d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 
	//d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); 
	//d3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
	d3dDevice->DrawPrimitive( D3DPT_TRIANGLEFAN, 0, 2 );
	d3dDevice->SetTexture(0, NULL);
   // d3dDevice->DrawPrimitive( D3DPT_LINESTRIP, 0, 3);
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	

	return 0;
}
Example #3
0
VOID RenderQuad()
{
	//// Disable lighting
	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE) ;

	// Set texture
	g_pd3dDevice->SetTexture(0, g_pTexture) ;
	g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex)) ;
	g_pd3dDevice->SetFVF(Vertex_FVF) ;

	// Draw quad
	g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID) ;
	g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ;
}
void ModelMesh::Render( LPDIRECT3DDEVICE9 device )
{
	if( !IsLoaded() )
		return;

	device->SetRenderState( D3DRS_FILLMODE, m_d3d_fillmode);
	device->SetRenderState( D3DRS_CULLMODE, m_d3d_cullmode );

 	device->SetStreamSource( 0, m_vb, 0, sizeof(ModelVertexStruct) );
	device->SetFVF( ModelVertexStruct::FVF );
	device->SetIndices( m_ib );

	device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, m_vertex_size, 0, m_index_size / 3 );
}
Example #5
0
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
	// 開始下繪圖指令
	device->BeginScene(); 
	// 設定資料格式
	device->SetFVF(D3DFVF_XYZ|D3DFVF_TEX1); 
	//device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);

	{
		Matrix4x4 IdentityMatrix; 
		IdentityMatrix.Identity();

		device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &IdentityMatrix);
		device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &IdentityMatrix);
		device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &IdentityMatrix);
		device->SetTexture(0, g_pTexture0);
		// ZBuffer測試條件設為永遠成立
		device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
		// 畫出矩形, 同時會清除ZBuffer
		device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_FullScreenQuad, sizeof(Vertex_VT));
		// ZBuffer測試條件設為小於
		device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS);
	}

	{
		device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &g_projection_matrix);
		// 鏡頭座標系轉換矩陣
		Matrix4x4 view_matrix = GutMatrixLookAtRH(g_eye, g_lookat, g_up);
		device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
		device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &g_world_matrix);
		device->SetTexture(0, g_pTexture1);
		// 開啟混色功能
		device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
		// source_blend_factor = 1
		device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
		// dest_blend_factor = 1
		device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
		// 混色公式 = source_color * 1 + dest_color * 1
		// 畫出矩形
		device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Quad, sizeof(Vertex_VT));
		// 關閉Alpha Test功能
		device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
	}

	// 宣告所有的繪圖指令都下完了
	device->EndScene(); 
	// 把背景backbuffer的畫面呈現出來
	device->Present( NULL, NULL, NULL, NULL );
}
Example #6
0
void CLcMdlSM::RenderMesh()
{
	LPDIRECT3DDEVICE9 pDev = (LPDIRECT3DDEVICE9)LcDev_GetD3Device();

	DWORD dMnLgt;

	pDev->GetRenderState( D3DRS_LIGHTING, &dMnLgt);
	pDev->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
	
	pDev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
	pDev->SetRenderState(D3DRS_ALPHAREF, 0x40);
	pDev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
	
	pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	pDev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	pDev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

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

	pDev->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
	pDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	pDev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

	pDev->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_MODULATE );
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	pDev->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );


	PDTX	pDXTex	= (PDTX)m_pTex->GetPointer();

	pDev->SetTexture(0, pDXTex);
	pDev->SetFVF(VtxNDUV1::FVF);
	pDev->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0
									, m_nVtx
									, m_nIdx
									, m_pIdx
									, D3DFMT_INDEX16
									, m_pVtx
									, sizeof(VtxNDUV1)
									);

	LcD3D_SetWorldIdentity(pDev);
	pDev->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
	pDev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);

	pDev->SetRenderState( D3DRS_LIGHTING, dMnLgt);
}
Example #7
0
	bool restore_objects()
	{
		if ( retry_count )
		{
			if ( --retry_count ) return false;

			release_objects();
			if ( lpdev->Reset( &dpp ) != D3D_OK ) return false;
		}

		retry_count = 0;

		LPDIRECT3DSURFACE9 lpbb;
		HRESULT hr;
		if( SUCCEEDED( hr = lpdev->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, & lpbb ) ) ) {
			lpbb->GetDesc( & d3dsd );
			lpbb->Release();
		}

		lpdev->SetTextureStageState(0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1);
		lpdev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
		lpdev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

		lpdev->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);
		lpdev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
		lpdev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

		lpdev->SetRenderState(D3DRS_LIGHTING, false);
		lpdev->SetRenderState(D3DRS_ZENABLE,  false);
		lpdev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

		lpdev->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA);
		lpdev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
		lpdev->SetRenderState(D3DRS_ALPHABLENDENABLE, false);

		lpdev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);

		if ( lpdev->CreateVertexBuffer( sizeof(d3dvertex) * 4, flags.v_usage, D3DFVF_XYZRHW | D3DFVF_TEX1, (D3DPOOL)flags.v_pool, &lpvbuf, NULL ) != D3D_OK )
			return false;

		update_filtering( 1 );

		lpdev->SetRenderState( D3DRS_DITHERENABLE,   TRUE );

		if ( lpdev->CreateTexture( surface_width, surface_height, 1, flags.t_usage, D3DFMT_X8R8G8B8, (D3DPOOL)flags.t_pool, &lptex, NULL ) != D3D_OK )
			return false;

		return true;
	}
//랜더
void Render(int timeDelta)
{
	//화면 청소
	if (SUCCEEDED(g_pDevice->Clear( 
		0,			//청소할 영역의 D3DRECT 배열 갯수		( 전체 클리어 0 )
		NULL,		//청소할 영역의 D3DRECT 배열 포인터		( 전체 클리어 NULL )
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,	//청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
		D3DCOLOR_XRGB(150, 150, 150),			//컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
		1.0f,				//깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
		0					//스텐실 버퍼를 채울값
		)))
	{
		//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
		g_pDevice->BeginScene();

		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&global->localTm);

		g_pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		g_pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		g_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
		g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, global->addressMode) ;
		g_pDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, global->addressMode) ;

		g_pDevice->SetMaterial(&global->mtrl);

		g_pDevice->SetTexture(0, global->texture);
		g_pDevice->SetStreamSource( 0, global->vb, 0, sizeof(Vertex) );
		g_pDevice->SetIndices(global->ib);
		g_pDevice->SetFVF( Vertex::FVF );
		g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, global->vtxSize, 0, global->faceSize);

		switch (global->mode)
		{
		case sGlobal::RENDER_FACE_NORMAL:
			g_pDevice->SetStreamSource( 0, global->fnvb, 0, sizeof(Vertex) );
			g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, global->faceNormalVtxSize/2);
			break;
		case sGlobal::RENDER_VERTEX_NORMAL:
			g_pDevice->SetStreamSource( 0, global->vnvb, 0, sizeof(Vertex) );
			g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, global->vertexNormalVtxSize/2);
			break;
		}

		//랜더링 끝
		g_pDevice->EndScene();
		//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
		g_pDevice->Present( NULL, NULL, NULL, NULL );
	}
}
Example #9
0
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
    // Clear the backbuffer and the zbuffer
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,	// | D3DCLEAR_STENCIL
                         D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );

    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
        // Setup the materials and lights
        SetupMaterials();
		SetupLights();

        // Setup the world, view, and projection matrices
        SetupMatrices();

        // Render the vertex buffer contents
        g_pd3dDevice->SetStreamSource( 0, g_pVBCylinder, 0, sizeof( CUSTOMVERTEXCYLINDER ) );
        g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEXCYLINDER );
        g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 * 52 - 2 );

		// F**K STENCILS ..|..
		// Enable stencil testing
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
		//
		// Specify the stencil comparison function
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILFUNC, D3DCMP_ALWAYS );
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_INCR );
		//g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
		//g_pd3dDevice->SetRenderState( D3DRS_TWOSIDEDSTENCILMODE, TRUE );

		// Set the comparison reference value
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILREF, 0x1 );

		// Specify a stencil mask 
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILMASK, 0xff00ffff );
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0x0000ffff );
		//g_pd3dDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_KEEP ); 

		// Render all the text
		RenderText();

        // End the scene
        g_pd3dDevice->EndScene();
    }

    // Present the backbuffer contents to the display
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #10
0
void LayerAR::SetRS()
{
	LPDIRECT3DDEVICE9 pDevice = EnvGetDevice();
	pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
	pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
	pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
	pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	pDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
	pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 
	pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
	pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
	pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
	pDevice->SetFVF(MYFVF_PDT);
}
Example #11
0
VOID jcd3d::jcd3d_display(DWORD timeDelta)
{
	if(lpd3dd)
	{
		lpd3dd->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
		lpd3dd->BeginScene();

		lpd3dd->SetStreamSource(0, lpquadvb, 0, sizeof(Vertex));
		lpd3dd->SetFVF(Vertex::FVF);
		lpd3dd->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

		lpd3dd->EndScene();
		lpd3dd->Present(NULL, NULL, NULL, NULL);
	}
}
Example #12
0
void StaticPlane::draw() {
	LPDIRECT3DDEVICE9 device = ShaderDevise::device();
	device->SetFVF(D3DFVF_CUSTOMVERTEX);

	D3DXMATRIX world, view = Camera::view(), proj = Camera::projection();
	D3DXMatrixIdentity(&world);

	device->SetTransform(D3DTS_WORLD, &world);
	device->SetTransform(D3DTS_VIEW, &view);
	device->SetTransform(D3DTS_PROJECTION, &proj);

	device->SetStreamSource(0, vtx, 0, sizeof(CUSTOMVERTEX));
	device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

}
Example #13
0
VOID Render()
{
    if( !g_pd3dDevice ) return;
    LPDIRECT3DDEVICE9 d = g_pd3dDevice;

    d->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
    
    if( SUCCEEDED( d->BeginScene() ) ) {
        d->SetStreamSource( 0, g_pVertexBuff, 0, sizeof(CUSTOMVERTEX) ); // 정점버퍼를 디바이스에 바인딩함
        d->SetFVF( D3DFVF_CUSTOMVERTEX );                                // 디바이스에 정점포맷을 지정
        d->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );                    // 정점버퍼의 폴리곤을 그림
        d->EndScene();
    }
    d->Present( NULL, NULL, NULL, NULL );
}
Example #14
0
VOID render(){

	g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET| D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(192,192,192), 1.0f, 0);
	if(SUCCEEDED(g_pDevice->BeginScene())){
		setupWorldMatrix();
		setLight();
		//Render to the back-buffer
		g_pDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
		g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
		g_pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2* 50 -2);

		g_pDevice->EndScene();
	}
	g_pDevice->Present(NULL, NULL, NULL, NULL);
}
Example #15
0
void CHud::DrawProgressBar(LPDIRECT3DDEVICE9 pd3dDevice, int x, int y, int height, int width, float percent, SColor c, bool bDrawBack){
	float left = (float) x, 
		right = (float) x + width,
		top = (float) y , 
		bottom = (float) y + height,
		fraction = (percent * width) + left;

	pd3dDevice->SetFVF( D3DFVF_XYZRHW|D3DFVF_DIFFUSE );

	// Draw darkened area
	DWORD color = D3DCOLOR_ARGB(alpha, c.r, c.g, c.b);
	SVertex bverts[] = 
	{
		{ left,		bottom,	0.0f,	1.0f,	color },
		{ left,		top,	0.0f,	1.0f,	color },
		{ fraction,	top,	0.0f,	1.0f,	color },
		{ fraction,	bottom,	0.0f,	1.0f,	color },
		{ left,		bottom,	0.0f,	1.0f,	color }
	};
	pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, bverts, sizeof(SVertex));

	if (bDrawBack) {
		// Draw faded area
		color =  D3DCOLOR_ARGB(alpha / 3, c.r, c.g, c.b);
		SVertex cverts[] = 
		{
			{ fraction,		bottom,	0.0f,	1.0f,	color },
			{ fraction,		top,	0.0f,	1.0f,	color },
			{ right,		top,	0.0f,	1.0f,	color },
			{ right,		bottom,	0.0f,	1.0f,	color },
			{ fraction,		bottom,	0.0f,	1.0f,	color }
		};
		pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, cverts, sizeof(SVertex));
	}
	// Draw border
	DWORD tcolor = D3DCOLOR_ARGB(alpha, 255, 255, 255);
	DWORD bcolor = D3DCOLOR_ARGB(alpha, 136, 136, 136);
	SVertex verts[] = 
	{
		{ left,		bottom,	0.0f,	1.0f,	tcolor },
		{ left,		top,	0.0f,	1.0f,	tcolor },
		{ right,	top,	0.0f,	1.0f,	tcolor },
		{ right,	top,	0.0f,	1.0f,	bcolor },
		{ right,	bottom,	0.0f,	1.0f,	bcolor },
		{ left,		bottom,	0.0f,	1.0f,	bcolor }
	};
	pd3dDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 5, verts, sizeof(SVertex));
}
	void cBatchRenderManager::renderLine()
	{
		_getRenderPropertyMgr()->begin();
		_getRenderPropertyMgr()->setProperty(sRenderProperty::LIGHTING, FALSE);

		LPDIRECT3DDEVICE9 device = cD3DSystem::getD3DDevice();
		device->SetTexture(0, NULL);
		device->SetVertexShader(NULL);
		device->SetPixelShader(NULL);
		device->SetFVF(sLineVertex::D3DFVF);

		renderLineList();
		renderLineStrip();

		_getRenderPropertyMgr()->end();
	}
Example #17
0
void RenderQuad()
{
	// Setup texture
	g_pd3dDevice->SetTexture(0, g_pRenderTexture) ;
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU,  D3DTADDRESS_WRAP );
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV,  D3DTADDRESS_WRAP );

	// Set stream source
	g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex) );
	g_pd3dDevice->SetFVF(VertexFVF) ;

	g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ;
}
Example #18
0
void CTile::Render(LPDIRECT3DDEVICE9 _device)
{
	_device->SetStreamSource( 0, m_pVB, 0, sizeof(TILEVERTEX) );
	_device->SetFVF( D3DFVF_CUSTOMVERTEX );
	_device->SetIndices( m_pIB );

	if(_b == true){
		_device->SetMaterial(&m_matrl);
	}else{
		ZeroMemory(&m_matrl, sizeof(D3DMATERIAL9));
		_device->SetMaterial(&m_matrl);
	}

	_device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 6, 0, 2);
	//_device->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);
}
Example #19
0
//랜더
void Render(int timeDelta)
{
	//화면 청소
	if (SUCCEEDED(g_pDevice->Clear( 
		0,			//청소할 영역의 D3DRECT 배열 갯수		( 전체 클리어 0 )
		NULL,		//청소할 영역의 D3DRECT 배열 포인터		( 전체 클리어 NULL )
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL,	//청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
		D3DCOLOR_XRGB(255, 255, 255),			//컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
		1.0f,				//깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
		0					//스텐실 버퍼를 채울값
		)))
	{
		//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
		g_pDevice->BeginScene();

		static float y = 0;
		y += timeDelta / 1000.f;
		// 각도가 2*PI 에 이르면 0으로 초기화한다.
		if (y >= 6.28f)
			y = 0;

		Matrix44 rx, ry, r;
		rx.SetRotationX(MATH_PI/4.f); 	// x축으로 45도 회전시킨다.
		ry.SetRotationY(y); // y축으로 회전
		r = rx*ry;
		g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&r);


		Matrix44 rry;
		rry.SetRotationY(-y); // y축으로 회전
		Vector3 dir = global->lightDir * rry;
		global->light.Direction = *(D3DXVECTOR3*)&dir;
		g_pDevice->SetLight(0, &global->light); // 광원 설정.


		g_pDevice->SetMaterial(&global->mtrl);
		g_pDevice->SetStreamSource( 0, global->vb, 0, sizeof(Vertex) );
		g_pDevice->SetIndices(global->ib);
		g_pDevice->SetFVF( Vertex::FVF );
		g_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, global->vtxSize, 0, global->faceSize);

		//랜더링 끝
		g_pDevice->EndScene();
		//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
		g_pDevice->Present( NULL, NULL, NULL, NULL );
	}
}
Example #20
0
// 使用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 = g_Control.GetViewMatrix();
	Matrix4x4 world_matrix = g_Control.GetObjectMatrix();
	device->SetTransform(D3DTS_VIEW, (D3DMATRIX *) &view_matrix);
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);
	// `設定資料格式`
	device->SetFVF(D3DFVF_XYZ|D3DFVF_TEX1); 

	switch(g_iMode)
	{
	case 1:
		device->SetTexture(0, g_pTexture0);
		// `關閉第 1 層貼圖的使用`
		device->SetTexture(1, NULL);
		device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
		break;
	case 2:
		device->SetTexture(0, g_pTexture1);
		// `關閉第 1 層貼圖的使用`
		device->SetTexture(1, NULL);
		device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
		break;
	case 3:
		device->SetTexture(0, g_pTexture0);
		// `套用并啟動第 1 層貼圖的使用`
		device->SetTexture(1, g_pTexture1);
		// `貼圖座標的來源為第 0 號貼圖座標`
		device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
		// `設定這張貼圖的顏色會做相加`
		//device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD);
		break;
	}

	// `畫出看板`
	device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, g_Quad, sizeof(Vertex_VT));
	// `宣告所有的繪圖指令都下完了`
	device->EndScene(); 
	// `把背景backbuffer的畫面呈現出來`
	device->Present( NULL, NULL, NULL, NULL );
}
Example #21
0
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	device->Clear(
		0, NULL, // 清除整個畫面 
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, // 清除顏色跟Z buffer 
		D3DCOLOR_ARGB(0, 0, 0, 0), // 設定要把顏色清成黑色
		1.0f, // 設定要把Z值清為1, 也就是離鏡頭最遠
		0 // 設定要把Stencil buffer清為0, 在這沒差.
		);

	// 開始下繪圖指令
	device->BeginScene(); 
	// 設定資料格式
	device->SetFVF(D3DFVF_XYZ); 

	for ( int i=0; i<4; i++ )
	{
		// `建立轉換矩陣`
		Matrix4x4 world_matrix;
		world_matrix.Scale_Replace(g_scale[i]); // `建立縮放矩陣`
		world_matrix[3] = g_position[i]; // `直接把位移填入矩陣左下角.`

		// `設定轉換矩陣`
		device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);

		// 畫出金字塔的8條邊線
		device->DrawIndexedPrimitiveUP(
			D3DPT_LINELIST, // 指定所要畫的基本圖形種類 
			0, // 會使用的最小頂點編號, 事實上沒太大用處
			5, // 頂點陣列里有幾個頂點
			8, // 要畫出幾個基本圖形
			g_indices, // 索引陣列
			D3DFMT_INDEX16, // 索引陣列的型態
			g_vertices, // 頂點陣列
			sizeof(Vector4) // 頂點陣列里每個頂點的記憶體間距
			); 
	}

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

	// 把背景backbuffer的畫面呈現出來
	device->Present( NULL, NULL, NULL, NULL );
}
Example #22
0
VOID CGameGUI::OnFrameRender(LPDIRECT3DDEVICE9 pd3dDevice, const CGameEngine::PlayerHashMap &phm, const CGameEngine::SRoundInfo &roundInfo){
	pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
	pd3dDevice->SetFVF( D3DFVF_XYZRHW|D3DFVF_DIFFUSE );

	// Draw HUD
	m_pHud->OnFrameRender(pd3dDevice, phm, roundInfo);

	// Draw registered windows
	int focused = -1;
	for (int i = 0; i < NUM_REGS; i++)
		if (!m_vFocus[i])
			DrawWindow(pd3dDevice, i);
		else
			focused = i;
	if (focused != -1) // Window with focus gets drawn last
		DrawWindow(pd3dDevice, focused);
}  
Example #23
0
void RenderQuad()
{
	// Setup texture
	g_pd3dDevice->SetTexture(0, g_pTexture) ;
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0xffff0000) ; // border color: red
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU,  g_AddressMode );
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV,  g_AddressMode );

	// Set stream source
	g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(Vertex) );
	g_pd3dDevice->SetFVF(VertexFVF) ;

	g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2) ;
}
Example #24
0
// 使用DirectX 9來繪圖
void RenderFrameDX9(void)
{
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	device->Clear(
		0, NULL, // 清除整個畫面 
		D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, // 清除顏色跟Z buffer 
		D3DCOLOR_ARGB(0, 0, 0, 0), // 設定要把顏色清成黑色
		1.0f, // 設定要把Z值清為1, 也就是離鏡頭最遠
		0 // 設定要把Stencil buffer清為0, 在這沒差.
		);

	static float angle = 0.0f;
	angle += 0.01f;

	// 開始下繪圖指令
	device->BeginScene(); 

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

	// 設定轉換矩陣
	Matrix4x4 world_matrix;
	world_matrix.RotateZ_Replace(angle); // 產生旋轉矩陣
	device->SetTransform(D3DTS_WORLD, (D3DMATRIX *) &world_matrix);

	// 畫出金字塔的8條邊線
	device->DrawIndexedPrimitiveUP(
		D3DPT_TRIANGLELIST, // 指定所要畫的基本圖形種類 
		0, // 會使用的最小頂點編號, 事實上沒太大用處
		5, // 頂點陣列里有幾個頂點
		6, // 要畫出幾個基本圖形
		g_indices, // 索引陣列
		D3DFMT_INDEX16, // 索引陣列的型態
		g_vertices, // 頂點陣列
		sizeof(Vertex_VC) // 頂點陣列里每個頂點的記憶體間距
		); 

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

	// 把背景backbuffer的畫面呈現出來
	device->Present( NULL, NULL, NULL, NULL );
}
Example #25
0
// @brief  : 描画
// @param  : 描画の種類
//--------------------------------------------------------------------
void Vertex3dCol::Draw(const TYPE &_type, const UINT &_prim_count)
{
    const D3DPRIMITIVETYPE type[MAX_TYPE] =
    {
        D3DPT_POINTLIST,
        D3DPT_LINELIST,
        D3DPT_LINESTRIP,
        D3DPT_TRIANGLELIST,
        D3DPT_TRIANGLESTRIP
    };
    HRESULT hr;
    LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device;

    hr = device->SetStreamSource(0,m_Buffer,0,sizeof(VERTEX_DX));
    hr = device->SetFVF(FVF);
    hr = device->DrawPrimitive(type[_type],0,_prim_count);
}
Example #26
0
void DxPoint::Draw(
	const float& positionX,
	const float& positionY,
	const float& positionZ,
	const float& scale,
	bool textureBlend)
{
	LPDIRECT3DDEVICE9 pDevice = D3DManager::getInstance()->getDevice();

	D3DXMATRIX matPos;
	D3DXMatrixTranslation(&matPos, positionX, positionY, positionZ);

	pDevice->SetTransform(D3DTS_WORLD, &matPos);

	pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, TRUE);
	pDevice->SetRenderState(D3DRS_POINTSCALE_A, 0);
	pDevice->SetRenderState(D3DRS_POINTSCALE_B, 0);
	pDevice->SetRenderState(D3DRS_POINTSCALE_C, 1036831949);
	pDevice->SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&scale));

	if (textureBlend)
	{
		pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
	}

	pDevice->SetStreamSource(0, mp_vertexBuffer, 0, sizeof(POINT_CUSTOMVERTEX));
	pDevice->SetFVF(POINT_CUSTOMVERTEX::D3DFVF_POINT);
	if (mp_texture)
	{
		pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
		pDevice->SetTexture(0, mp_texture);
	}
	pDevice->DrawPrimitive(D3DPT_POINTLIST, 0, 1);

	if (mp_texture)
	{
		pDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, FALSE);
	}
	pDevice->SetRenderState(D3DRS_POINTSCALEENABLE, FALSE);

	if (textureBlend)
	{
		pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	}
}
Example #27
0
//-----------------------------------------------------------------------------
// Desc: 渲染图形
//-----------------------------------------------------------------------------
VOID Render()
{
	//清空后台缓冲区
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(60, 60, 60), 1.0f, 0 );

	//开始在后台缓冲区绘制图形
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		//在后台缓冲区绘制图形
		g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
		g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
		switch(g_iType)  //选择绘制图元的类型
		{
		case 1:   //三角形条带
			g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 4 );
			break;

		case 2:   //三角形列表
			g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2 );
			break;

		case 3:   //线段条带
			g_pd3dDevice->DrawPrimitive( D3DPT_LINESTRIP, 0, 5 );
			break;

		case 4:  //线段列表
			g_pd3dDevice->DrawPrimitive( D3DPT_LINELIST, 0, 3 );
			break;

		case 5:  //点列表
			g_pd3dDevice->DrawPrimitive( D3DPT_POINTLIST, 0, 6 );
			break;

		case 6:
			g_pd3dDevice->DrawPrimitive(  D3DPT_TRIANGLEFAN, 0, 4);
			break;
		}

		//结束在后台缓冲区渲染图形
		g_pd3dDevice->EndScene();
	}

	//将在后台缓冲区绘制的图形提交到前台缓冲区显示
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #28
0
//**************************Render and display the scene in DirectX***********************
void RenderDX()
{
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Rendering of scene objects can happen here
		g_pd3dDevice->SetStreamSource( 0, vbo, 0, sizeof(CUSTOMVERTEX) );
		g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
		g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );

		// End the scene
		g_pd3dDevice->EndScene();
	}

	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Example #29
0
// 사각형 그리기
void CTexture::DrawRect(
	LPDIRECT3DDEVICE9 device,
	float x, float y, float dx, float dy,
	float u, float v, float du, float dv,
	D3DCOLOR diffuse
	) {
	// 정점 좌표 설정
	VERTEX vertex[4] = {
		{ x, y, 0, 1, diffuse, u, v },
		{ x + dx, y, 0, 1, diffuse, u + du, v },
		{ x, y + dy, 0, 1, diffuse, u, v + dv },
		{ x + dx, y + dy, 0, 1, diffuse, u + du, v + dv }
	};

	// 그리기
	device->SetFVF(D3DFVF_VERTEX);
	device->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, vertex, sizeof(VERTEX));
}
Example #30
0
// 描画
bool CBoard::Draw(const LPDIRECT3DDEVICE9 lpDevice) const 
{
	lpDevice->SetFVF( FVF_VERTEX );

	if( m_IsShaderDraw && m_lpEffect && m_lphWorld )
	{
		D3DXMATRIX mWorld;

		// デバイスから行列獲得
		D3D::GetDevice()->GetTransform( D3DTS_WORLD, &mWorld );

		m_lpEffect->SetValue( m_lphWorld, &mWorld, sizeof(D3DXMATRIX) );
	}

	lpDevice->DrawPrimitiveUP( D3DPT_TRIANGLEFAN, 2, &m_Vertex, sizeof( Vertex ) );
	
	return true;
}