™️ Welcome And SwiftGamerz ™️™️[-] The User Has Not IN SwiftGamerz Please Register.[-] Existing expected to log in first.[-] Many Public Hacks In Our Forum[-] Register for your User. (There are More Applications).Thankz ~ ~ For ALL SwiftGamerz
™️ Welcome And SwiftGamerz ™️™️[-] The User Has Not IN SwiftGamerz Please Register.[-] Existing expected to log in first.[-] Many Public Hacks In Our Forum[-] Register for your User. (There are More Applications).Thankz ~ ~ For ALL SwiftGamerz
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
PortalHomeLatest imagesRegisterLog in

Share | 
 

 Drawing Sprite

View previous topic View next topic Go down 
AuthorMessage
___RJ___
___RJ___
Moderator
Moderator

Posts : 15
Join date : 2012-01-18
Age : 32
Location : Cebu

Drawing Sprite   Empty
PostSubject: Drawing Sprite    Drawing Sprite   Icon_minitimeFri Jan 27, 2012 4:49 pm

Quote :
ill show u how this can be done, im using it and works really good:

u'll need to detour Reset and Present/ES/BS


Some Globals:

Code:

LPDIRECT3DTEXTURE9 TextureMenu; //Texture for ur menu
LPD3DXSPRITE Sprite; //sprite to draw

//draw sprite function
#define flt (float)
void DrawTexture(int x, int y, LPDIRECT3DTEXTURE9 dTexture)
{
Sprite->Begin(D3DXSPRITE_ALPHABLEND);
Sprite->Draw(dTexture,NULL,NULL,&D3DXVECTOR3(flt x,flt y, 0.0f), 0xFFFFFFFF);
Sprite->End();
return;
}

first of all create ur reset sprite/texture functs:

Code:

void PreSprite()
{
if (Sprite && TextureMenu) //if they arent null
{
Sprite->OnLostDevice(); //release
Sprite = NULL; //null ptr
TextureMenu->Release();  //release
TextureMenu = NULL; //null ptr
}
}

void PostSprite(LPDIRECT3DDEVICE9 pDevice)
{
D3DXCreateSprite(pDevice, &Sprite); //create sprite
D3DXCreateTextureFromFileInMemory(pDevice, &myMenu, sizeof(myMenu), &TextureMenu); //create texture menu (i do that from file in memory)
if (Sprite)  //if sprite isnt null
{
Sprite->OnResetDevice(); //reset
}
}
now where ur drawing (Present/ES/BS):
Code:

if (Sprite==NULL) //if sprite is null
PostSprite(pDevice); //recreate it
else
DrawTexture(100,100,TextureMenu);

and finally in Reset:

Code:

HRESULT WINAPI hhkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* Pars)
{
PreSprite();
HRESULT hrtn = oReset(pDevice, Parsi);
return hrtn;
}
remember u have to reset/release/recreate ur fonts,textures and sprites, to make them working in CA, and i suggest to use CD3DFont to avoid text-disappearing and checking for device changes

credits to me Smile

Back to top Go down
 

Drawing Sprite

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
 :: FORUM LEARN/TEACH :: Direct3Device D3D-