Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    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
    4,922
    My Mood
    Cool

    Talking Texture Mapping [DrawTexBox()]

    TEXTURE MAPPING

    Credit:
    - Topblast
    - mmbob

    Well i am posting this because most of you do not know what sprites are and how to use them. Texture mapping is Fitting a texture around a Primitive like a rectangle , triangle and so on. Also an other reason is am doing this because most of you are having problems with sprites and fitting it to your menu like if you want it to be 100 wide and 200 long. You cant do that as well.



    this is acid burn's color picker as u can see i can edit the size of it in any way as well in the next image.


    This is a menu i made Paint .


    Credit:
    - Topblast
    - mmbob


    Code:
    void DrawTexBox(
    __in LPDIRECT3DDEVICE9 pDevice,
    __in LPDIRECT3DTEXTURE9 pTexture,
    __in int x,
    __in int y,
    __in int w,
    __in int h);
    
    
    Parameters
    
    pDevice [in]
    LPDIRECT3DDEVICE9
    Pointer to an IDirect3DDevice9 interface, the device to be associated with the drawing of the object.
    
    pTexture [in]
    LPDIRECT3DTEXTURE9 
    Pointer to an LPDIRECT3DTEXTURE9 interface, the texture that will be mapped around the primitive.
    
    X [in]
    INT
    Specifies the x-coordinate of the rectangle''s upper-left corner.
    
    Y [in]
    INT
    Specifies the y-coordinate of the rectangle''s upper-left corner.
    
    W (Weight) [in]
    INT
    The width of the Square in logical units.
    
    H (Height) [in]
    INT
    The height of the Square in logical units.




    Credit:
    - Topblast
    - mmbob


    Code:
    void DrawTexBox(LPDIRECT3DDEVICE9 pDevice,
    		LPDIRECT3DTEXTURE9 pTexture,
    		int x,
    		int y,
    		int w,
    		int h)
    {
    	struct tVertex
    	{
    		float X, Y, Z, RHW;
    		float IU, IV;
    		 enum FVF
    		{
    			FVF_Flags = (D3DFVF_XYZRHW | D3DFVF_TEX1)
    		};
    	
    	};
    
    	tVertex Veri[4] =
    	{
    		{(float)x		,(float)y		, 0.0f, 1.0f, 0.0f, 0.0f },
    		{(float)(x+w)	,(float)y		, 0.0f, 1.0f, 1.0f, 0.0f },
    		{(float)x		,(float)(y+h)	, 0.0f, 1.0f, 0.0f, 1.0f },
    		{(float)(x+w)	,(float)(y+h)	, 0.0f, 1.0f, 1.0f, 1.0f },
    	};
    	
    	pDevice->SetTexture( 0, pTexture );
    	//
    	// Credit mmbob for helping fixing the problem
    	//
    	pDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
    	pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    	pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE );
    	pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1  );
    	pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE );
    	//
    	// Credit mmbob for helping fixing the problem
    	//
    	pDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
    	pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
    	////////////////////////////////////
    
    	pDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
    	pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
    	pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    	pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
    	pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
    	pDevice->SetRenderState( D3DRS_FOGENABLE, false );
    
    	pDevice->SetFVF( tVertex::FVF_Flags  );
    	pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,Veri,sizeof(tVertex));
    }
    I just like programming, that is all.

    Current Stuff:

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

  2. The Following 6 Users Say Thank You to topblast For This Useful Post:

    -Stephen (01-22-2011),ac1d_buRn (01-22-2011),GodHack2 (01-22-2011),S0aD (01-27-2011),why06 (01-22-2011),_Fk127_ (01-22-2011)

  3. #2
    whatup777's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    CA Source Code Section
    Posts
    4,030
    Reputation
    147
    Thanks
    351
    My Mood
    Dead
    Good Job Topblast.
    Quotes I live by.


    A foolish person learns from his mistakes, I wise person learns from others.
    Quote Originally Posted by AVGN View Post



    mhm

    i live in texas

    i was at the grocery store with my son. He saw a mexican guy, and he said "Look daddy! a mower man!"

    he's 4 yrs old

  4. #3
    -Stephen's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    42
    Reputation
    10
    Thanks
    4
    Good Job. +Thanks.

  5. #4
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    724
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    Good job as always.



    Put this image in your signature if you support HTML5 development!

  6. #5
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Weee~ people are learning

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

    why06 (01-22-2011)

  8. #6
    ac1d_buRn's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Location
    CA Source Section
    Posts
    3,406
    Reputation
    157
    Thanks
    3,991
    My Mood
    Flirty
    gj.

    I want to know tho, Do you use quality in the image?

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

    I want to know tho, Do you use quality in the image?
    errr, wut? |:

  10. #8
    ac1d_buRn's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Location
    CA Source Section
    Posts
    3,406
    Reputation
    157
    Thanks
    3,991
    My Mood
    Flirty
    Quote Originally Posted by freedompeace View Post
    errr, wut? |:
    whoops. Typo.
    Is there any quality loss in the image?

  11. #9
    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
    4,922
    My Mood
    Cool
    Quote Originally Posted by ac1d_buRn View Post


    whoops. Typo.
    Is there any quality loss in the image?
    the quality of the image is very High, but messing around with it like stretching it to much will make it ugly. then u will have to use the function
    SetSampleState() i think that is it... to perfect it.
    I just like programming, that is all.

    Current Stuff:

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

  12. #10
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by ac1d_buRn View Post


    whoops. Typo.
    Is there any quality loss in the image?
    make your own and save it in a lossless format

  13. #11
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,305
    Reputation
    170
    Thanks
    2,194
    My Mood
    Flirty
    Quote Originally Posted by freedompeace View Post
    Weee~ people are learning
    Ikr. It's about time. This makes me wanna forgive topblast for acting like an idiot earlier today.

    Goodjob topblast.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  14. #12
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by why06 View Post


    Ikr. It's about time. This makes me wanna forgive topblast for acting like an idiot earlier today.

    Goodjob topblast.
    Yeah ! xD

    But it's going to happen again, I can feel it ~.~

    I hope more people start taking this as a catalyst to learn new things. It'll make this place better and the questions and discussions more interesting.

  15. #13
    GodHack2's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    645
    Reputation
    38
    Thanks
    762
    My Mood
    Amused
    Quote Originally Posted by freedompeace View Post
    Yeah ! xD

    But it's going to happen again, I can feel it ~.~

    I hope more people start taking this as a catalyst to learn new things. It'll make this place better and the questions and discussions more interesting.
    why are u sad tho?





    beat this bitches ^^^^^^^

    Current Stats : Bored :/


    Respect list :
    Crash !
    Gordon'
    Markoj

  16. #14
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,035
    Reputation
    340
    Thanks
    2,784
    My Mood
    Sad
    Quote Originally Posted by GodHack2 View Post
    why are u sad tho?
    sad?

    (filler)

  17. #15
    GodHack2's Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    645
    Reputation
    38
    Thanks
    762
    My Mood
    Amused
    Quote Originally Posted by freedompeace View Post
    sad?

    (filler)
    your mood :/





    beat this bitches ^^^^^^^

    Current Stats : Bored :/


    Respect list :
    Crash !
    Gordon'
    Markoj

Page 1 of 2 12 LastLast