Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh

    D3D Alpha Blend Boxes

    As some of you know I am working on a D3d Menu in Delphi, Anyway I am more interested about the AlphaBlending of D3DCOLOR as its 8bits(4Bytes) each byte representing A(alpha)R(red)G(green)B(blue) Problem is the Alpha tranperancy doesn't seem to be working lets say we had $FFFF0000 as the color this should be full Red with no transparent, If we Did $78FF0000 this should be just under 50% transparency, Question is why doesn't My box drawn have transparency??

    This Demo menu below uses $78 for the Alpha Color and as you can see there is no transparency, I should be able to see the combat arms logo through the box.. Any Help or advice would be really nice

    No Transparency:

  2. #2
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    653
    Reputation
    70
    Thanks
    1,157
    My Mood
    Bitchy
    Code:
    pDevice->Clear(...);
    does not support transparency. You have to use a sprite or draw a few primitives yourself.

  3. The Following User Says Thank You to mmbob For This Useful Post:

    Departure (05-07-2011)

  4. #3
    Stephen's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Engine.exe
    Posts
    4,689
    Reputation
    184
    Thanks
    1,149
    My Mood
    Aggressive
    Holy. Shit. You. Did. It.

  5. #4
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Yeah I think I have to try the load Image from resource method, Found an example in C++ on GDeception, Which means more porting code over to Delphi and hoping it works

    Thanks mmbob for the info

  6. #5
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    @depature, I'll PM you my textured quad class/wrapper when I get home. Supports alpha, rotation (in all axis) etc...

    Should be easy to port over to Delphi

  7. The Following User Says Thank You to freedompeace For This Useful Post:

    Departure (05-07-2011)

  8. #6
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    5,052
    My Mood
    Cool
    Quote Originally Posted by freedompeace View Post
    @depature, I'll PM you my textured quad class/wrapper when I get home. Supports alpha, rotation (in all axis) etc...

    Should be easy to port over to Delphi
    hmm, arent them all?
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  9. #7
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by topblast View Post


    hmm, arent them all?
    Aren't what all?

    @Departure, sorry for the delay, still haven't been home :P

  10. #8
    topblast's Avatar
    Join Date
    Mar 2010
    Gender
    male
    Location
    Far from around you Programmer: C++ | VB | C# | JAVA
    Posts
    3,607
    Reputation
    149
    Thanks
    5,052
    My Mood
    Cool
    that is what i use for 2D textures

    [highlight=c++]struct tVertex
    {
    float X, Y, Z, RHW;
    float IU, IV;
    enum FVF
    {
    FVF_Flags = (D3DFVF_XYZRHW | D3DFVF_TEX1)
    };

    };[/highlight]
    I just like programming, that is all.

    Current Stuff:

    • GPU Programmer (Cuda)
    • Client/Server (Cloud Server)
    • Mobile App Development

  11. The Following User Says Thank You to topblast For This Useful Post:

    Departure (05-09-2011)

  12. #9
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Well I just ported Hans DrawBox which supports Alpha blending, but I get all weird shit in the test9.exe environment, can someone confirm his function still works???

    Hans DrawBox:
    Code:
    void DrawBox(pD3DdeviceX pDevice, int x, int y, int w, int h, D3DCOLOR col)
    {
    	struct {
    		float x,y,z,rhw;
    		DWORD dwColor;
    	} qV[4] = { { (float)x    , (float)(y+h), 0.0f, 0.0f, col},
    				{ (float)x    , (float)y    , 0.0f, 0.0f, col},
    				{ (float)(x+w), (float)(y+h), 0.0f, 0.0f, col},
    				{ (float)(x+w), (float)y    , 0.0f, 0.0f, col} };
    
    	pDevice->SetPixelShader(NULL);
        pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
        pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
        pDevice->SetTexture(0, NULL);
        pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,qV,sizeof(qV[0]));
    }


    Mine Ported to Delphi:
    [highlight=delphi]
    procedure DrawBox(const iXleft, iYtop, iWidth, iHight: Integer; d3dARGB : D3DCOLOR);
    type
    tVertex = packed record
    x, y, z, rhw: Single;
    Color: D3DCOLOR;
    end;
    procedure AssignVertex(var Vertex: tVertex; x, y, z, rhw: Single; Color: D3DCOLOR);
    begin
    Vertex.x:= x; Vertex.y:= y; Vertex.z:= z; Vertex.rhw:= rhw;
    Verte*****lor:= Color;
    end;
    var
    qV: array[0..3] of tVertex;
    begin

    AssignVertex(qV[0], iXLeft, iYtop + iHight, 0.0, 0.0, d3dARGB);
    AssignVertex(qV[1], iXLeft, iYtop, 0.0, 0.0, d3dARGB);
    AssignVertex(qV[2], iXLeft + iWidth, iYtop + iHight, 0.0, 0.0, d3dARGB);
    AssignVertex(qV[3], iXLeft + iWidth, iYtop, 0.0, 0.0, d3dARGB);

    GetDevice.SetPixelShader(Nil);
    GetDevice.SetRenderState(D3DRS_ALPHABLENDENABLE,1) ;
    GetDevice.SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ INVSRCALPHA);
    GetDevice.SetTexture(0, Nil);
    GetDevice.DrawPrimitiveUP(D3DPT_LINESTRIP,2,qV,Siz eOf(qV[0]));
    //Old DrawRetangle
    //GetDevice.Clear(1,@D3DRectangle, D3DCLEAR_TARGET, d3dARGB, 0, 0);
    end;
    [/highlight]
    Last edited by Departure; 05-08-2011 at 08:43 AM.

  13. #10
    mmbob's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    ja
    Posts
    653
    Reputation
    70
    Thanks
    1,157
    My Mood
    Bitchy
    What does it look like in the environment?

  14. #11
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Never mind Its fixed...

    here is working Transparent box in Delphi

    DrawBox:
    [highlight=delphi]
    procedure DrawBox(const iXleft, iYtop, iWidth, iHight: Integer; d3dARGB : D3DCOLOR);
    type
    tStruct = packed record
    x, y, z, rhw: Single;
    Color: dWord;
    end;
    procedure AssignVertex(var Vertex: tStruct; x, y, z, rhw: Single; Color: dWord);
    begin
    Vertex.x:= x; Vertex.y:= y; Vertex.z:= z; Vertex.rhw:= rhw;
    Verte*****lor:= Color;
    end;
    var
    qV: array[0..3] of tStruct;
    begin

    AssignVertex(qV[0], iXLeft, iYtop + iHight, 0.0, 0.0, d3dARGB);
    AssignVertex(qV[1], iXLeft, iYtop, 0.0, 0.0, d3dARGB);
    AssignVertex(qV[2], iXLeft + iWidth, iYtop + iHight, 0.0, 0.0, d3dARGB);
    AssignVertex(qV[3], iXLeft + iWidth, iYtop, 0.0, 0.0, d3dARGB);

    GetDevice.SetPixelShader(Nil);
    GetDevice.SetRenderState(D3DRS_ALPHABLENDENABLE,1) ;
    GetDevice.SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ INVSRCALPHA);
    GetDevice.SetTexture(0, Nil);
    GetDevice.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,qV ,SizeOf(qV[0]));
    end;
    [/highlight]


    Forgot to change the type when calling DrawPrimitiveUP, I was playing around yesterday before I got hold of hans's Function

    Changed
    GetDevice.DrawPrimitiveUP(D3DPT_LINESTRIP,2,qV,SizeOf(qV[0]));
    to
    GetDevice.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,qV,SizeOf(qV[0]));


    //Edit

    Danmm must be detected in Combat Arms I think its the call to DrawPrimiriveUP
    Last edited by Departure; 05-08-2011 at 09:50 AM. Reason: Added ScreenShot

  15. The Following User Says Thank You to Departure For This Useful Post:

    markoj (05-08-2011)

  16. #12
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Anyone have suggestions about bypassing the DrawPrimitiveUP Detection? I spent all that time working how to draw a alpha blended box only to have it detected Before I start looking into Sprite's to do the job instead, is there anything I should know about these getting detected? I dont really want to spend the next few hours learning about sprites and coding something to work only to have it detected in combat arms.


    //Edit

    I have decided not to go with Alpha Blended background for menu, I don't want to hook too many functions, its a recipe for disaster.... But I would like to know what the deal is with everyone hooking Reset and doing font stuff there? can someone please explain the reset stuff incase I need to look into hooking it..
    Last edited by Departure; 05-08-2011 at 01:15 PM.

  17. #13
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    @topblast, @whit

    Going from TopBlast's structure and looking at gellins VIP base I came up with this...

    Code:
    procedure DrawBox(const iXleft, iYtop, iWidth, iHight: Integer; d3dARGB : D3DCOLOR);
    type
      tStruct = packed record
        x, y, z, rhw: Single;
        Color: dWord;
        tu,tv: Single;
        VFV: dWord;
    end;
    procedure AssignVertex(var Vertex: tStruct; x, y, z, rhw: Single; Color: dWord; tu, tv: Single; VFV: dWord);
     begin
       Vertex.x:= x; Vertex.y:= y; Vertex.z:= z;  Vertex.rhw:= rhw;
       Verte*****lor:= Color;
       Vertex.tu:= tu;  Vertex.tv:= tv;
       Vertex.VFV:= VFV;
     end;
    var
      qV: array[0..3] of tStruct;
    begin
    
       AssignVertex(qV[0], iXLeft, iYtop, 0.0, 0.0, d3dARGB, 0.0, 0.0, D3DFVF_XYZRHW or D3DFVF_TEX1);
       AssignVertex(qV[1], iXLeft  + iWidth, iYtop, 0.0, 0.0, d3dARGB, 0.0, 0.0, D3DFVF_XYZRHW or D3DFVF_TEX1);
       AssignVertex(qV[2], iXLeft + iWidth, iYtop + iHight, 0.0, 0.0, d3dARGB, 0.0, 0.0, D3DFVF_XYZRHW or D3DFVF_TEX1);
       AssignVertex(qV[3], iXLeft, iYtop  + iHight, 0.0, 0.0, d3dARGB, 0.0, 0.0, D3DFVF_XYZRHW or D3DFVF_TEX1);
    
       GetDevice.SetPixelShader(Nil);
       GetDevice.SetRenderState(D3DRS_ALPHABLENDENABLE,1);
       GetDevice.SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
       GetDevice.SetTexture(0, Nil);
       GetDevice.DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,qV,SizeOf(tStruct));
    end;
    It works in the test9 environment, and works up untill the login then it disappears, Also when joining a game with it on it will crash on me, this is normally a good indication of it being detected. Can you recommend a solution?? is it the "DrawPrimitiveUP" thats getting detected? btw I am calling this function from hooked "Present"

  18. #14
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,409
    My Mood
    In Love
    I used to have troubles using a DrawBox method like this.
    Code:
    void FillBox( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
    {
    	D3DRECT rec = { x, y, x + w, y + h };
    	pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
    }
    void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
    {
    	FillBox( x, (y + h - px), w, px,	BorderColor, pDevice );
    	FillBox( x, y, px, h,				BorderColor, pDevice );
    	FillBox( x, y, w, px,				BorderColor, pDevice );
    	FillBox( (x + w - px), y, px, h,	BorderColor, pDevice );
    }
    void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
    {
    	FillBox( x, y, w, h,		BoxColor, pDevice );
    	DrawBorder( x, y, w, h, 1,	BorderColor, pDevice );
    }
    This works perfectly fine.
    When I use DrawPrimitiveUp, the boxes randomly dissapear.
    No I do not make game hacks anymore, please stop asking.

  19. #15
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    805
    Reputation
    125
    Thanks
    1,794
    My Mood
    Doh
    Quote Originally Posted by flameswor10 View Post
    I used to have troubles using a DrawBox method like this.
    Code:
    void FillBox( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
    {
    	D3DRECT rec = { x, y, x + w, y + h };
    	pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
    }
    void DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
    {
    	FillBox( x, (y + h - px), w, px,	BorderColor, pDevice );
    	FillBox( x, y, px, h,				BorderColor, pDevice );
    	FillBox( x, y, w, px,				BorderColor, pDevice );
    	FillBox( (x + w - px), y, px, h,	BorderColor, pDevice );
    }
    void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
    {
    	FillBox( x, y, w, h,		BoxColor, pDevice );
    	DrawBorder( x, y, w, h, 1,	BorderColor, pDevice );
    }
    This works perfectly fine.
    When I use DrawPrimitiveUp, the boxes randomly dissapear.
    Yeah I already had this to start with but didn't support Alpha Blending(see first post) I really would have liked Alpha blending of the boxes

Page 1 of 2 12 LastLast