Texture Size power of 2

Blitz3D Forums/Blitz3D Programming/Texture Size power of 2

Bobysait(Posted 2006) [#1]
Here is maybe a subject ever posted... if so, feel free to delete !

I knew about restriction with power of 2 for createtexture , but i didn't know texture was resized when we load them ...

As we can see in this code, i tryed to compare image and texture.

Graphics3D 800,600,0,2
SetBuffer BackBuffer()

; creation d'une image...
Img=CreateImage(800,50)
; enregistre l'image
SaveImage Img,"ImageDemoTemp.bmp"
FreeImage Img

If FileType ("ImageDemoTemp.bmp")=1
	; charge l'image pour verifier que la taille est bonne
	Img=LoadImage("ImageDemoTemp.bmp")
	Print "Image : =========================="
	Print "taille X:"+ImageWidth(Img)
	Print "taille Y:"+ImageHeight(Img)
	FreeImage Img


	; compare avec la taille de la même image mais en texture !
	Tex=LoadTexture("ImageDemoTemp.bmp")
	Print "texture : =========================="
	Print "taille X:"+TextureWidth(Tex)
	Print "taille Y:"+TextureHeight(Tex)
	FreeTexture Tex

	DeleteFile "ImageDemoTemp.bmp"
Else
	Print "y a bug là !"
EndIf


WaitKey
End


I didn't test it using previous version of Blitz3D, and maybe it's just the new version that can't handle texture not powered of 2 ... so if anyone could confirm with previous version , texture are loaded in 64,128,256,etc... size type :)

I think it's a convinient cause by direct X and graphics card support, but as i'm not sure ( not expert ), i better ask !


jfk EO-11110(Posted 2006) [#2]
yes, they are resized to the next bigger power of two number, so eg. a texture like 110* 220 would be resized to 128*256.

This happens to give you the highest possible compatibility with most Graphics cards.


Bobysait(Posted 2006) [#3]
Ok, thanx. So that may be the raison for i have trouble with certain Copyrect function to grab screen on textures... sometimes they don't feet the screen.


Dreamora(Posted 2006) [#4]
Use square textures. At least if you want to prevent having ugly problems with NVidia cards.


Gabriel(Posted 2006) [#5]
Use square textures. At least if you want to prevent having ugly problems with NVidia cards.


No, use power of two textures. There is no reason to restrict yourself to textures where the width and height are equal as well though. In fact you can probably go as far as a ratio of 8:1 between height and width ( or vice versa ) without any problems, so long as they're powers of 2.


Bobysait(Posted 2006) [#6]
so it does not matter if the width is different of the height ... thanx for nfo !


Gabriel(Posted 2006) [#7]
There's a DirectX Caps setting to get your card's ability to handle non-square textures. Perhaps Tom has this in one of his DLL's, I don't know. I think it's called D3DPTEXTURECAPS_SQUAREONLY and I'm pretty sure that only ancient videocards have it set. I've used non-square textures in all of my games, and I've never had an error report related to it, nor have I had issues with blank areas appearing where textures have been automatically resized. So I'm very confident that you won't have issues with non-square textures, providing you stay within a ratio of 1:8 or 8:1.


Bobysait(Posted 2006) [#8]
There is no issue.
It 's just textures are automatically resized to prevent it.

But, if we don't realise it, and we try to "draw" on a texturebuffer , the real position of the texture won't be the same that this one we expect ...