Creating Textures and Materials at runtime
Posted: Tue Oct 25, 2016 10:33 pm
Hi all,
I am a bit stumped. I get two red balls on my screen, not one red and one blue. Can anyone see where I am going wrong?
Michael
I am a bit stumped. I get two red balls on my screen, not one red and one blue. Can anyone see where I am going wrong?
Michael
Code: Select all
XIncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
Screen3DRequester()
CreateNode(0, 0, 0, 0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, -5, 0)
CreateLight(#PB_Any, RGB(255, 255, 255), 0, 5, 0)
CreateSphere(0, 0.5)
CreateSphere(1, 1)
;textures and materials for the balls
TextureRed.i = CreateTexture(#PB_Any , 32, 32)
StartDrawing(TextureOutput(TextureRed))
Box(0, 0, TextureWidth(TextureRed), TextureHeight(TextureRed), RGB(255, 0, 0))
StopDrawing()
MaterialRed.i = CreateMaterial(#PB_Any, TextureID(TextureRed))
TextureBlue.i = CreateTexture(#PB_Any, 256, 256)
StartDrawing(TextureOutput(TextureBlue))
Box(0, 0, TextureWidth(TextureBlue), TextureHeight(TextureBlue), RGB(0, 0, 255))
StopDrawing()
MaterialBlue.i = CreateMaterial(#PB_Any, TextureID(TextureBlue))
RedBall = CreateEntity(#PB_Any, MeshID(0), MaterialID(MaterialRed), -1, 0, 0)
BlueBall = CreateEntity(#PB_Any, MeshID(1), MaterialID(MaterialBlue), 1, 0, 0)
Repeat
Screen3DEvents()
ExamineKeyboard()
CameraFollow(0, NodeID(0), 0, 10, 10, 1, 1, #True)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)