Page 1 of 1

3dtext

Posted: Sun Nov 03, 2019 3:28 pm
by pfaber11
I am trying to use the 3d text command but it keeps saying #3dtext not initialised I've looked at the documentation and example but I can't find the answer . Any help would be most appreciated . Thanks for reading .

Code: Select all

 CreateText3D(0, "Hello world")
    Text3DColor(0, RGBA(255, 0, 0, 255))
    Text3DAlignment(0, #PB_Text3D_HorizontallyCentered)
    MoveText3D(0, 0, 2, 2)
This is the offending code.

Re: 3dtext

Posted: Sun Nov 03, 2019 4:27 pm
by DK_PETER
Take a look at the 3Dtext example provided in PureBasic and the proper-definitions.fontdef file pointed to by
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/fonts", #PB_3DArchive_FileSystem)
Without it, it can't access a font.

Re: 3dtext

Posted: Sun Nov 03, 2019 5:36 pm
by pfaber11
Yes thanks for that got it working had to use parse script() too. This is not really what I wanted . What I would like to know is how to put ordinary text on the screen while using 3D . At least I've learnt something today. like a high score.

Re: 3dtext

Posted: Sun Nov 03, 2019 6:12 pm
by DK_PETER
Use ordinary sprites to display text.

Re: 3dtext

Posted: Sun Nov 03, 2019 6:18 pm
by pfaber11
ok thanks that sounds like a good solution. I'll go and give it a try thanks . I didn't think you could mix 2d and 3d code . Thanks for your time .

Re: 3dtext

Posted: Sun Nov 03, 2019 6:21 pm
by DK_PETER

Code: Select all

InitEngine3D()
InitSprite()
InitKeyboard()

OpenWindow(0, 0, 0, 800, 600, "text", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800,600)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 1)
CreateCube(0, 0.1)
CreateTexture(0, 100, 100, "Lines")
StartDrawing(TextureOutput(0))
Box(0, 0, 100, 100, $00FF16)
Box(3, 3, 94, 94, $0)
StopDrawing()
CreateMaterial(0, TextureID(0))
MaterialBlendingMode(0, #PB_Material_Add)
MaterialCullingMode(0, #PB_Material_NoCulling)
CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 0)
CreateSprite(0, 200, 100)
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(1, 50, "THIS IS TEXT", $00FF16)
StopDrawing()
TransparentSpriteColor(0, $0)

Repeat
  
  Repeat: ev = WindowEvent() : Until ev = 0
  
  RotateEntity(0, 0.3, 0.1, 0.3, #PB_Relative)
  RenderWorld()
  DisplayTransparentSprite(0, ScreenWidth()/2-50, ScreenHeight()/2 )
  FlipBuffers()
  
  ExamineKeyboard()
  
Until KeyboardPushed(#PB_Key_Escape)

Re: 3dtext

Posted: Mon Nov 04, 2019 10:48 am
by pfaber11
Thanks for that the answer I was looking for was in there somewhere. Thanks for the excellent reply . Understood how it works too which is a bonus.

Re: 3dtext

Posted: Mon Nov 04, 2019 1:45 pm
by pfaber11
I have another question using this method

Code: Select all

DrawText(100, 20, "THIS IS TEXT",#Green,#Black)
what do I need to do to increase the size of the text?
Looked through the documentation and can't find the answer so thought I would ask .

Re: 3dtext

Posted: Mon Nov 04, 2019 6:59 pm
by pfaber11
Found out how to increase the size of the text with loadfont() . Thanks for your help.