Exemple #1
0
void CMessageBoxScene::Draw(float dt)
{
	LPD3DXSPRITE pSprite = GetSprite();
	LPD3DXFONT pFont = GetFont();

	// Darken down any other Scenes that were drawn beneath the popup.
	float alpha = 1 - GetTransPos();
	GetEngine()->DrawColourTint(D3DXCOLOR(0, 0, 0, alpha * 2 / 3));

	// compute the sizes
	RECT scr = GetEngine()->GetWindowRect();
	D3DXVECTOR2 scrSize((float)scr.right, (float)scr.bottom);
	D3DXVECTOR2 textSize = GetTextSize(pFont, mText.c_str());
	D3DXVECTOR2 textPos = (scrSize - textSize) / 2;

	const int VPAD = 16, HPAD = 32;	// padding
	RECT bg;
	bg.left = (int)textPos.x - HPAD;
	bg.top = (int)textPos.y - VPAD;
	bg.right = bg.left + (int)textSize.x + HPAD * 2;
	bg.bottom = bg.top + (int)textSize.y + VPAD * 2;

	D3DCOLOR col = D3DCOLOR_ARGB((int)(255 * alpha), 255, 255, 255);
	pSprite->Begin(D3DXSPRITE_ALPHABLEND);	// must have ALPHABLEND or font looks awful
	// stretch the 8x8 background into its area
	DrawSprite(pSprite, mpTexture, bg, col);
	// add text (using the sprite batch)
	DrawD3DFontEx(pFont, pSprite, mText.c_str(), (int)textPos.x, (int)textPos.y,
		col);
	pSprite->End();
}
void CImage::DrawSprite(LPD3DXSPRITE SpriteInterface, LPDIRECT3DTEXTURE9 TextureInterface, int PosX, int PosY, int Rotation, int Align)
{
	if(SpriteInterface == NULL || TextureInterface == NULL)
		return;

	D3DXVECTOR3 Vec;

	Vec.x = (FLOAT)PosX;
	Vec.y = (FLOAT)PosY;
	Vec.z = (FLOAT)0.0f;

	D3DXMATRIX mat;
	D3DXVECTOR2 scaling(1.0f, 1.0f);
	D3DSURFACE_DESC desc;
	TextureInterface->GetLevelDesc(0, &desc);
	D3DXVECTOR2 spriteCentre;
	if(Align == 1)
		spriteCentre = D3DXVECTOR2((FLOAT)desc.Width / 2, (FLOAT)desc.Height / 2);
	else
		spriteCentre = D3DXVECTOR2(0, 0);
	D3DXVECTOR2 trans = D3DXVECTOR2(0, 0);
	D3DXMatrixTransformation2D(&mat, NULL, 0.0, &scaling, &spriteCentre, (FLOAT)Rotation, &trans);

	SpriteInterface->SetTransform(&mat);
	SpriteInterface->Begin(D3DXSPRITE_ALPHABLEND);
	SpriteInterface->Draw(TextureInterface, NULL, NULL, &Vec, 0xFFFFFFFF);
	SpriteInterface->End();
}
Exemple #3
0
void CGameEnd::Render(LPDIRECT3DDEVICE9& dxdevice, LPD3DXSPRITE& dxsprite)
{
	dxsprite->Begin(D3DXSPRITE_ALPHABLEND);
	dxsprite->Draw(GMAIN->m_pGameTex[6].m_pTex, &(GMAIN->rc), NULL, &(GMAIN->vcPos), D3DXCOLOR(1, 1, 1, 1.f));
	////////////////////////////////////////////////////////////////////////////////
	dxsprite->End();

	GMAIN->m_text.Begin();
	char	scoreBuf[80];
	TCHAR	fpsBuf[128];

	if (GMAIN->m_nGameBeforePhase == ST_MULTI) {
		sprintf(scoreBuf, "%d", GGAMEMULTI->score);//멀티 게임 점수
	}
	else {
		sprintf(scoreBuf, "%d", GGAME->score);//싱글 게임 점수.
	}
	

	GMAIN->m_text.Draw("Game Over", 355, 250, D3DXCOLOR(0, 0, 0, 1));

	GMAIN->m_text.Draw("Total Score", 355, 300, D3DXCOLOR(0, 0, 0, 1));
	GMAIN->m_text.Draw(scoreBuf, 355, 320, D3DXCOLOR(0, 0, 0, 1));

	GMAIN->m_text.Draw("Press Enter for going back to Menu", 250, 400, D3DXCOLOR(0, 0, 0, 1));

	////////////////////////////////////////////////////////////////////////////////
	//FPS 화면에 출력
	sprintf(fpsBuf, "FPS: %4.1f", GMAIN->m_fFps);
	GMAIN->m_text.Draw(fpsBuf, 700, 300);

	GMAIN->m_text.End();
}
Exemple #4
0
void Renderer::End(){
#if IS_XBOX
	// Present the backbuffer contents to the display
	//g_pd3dDevice->EndScene();
	m_sprite->End();
	g_pd3dDevice->Present( nullptr, nullptr, nullptr, nullptr );
#endif
}
Exemple #5
0
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();
		}
	}
}
Exemple #6
0
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
	renderDevice->Clear(0,NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);
	renderDevice->BeginScene();
	if(bg->getTexture())
	{
		sprite->Begin(D3DXSPRITE_ALPHABLEND);
		sprite->Draw(bg->getTexture(), bg->getSource(), bg->getCenter(), bg->getPosition(), 0xFFFFFFFF);
		sprite->End();
		// End the scene
	}
	renderDevice->EndScene();
	renderDevice->Present( NULL, NULL, NULL, NULL );
}
Exemple #7
0
void HookD3D9::DrawSprite(unsigned int texId, long left, long top, long right, long bottom, float posX,
						  float posY, int r, int g, int b, int a)
{
	RECT destRect = {left, top, right, bottom};
	LPD3DXSPRITE sprite = sprites[texId];
	LPDIRECT3DTEXTURE9 texture = textures[texId];
	D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 pos(posX, posY, 0.0f);

	sprite->Begin(D3DXSPRITE_ALPHABLEND);

    sprite->Draw(texture, NULL, NULL, &pos, D3DCOLOR_RGBA(r, g, b, a));

	sprite->End();
}
Exemple #8
0
BOOL dx9vid_render()
{
   // clear the window to a deep blue
   d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
   d3ddev->BeginScene();    // begins the 3D scene
   g_screenSprite->Begin( 0 );

   d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
   d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
   d3ddev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);

   g_screenSprite->Draw( g_screenTex, &srcRect, &vCenter, &vPosition,
                     D3DCOLOR_COLORVALUE(1.0f,1.0f,1.0f,1.0f) );
   g_screenSprite->End();
   d3ddev->EndScene();    // ends the 3D scene
   d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
   return TRUE;
}
void TextBox::Render()
{
	LPD3DXSPRITE sprite;
	D3DXCreateSprite(device, &sprite);
	sprite->Begin(0);

	if (!masked) font->DrawText(sprite, (label + text).c_str(), -1, &surface, DT_LEFT|DT_NOCLIP, color);
	else
	{
		std::string mask = "";
		for(unsigned int i = 0; i < text.length(); ++i)
			mask.push_back('*');

		font->DrawText(sprite, (label + mask).c_str(), -1, &surface, DT_LEFT|DT_NOCLIP,  color);
	}

	sprite->End();
	sprite->Release();
}
Exemple #10
0
	void DrawTexture(Texture *texture, int x, int y) {
		if(texture->imageLoaded == false) {
			return;
		}

		D3DXVECTOR3 pos(x, y, 0);
		//draw sprite with or without alpha-channel transparency
		if(transparent) {
			spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);
		} else {
			spriteHandler->Begin(NULL);
		}

		TransformTexture();

		spriteHandler->Draw(textureList[texture->textureIndex], NULL, NULL, &pos,
												texture->color);

		spriteHandler->End();
	}
Exemple #11
0
HRESULT Game::render( IDirect3DDevice9 *d3dDevice, double totalTime,
					 float elapsedTime, void *data )
{
	HRESULT hr;

	V(d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(0, 45, 50, 170), 1.0f, 0));
	if(SUCCEEDED(d3dDevice->BeginScene()))
	{
		LPD3DXSPRITE sprite = ClientController::instance().getSprite();
		if(SUCCEEDED(sprite->Begin(0)))
			V(sprite->End());
		wObjects.swap();
		world->Render();
		terrainTest->Render();
		particleTest->render();
		V(d3dDevice->EndScene());
		d3dDevice->Present(NULL, NULL, NULL, NULL);
		// Update Sound
		sound.DoWork();
	}
	return S_OK;
}
Exemple #12
0
void CGameStart::Render(LPDIRECT3DDEVICE9& dxdevice, LPD3DXSPRITE& dxsprite)
{
	dxsprite->Begin(D3DXSPRITE_ALPHABLEND);
	dxsprite->Draw(GMAIN->m_pGameTex[5].m_pTex, &(GMAIN->rc), NULL, &(GMAIN->vcPos), D3DXCOLOR(1, 1, 1, 1.f));
	dxsprite->End();
}
Exemple #13
0
void renderD3d(void) {
    static float movementA = 0.1f, rotateB = 0.0f;
    rotateB += 0.1f;
    rotateAZ = rotateB;
    D3DXMATRIX matrixMoveA, matrixMoveB, matrixMoveC, matrixRotateAX, matrixRotateAX2, matrixRotateAY;
    D3DXMATRIX matrixRotateAY2, matrixRotateAZ, matrixRotateBX, matrixRotateBY, matrixRotateBWide;
    D3DXMATRIX matrixRotateMesh3, matrixScaleA, matrixScaleB, matrixView, matrixProjection;	//	pipeline projection matrixes
    D3DXMATRIX matrixCamRotateY, matrixCamMove;
    RECT part;	//	rectangular area for sprite drawing
    D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);	//	center at the upper-left corner (I dont get it) for sprite
    D3DXVECTOR3 position((float)SCREEN_WIDTH/2-128, 20.0f, 0.0f);	//	position sprite at center
    if (launch)
        if (movementA < 50.0f) movementA *= 1.1f;
        else movementA += 5.0f;
    if (movementA > 100.0f) {
        movementA = 0.1f;
        launch = false;
    }

    // clear the window to specified colors
    d3d9dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(backgroundColorRed, backgroundColorGreen, backgroundColorBlue), 1.0f, 0);

    //	pipeline transformations
    //	build a matrix to rotate the model based on the increasing float value
    // do 3D rendering on the back buffer here
    d3d9dev->BeginScene();    // begins the 3D scene
    D3DXMatrixLookAtLH(&matrixView,
                       &D3DXVECTOR3 (0.0f, 0.0f, 10.0f),    // the camera position
                       &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),    // the look-at position
                       &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));    // the up direction
    d3d9dev->SetTransform(D3DTS_VIEW, &matrixView);    // set the view transform to matView
    D3DXMatrixPerspectiveFovLH(&matrixProjection,
                               D3DXToRadian(45),    // the horizontal field of view
                               (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT, // aspect ratio
                               1.0f,    //	the near view-plane
                               100.0f);    // the far view-plane
    d3d9dev->SetTransform(D3DTS_PROJECTION, &matrixProjection);    // set the projection

    D3DXMatrixTranslation(&matrixCamMove, moveCamX, moveCamY, moveCamZ);
    D3DXMatrixRotationY(&matrixCamRotateY, rotateCamY);
    d3d9dev->SetTransform(D3DTS_VIEW, &(matrixCamMove*matrixCamRotateY));	//	move camera

    d3d9dev->SetFVF(CUSTOMFVF);	// select which vertex format we are using
    d3d9dev->SetStreamSource(0, d3d9VertexBuffer1, 0, sizeof(CUSTOMVERTEX));	// select the triangle vertex buffer to display
    d3d9dev->SetMaterial(material);
    d3d9dev->SetTexture(0, texture3);
    D3DXMatrixTranslation(&matrixMoveA, -2.0f, 2.0f, 3.0f);
    D3DXMatrixRotationX(&matrixRotateAX, rotateAX);
    D3DXMatrixRotationX(&matrixRotateAX2, rotateAX-2.0f*rotateAX);
    D3DXMatrixRotationY(&matrixRotateAY, rotateAY);
    D3DXMatrixRotationY(&matrixRotateAY2, rotateAY+3.14159f);
    D3DXMatrixRotationZ(&matrixRotateAZ, rotateAZ);
    //	a matrix to scale the triangle
    D3DXMatrixScaling(&matrixScaleA, scaleA, scaleA, scaleA);
    //	tell Direct3D about our matrixes, set them in action
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixRotateAX*matrixRotateAY*matrixRotateAZ*matrixMoveA));
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixRotateAX2*matrixRotateAY2*matrixRotateAZ*matrixMoveA));
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);

    //	draw mesh, using almost same transformations as the triangle
    D3DXMatrixRotationY(&matrixRotateMesh3, 1.0f);
    D3DXMatrixTranslation(&matrixMoveA, 0.0f, 0.0f, (0.0f-movementA));
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixScaleA*matrixMoveA*matrixRotateAX*matrixRotateAY));
    for (DWORD i = 0; i < numMaterials; i++) {
        d3d9dev->SetMaterial(&materialX[i]);
        d3d9dev->SetTexture(0, planeTexture[i]);
        mesh3->DrawSubset(i);
    }

    d3d9dev->SetFVF(CUSTOMFVF);
    d3d9dev->SetMaterial(material);
    //	cube
    D3DXMatrixTranslation(&matrixMoveB, 0.0f, 0.0f, 3.0f);
    D3DXMatrixRotationX(&matrixRotateBX, rotateB);
    D3DXMatrixRotationY(&matrixRotateBY, rotateB);
    D3DXMatrixRotationY(&matrixRotateBWide, rotateB);
    D3DXMatrixScaling(&matrixScaleB, 0.2f, 0.2f, 0.2f);
    //	set vertex buffer source (contains the vertices coord-array in the video ram)
    d3d9dev->SetStreamSource(0, d3d9VertexBuffer2, 0, sizeof(CUSTOMVERTEX));
    // set the texture to be drawn on everything below
    d3d9dev->SetTexture(0, texture1);
    //	apply transformations (animation matrixes)
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixRotateBX*matrixRotateBY*matrixScaleB*matrixMoveB*matrixRotateBWide));
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
    //	change texture for last side of cube
    //	set the texture to be drawn on everything below
    d3d9dev->SetTexture(0, texture2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);
    d3d9dev->SetTexture(0, texture1);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 8, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 12, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 16, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 20, 2);

    //	cube2
    D3DXMatrixTranslation(&matrixMoveB, 2.0f, 2.0f, 3.0f);
    D3DXMatrixRotationX(&matrixRotateBX, rotateB*1.1f);
    D3DXMatrixRotationY(&matrixRotateBY, rotateB*0.9f);
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixRotateBX*matrixRotateBY*matrixScaleB*matrixMoveB));
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
    //	change texture for last side of cube
    //	set the texture to be drawn on everything below
    d3d9dev->SetTexture(0, texture2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);
    d3d9dev->SetTexture(0, texture1);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 8, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 12, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 16, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 20, 2);

    //	cube3
    D3DXMatrixTranslation(&matrixMoveB, -2.0f, -2.0f, 3.0f);
    D3DXMatrixRotationX(&matrixRotateBX, rotateB*0.44f);
    D3DXMatrixRotationY(&matrixRotateBY, rotateB);
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixRotateBX*matrixRotateBY*matrixScaleB*matrixMoveB));
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
    //	change texture for last side of cube
    //	set the texture to be drawn on everything below
    d3d9dev->SetTexture(0, texture2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 4, 2);
    d3d9dev->SetTexture(0, texture1);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 8, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 12, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 16, 2);
    d3d9dev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 20, 2);

    d3d9dev->SetTexture(0, NULL);
    D3DXMatrixTranslation(&matrixMoveB, 5.0f, -5.0f, -20.0f);
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixRotateAY*matrixRotateAX*matrixMoveB));
    mesh1->DrawSubset(0);

    //	spheres
    D3DXMatrixRotationX(&matrixRotateBX, rotateB);
    D3DXMatrixRotationY(&matrixRotateBY, rotateB*0.9f);
    D3DXMatrixRotationZ(&matrixRotateAZ, rotateB*1.1f);
    D3DXMatrixTranslation(&matrixMoveA, -1.4f, 0.0f, 0.0f);
    D3DXMatrixTranslation(&matrixMoveB, -2.0f, -2.0f, 3.0f);
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixMoveA*matrixRotateBY*matrixRotateBX*matrixRotateAZ*matrixMoveB));
    mesh2->DrawSubset(0);
    D3DXMatrixTranslation(&matrixMoveA, 1.4f, 0.0f, 0.0f);
    D3DXMatrixTranslation(&matrixMoveB, -2.0f, -2.0f, 3.0f);
    d3d9dev->SetTransform(D3DTS_WORLD, &(matrixMoveA*matrixRotateBY*matrixRotateBX*matrixMoveB));
    mesh2->DrawSubset(0);

    //	sprite legend
    legendSprite->Begin(D3DXSPRITE_ALPHABLEND);
    SetRect(&part, 0, 0, 256, 256);
    position = D3DXVECTOR3(0.0f, 0.0f, 0.0f);	//	position at center
    legendSprite->Draw(legendTexture, &part, &center, &position, D3DCOLOR_ARGB(127, 255, 255, 255));
    legendSprite->End();	//	end sprite drawing

    //	sprite menu effect
    sprite->Begin(D3DXSPRITE_ALPHABLEND);

    /*	sprite sample by directxtutorial.com
    //	count from 0 to 22 to determine the current frame
    if(frame < 22) frame++;	//	if we aren't on the last frame, go to the next frame
    if(frame < 11) xpos = frame * 182 + 1;
    if(frame > 12 && frame < 22) xpos = (frame - 12) * 182 + 1;
    if(frame < 11) ypos = 1;
    if(frame > 12 && frame < 22) ypos = 123;

    //	draw the selected frame using the coordinates
    SetRect(&part, xpos, ypos, xpos + 181, ypos + 121);
    position = D3DXVECTOR3((float)SCREEN_WIDTH/2-91, (float)SCREEN_HEIGHT/2-61, 0.0f);	//	position at center
    */

    //	my sprite
    //	sprite.png frames:
    //	1st row    1 | 2 | 3 | 4
    //	           -------------
    //	2nd row    5 | 6 | 7 | 8
    if (frame < 8) {
        frame++;	//	if we aren't on the last frame, go to the next frame
    }
    if (frame == 1) {
        xpos = 1;	//	if we're on the first frame on the first row, xpos is at the first horizontal pixel
    }
    else if (frame < 5) {
        xpos = (frame - 1) * 513;	//	if we're on the first row of the sprite
    }
    else if (frame > 4) {
        xpos = (frame - 5) * 513;	//	if we're at the second row of the sprite
    }
    if (frame < 5) {
        ypos = 1;	//	if were on the first row, ypos is at the first vertical pixel
    }
    else {
        ypos = 257;	//	if we're on the second row, ypos starts from hte 257th pixel (1-256 are in the first row)
    }
    SetRect(&part, xpos, ypos, xpos + 511, ypos + 255);	//	construct the selected frame using the coordinates
    position = D3DXVECTOR3((float)SCREEN_WIDTH/2-256, (float)SCREEN_HEIGHT/2-128, 0.0f);	//	position at center
    if (frameGo) {	//	this adds transparent dissapearing of the sprite after ~5s
        sprite->Draw(spriteTexture, &part, &center, &position, D3DCOLOR_ARGB(((frameGoCount>180)?180:frameGoCount), 255, 255, 255));
        frameGoCount -= 3;
        if (frameGoCount < 5) {
            frameGo = FALSE;
        }
    }
    sprite->End();	//	end sprite drawing

    d3d9dev->EndScene();	//	ends the 3D scene
    d3d9dev->Present(NULL, NULL, NULL, NULL);	//	displays the created frame on the screen
    return;
}
Exemple #14
0
void Renderer::DrawSprite(Vector2 position, float width, float height, TexCoord textureCoordinates, float angle,Vector2 rotationPoint)
{
#if IS_XBOX

	// Convert Param Information into proper structures

	XGVECTOR2 scale;
	scale.x = (IMAGE_TO_SCREEN_X / SCREEN_WIDTH) / textureCoordinates.width  * width;
	scale.y = (IMAGE_TO_SCREEN_Y / SCREEN_HEIGHT) / textureCoordinates.height * height;

	RECT tex;
	tex.top = (LONG)((textureCoordinates.y)*IMAGE_HEIGHT);
	tex.bottom = (LONG)((textureCoordinates.y + textureCoordinates.height)*IMAGE_HEIGHT);
	tex.left = (LONG)((textureCoordinates.x)*IMAGE_WIDTH);
	tex.right = (LONG)((textureCoordinates.x + textureCoordinates.width)*IMAGE_WIDTH);
	
	XGVECTOR2 rot;
	rot.x = rotationPoint.x - position.x;
	rot.y = rotationPoint.y - position.y;

	XGVECTOR2 pos;
	pos.x = position.x;
	pos.y = position.y;

	m_sprite->Begin();

	// Transform and Draw the Sprite
#	if FALSE 
	// Apply Transform Matrix
	D3DXMATRIX matWorld;
	D3DXMatrixIdentity(&matWorld);
	D3DXMATRIX matTransform;
	D3DXMatrixScaling(&matTransform, scale.x, scale.y, 1);
	D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);

	if(angle != 0){
		D3DXMatrixTranslation(&matTransform, - rotationPoint.x, - rotationPoint.y , 0.0f);
		D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
		D3DXMatrixRotationZ(&matTransform, angle);
		D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
		D3DXMatrixTranslation(&matTransform, rotationPoint.x, rotationPoint.y , 0.0f);
		D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);
	}

	D3DXMatrixTranslation(&matTransform, position.x, position.y, 0.0f);
	D3DXMatrixMultiply(&matWorld, &matWorld, &matTransform);

	m_sprite->DrawTransform(g_pTextureMap[currentID], &tex, &matWorld,  0xffffffff);
#	else
	// Trust Draw Method
	m_sprite->Draw(g_pTextureMap[currentID], &tex, &scale, &rot, angle, &pos, 0xffffffff);
#	endif

	m_sprite->End();
#else
	// Simple inversion of the texture for DirectX
	textureCoordinates.y = 1 - textureCoordinates.y;

	GLdouble matrix[16];
	glGetDoublev(GL_MODELVIEW_MATRIX, matrix);

	Vector2 topLeft, topRight, bottomLeft, bottomRight;
	topLeft = position;
	topRight = position;
	bottomLeft = position;
	bottomRight = position;

	topRight.x += width;

	bottomLeft.y += height;

	bottomRight.x += width;
	bottomRight.y += height;

	if (angle != 0) {
		topLeft.rotateOnPivot(angle, &rotationPoint);
		topRight.rotateOnPivot(angle, &rotationPoint);
		bottomLeft.rotateOnPivot(angle, &rotationPoint);
		bottomRight.rotateOnPivot(angle, &rotationPoint);
	}

	glGetDoublev(GL_MODELVIEW_MATRIX, matrix);

	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, mTextureID[currentID]);
	glBegin(GL_QUADS);
	glTexCoord2f(textureCoordinates.x, textureCoordinates.y);

	glVertex2f(topLeft.x, topLeft.y);
	glTexCoord2f(textureCoordinates.x, textureCoordinates.y - textureCoordinates.height);

	glVertex2f(bottomLeft.x, bottomLeft.y );

	glTexCoord2f(textureCoordinates.x + textureCoordinates.width, textureCoordinates.y - textureCoordinates.height);
	glVertex2f(bottomRight.x  , bottomRight.y );

	glTexCoord2f(textureCoordinates.x + textureCoordinates.width, textureCoordinates.y);

	glVertex2f(topRight.x, topRight.y);

	glEnd();
	glGetDoublev(GL_MODELVIEW_MATRIX, matrix);
#endif
}
Exemple #15
0
void EndSpriteRender()
{
	ddraw->End();
}