Results 1 to 4 of 4
  1. #1
    Coders (+)_'s Avatar
    Join Date
    Jan 2010
    Location
    Earth
    Posts
    461

    Arrow Draw Primitives again

    Draw Some primitives again.

    Credits:
    UC Assorted
    aB and more

    Code:
    typedef struct _D3DTLVERTEX{
        FLOAT fX;
        FLOAT fY;
        FLOAT fZ;
        FLOAT fRHW;
        D3DCOLOR Color;
        FLOAT fU;
        FLOAT fV;
    }D3DTLVERTEX,*PD3DTLVERTEX;
    
    LPDIRECT3DSTATEBLOCK9 pStateBlock = NULL;
    LPDIRECT3DTEXTURE9 pGreen = NULL;
    D3DVIEWPORT9 Vpt;
    //=====================================================================================
    
    HRESULT WINAPI Reset_Detour(LPDIRECT3DDEVICE9 Device_Interface, D3DPRESENT_PARAMETERS* PresentationParameters)
    {
    	if( pStateBlock )		{ pStateBlock->Release( ); pStateBlock = NULL; }
    	if( pGreen )			{ pGreen->Release( ); pGreen = NULL; }
    
    	return Reset_Pointer(Device_Interface, PresentationParameters);
    }
    
    //=====================================================================================
    
    HRESULT WINAPI EndScene_Detour(LPDIRECT3DDEVICE9 Device_Interface)
    {
    	Device_Interface->GetViewport( &Vpt );
    
    	if( !pStateBlock )	Device_Interface->CreateStateBlock( D3DSBT_ALL, &pStateBlock );
    	if( !pGreen )	GenerateTexture( Device_Interface, &pGreen, D3DCOLOR_ARGB( 180, 20, 255, 20 ) );
    
    	DrawLine( 0.0f, FLOAT(Vpt.Height/2), FLOAT(Vpt.Width), FLOAT(Vpt.Height/2), 
    		D3DCOLOR_ARGB( 180, 20, 255, 20 ), pGreen, Device_Interface, pStateBlock );
    
    	DrawLine( FLOAT(Vpt.Width/2), 0.0f, FLOAT(Vpt.Width/2), FLOAT(Vpt.Height), 
    		D3DCOLOR_ARGB( 180, 20, 255, 20 ), pGreen, Device_Interface, pStateBlock );
    
    	D3DFillRect( 200, 100, D3DCOLOR_ARGB( 180, 20, 255, 20 ), 100, 50, 
    		pGreen, Device_Interface, pStateBlock );
    
    	D3DDrawCircle( FLOAT(Vpt.Width-300), 200, D3DCOLOR_ARGB( 180, 20, 255, 20 ), 
    		pGreen, Device_Interface, 100, pStateBlock );
    
    	return EndScene_Pointer(Device_Interface);
    }
    
    //=====================================================================================
    
    BOOL WINAPI DrawLine( FLOAT X1, FLOAT Y1, FLOAT X2, FLOAT Y2, DWORD COLOR,
    	LPDIRECT3DTEXTURE9 pTexture, LPDIRECT3DDEVICE9 pDev, 
    		LPDIRECT3DSTATEBLOCK9 pStateBlock )
    {
    	D3DTLVERTEX D3DTLV[20];
    
    	if( !pStateBlock )
    		return FALSE;
    
    	if( FAILED ( pStateBlock->Capture( ) ) )
    		return FALSE;
    
    	if( pTexture )
    		pDev->SetTexture( 0, pTexture );
    
    	BuildVertex( X1, Y1, COLOR, PD3DTLVERTEX(&D3DTLV), 0 );
    	BuildVertex( X2, Y2, COLOR, PD3DTLVERTEX(&D3DTLV), 1 );
    
    	pDev->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
    
    	pDev->DrawPrimitiveUP( D3DPT_LINELIST, 2, &D3DTLV, sizeof(D3DTLVERTEX) );
    
    	pStateBlock->Apply( );
    
    	return TRUE;
    }
    
    //=====================================================================================
    
    BOOL WINAPI D3DFillRect( FLOAT X, FLOAT Y, DWORD COLOR, UINT Width, UINT Height,
    	 LPDIRECT3DTEXTURE9 pTexture, LPDIRECT3DDEVICE9 pDev, 
    		LPDIRECT3DSTATEBLOCK9 pStateBlock )
    {
    	D3DTLVERTEX D3DTLV[20];
    
    	if( !pStateBlock )
    		return FALSE;
    
    	if( FAILED ( pStateBlock->Capture( ) ) )
    		return FALSE;
    
    	if( pTexture )
    		pDev->SetTexture( 0, pTexture );
    
    	BuildVertex( X-Width, Y+Height, COLOR, PD3DTLVERTEX(&D3DTLV), 0 );
    	BuildVertex( X-Width, Y-Height, COLOR, PD3DTLVERTEX(&D3DTLV), 1 );
    	BuildVertex( X+Width, Y-Height, COLOR, PD3DTLVERTEX(&D3DTLV), 2 );
    
    	BuildVertex( X+Width, Y-Height, COLOR, PD3DTLVERTEX(&D3DTLV), 3 );
    	BuildVertex( X+Width, Y+Height, COLOR, PD3DTLVERTEX(&D3DTLV), 4 );
    	BuildVertex( X-Width, Y+Height, COLOR, PD3DTLVERTEX(&D3DTLV), 5 );
    
    	pDev->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
    
    	pDev->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 6, &D3DTLV, sizeof(D3DTLVERTEX) );
    
    	pStateBlock->Apply( );
    
    	return TRUE;
    }
    
    //=====================================================================================
    
    BOOL WINAPI D3DDrawCircle( FLOAT X, FLOAT Y, DWORD COLOR,
    	 LPDIRECT3DTEXTURE9 pTexture, LPDIRECT3DDEVICE9 pDev, FLOAT Radius,
    		LPDIRECT3DSTATEBLOCK9 pStateBlock )
    {
    	D3DTLVERTEX D3DTLV[400];
    
    	if( !pStateBlock )
    		return FALSE;
    
    	if( FAILED ( pStateBlock->Capture( ) ) )
    		return FALSE;
    
    	if( pTexture )
    		pDev->SetTexture( 0, pTexture );
    
    	FLOAT X1	= X;
    	FLOAT Y1	= Y;
    
    	for( int i=0;i<=363;i+=3 )
    	{
    		FLOAT angle		= ( i / 57.3f );   
    
    		FLOAT X2		= X + ( Radius * sin( angle ) );
    		FLOAT Y2		= Y + ( Radius * cos( angle ) );        
    
    		BuildVertex( X, Y, COLOR, PD3DTLVERTEX(&D3DTLV), i );
    		BuildVertex( X1, Y1, COLOR, PD3DTLVERTEX(&D3DTLV), i + 1 );
    		BuildVertex( X2, Y2, COLOR, PD3DTLVERTEX(&D3DTLV), i + 2 );
    
    		Y1 = Y2;
    		X1 = X2;
    	}
    
    	pDev->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
    	pDev->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 363, &D3DTLV, sizeof(D3DTLVERTEX) );
    
    	pStateBlock->Apply( );
    
    	return TRUE;
    }
    
    //=====================================================================================
    
    VOID WINAPI BuildVertex( FLOAT X, FLOAT Y, DWORD COLOR, PD3DTLVERTEX PD3DTLV, UINT Index )
    {
    	PD3DTLV[Index].fX			= X;
    	PD3DTLV[Index].fY				= Y;
    	PD3DTLV[Index].fZ			= 0.0f;
    	PD3DTLV[Index].fU			= 0.0f;
    	PD3DTLV[Index].fV			= 0.0f;
    	PD3DTLV[Index].fRHW		= 1.0f;
    	PD3DTLV[Index].Color		= COLOR;
    }
    
    //=====================================================================================


    Added DrawLineCircle.

    Credits:
    UCForum
    Reunion

    Code:
    VOID WINAPI DrawLineCircle( FLOAT X, FLOAT Y, LPDIRECT3DTEXTURE9 pTexture, 
    	LPDIRECT3DDEVICE9 pDev, DWORD COLOR, FLOAT Radius, LPDIRECT3DSTATEBLOCK9 pStateBlock )
    {
    	D3DTLVERTEX D3DTLV[256];
    
    	if( FAILED ( pStateBlock->Capture( ) ) )
    		return;
    
    	if( pTexture )
    		pDev->SetTexture( 0, pTexture );
    
    	INT NumOfPoints						= 128;
    	INT Count									= 0;
    	FLOAT circ1								= 0.0f;
    	FLOAT circ2								= 0.0f;
    	FLOAT circ3								= 0.0f;
    	FLOAT circ4								= 0.0f;
    	FLOAT Step								= 0.0f;
    	FLOAT PIX2								= 6.283185f;
    
    	Step											= PIX2/(FLOAT)NumOfPoints;
    
    	for( FLOAT index=0.0f; index < PIX2; index += Step )
    	{
    		circ1 = X +	Radius * (FLOAT)cos(	DOUBLE(index)		);
    		circ2 = Y +	Radius * (FLOAT)sin(	DOUBLE(index)		);
    		circ3 = X +	Radius * (FLOAT)cos(	DOUBLE(index+Step)		);
    		circ4 = Y +	Radius * (FLOAT)sin(	DOUBLE(index+Step)		);
    		BuildVertex( circ1, circ2, COLOR, D3DTLV, Count );
    		BuildVertex( circ3, circ4, COLOR, D3DTLV, Count+1 );
    		Count += 2;
    	}
    
    	pDev->SetFVF( D3DFVF_XYZRHW | D3DFVF_DIFFUSE );
    
    	pDev->DrawPrimitiveUP( D3DPT_LINELIST, NumOfPoints, D3DTLV, sizeof(D3DTLVERTEX) );
    
    	pStateBlock->Apply( );
    }
    Last edited by (+)_; May 2nd, 2013 at 10:45.

  2. #2

    Re: Draw Primitives again

    I guess you're Zoom
    thanks for this
    Last edited by newtechnology; April 15th, 2013 at 20:21.

  3. #3

    Re: Draw Primitives again

    Quote Originally Posted by newtechnology View Post
    I guess you're Zoom
    thanks for this
    Yes he is.


  4. #4
    Coders (+)_'s Avatar
    Join Date
    Jan 2010
    Location
    Earth
    Posts
    461

    Re: Draw Primitives again

    Added DrawLineCircle.

    Credits:
    UCForum
    Reunion

Similar Threads

  1. DirectX 10 Draw Text
    By (+)_ in forum D3D
    Replies: 0
    Last Post: May 3rd, 2013, 21:25
  2. Black Ops Draw Compass Map
    By King-OrgY in forum Client Hooks
    Replies: 0
    Last Post: February 13th, 2011, 18:38
  3. Black Ops Draw name Tags
    By King-OrgY in forum Client Hooks
    Replies: 0
    Last Post: February 11th, 2011, 22:15
  4. [HELP] Draw Gradient
    By cykLone in forum Visual Basic
    Replies: 16
    Last Post: May 8th, 2008, 15:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •