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


C++ D3DXCreateSprite函数代码示例

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


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

示例1: Assert

MapilVoid D3DSprite::Create( SharedPointer < GraphicsController > pCtrl )
{
Assert(	!m_IsUsed, CURRENT_POSITION, TSTR( "The sprite was already created." ), -1 );

//Create sprite
if( FAILED( D3DXCreateSprite( m_pDev->GetDev().GetPointer(), &m_pD3DSprite ) ) ) {
    throw MapilException( CURRENT_POSITION, TSTR( "Failed to create sprite." ), -1 );
}

m_pGraphicsCtrl = pCtrl;

m_IsUsed = MapilTrue;
}
开发者ID:nutti,项目名称:MAPIL,代码行数:13,代码来源:D3DSprite.cpp

示例2: D3DXCreateSprite

C_Renderer::C_Renderer(C_Device* dev)
{
	m_sprite = 0;
	vb = 0;
	m_dev = dev;
	D3DXCreateSprite(m_dev->GetDevice(), &m_sprite);
	dev->GetDevice()->CreateVertexBuffer(sizeof(Vertex)*VBMAX, D3DUSAGE_DYNAMIC, Vertex_FVF, D3DPOOL_DEFAULT, &vb, 0);

	m_dev->OnDeviceCreated.RegisterSingleHandler<C_Renderer, &C_Renderer::OnDeviceCreated>(this);
	m_dev->OnDeviceLost.RegisterSingleHandler<C_Renderer, &C_Renderer::OnDeviceLost>(this);
	m_dev->OnDeviceRelease.RegisterSingleHandler<C_Renderer, &C_Renderer::OnDeviceRelease>(this);
	m_dev->OnDeviceReset.RegisterSingleHandler<C_Renderer, &C_Renderer::OnDeviceReset>(this);
}
开发者ID:omkar-developer,项目名称:OmkEngine,代码行数:13,代码来源:Dx9Renderer.cpp

示例3: initialize

//------------------------------------------------------------------------------------------------
// Name:  initialize
// Desc:  Sets up the sprite manager for use.  This must be called before
//------------------------------------------------------------------------------------------------
bool SpriteManager::initialize(LPDIRECT3DDEVICE9 d3dDevice)
{
    // Make sure the sprite renderer doesn't already exist
    if (APP_WARNING(mySpriteRenderer != 0)("SpriteManager - multiple initialization"))
        return false;

    // Create the rendering sprite
    if (APP_ERROR(FAILED(D3DXCreateSprite(d3dDevice, &mySpriteRenderer)))("Unable to create sprite renderer for GUI"))
        return false;

    // Success
    return true;
}
开发者ID:karlgluck,项目名称:evidyon-2.10,代码行数:17,代码来源:spritemanager.cpp

示例4: DragAcceptFiles

bool cViewer::OnInit()
{
	DragAcceptFiles(m_hWnd, TRUE);

	D3DXCreateSprite(graphic::GetDevice(), &m_sprite);


	m_scene = new cTestScene(m_sprite);
	m_scene->SetPos(Vector3(100,100,0));




	m_filePath = "../media/mesh.dat";
	m_model = new graphic::cModel();
	//m_model->Create( m_filePath );
	//m_texture.Create("../media/001 copy.jpg");
	//m_model->SetAnimation("../media/ani.ani");
	//m_model->SetAnimation("../media/ani4.ani");
	//m_texture.Create("../media/강소라.jpg");

	//m_image = new graphic::cSprite(m_sprite, 0, "image1");
	//m_image->Create( "../media/강소라.jpg");
	//m_image->SetScale(Vector3(0.5f,0.5f,0.5f));
	//m_image->SetPos( Vector3(200, 200, 0) );


	m_mtrl.InitWhite();

	Vector4 color(1,1,1,1);
	m_light.Init( graphic::cLight::LIGHT_DIRECTIONAL, color * 0.4f, color, color * 0.6f, Vector3(0,-1,0));
	m_light.Bind(0);


	m_camPos = Vector3(100,100,-500);
	m_lookAtPos = Vector3(0,0,0);
	UpdateCamera();

	const int WINSIZE_X = 1024;		//초기 윈도우 가로 크기
	const int WINSIZE_Y = 768;	//초기 윈도우 세로 크기
	Matrix44 proj;
	proj.SetProjection(D3DX_PI / 4.f, (float)WINSIZE_X / (float) WINSIZE_Y, 1.f, 10000.0f) ;
	graphic::GetDevice()->SetTransform(D3DTS_PROJECTION, (D3DXMATRIX*)&proj) ;


	graphic::GetDevice()->LightEnable (
		0, // 활성화/ 비활성화 하려는 광원 리스트 내의 요소
		true); // true = 활성화 , false = 비활성화

	return true;
}
开发者ID:kami36,项目名称:3Dproject,代码行数:51,代码来源:Viewer.cpp

示例5: OnResetDevice

//--------------------------------------------------------------------------------------
// This callback function will be called immediately after the Direct3D device has been 
// reset, which will happen after a lost device scenario. This is the best location to 
// create D3DPOOL_DEFAULT resources since these resources need to be reloaded whenever 
// the device is lost. Resources created here should be released in the OnLostDevice 
// callback. 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnResetDevice( IDirect3DDevice9* pd3dDevice,
                                const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
    HRESULT hr;

    V_RETURN( g_DialogResourceManager.OnD3D9ResetDevice() );
    V_RETURN( g_SettingsDlg.OnD3D9ResetDevice() );

    if( g_pFont )
        V_RETURN( g_pFont->OnResetDevice() );
    if( g_pEffect )
        V_RETURN( g_pEffect->OnResetDevice() );

    // Store the correct technique handles for each material
    for( UINT i = 0; i < g_MeshLoader.GetNumMaterials(); i++ )
    {
        Material* pMaterial = g_MeshLoader.GetMaterial( i );

        const char* strTechnique = NULL;

        if( pMaterial->pTexture && pMaterial->bSpecular )
            strTechnique = "TexturedSpecular";
        else if( pMaterial->pTexture && !pMaterial->bSpecular )
            strTechnique = "TexturedNoSpecular";
        else if( !pMaterial->pTexture && pMaterial->bSpecular )
            strTechnique = "Specular";
        else if( !pMaterial->pTexture && !pMaterial->bSpecular )
            strTechnique = "NoSpecular";

        pMaterial->hTechnique = g_pEffect->GetTechniqueByName( strTechnique );
    }

    // Create a sprite to help batch calls when drawing many lines of text
    V_RETURN( D3DXCreateSprite( pd3dDevice, &g_pTextSprite ) );

    // Setup the camera's projection parameters
    float fAspectRatio = pBackBufferSurfaceDesc->Width / ( FLOAT )pBackBufferSurfaceDesc->Height;
    g_Camera.SetProjParams( D3DX_PI / 4, fAspectRatio, 0.1f, 1000.0f );
    g_Camera.SetWindow( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height );


    g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 );
    g_HUD.SetSize( 170, 170 );
    g_HUD.Refresh();

    g_SampleUI.SetLocation( pBackBufferSurfaceDesc->Width - 170, pBackBufferSurfaceDesc->Height - 350 );
    g_SampleUI.SetSize( 170, 300 );
    g_SampleUI.Refresh();

    return S_OK;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:58,代码来源:MeshFromObj.cpp

示例6: D3DXCreateTextureFromFile

void MOUSE::InitMouse(IDirect3DDevice9* Dev, HWND wnd)
{
	try
	{
		m_pDevice = Dev;

		//Load texture and init sprite
		D3DXCreateTextureFromFile(m_pDevice, "cursor/cursor.dds", &m_pMouseTexture);
		D3DXCreateSprite(m_pDevice, &m_pSprite);

		//Get directinput object
		LPDIRECTINPUT8 directInput = NULL;

		DirectInput8Create(GetModuleHandle(NULL),	// Retrieves the application handle
						   0x0800,					// v.8.0	
						   IID_IDirectInput8,		// Interface ID
						   (VOID**)&directInput,	// Our DirectInput Object
						   NULL);

		//Acquire Default System mouse
		directInput->CreateDevice(GUID_SysMouse, &m_pMouseDevice, NULL);		
		m_pMouseDevice->SetDataFormat(&c_dfDIMouse);
		m_pMouseDevice->SetCooperativeLevel(wnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
		m_pMouseDevice->Acquire();	        

		//Get viewport size and init mouse location
		D3DVIEWPORT9 v;
		m_pDevice->GetViewport(&v);
		m_viewport.left = v.X;
		m_viewport.top = v.Y;
		m_viewport.right = v.X + v.Width;
		m_viewport.bottom = v.Y + v.Height;

		x = v.X + v.Width / 2;
		y = v.Y + v.Height / 2;

		//Release Direct Input Object
		directInput->Release();

		//Create Mouse Sphere
		D3DXCreateSphere(m_pDevice, 0.2f, 5, 5, &m_pSphereMesh, NULL);

		//Create Ball Material
		m_ballMtrl.Diffuse = D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f);
		m_ballMtrl.Specular = m_ballMtrl.Ambient = m_ballMtrl.Emissive = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f);
	}
	catch(...)
	{
		debug.Print("Error in MOUSE::InitMouse()");
	}	
}
开发者ID:Alriightyman,项目名称:RTS,代码行数:51,代码来源:mouse.cpp

示例7: D3DXCreateSprite

	bool Sprite::_Init(std::wstring path)
	{
		LPDIRECT3DDEVICE9 pd3dDevice = pooptube::Application::GetInstance()->GetSceneManager()->GetRenderer()->GetDevice();
		D3DXCreateSprite(pd3dDevice, &m_psprite);

		D3DXCreateTextureFromFile(pd3dDevice, path.c_str(), &m_ptexture);
		D3DSURFACE_DESC desc;
		m_ptexture->GetLevelDesc(0, &desc);
		m_width_texture = desc.Width;
		m_height_texture = desc.Height;
		D3DXMatrixIdentity(&m_matTransform);

		return true;
	}
开发者ID:NHNNEXT,项目名称:2014-01-HUDIGAME-PoopTube,代码行数:14,代码来源:Sprite.cpp

示例8: myAdditions

static void myAdditions(LPDIRECT3DDEVICE9 Device_Interface)
{
	D3DXVECTOR3 imagepos;
	BOOL currentState = (BOOL)(GetAsyncKeyState(VK_INSERT) & 0x8000);

	//Switch ON and OFF
	if(!currentState && oldState) //Si la touche passe de enfoncée à relevée
		DRAW_CROSSHAIR ^= TRUE;
	oldState = currentState;

	if(DRAW_CROSSHAIR)
	{
		//Checks / Init =============================================================================================================
		if(imagetex == NULL)
		{	
			if(!SUCCEEDED(D3DXCreateTextureFromFileEx(Device_Interface, "crosshair.png", D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT_NONPOW2, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, &imageInfo, NULL, &imagetex)))
			{
				DRAW_CROSSHAIR = FALSE;
				return;
			}
		}
		if(sprite == NULL)
		{
			if(!SUCCEEDED(D3DXCreateSprite(Device_Interface, &sprite)))
			{
				DRAW_CROSSHAIR = FALSE;
				return;
			}
		}
		//=============================================================================================================

		if(SUCCEEDED(Device_Interface->BeginScene()))
		{
			//RESOLUTION ?
			D3DVIEWPORT9 vp;
			Device_Interface->GetViewport(&vp);

			imagepos.x = (vp.Width - imageInfo.Width)/2.0f;		//coord x of our sprite
			imagepos.y = (vp.Height - imageInfo.Height)/2.0f;		//coord y of out sprite
			imagepos.z = 0.0f;	

			if(SUCCEEDED(sprite->Begin(D3DXSPRITE_ALPHABLEND)))
			{
				sprite->Draw(imagetex, NULL, NULL, &imagepos, 0xFFFFFFFF);
				sprite->End();
			}
			Device_Interface->EndScene();
		}
	}
}
开发者ID:ergrelet,项目名称:mumble_ol,代码行数:50,代码来源:d3d9.cpp

示例9: srand

void CMarioGame::LoadResources(LPDIRECT3DDEVICE9 d3ddv)
{
    srand((unsigned)time(NULL));

    // TO-DO: not a very good place to initial sprite handler
    D3DXCreateSprite(d3ddv, &_SpriteHandler);


    _Background = CreateSurfaceFromFile(_d3ddv, BACKGROUND_FILE);

    HRESULT res = D3DXCreateSprite(_d3ddv, &_SpriteHandler);

    //khởi tạo mario
    mario_x = 20;
    mario_y = GROUND_Y;

    _IsOnGround = true;

    mario_vx = 0;
    mario_vx_last = 1.0f;
    mario_vy = 0;

    marioSprite = new CSprite(_SpriteHandler, MARIO_IMAGE, 36, 34, 50, 18);

    mario = new Mario(mario_x, mario_y, 36, 34, mario_vx, 0, 0, MARIO_ACCELERATION_X , 0, NULL, marioSprite, NULL, NULL);

    // One sprite only :)
    ground_middle = new CSprite(_SpriteHandler, GROUND_MIDDLE, 32, 32, 1, 1);
    brick = new CSprite(_SpriteHandler, BRICK, 32, 32, 1, 1);

    fallDown = new CSprite(_SpriteHandler, CHECK_FALL, 4, 619, 1, 1);
    //fallBox = new Object(600, 0, 4, 619, 0, 0, fallDown);
    //_CollisionBox = new Object(mario_x, mario_y, 32, 32, mario_vx, mario_vy, mario_right);
    _IsFallOfGround = false;


}
开发者ID:TranAnhMinh,项目名称:NewSuperMarioBrosPC,代码行数:37,代码来源:MarioGame.cpp

示例10: LoadEffectResources

void LoadEffectResources(IDirect3DDevice9 *m_pDevice)
{
	//Calculate sight mesh (a simple quad)
	D3DXCreateMeshFVF(2, 4, D3DXMESH_MANAGED, SimpleVertex::FVF, m_pDevice, &billboardMesh);

	//Create 4 vertices
	SimpleVertex* v = 0;
	billboardMesh->LockVertexBuffer(0,(void**)&v);
	v[0] = SimpleVertex(D3DXVECTOR3(-0.5f, 0.0f, 0.5f), D3DXVECTOR3(0.0f, 1.0f, 0.0f), D3DXVECTOR2(0, 0));
	v[1] = SimpleVertex(D3DXVECTOR3( 0.5f, 0.0f, 0.5f), D3DXVECTOR3(0.0f, 1.0f, 0.0f), D3DXVECTOR2(1, 0));
	v[2] = SimpleVertex(D3DXVECTOR3(-0.5f, 0.0f, -0.5f),D3DXVECTOR3(0.0f, 1.0f, 0.0f), D3DXVECTOR2(0, 1));
	v[3] = SimpleVertex(D3DXVECTOR3( 0.5f, 0.0f, -0.5f),D3DXVECTOR3(0.0f, 1.0f, 0.0f), D3DXVECTOR2(1, 1));
	billboardMesh->UnlockVertexBuffer();

	//Create 2 faces
	WORD* indices = 0;
	billboardMesh->LockIndexBuffer(0,(void**)&indices);	
	indices[0] = 0; indices[1] = 1; indices[2] = 2;
	indices[3] = 1; indices[4] = 3; indices[5] = 2;
	billboardMesh->UnlockIndexBuffer();

	//Set Attributes for the 2 faces
	DWORD *att = 0;
	billboardMesh->LockAttributeBuffer(0,&att);
	att[0] = 0; att[1] = 0;
	billboardMesh->UnlockAttributeBuffer();

	//Sight MTRL
	memset(&whiteMtrl, 0, sizeof(D3DMATERIAL9));
	whiteMtrl.Diffuse = whiteMtrl.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);

	//Load Shaders
	effectVertexShader.Init(m_pDevice, "shaders/effect.vs", VERTEX_SHADER);
	effectPixelShader.Init(m_pDevice, "shaders/effect.ps", PIXEL_SHADER);

	//Get constants
	effectMatW = effectVertexShader.GetConstant("matW");
	effectMatVP = effectVertexShader.GetConstant("matVP");
	effectVCol = effectVertexShader.GetConstant("vertexColor");

	//Create Sprite
	D3DXCreateSprite(m_pDevice, &sprite);

	//Load textures
	D3DXCreateTextureFromFile(m_pDevice, "textures/runes.dds", &runesTexture);
	D3DXCreateTextureFromFile(m_pDevice, "textures/cloud.dds", &cloudTexture);
	D3DXCreateTextureFromFile(m_pDevice, "textures/fireball.dds", &fireballTexture);
	D3DXCreateTextureFromFile(m_pDevice, "textures/lensflare.dds", &lensflareTexture);
}
开发者ID:Alriightyman,项目名称:RTS,代码行数:49,代码来源:effect.cpp

示例11: EnvGetDevice

bool SpriteBatch::Init()
{
	if (sm_state != NOT_READY) return false;
	if (EnvIsInited())
	{
		IDirect3DDevice9* pDevice = EnvGetDevice();
		HRESULT hr = D3DXCreateSprite(pDevice, &g_pSprite);
		if (SUCCEEDED(hr)) 
		{
			sm_state = READY;
			return true;
		}
	}
	return false;
}
开发者ID:gyankatsura,项目名称:GYGF,代码行数:15,代码来源:SpriteBatch.cpp

示例12: OnD3D9CreateDevice

//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    HRESULT hr;

	D3DXCreateSprite( DXUTGetD3D9Device(), &g_pSprite9 );

    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );

	g_pMain	=	new	cMain;
	g_pMain->Init();
	
    return S_OK;
}
开发者ID:tpghks98,项目名称:VirusShot,代码行数:19,代码来源:Peanut.cpp

示例13: UtilityError

	void D3D9GraphicsLayer::Reset()
	{
		HRESULT hResult = m_pD3DDevice->Reset( &m_D3DPresParams );

		if( FAILED( hResult ) )
		{
			throw UtilityError( "[D3D9GraphicsLayer::Reset]: Call to IDirect3DDevice9::Reset failed unexpectedly." );
		}

		// Re-acquire pointer to backbuffer.
		m_pD3DDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &m_pBackBuffer );

		// Re-create the D3DXSprite interface.
		D3DXCreateSprite( m_pD3DDevice, &m_pSpriteInterface );
	}
开发者ID:Jerorfigan,项目名称:GameUtilities,代码行数:15,代码来源:D3D9GraphicsLayer.cpp

示例14:

bool CP3DDraw2D::Sprite_Begin(DWORD flags)
{
    if(!m_pSprite) // vytvor sprite objekt
    {
        if(FAILED(D3DXCreateSprite(g_pD3DDevice, &m_pSprite))) return false;
    }

    if(flags & SPRITE_BILLBOARD || flags & SPRITE_SORT_DEPTH_BACKTOFRONT || flags & SPRITE_SORT_DEPTH_FRONTTOBACK)
    {
        m_pSprite->SetWorldViewLH(NULL, &g_matView);
    }

    if(FAILED(m_pSprite->Begin(flags))) return false;
    return true;
}
开发者ID:k3a,项目名称:Panther3D-1,代码行数:15,代码来源:draw2d.cpp

示例15: OnResetDevice

HRESULT CALLBACK OnResetDevice(IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext)
{
    HRESULT hr;

    V_RETURN(g_DialogResourceManager.OnD3D9ResetDevice());

    if(g_pFont)
        V_RETURN(g_pFont->OnResetDevice());

    V_RETURN(D3DXCreateSprite(pd3dDevice, &g_pTextSprite));

    V_RETURN(g_Board.OnResetDevice(pd3dDevice, pBackBufferSurfaceDesc));
    V_RETURN(g_BackgroundQuad.OnResetDevice());

    D3DXMATRIXA16 matrix;
    D3DXMatrixIdentity(&g_BackgroundQuad.World);

    D3DXMatrixScaling(&matrix, (float)pBackBufferSurfaceDesc->Width, (float)pBackBufferSurfaceDesc->Height,
                       1.0f);
    D3DXMatrixMultiply(&g_BackgroundQuad.World, &g_BackgroundQuad.World, &matrix);

    D3DXMatrixTranslation(&matrix, (float)pBackBufferSurfaceDesc->Width / 2.0f, pBackBufferSurfaceDesc->Height /
                           2.0f, 0.0f);
    D3DXMatrixMultiply(&g_BackgroundQuad.World, &g_BackgroundQuad.World, &matrix);

    g_Board.SetPosition(D3DXVECTOR3(pBackBufferSurfaceDesc->Width / 2.0f, pBackBufferSurfaceDesc->Height / 2.0f,
                                      0));
    g_Board.SetSize(min(pBackBufferSurfaceDesc->Height, pBackBufferSurfaceDesc->Width) * 0.7f);

    g_WhiteArrowDialog.SetLocation(100, pBackBufferSurfaceDesc->Height / 2 - g_WhiteArrowDialog.GetHeight() / 2);
    g_BlackArrowDialog.SetLocation(-100 + pBackBufferSurfaceDesc->Width - g_BlackArrowDialog.GetWidth(),
                                    pBackBufferSurfaceDesc->Height / 2 - g_BlackArrowDialog.GetHeight() / 2);

    g_TheWhiteWinnerDialog.SetLocation(50, pBackBufferSurfaceDesc->Height - 100);
    g_TheBlackWinnerDialog.SetLocation(50, pBackBufferSurfaceDesc->Height - 100);

    float fAspectRatio = pBackBufferSurfaceDesc->Width / (FLOAT)pBackBufferSurfaceDesc->Height;
    g_Camera.SetProjParams(D3DX_PI / 4, fAspectRatio, 0.1f, 1000.0f);
    g_Camera.SetWindow(pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height);

    g_HUD.SetLocation(pBackBufferSurfaceDesc->Width - 170, 0);
    g_HUD.SetSize(170, 170);
    g_SampleUI.SetLocation(pBackBufferSurfaceDesc->Width - 170, 0);
    g_SampleUI.SetSize(170, 300);

    return S_OK;
}
开发者ID:Bastila,项目名称:c-plus-plus-examples,代码行数:47,代码来源:NsRenju.cpp


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