Creating Textures and Materials at runtime

Everything related to 3D programming
tastyraspberry
User
User
Posts: 39
Joined: Fri Sep 28, 2012 10:22 am

Creating Textures and Materials at runtime

Post by tastyraspberry »

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

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)
User avatar
Comtois
Addict
Addict
Posts: 1432
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Creating Textures and Materials at runtime

Post by Comtois »

It's a bug with new parameter.
While waiting a fix , write last parameter
TextureRed.i = CreateTexture(#PB_Any , 32, 32, "")
TextureBlue.i = CreateTexture(#PB_Any, 256, 256, "")
Please correct my english
http://purebasic.developpez.com/
tastyraspberry
User
User
Posts: 39
Joined: Fri Sep 28, 2012 10:22 am

Re: Creating Textures and Materials at runtime

Post by tastyraspberry »

oh thank you!

I didn't realise there was a 'new parameter'! Will check the forum!

It now works..

Sigh of relief!

Michael
Post Reply