Go Back   UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats > Anti-Cheat Software & Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/

Welcome to the UnKnoWnCheaTs - Multiplayer Game Hacks and Cheats.
You have to register before you can post and see and access any of the advanced forum features, please click the register link to proceed to the registration form. To start viewing threads or posts, select a forum that you want to visit from the selection below.
Direct3D
hacking programming reversing
You are Unregistered, please register to gain Full access.    
Reply
 
Thread Tools

Draw with DrawPrimitive
Old 09-08-2010, 04:25 PM   #1
h4x0r

SystemFiles's Avatar

Join Date: Jul 2009
Location: The Netherlands
Posts: 437
Reputation: 13685
Rep Power: 176
SystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server spaceSystemFiles 's rep takes up 1 gig of server space
Points: 11,039, Level: 13
Points: 11,039, Level: 13 Points: 11,039, Level: 13 Points: 11,039, Level: 13
Activity: 9.4%
Activity: 9.4% Activity: 9.4% Activity: 9.4%
Last Achievements
Draw with DrawPrimitive

Hi hackers here are my functions to draw with DrawPrimitive:

Somewhere in your initialize function:

Code:
if( FAILED( pDevice->CreateVertexBuffer( 31 * sizeof( CVertexList ), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &pVertexBuffer, NULL ) ) )
{
	return E_FAIL;
}
The functions:

Code:
HRESULT CDraw::DrawRect( LPDIRECT3DDEVICE9 pDevice, FLOAT X, FLOAT Y, FLOAT Width, FLOAT Height, D3DCOLOR dColor )
{
	CVertexList* pVertexList;

	pVertexBuffer->Lock( 0, 0, ( PVOID* )&pVertexList, D3DLOCK_NOSYSLOCK | D3DLOCK_DISCARD );

	pVertexList[0].X = X;
	pVertexList[0].Y = Y + Height;
	pVertexList[0].Z = 0.0f;
	pVertexList[0].RHW = 0.0f;
	pVertexList[0].dColor = dColor;

	pVertexList[1].X = X;
	pVertexList[1].Y = Y;
	pVertexList[1].Z = 0.0f;
	pVertexList[1].RHW = 0.0f;
	pVertexList[1].dColor = dColor;

	pVertexList[2].X = X + Width;
	pVertexList[2].Y = Y + Height;
	pVertexList[2].Z = 0.0f;
	pVertexList[2].RHW = 0.0f;
	pVertexList[2].dColor = dColor;

	pVertexList[3].X = X + Width;
	pVertexList[3].Y = Y;
	pVertexList[3].Z = 0.0f;
	pVertexList[3].RHW = 0.0f;
	pVertexList[3].dColor = dColor;

	pVertexBuffer->Unlock( );

	pDevice->SetTexture( 0, NULL );
	pDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof( CVertexList ) );
	pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

	return pDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
}

HRESULT CDraw::DrawCircle( LPDIRECT3DDEVICE9 pDevice, FLOAT X, FLOAT Y, FLOAT RadiusW, FLOAT RadiusH, D3DCOLOR dColor )
{
	CONST INT NUMPOINTS = 30;
	CONST FLOAT Angle = ( 2.0f * D3DX_PI ) / NUMPOINTS;

	CVertexList* pVertexList;

	pVertexBuffer->Lock( 0, 0, ( PVOID* )&pVertexList, D3DLOCK_NOSYSLOCK | D3DLOCK_DISCARD );

	for( INT i = 0; i <= NUMPOINTS; i++ )
	{
		FLOAT CurAngle = ( FLOAT )i * Angle;
		FLOAT DrawPosX = ( X + RadiusW * cos( CurAngle ) );
		FLOAT DrawPosY = ( Y - RadiusH * sin( CurAngle ) );
		
		pVertexList[i].X = DrawPosX;
		pVertexList[i].Y = DrawPosY;
		pVertexList[i].Z = 0.0f;
		pVertexList[i].RHW = 0.0f;
		pVertexList[i].dColor = dColor;
	}

	pVertexBuffer->Unlock( );

	pDevice->SetTexture( 0, NULL );
	pDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof( CVertexList ) );
	pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

	return pDevice->DrawPrimitive( D3DPT_LINESTRIP, 0, NUMPOINTS );
}

HRESULT CDraw::DrawLine( LPDIRECT3DDEVICE9 pDevice, FLOAT X, FLOAT Y, FLOAT X2, FLOAT Y2, D3DCOLOR dColor )
{
	CVertexList* pVertexList;

	pVertexBuffer->Lock( 0, 0, ( PVOID* )&pVertexList, D3DLOCK_NOSYSLOCK | D3DLOCK_DISCARD );

	pVertexList[0].X = X;
	pVertexList[0].Y = Y;
	pVertexList[0].Z = 0.0f;
	pVertexList[0].RHW = 0.0f;
	pVertexList[0].dColor = dColor;

	pVertexList[1].X = X2;
	pVertexList[1].Y = Y2;
	pVertexList[1].Z = 0.0f;
	pVertexList[1].RHW = 0.0f;
	pVertexList[1].dColor = dColor;

	pVertexBuffer->Unlock( );

	pDevice->SetTexture( 0, NULL );
	pDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof( CVertexList ) );
	pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

	return pDevice->DrawPrimitive( D3DPT_LINELIST, 0, 1 );
} 

HRESULT CDraw::DrawGradientRect( LPDIRECT3DDEVICE9 pDevice, FLOAT X, FLOAT Y, FLOAT Width, FLOAT Height, D3DCOLOR dColor1, D3DCOLOR dColor2 )
{
	CVertexList* pVertexList;

	pVertexBuffer->Lock( 0, 0, ( PVOID* )&pVertexList, D3DLOCK_NOSYSLOCK | D3DLOCK_DISCARD );

	pVertexList[0].X = X;
	pVertexList[0].Y = Y + Height;
	pVertexList[0].Z = 0.0f;
	pVertexList[0].RHW = 0.0f;
	pVertexList[0].dColor = dColor2;

	pVertexList[1].X = X;
	pVertexList[1].Y = Y;
	pVertexList[1].Z = 0.0f;
	pVertexList[1].RHW = 0.0f;
	pVertexList[1].dColor = dColor1;

	pVertexList[2].X = X + Width;
	pVertexList[2].Y = Y + Height;
	pVertexList[2].Z = 0.0f;
	pVertexList[2].RHW = 0.0f;
	pVertexList[2].dColor = dColor2;

	pVertexList[3].X = X + Width;
	pVertexList[3].Y = Y;
	pVertexList[3].Z = 0.0f;
	pVertexList[3].RHW = 0.0f;
	pVertexList[3].dColor = dColor1;

	pVertexBuffer->Unlock( );

	pDevice->SetTexture( 0, NULL );
	pDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof( CVertexList ) );
	pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

	return pDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
}

HRESULT CDraw::DrawGradientLine( LPDIRECT3DDEVICE9 pDevice, FLOAT X, FLOAT Y, FLOAT X2, FLOAT Y2, D3DCOLOR dColor1, D3DCOLOR dColor2 )
{
	CVertexList* pVertexList;

	pVertexBuffer->Lock( 0, 0, ( PVOID* )&pVertexList, D3DLOCK_NOSYSLOCK | D3DLOCK_DISCARD );

	pVertexList[0].X = X;
	pVertexList[0].Y = Y;
	pVertexList[0].Z = 0.0f;
	pVertexList[0].RHW = 0.0f;
	pVertexList[0].dColor = dColor1;

	pVertexList[1].X = X2;
	pVertexList[1].Y = Y2;
	pVertexList[1].Z = 0.0f;
	pVertexList[1].RHW = 0.0f;
	pVertexList[1].dColor = dColor2;

	pVertexBuffer->Unlock( );

	pDevice->SetTexture( 0, NULL );
	pDevice->SetStreamSource( 0, pVertexBuffer, 0, sizeof( CVertexList ) );
	pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );

	return pDevice->DrawPrimitive( D3DPT_LINELIST, 0, 1 );
}
Credits: Me, Toymaker.info

Last edited by SystemFiles; 09-17-2010 at 03:52 PM.
SystemFiles is online now

Reply With Quote

Reply  

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit



Tags
draw, drawprimitive
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +1. The time now is 07:32 AM.