Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    Draw D3D Crosshair


    NeoIII
     Share

    Recommended Posts

    void DoCrosshair( LPDIRECT3DDEVICE8 pDevice )
    {
    D3DCOLOR xcolor = D3DCOLOR_ARGB( 255, 0, 0, 255 );
    
    int size = 13, strong = 1;
    int iCenterX = Ge*Zensored*temMetrics( 0 ) / 2;
    int iCenterY = Ge*Zensored*temMetrics( 1 ) / 2;
    if( iCenterX < 20 && iCenterY < 20 )
    {
    	iCenterX = ( Ge*Zensored*temMetrics( 0 ) / 2 );
    	iCenterY = ( Ge*Zensored*temMetrics( 1 ) / 2 );
    }
    D3DRECT rec2 = { iCenterX- size, iCenterY, iCenterX+ size, iCenterY+ strong};
    D3DRECT rec3 = { iCenterX, iCenterY- size, iCenterX+ strong,iCenterY+ size};
    pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 0,  0);
    pDevice->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 0,  0);
    }

    Link to comment
    Share on other sites

    • 1 month later...

    I have been trying to make a circle xhair, do you know how i can do this without making a few hundred rects?

     

    thanks in advance.

    Link to comment
    Share on other sites

    by gamedev.net

    #define D3DFVF_TL (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)

    struct D3DTLVERTEX
    {
    float fX;
    float fY;
    float fZ;
    float fRHW;
    D3DCOLOR Color;
    float fU;
    float fV;
    };
    
    //-----------------------------------------------------------------------------------
    //CreateD3DTLVERTEX--Populate a D3DTLVERTEX structure
    //-----------------------------------------------------------------------------------
    D3DTLVERTEX CreateD3DTLVERTEX (float X, float Y, float Z, float RHW, 
    														 D3DCOLOR color, float U, float V)
    {
    D3DTLVERTEX v;
    
    v.fX = X;
    v.fY = Y;
    v.fZ = Z;
    v.fRHW = RHW;
    v.Color = color;
    v.fU = U;
    v.fV = V;
    
    return v;
    }//CreateD3DTLVERTEX

    void Draw2DCircle(POINT pt, float radius, D3DCOLOR color, LPDIRECT3DDEVICE9 dev)
    {
    const int NUMPOINTS = 24;
    	const float PI = 3.14159;
    
    D3DTLVERTEX Circle[NUMPOINTS + 1];
    int i;
    float X;
    float Y;
    float Theta;
    float WedgeAngle;	//Size of angle between two points on the circle (single wedge)
    
    //Precompute WedgeAngle
    WedgeAngle = (float)((2*PI) / NUMPOINTS);
    
    //Set up vertices for a circle
    //Used <= in the for statement to ensure last point meets first point (closed circle)
    for(i=0; i<=NUMPOINTS; i++)
    {
    	//Calculate theta for this vertex
    	Theta = i * WedgeAngle;
    
    	//Compute X and Y locations
    	X = (float)(pt.x + radius * cos(Theta));
    	Y = (float)(pt.y - radius * sin(Theta));
    
    	Circle[i] = CreateD3DTLVERTEX(X, Y, 0.0f, 1.0f, color, 0.0f, 0.0f);
    }
    
    //Now draw the circle
    	dev->SetFVF(D3DFVF_TL);
    dev->SetTexture(0, NULL);
    dev->DrawPrimitiveUP(D3DPT_LINESTRIP, NUMPOINTS, &Circle[0], sizeof(Circle[0]));
    
    }//Draw2DCircle

    Link to comment
    Share on other sites

    WoW nice love these tuts :9

    Link to comment
    Share on other sites

    Thank you very much! Oh and blame Gellin for tellin me to draw 100 rects (1 per pixel xD)

     

    I will enjoy my circles ;)

     

    Edit: Just notice this is for Direct9 device. I tried porting it to d3d8 but there obviously isn't an API for circles. O.o

    Edited by StRyDeR
    Link to comment
    Share on other sites

    • 4 weeks later...
    • 2 weeks later...
    by gamedev.net

    #define D3DFVF_TL (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1)

    struct D3DTLVERTEX
    {
    float fX;
    float fY;
    float fZ;
    float fRHW;
    D3DCOLOR Color;
    float fU;
    float fV;
    };
    
    //-----------------------------------------------------------------------------------
    //CreateD3DTLVERTEX--Populate a D3DTLVERTEX structure
    //-----------------------------------------------------------------------------------
    D3DTLVERTEX CreateD3DTLVERTEX (float X, float Y, float Z, float RHW, 
    														 D3DCOLOR color, float U, float V)
    {
    D3DTLVERTEX v;
    
    v.fX = X;
    v.fY = Y;
    v.fZ = Z;
    v.fRHW = RHW;
    v.Color = color;
    v.fU = U;
    v.fV = V;
    
    return v;
    }//CreateD3DTLVERTEX

    void Draw2DCircle(POINT pt, float radius, D3DCOLOR color, LPDIRECT3DDEVICE9 dev)
    {
    const int NUMPOINTS = 24;
    	const float PI = 3.14159;
    
    D3DTLVERTEX Circle[NUMPOINTS + 1];
    int i;
    float X;
    float Y;
    float Theta;
    float WedgeAngle;	//Size of angle between two points on the circle (single wedge)
    
    //Precompute WedgeAngle
    WedgeAngle = (float)((2*PI) / NUMPOINTS);
    
    //Set up vertices for a circle
    //Used <= in the for statement to ensure last point meets first point (closed circle)
    for(i=0; i<=NUMPOINTS; i++)
    {
    	//Calculate theta for this vertex
    	Theta = i * WedgeAngle;
    
    	//Compute X and Y locations
    	X = (float)(pt.x + radius * cos(Theta));
    	Y = (float)(pt.y - radius * sin(Theta));
    
    	Circle[i] = CreateD3DTLVERTEX(X, Y, 0.0f, 1.0f, color, 0.0f, 0.0f);
    }
    
    //Now draw the circle
    	dev->SetFVF(D3DFVF_TL);
    dev->SetTexture(0, NULL);
    dev->DrawPrimitiveUP(D3DPT_LINESTRIP, NUMPOINTS, &Circle[0], sizeof(Circle[0]));
    
    }//Draw2DCircle

     

    i read it.......but what is the section of d3d8dev.cpp where i put the code??

     

    ex EndScene, BeginScene.........

    Link to comment
    Share on other sites

    • 4 weeks later...

    Ich kapier nich wo ich das alles reinmachen muss....

    alles in eine Datei oder was??

    Link to comment
    Share on other sites

    • 1 month later...

    lool i posted this on 23 november??

    wth a n00b...xDD

    now i understand much of this stuff...xDD

    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...