Copy an Image to a Texture

Blitz3D Forums/Blitz3D Programming/Copy an Image to a Texture

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yes, you can use that command to copy an image onto a texture. For the buffers, use ImageBuffer() and TextureBuffer():
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

;setup 3d objects
cam = CreateCamera()
MoveEntity cam, 0, 0, -15

cube = CreateCube()

;create texture
tex = CreateTexture(256, 256, 256)

;create image
image = CreateImage(256, 256)
Color 255, 255, 0
Rect 0, 0, 256, 256
Color 255, 0, 0
Oval 0, 0, 256, 256
Color 0, 0, 255
Line 0, 0, 256, 256
Line 256, 0, 0, 256
Line 128, 0, 128, 256
Line 0, 128, 256, 128
Oval 0, 0, 256, 256, 0
GrabImage image, 0, 0

Color 255, 255, 255
Text 0, 260, "Press any key"
Flip

FlushKeys()
WaitKey()
Cls

;copy image to texture
CopyRect 0, 0, 256, 256, 0, 0, ImageBuffer(image), TextureBuffer(tex)

;apply tex
EntityTexture cube, tex

;show preview
Repeat

	TurnEntity cube, 0, 1, 0
	RenderWorld
	Flip
	
Until KeyHit(1)

End

I'm not sure if the 'offset' value needed for that method using banks with textures can be found somewhere. However I can imagine that is it different that the image's offset. (72)
I found this topic: http://www.blitzforum.de/forum/viewtopic.php?p=83935&sid=ef10e840ad9c2c239204839a1fdcd8c3
It contains a list of many 'offset' values that can be used with that method.