UnrealSkill-VIP
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

[Source]Draw Primitives again

Ir em baixo

[Source]Draw Primitives again Empty [Source]Draw Primitives again

Mensagem por uNreal 2/7/2020, 02:50

[Source]Draw Primitives again Draw_zpsb3e51ab0

Código:
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;
}

//=====================================================================================

[Source]Draw Primitives again 8701508828_0321ef426a_b

Código:
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( );
}

Credits:
UCForum
Reunion
uNreal
uNreal
ADM
ADM


Voltar ao Topo Ir em baixo

Voltar ao Topo


 
Permissão neste fórum:
Você não pode responder aos tópicos neste fórum