当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECT3DDEVICE8类代码示例

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


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

示例1: BlitRect

void BlitRect(LPDIRECT3DDEVICE8 lpDevice,
			  LPDIRECT3DTEXTURE8 lpSrc,
              RECT* destRect,
			  D3DXVECTOR4* srcTextureCoodRect,
              D3DCOLOR col,float z)
{
    // calculate rhw
	static float inc = 0.05f;
    static float rhw=1.0f; ///(z*990.0f+10.0f);
	if ((rhw<=0) || (rhw>=1))
		inc = - inc;

	rhw += inc;
	
    // set up rectangle
    D3DTLVERTEX verts[4];

    verts[0]=D3DTLVERTEX(D3DXVECTOR3(destRect->left-0.5f,  destRect->top-0.5f,    z),rhw,col,srcTextureCoodRect->x,srcTextureCoodRect->y); 
    verts[1]=D3DTLVERTEX(D3DXVECTOR3(destRect->right-0.5f, destRect->top-0.5f,    z),rhw,col,srcTextureCoodRect->z,srcTextureCoodRect->y);
    verts[2]=D3DTLVERTEX(D3DXVECTOR3(destRect->right-0.5f, destRect->bottom-0.5f,  z),rhw,col,srcTextureCoodRect->z,srcTextureCoodRect->w); 
    verts[3]=D3DTLVERTEX(D3DXVECTOR3(destRect->left-0.5f,  destRect->bottom-0.5f, z),rhw,col,srcTextureCoodRect->x,srcTextureCoodRect->w);

    // set the texture
    lpDevice->SetTexture(0,lpSrc);

    // configure shader for vertex type
    lpDevice->SetVertexShader(D3DFVF_TLVERTEX);

    // draw the rectangle

	//lpDevice->SetTextureStageState(0, D3DTSS_MINFILTER , D3DTEXF_POINT);

    lpDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,verts,sizeof(D3DTLVERTEX));
}
开发者ID:MartinMReed,项目名称:XenDLL,代码行数:34,代码来源:blit.cpp

示例2:

//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DFrame::Render( LPDIRECT3DDEVICE8 pd3dDevice, BOOL bDrawOpaqueSubsets,
                           BOOL bDrawAlphaSubsets, D3DXMATRIX* pmatWorldMatrix )
{
    // For pure devices, specify the world transform. If the world transform is not
    // specified on pure devices, this function will fail.

    D3DXMATRIX matSavedWorld, matWorld;

    if ( NULL == pmatWorldMatrix )
        pd3dDevice->GetTransform( D3DTS_WORLD, &matSavedWorld );
    else
        matSavedWorld = *pmatWorldMatrix;

    D3DXMatrixMultiply( &matWorld, &m_mat, &matSavedWorld );
    pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    if( m_pMesh )
        m_pMesh->Render( pd3dDevice, bDrawOpaqueSubsets, bDrawAlphaSubsets );

    if( m_pChild )
        m_pChild->Render( pd3dDevice, bDrawOpaqueSubsets, bDrawAlphaSubsets, &matWorld );

    pd3dDevice->SetTransform( D3DTS_WORLD, &matSavedWorld );

    if( m_pNext )
        m_pNext->Render( pd3dDevice, bDrawOpaqueSubsets, bDrawAlphaSubsets, &matSavedWorld );

    return S_OK;
}
开发者ID:siruhu,项目名称:Rigidchips15C,代码行数:33,代码来源:d3dfile.cpp

示例3: BeginFrame

bool RageDisplay_D3D::BeginFrame()
{
	GraphicsWindow::Update();

	switch( g_pd3dDevice->TestCooperativeLevel() )
	{
	case D3DERR_DEVICELOST:
		return false;
	case D3DERR_DEVICENOTRESET:
		{
			bool bIgnore = false;
			RString sError = SetD3DParams( bIgnore );
			if( sError != "" )
				RageException::Throw( sError );

			break;
		}
	}

	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
						 D3DCOLOR_XRGB(0,0,0), 1.0f, 0x00000000 );
	g_pd3dDevice->BeginScene();

	return RageDisplay::BeginFrame();
}
开发者ID:SamDecrock,项目名称:stepmania5-http-post-scores,代码行数:25,代码来源:RageDisplay_D3D.cpp

示例4: render

void render()
{
   static RECT rc = {0, 0, 320, 100};   // rectangular region.. used for text drawing
   static DWORD frameCount = 0;
   static DWORD startTime = clock();
   char str[16];

   doMath();   // do the math.. :-P   
   
   frameCount++;   //  increment frame count
    
   // Clear the back buffer to a black... values r g b are 0-256
    lpD3DDevice8->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER ,D3DCOLOR_XRGB(256, 256, 256), 1.0f, 0);

   // render the cubes
   myRect1->render(clock());
   myRect2->render(clock());

   // this function writes a formatted string to a character string
   // in this case.. it will write "Avg fps" followed by the 
   // frames per second.. with 2 decimal places
   sprintf(str, "Avg fps %.2f", (float) frameCount / ((clock() - startTime) / 1000.0f));
      
   // draw the text string..
   lpD3DXFont->Begin();
   lpD3DXFont->DrawText(str, -1, &rc, DT_LEFT, 0xFFFFFFFF);
   lpD3DXFont->End();
   
    // present the back buffer.. or "flip" the page
    lpD3DDevice8->Present( NULL, NULL, NULL, NULL );   // these options are for using rectangular
    // regions for rendering/drawing...
    // 3rd is which target window.. NULL makes it use the currently set one (default)
    // last one is NEVER used.. that happens with DirectX often
}
开发者ID:pnchang,项目名称:advgraphics,代码行数:34,代码来源:example03.cpp

示例5: update

void RenderingManagerC::update()
{

	

	// Clear the backbuffer to a blue color
	    g_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 
	                         D3DCOLOR_XRGB(0,0,255), 1.0f, 0L );
	
	    // Begin the scene
	    g_pd3dDevice->BeginScene();
	
		DrawBackground();
		DrawPlayer();
		
		DrawRaycast();

		DrawPortal(true);
		DrawPortal(false);

		DrawCrossHair();
		//DrawBox(71.0f, 673.0f, 1218.0f, 673.0f, 0x00000000, 0xFFFFFFFF);
		DrawStaticObjects();

	

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

		// Present the backbuffer contents to the display
		g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
开发者ID:maheshvele,项目名称:PortalClone,代码行数:33,代码来源:RenderingManager.cpp

示例6: SetupLights

//-----------------------------------------------------------------------------
// Name: SetupLights()
// Desc: Sets up the lights and materials for the scene.
//-----------------------------------------------------------------------------
VOID SetupLights()
{
    // Set up a material. The material here just has the diffuse and ambient
    // colors set to yellow. Note that only one material can be used at a time.
    D3DMATERIAL8 mtrl;
    ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
    mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
    mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
    mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
    mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
    g_pd3dDevice->SetMaterial( &mtrl );

    // Set up a white, directional light, with an oscillating direction.
    // Note that many lights may be active at a time (but each one slows down
    // the rendering of our scene). However, here we are just using one. Also,
    // we need to set the D3DRS_LIGHTING renderstate to enable lighting
    D3DXVECTOR3 vecDir;
    D3DLIGHT8 light;
    ZeroMemory( &light, sizeof(D3DLIGHT8) );
    light.Type       = D3DLIGHT_DIRECTIONAL;
    light.Diffuse.r  = 1.0f;
    light.Diffuse.g  = 1.0f;
    light.Diffuse.b  = 1.0f;
    vecDir = D3DXVECTOR3(cosf(timeGetTime()/350.0f),
                         1.0f,
                         sinf(timeGetTime()/350.0f) );
    D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
    light.Range       = 1000.0f;
    g_pd3dDevice->SetLight( 0, &light );
    g_pd3dDevice->LightEnable( 0, TRUE );
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

    // Finally, turn on some ambient light.
    g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
}
开发者ID:grakidov,项目名称:Render3D,代码行数:39,代码来源:Lights.cpp

示例7: SetupMatrices

//-----------------------------------------------------------------------------
// Name: SetupMatrices()
// Desc: Sets up the world, view, and projection transform matrices.
//-----------------------------------------------------------------------------
VOID SetupMatrices()
{
    // For our world matrix, we will just rotate the object about the y-axis.
    D3DXMATRIX matWorld;
    D3DXMatrixRotationY( &matWorld, timeGetTime()/150.0f );
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    // Set up our view matrix. A view matrix can be defined given an eye point,
    // a point to lookat, and a direction for which way is up. Here, we set the
    // eye five units back along the z-axis and up three units, look at the
    // origin, and define "up" to be in the y-direction.
    D3DXMATRIX matView;
    D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 3.0f,-5.0f ),
                                  &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
                                  &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
    g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );

    // For the projection matrix, we set up a perspective transform (which
    // transforms geometry from 3D view space to 2D viewport space, with
    // a perspective divide making objects smaller in the distance). To build
    // a perpsective transform, we need the field of view (1/4 pi is common),
    // the aspect ratio, and the near and far clipping planes (which define at
    // what distances geometry should be no longer be rendered).
    D3DXMATRIX matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
    g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
}
开发者ID:grakidov,项目名称:Render3D,代码行数:31,代码来源:Matrices.cpp

示例8: InitD3D

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object.
    if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    // Get the current desktop display mode, so we can set up a back
    // buffer of the same format
    D3DDISPLAYMODE d3ddm;
    if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
        return E_FAIL;

    // Set up the structure used to create the D3DDevice
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = d3ddm.Format;

    // Create the D3DDevice
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Turn off culling, so we see the front and back of the triangle
    g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

    // Turn off D3D lighting, since we are providing our own vertex colors
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:39,代码来源:Matrices.cpp

示例9: setup

void setup()
{
 // Turn off culling, so we see the front and back of the triangle
    d3ddevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );

    d3ddevice->SetRenderState( D3DRS_AMBIENT, 0x00000000 );
	d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE ,TRUE );
	d3ddevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
	d3ddevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
	d3ddevice->SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
	d3ddevice->SetTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
	d3ddevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG2);
	d3ddevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );
	d3ddevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

 
	d3ddevice->SetRenderState( D3DRS_ZENABLE, TRUE );
    d3ddevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE);
 	
	D3DXMatrixIdentity(&matView);
	D3DXMatrixIdentity(&matProj);
	D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 0.0f,-15.0f ),
                              &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
                              &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
	D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.333f, 1.0f, 100.0f );

	CreateShaders();
    CreateObjects();
}
开发者ID:duhone,项目名称:Old3DWork,代码行数:29,代码来源:diffuse+specular+bump+map.cpp

示例10:

void RageDisplay_D3D::SetSphereEnvironmentMapping( bool b )
{
	if( g_iCurrentTextureIndex >= (int) g_DeviceCaps.MaxSimultaneousTextures )	// not supported
		return;

	// http://www.gamasutra.com/features/20000811/wyatt_03.htm

	if( b )
	{
		RageMatrix tex = RageMatrix
		(
			0.40f,  0.0f,  0.0f, 0.0f,
			0.0f,  -0.40f, 0.0f, 0.0f,
			0.0f,   0.0f,  0.0f, 0.0f,
			0.50,  -0.50,  0.0f, 1.0f
		);
		g_pd3dDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+g_iCurrentTextureIndex), (D3DMATRIX*)&tex);
	}

    // Tell D3D to use transformed reflection vectors as texture co-ordinate 0
    // and then transform this coordinate by the specified texture matrix, also
    // tell D3D that only the first two coordinates of the output are valid.
    g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_TEXTURETRANSFORMFLAGS, b ? D3DTTFF_COUNT2 : D3DTTFF_DISABLE );    
    g_pd3dDevice->SetTextureStageState( g_iCurrentTextureIndex, D3DTSS_TEXCOORDINDEX, b ? D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR : D3DTSS_TCI_PASSTHRU );    
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:25,代码来源:RageDisplay_D3D.cpp

示例11: CreateLight

void CreateLight()
{

    // Fill in a light structure defining our light
    D3DLIGHT8 light;
    memset( &light, 0, sizeof(D3DLIGHT8) );
    light.Type    = D3DLIGHT_POINT;
    light.Ambient = (D3DXCOLOR)D3DCOLOR_RGBA(0,0,0,255);
    light.Diffuse = (D3DXCOLOR)D3DCOLOR_RGBA(255,255,255,255);
    light.Specular = (D3DXCOLOR)D3DCOLOR_RGBA(150,150,150,255);
    light.Range   = 300.0f;
    light.Position = D3DXVECTOR3(0,-5,5);
    light.Attenuation0 = 0.5f;
    light.Attenuation1 = 0.02f;
    light.Attenuation2 = 0.0f;

    // Create a direction for our light - it must be normalized
    light.Direction = g_lightDir;

    // Tell the device about the light and turn it on
    g_pd3dDevice->SetLight( 0, &light );
    g_pd3dDevice->LightEnable( 0, TRUE );
    d3dSetRenderState( D3DRS_LIGHTING, TRUE );

}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例12: sizeof

void RageDisplay_D3D::SetLightDirectional( 
	int index, 
	const RageColor &ambient, 
	const RageColor &diffuse, 
	const RageColor &specular, 
	const RageVector3 &dir )
{
	g_pd3dDevice->LightEnable( index, true );

	D3DLIGHT8 light;
	ZERO( light );
	light.Type = D3DLIGHT_DIRECTIONAL;

	/* Z for lighting is flipped for D3D compared to OpenGL.
	 * XXX: figure out exactly why this is needed.  Our transforms 
	 * are probably goofed up, but the Z test is the same for both
	 * API's, so I'm not sure why we don't see other weirdness. -Chris */
	float position[] = { dir.x, dir.y, -dir.z };
	memcpy( &light.Direction, position, sizeof(position) );
	memcpy( &light.Diffuse, diffuse, sizeof(diffuse) );
	memcpy( &light.Ambient, ambient, sizeof(ambient) );
	memcpy( &light.Specular, specular, sizeof(specular) );
	
	// Same as OpenGL defaults.  Not used in directional lights.
//	light.Attenuation0 = 1;
//	light.Attenuation1 = 0;
//	light.Attenuation2 = 0;

	g_pd3dDevice->SetLight( index, &light );
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:30,代码来源:RageDisplay_D3D.cpp

示例13: SetupRenderState

void SetupRenderState()
{
    SetCamera();
    SetMaterial();

    d3dSetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
    d3dSetRenderState( D3DRS_LIGHTING, TRUE );
    d3dSetRenderState( D3DRS_ZENABLE, TRUE); //D3DZB_TRUE );
    d3dSetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
    d3dSetRenderState( D3DRS_NORMALIZENORMALS, FALSE );
    d3dSetRenderState( D3DRS_SPECULARENABLE, g_shininess > 0 );
    if(world.isWireframe)
        d3dSetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
    else
        d3dSetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);


    if (world.isTextureMode)
    {
        d3dSetTextureStageState(0, D3DTSS_COLOROP,	 D3DTOP_MODULATE);
        d3dSetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
        d3dSetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);
        d3dSetTextureStageState(0, D3DTSS_ALPHAOP,	 D3DTOP_DISABLE);
        d3dSetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
        d3dSetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
        d3dSetTextureStageState(0, D3DTSS_MIPFILTER, D3DTEXF_NONE);
        d3dSetTextureStageState(0, D3DTSS_ADDRESSU,  D3DTADDRESS_CLAMP);
        d3dSetTextureStageState(0, D3DTSS_ADDRESSV,  D3DTADDRESS_CLAMP);
        d3dSetTextureStageState(1, D3DTSS_COLOROP,	 D3DTOP_DISABLE);
        d3dSetTextureStageState(1, D3DTSS_ALPHAOP,	 D3DTOP_DISABLE);

        g_pd3dDevice->SetTexture( 0, g_Texture );
        g_pd3dDevice->SetTexture( 1, NULL );
    }
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例14: max

void RageDisplay_D3D::DrawQuadStripInternal( const RageSpriteVertex v[], int iNumVerts )
{
	// there isn't a quad strip primitive in D3D, so we have to fake it with indexed triangles
	int iNumQuads = (iNumVerts-2)/2;
	int iNumTriangles = iNumQuads*2;
	int iNumIndices = iNumTriangles*3;

	// make a temporary index buffer
	static vector<uint16_t> vIndices;
	unsigned uOldSize = vIndices.size();
	unsigned uNewSize = max(uOldSize,(unsigned)iNumIndices);
	vIndices.resize( uNewSize );
	for( uint16_t i=(uint16_t)uOldSize/6; i<(uint16_t)iNumQuads; i++ )
	{
		vIndices[i*6+0] = i*2+0;
		vIndices[i*6+1] = i*2+1;
		vIndices[i*6+2] = i*2+2;
		vIndices[i*6+3] = i*2+1;
		vIndices[i*6+4] = i*2+2;
		vIndices[i*6+5] = i*2+3;
	}

	g_pd3dDevice->SetVertexShader( D3DFVF_RageSpriteVertex );
	SendCurrentMatrices();
	g_pd3dDevice->DrawIndexedPrimitiveUP(
		D3DPT_TRIANGLELIST, // PrimitiveType
		0, // MinIndex
		iNumVerts, // NumVertices
		iNumTriangles, // PrimitiveCount,
		&vIndices[0], // pIndexData,
		D3DFMT_INDEX16, // IndexDataFormat,
		v, // pVertexStreamZeroData,
		sizeof(RageSpriteVertex) // VertexStreamZeroStride
	);
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:35,代码来源:RageDisplay_D3D.cpp

示例15: EndFrame

void EndFrame()
{
	d3ddevice->EndScene();


	d3ddevice->Present( NULL, NULL, NULL, NULL );

}
开发者ID:duhone,项目名称:Old3DWork,代码行数:8,代码来源:diffuse+specular+bump+map.cpp


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