Thread: Draw Circle

Results 1 to 5 of 5
  1. #1
    Donor's Avatar
    Join Date
    Jun 2013
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    0

    Question Draw Circle

    I decided to make myself a "cool" crosshair.)))))
    and for one to learn to draw in D3D.
    I drawed this.
    Code:
    void CrossHair1(LPDIRECT3DDEVICE9 pDevice, int size, int strong,  D3DCOLOR xcolor)
    {
    	int iCenterX = GetSystemMetrics( 0 ) / 2;
    	int iCenterY = GetSystemMetrics( 1 ) / 2;
    
    	if( iCenterX < 20 && iCenterY < 20 )
    	{
    		iCenterX = ( GetSystemMetrics( 1 ) / 2 );
    		iCenterY = ( GetSystemMetrics( 0 ) / 2 );
    	}
    
    	D3DRECT rec1 = { iCenterX- size, iCenterY - 1, iCenterX+ size -1 , iCenterY+ strong };
    	D3DRECT rec2 = { iCenterX -1, iCenterY- size, iCenterX+ strong ,iCenterY+ size -1 };
    	pDevice->Clear(1, &rec1, D3DCLEAR_TARGET, xcolor, 1000,  0);
    	pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 100,  0);
    }
    
    
    void CrossHair2(LPDIRECT3DDEVICE9 pDevice, int size, int strong,  D3DCOLOR xcolor)
    {
    	int iCenterX = GetSystemMetrics( 0 ) / 2;
    	int iCenterY = GetSystemMetrics( 1 ) / 2;
    
    	if( iCenterX < 20 && iCenterY < 20 )
    	{
    		iCenterX = ( GetSystemMetrics( 1 ) / 2 );
    		iCenterY = ( GetSystemMetrics( 0 ) / 2 );
    	}
    	
    	D3DRECT rec5 = {iCenterX-3, iCenterY - 2, iCenterX+ 3-1, iCenterY+1};
        D3DRECT rec6 = {iCenterX - 2, iCenterY-3, iCenterX+ 1,iCenterY+3-1}; 
        pDevice->Clear( 1, &rec5, D3DCLEAR_TARGET, xcolor, 0, 0 );
        pDevice->Clear( 1, &rec6, D3DCLEAR_TARGET, xcolor, 0, 0 );
    }
    Works fine in the game.

    But when I draw this:

    Code:
    void CrossHair4(int x, int y, LPDIRECT3DDEVICE9 pDevice)
    {
            DrawCircle(x, y, 8, 8, Red);//Circle
    	FillRGB(x-17, y, 10, 1,Red,pDevice);//Left line
    	FillRGB(x+9, y, 10, 1,Red,pDevice); // Right line
    	FillRGB(x, y - 17, 1, 10,Red,pDevice);//Top line
    	FillRGB(x, y + 9, 1, 10,Red,pDevice);//Bottom line
    }
    My Game is crashed. why?
    I have two Hooks:
    1. for menu
    2. for wallhack

    Code:
    DWORD WINAPI Hook(LPVOID lpArgs)
    {
    	DWORD dwD3D9 = 0;
    
    	while(!dwD3D9) {
    		Sleep(100);
    		dwD3D9 = (DWORD)GetModuleHandleA("d3d9.dll");
    	}
    
    	DWORD dwVTable[2] = { 0 };
    	CreateDevice(dwVTable);
    
    	oReset   = (tReset)  DetourCreate((PBYTE) dwVTable[0], (PBYTE) &hkReset, 5);
    	oPresent = (tPresent)DetourCreate((PBYTE) dwVTable[1], (PBYTE) &hkPresent, 5);
    	
    	return FALSE;
    }  
    
    void D3D_Hook()
    {
    	
    
    switch(GAME)
    {
    		case Game::CombatArms:
    				{ 
    					    DWORD dwVTable[2] = { 0 };
    						DWORD *vtbl;
    				DWORD hD3D=0;
    				do {
    						hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
    						
    						Sleep(10);
    				}
    				while(!hD3D);
    						DWORD adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
    						if(adr)
    						{
    								memcpy(&vtbl,(void *)(adr+2),4);
     
    								nomar = vtbl[152] + 5;
    								       
    										pDrawIndexedPrimitive   = (DrawIndexedPrimitive_)DetourCreate((PBYTE)(vtbl[152]),(PBYTE)MyDIP_CA,5);
    										return;
    						}
    					}
    		break;
    		
    		
    		break;
    }
    }
    Explain what the problem is. Please)))
    Last edited by Donor; 06-24-2013 at 03:56 PM.

  2. #2
    Herpina's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    64
    Reputation
    10
    Thanks
    55
    Post your DrawCircle function? Then I can help better

  3. #3
    Donor's Avatar
    Join Date
    Jun 2013
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    0
    void DrawCircle(int x, int y, int radius, int numSides, DWORD Color)
    {
    #define PI 3.14159265
    D3DXVECTOR2 Line[128];
    float Step = PI * 2.0 / numSides;
    int Count = false;
    for(float a = 0; a < PI * 2.0; a += Step)
    {
    float x1 = radius * cos(a)+ x;
    float y1 = radius * sin(a)+ y;
    float x2 = radius * cos(a + Step) + x;
    float y2 = radius * sin(a + Step) + y;
    Line[Count].x = x1;
    Line[Count].y = y1;
    Line[Count + 1].x = x2;
    Line[Count + 1].y = y2;
    Count += 2;
    }
    Directx.pLine->Begin();
    Directx.pLine->Draw(Line, Count, Color);
    Directx.pLine->End();
    }

  4. #4
    Coder.DiasII's Avatar
    Join Date
    Feb 2013
    Gender
    male
    Location
    In My World
    Posts
    1,511
    Reputation
    156
    Thanks
    5,755
    My Mood
    Aggressive
    Quote Originally Posted by Donor View Post
    void DrawCircle(int x, int y, int radius, int numSides, DWORD Color)
    {
    #define PI 3.14159265
    D3DXVECTOR2 Line[128];
    float Step = PI * 2.0 / numSides;
    int Count = false;
    for(float a = 0; a < PI * 2.0; a += Step)
    {
    float x1 = radius * cos(a)+ x;
    float y1 = radius * sin(a)+ y;
    float x2 = radius * cos(a + Step) + x;
    float y2 = radius * sin(a + Step) + y;
    Line[Count].x = x1;
    Line[Count].y = y1;
    Line[Count + 1].x = x2;
    Line[Count + 1].y = y2;
    Count += 2;
    }
    Directx.pLine->Begin();
    Directx.pLine->Draw(Line, Count, Color);
    Directx.pLine->End();
    }

    functions

    DrawCircle

    Code:
    VOID DrawCircle(int X, int Y, int radius, int numSides, DWORD Color)
    {
    	#define PI 3.14159265358979f
    	D3DXVECTOR2 Line[128];
        float Step = PI * 2.0 / numSides;
        int Count = 0;
        for (float a=0; a < PI*2.0; a += Step)
        {
            float X1 = radius * cos(a) + X;
            float Y1 = radius * sin(a) + Y;
            float X2 = radius * cos(a+Step) + X;
            float Y2 = radius * sin(a+Step) + Y;
            Line[Count].x = X1;
            Line[Count].y = Y1;
            Line[Count+1].x = X2;
            Line[Count+1].y = Y2;
            Count += 2;
        }
    }
    DrawLine

    Code:
    void DrawLine(float x, float y, float x2, float y2, float width, DWORD color)
    {
    D3DXVECTOR2 vLine[2];
    pLine->SetWidth( width );
    pLine->SetAntialias( false );
    pLine->SetGLLines( true );
    vLine[0].x = x;
    vLine[0].y = y;
    vLine[1].x = x2;
    vLine[1].y = y2;
    pLine->Begin();
    pLine->Draw( vLine, 2, color );
    pLine->End();
    }

    Cross Hair

    Code:
    void CrossHair(int Value, D3DCOLOR Color, LPDIRECT3DDEVICE9 pDevice)
    {
    	D3DVIEWPORT9 Viewport;
    	pDevice->GetViewport(&Viewport);
    	DWORD ScreenX = Viewport.Width / 2;
    	DWORD ScreenY = Viewport.Height / 2;
    	if (Value == 1){
    	DrawCircle(ScreenX-1,ScreenY-1,8,8,Red);
    	FillRGB(ScreenX-18, ScreenY-1, 10, 1,Red,pDevice);
    	FillRGB(ScreenX+8, ScreenY-1, 10, 1,Red,pDevice);
    	FillRGB(ScreenX-1, ScreenY-18, 1, 10,Red,pDevice);
    	FillRGB(ScreenX-1, ScreenY+8, 1, 10,Red,pDevice);
    	FillRGB(ScreenX-1, ScreenY-1, 1, 1, Red, pDevice);
    	}
    	if (Value == 2){
    	DrawCircle(ScreenX,ScreenY,8,8,Red);//circulo
    	FillRGB(ScreenX-17, ScreenY, 10, 1,Red,pDevice);//Left line
    	FillRGB(ScreenX+9, ScreenY, 10, 1,Red,pDevice); // Right line
    	FillRGB(ScreenX, ScreenY-17, 1, 10,Red,pDevice);//Top line
    	FillRGB(ScreenX, ScreenY+9, 1, 10,Red,pDevice);//Bottom line
    	}
    	if (Value == 3){
    	FillRGB(ScreenX-13, ScreenY, 10, 1,Red,pDevice);//Left line
    	FillRGB(ScreenX+4, ScreenY, 10, 1,Red,pDevice);//Right line
    	FillRGB(ScreenX, ScreenY-13, 1, 10,Red,pDevice);//Top line
    	FillRGB(ScreenX, ScreenY+4, 1, 10,Red,pDevice);//Bottom line
    	}
    	if (GetAsyncKeyState(VK_LBUTTON) <0){
    	DrawCircle(ScreenX-1, ScreenY-1, 22,22,Color);
    	}
    }
    • Registered - February 03, 2012
    • Contributor since August 05, 2014



    CombatArms Brasil


    PointBlank Brasil


  5. The Following User Says Thank You to Coder.DiasII For This Useful Post:

    Donor (06-25-2013)

  6. #5
    Donor's Avatar
    Join Date
    Jun 2013
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Coder.DiasII View Post



    functions

    DrawCircle

    Code:
    VOID DrawCircle(int X, int Y, int radius, int numSides, DWORD Color)
    {
    	#define PI 3.14159265358979f
    	D3DXVECTOR2 Line[128];
        float Step = PI * 2.0 / numSides;
        int Count = 0;
        for (float a=0; a < PI*2.0; a += Step)
        {
            float X1 = radius * cos(a) + X;
            float Y1 = radius * sin(a) + Y;
            float X2 = radius * cos(a+Step) + X;
            float Y2 = radius * sin(a+Step) + Y;
            Line[Count].x = X1;
            Line[Count].y = Y1;
            Line[Count+1].x = X2;
            Line[Count+1].y = Y2;
            Count += 2;
        }
    }
    DrawLine

    Code:
    void DrawLine(float x, float y, float x2, float y2, float width, DWORD color)
    {
    D3DXVECTOR2 vLine[2];
    pLine->SetWidth( width );
    pLine->SetAntialias( false );
    pLine->SetGLLines( true );
    vLine[0].x = x;
    vLine[0].y = y;
    vLine[1].x = x2;
    vLine[1].y = y2;
    pLine->Begin();
    pLine->Draw( vLine, 2, color );
    pLine->End();
    }

    Cross Hair

    Code:
    void CrossHair(int Value, D3DCOLOR Color, LPDIRECT3DDEVICE9 pDevice)
    {
    	D3DVIEWPORT9 Viewport;
    	pDevice->GetViewport(&Viewport);
    	DWORD ScreenX = Viewport.Width / 2;
    	DWORD ScreenY = Viewport.Height / 2;
    	if (Value == 1){
    	DrawCircle(ScreenX-1,ScreenY-1,8,8,Red);
    	FillRGB(ScreenX-18, ScreenY-1, 10, 1,Red,pDevice);
    	FillRGB(ScreenX+8, ScreenY-1, 10, 1,Red,pDevice);
    	FillRGB(ScreenX-1, ScreenY-18, 1, 10,Red,pDevice);
    	FillRGB(ScreenX-1, ScreenY+8, 1, 10,Red,pDevice);
    	FillRGB(ScreenX-1, ScreenY-1, 1, 1, Red, pDevice);
    	}
    	if (Value == 2){
    	DrawCircle(ScreenX,ScreenY,8,8,Red);//circulo
    	FillRGB(ScreenX-17, ScreenY, 10, 1,Red,pDevice);//Left line
    	FillRGB(ScreenX+9, ScreenY, 10, 1,Red,pDevice); // Right line
    	FillRGB(ScreenX, ScreenY-17, 1, 10,Red,pDevice);//Top line
    	FillRGB(ScreenX, ScreenY+9, 1, 10,Red,pDevice);//Bottom line
    	}
    	if (Value == 3){
    	FillRGB(ScreenX-13, ScreenY, 10, 1,Red,pDevice);//Left line
    	FillRGB(ScreenX+4, ScreenY, 10, 1,Red,pDevice);//Right line
    	FillRGB(ScreenX, ScreenY-13, 1, 10,Red,pDevice);//Top line
    	FillRGB(ScreenX, ScreenY+4, 1, 10,Red,pDevice);//Bottom line
    	}
    	if (GetAsyncKeyState(VK_LBUTTON) <0){
    	DrawCircle(ScreenX-1, ScreenY-1, 22,22,Color);
    	}
    }
    Dias does not draw a circle, and everything else draws the line currents are all there.
    This is code from your cheat? in your cheat does not draw a circle too.
    Last edited by Donor; 06-24-2013 at 06:42 PM.

Similar Threads

  1. Rude drawings that will fool you...
    By tradami in forum General
    Replies: 13
    Last Post: 09-07-2008, 12:26 AM
  2. [request] Boxes/Circles Addresses
    By K2 Nemico in forum WarRock - International Hacks
    Replies: 7
    Last Post: 01-24-2008, 09:24 AM
  3. My Very Second High Drawing
    By ace76543 in forum General
    Replies: 4
    Last Post: 09-05-2007, 09:24 PM
  4. paint drawing
    By ace76543 in forum Art & Graphic Design
    Replies: 12
    Last Post: 08-04-2007, 12:31 AM
  5. How to draw a car in MS
    By AN1MAL in forum Entertainment
    Replies: 9
    Last Post: 12-18-2006, 06:38 PM