2 questions

Blitz3D Forums/Blitz3D Programming/2 questions

here, i coded this quickly so it's far from perfect, but may give you a starting point.
it grabs the screen image and creates a texture and then textures the cube with it.
press the 1 key to perform texturing. to run this code you need an square image (ie 128x128) called height.bmp

Graphics3D 800,600

SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,20,0
RotateEntity camera,90,0,0

texture=LoadTexture("height.bmp")

map=LoadTerrain("height.bmp")
TerrainShading map,True
PositionEntity map,-5,0,-5
ScaleEntity map,0.5,5,0.5
EntityTexture map,texture

light=CreateLight()


cube=CreateCube()
TurnEntity cube,30,30,30
PositionEntity cube,0,2,-9



While Not KeyHit(1)


If KeyHit(2) Then Gosub takepicture

TurnEntity cube,1,1,1



UpdateWorld
RenderWorld
Flip
Wend
End


.takepicture
cubetex=CreateTexture(800,600); create a texture the size of the screen
ctex=CreateImage(800,600); create an image the size of the screen
GrabImage ctex,0,0; grab the image onscreen and put it in the image ctex
CameraClsMode camera,False,True; set camera mode so 2d graphics appear as backround
Cls; clear the screen
SetBuffer TextureBuffer(cubetex); set the drawing buffer to the texture
DrawImage ctex,0,0; draw the image grabbed from the screen
SetBuffer BackBuffer(); set the buffer back to the back buffer
CameraClsMode camera,True,True; reset the cameraclsmode
EntityTexture cube,cubetex; texture the cube with the screen
Return