Results 1 to 6 of 6
  1. #1
    Ch40zz-C0d3r's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    839
    Reputation
    44
    Thanks
    400
    My Mood
    Twisted

    DirectX Draw Sprite "Bug"

    Hey guys
    Hope someone of you can help me with this problem!
    I made an awesome menu with photoshop, and I wanted to put it as my hackmenu.
    I searched for drawing sprites with scale function, and I found a cool working method:

    Code:
    void CDirectx::DrawSprite(LPDIRECT3DDEVICE9 pDevice, LPDIRECT3DTEXTURE9 pTexture, int x, int y, int w, int h)
    {
    	if(!cHacks.ValidPointer(pDevice) || !cHacks.ValidPointer(pTexture))
    		return;
    
    	struct tVertex
    	{
    		float X, Y, Z, RHW;
    		float IU, IV;
    		 enum FVF
    		{
    			FVF_Flags = (D3DFVF_XYZRHW | D3DFVF_TEX1)
    		};
    	
    	};
    
    	tVertex Veri[4] =
    	{
    		{(float)x		,(float)y		, 0.0f, 1.0f, 0.0f, 0.0f },
    		{(float)(x+w)	,(float)y		, 0.0f, 1.0f, 1.0f, 0.0f },
    		{(float)x		,(float)(y+h)	, 0.0f, 1.0f, 0.0f, 1.0f },
    		{(float)(x+w)	,(float)(y+h)	, 0.0f, 1.0f, 1.0f, 1.0f },
    	};
    	
    	pDevice->SetTexture( 0, pTexture );
    	pDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    	pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    	pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE );
    	pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1  );
    	pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE );
    	pDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
    	pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
    
    	pDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
    	pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
    	pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    	pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
    	pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
    	pDevice->SetRenderState( D3DRS_FOGENABLE, false );
    
    	pDevice->SetFVF( tVertex::FVF_Flags  );
    	pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,Veri,sizeof(tVertex));
    }
    But sometimes, my menu keeps crashing!
    Its not detected, if I comment all my spritedrawing out it works, my old d3d-menu works too!
    Could it be, that this function is crashing me, because Im drawing too much sprites?
    Is there a fix for it?
    Please help me

    Progress with my game - "Disbanded"
    • Fixed FPS lag on spawning entities due to the ent_preload buffer!
    • Edit the AI code to get some better pathfinding
    • Fixed the view bug within the sniper scope view. The mirror entity is invisible now!
    • Added a new silencer for ALL weapons. Also fixed the rotation bugs
    • Added a ton of new weapons and the choice to choose a silencer for every weapon
    • Created a simple AntiCheat, noobs will cry like hell xD
    • The name will be Disbanded, the alpha starts on the 18th august 2014



    Some new physics fun (Serversided, works on every client)



    My new AI
    http://www.youtube.com/watch?v=EMSB1GbBVl8

    And for sure my 8 months old gameplay with 2 friends
    http://www.youtube.com/watch?v=Na2kUdu4d_k

  2. #2
    ac1d_buRn's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Location
    CA Source Section
    Posts
    3,406
    Reputation
    157
    Thanks
    3,991
    My Mood
    Flirty
    you resetting the sprite when the device changes?

  3. #3
    Ch40zz-C0d3r's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    839
    Reputation
    44
    Thanks
    400
    My Mood
    Twisted
    Thank you for replying, but as you see in the code, there is no sprite.
    Its using the device directly to draw, thats the good thing!
    But something is crashing me :/

    EDIT: I know why it crashed. I hooked soemthing with mc detours. Using now selfmade detours and works fine. But what I dont know is, why it crashed just with my new menu o_0
    Thanks for help
    Last edited by Ch40zz-C0d3r; 07-11-2012 at 10:35 AM.

    Progress with my game - "Disbanded"
    • Fixed FPS lag on spawning entities due to the ent_preload buffer!
    • Edit the AI code to get some better pathfinding
    • Fixed the view bug within the sniper scope view. The mirror entity is invisible now!
    • Added a new silencer for ALL weapons. Also fixed the rotation bugs
    • Added a ton of new weapons and the choice to choose a silencer for every weapon
    • Created a simple AntiCheat, noobs will cry like hell xD
    • The name will be Disbanded, the alpha starts on the 18th august 2014



    Some new physics fun (Serversided, works on every client)



    My new AI
    http://www.youtube.com/watch?v=EMSB1GbBVl8

    And for sure my 8 months old gameplay with 2 friends
    http://www.youtube.com/watch?v=Na2kUdu4d_k

  4. #4
    Xipher's Avatar
    Join Date
    Jul 2011
    Gender
    male
    Location
    Melbourne, AU.
    Posts
    1,784
    Reputation
    472
    Thanks
    1,688
    My Mood
    Innocent
    So it's solved then?

  5. #5
    Ch40zz-C0d3r's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    839
    Reputation
    44
    Thanks
    400
    My Mood
    Twisted
    Quote Originally Posted by Xipher View Post
    So it's solved then?
    Yeah, you can close it
    Hope people learn from it that microsoft detours isn't the best way
    Im writing my own atm

    Progress with my game - "Disbanded"
    • Fixed FPS lag on spawning entities due to the ent_preload buffer!
    • Edit the AI code to get some better pathfinding
    • Fixed the view bug within the sniper scope view. The mirror entity is invisible now!
    • Added a new silencer for ALL weapons. Also fixed the rotation bugs
    • Added a ton of new weapons and the choice to choose a silencer for every weapon
    • Created a simple AntiCheat, noobs will cry like hell xD
    • The name will be Disbanded, the alpha starts on the 18th august 2014



    Some new physics fun (Serversided, works on every client)



    My new AI
    http://www.youtube.com/watch?v=EMSB1GbBVl8

    And for sure my 8 months old gameplay with 2 friends
    http://www.youtube.com/watch?v=Na2kUdu4d_k

  6. #6
    Xipher's Avatar
    Join Date
    Jul 2011
    Gender
    male
    Location
    Melbourne, AU.
    Posts
    1,784
    Reputation
    472
    Thanks
    1,688
    My Mood
    Innocent
    :3 Closed.

Similar Threads

  1. Quote notification bug?
    By Ed in forum General
    Replies: 14
    Last Post: 01-03-2012, 11:24 PM
  2. [Tutorial] Drawing Sprites
    By roabx1 in forum WarRock Hack Source Code
    Replies: 6
    Last Post: 08-29-2011, 06:04 AM
  3. MPGH IRC Chat Quote Thread
    By i eat trees in forum Entertainment
    Replies: 746
    Last Post: 07-02-2011, 11:07 PM
  4. DirectX drawing 2D sprites STUPID EXCEPTION
    By PsychicSounds in forum C++/C Programming
    Replies: 9
    Last Post: 05-08-2011, 10:16 AM
  5. [RELEASE] How To Draw Sprites
    By ac1d_buRn in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 37
    Last Post: 10-12-2010, 06:50 AM