Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXSPRITE problem?

Started by disjunction May 29, 2002 at 12:57 AM 3 replies 950+ views
Original Post
disjunction
disjunction
hi, im new to d3d, and thought id start off by doing some d3dxsprite stuff... im working from some tutorials i found on nexe. i made a 640x480 display, and when i load a texture to a sprite and draw it, the texture appears like alot larger than it should. the texture is 256x256, and i do this:
  
	hr = D3DXCreateTextureFromFileExA(
	        pDisplay()->getDevice(),
		path.c_str(),
		width,
		height,
		D3DX_DEFAULT,
		0,
		D3DFMT_UNKNOWN,
		D3DPOOL_MANAGED,
		D3DX_FILTER_NONE,
		D3DX_FILTER_NONE,
		0xff000000, 
		&imageInfo,
		NULL,
		&_pTexture);
  
yet the resulting texture is alot larger. shouldnt FILTER_NONE not do any strechting?!
Omnipotent_Q
Omnipotent_Q
Maybe the problem is in the code that puts the texture on the screen? Could you post that as well?

------------------------------
Omnipotent_Q
"Poor people are crazy. I''m eccentric."
------------------------------Omnipotent_Q"Poor people are crazy. I'm eccentric."
aftermath
aftermath
There are some problems that might cause those effects:
1. Your card apparently doesn’t support 256x256 sized textures.
2. The texture you are loading is not that size, but maybe off my one pixel. It has to be (in both width and/or height) n^2 in size.
3. In the drawing function for ID3DSprite, you are specifying a scale larger then (1.0f,1.0f).
4. When you load your textures, make sure you are loading with the appropriate size (see 2)

My best guess would be either 2 or 4.


Rate me up.
stefandxm
stefandxm
quote:
Original post by disjunction
shouldnt FILTER_NONE not do any strechting?!


ehem, No, it should turn off bilinear filtering i guess

You need to draw your sprite in the same res manually (use the FVF wich is for 2d polys and then you will get it in proper size and the filtering shouldnt occour since its drawn in nature resolution.
--mega!--
disjunction
disjunction
thanks guys.

ok, so i imagine that the dimensions specified in CreateTextureFromFile must also be in a power of 2?
if thats the case, then i need to load a texture at the nearest power of 2, and adjust the scaleX and Y for drawing (to stretch a texture to 640x480, for instance)- thats not going to slow down the drawing much?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.