💬 Texture Mapping [DrawTexBox()]

Posts 1–15 of 17 · Page 1 of 2
💬 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));
}
Good Job Topblast.
Good Job. +Thanks.
Good job as always.
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.
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.
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?
Quote Originally Posted by GodHack2 View Post
why are u sad tho?
sad?

(filler)
Quote Originally Posted by freedompeace View Post
sad?

(filler)
your mood :/
gj.

I want to know tho, Do you use quality in the image?
Quote Originally Posted by ac1d_buRn View Post
gj.

I want to know tho, Do you use quality in the image?
errr, wut? |:
Quote Originally Posted by freedompeace View Post
errr, wut? |:
whoops. Typo.
Is there any quality loss in the image?
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.
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
Posts 1–15 of 17 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us