3dtext

Everything related to 3D programming
pfaber11
User
User
Posts: 48
Joined: Sat Apr 13, 2019 12:17 pm

3dtext

Post 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.
User avatar
DK_PETER
Addict
Addict
Posts: 871
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: 3dtext

Post 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.
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations:
Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Windows 10, Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
pfaber11
User
User
Posts: 48
Joined: Sat Apr 13, 2019 12:17 pm

Re: 3dtext

Post 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.
User avatar
DK_PETER
Addict
Addict
Posts: 871
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: 3dtext

Post by DK_PETER »

Use ordinary sprites to display text.
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations:
Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Windows 10, Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
pfaber11
User
User
Posts: 48
Joined: Sat Apr 13, 2019 12:17 pm

Re: 3dtext

Post 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 .
User avatar
DK_PETER
Addict
Addict
Posts: 871
Joined: Sat Feb 19, 2011 10:06 am
Location: Denmark
Contact:

Re: 3dtext

Post 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)
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations:
Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.
Windows 10, Amd Ryzen 9 5950X, GeForce 3070, 128 gb ram.
pfaber11
User
User
Posts: 48
Joined: Sat Apr 13, 2019 12:17 pm

Re: 3dtext

Post 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.
pfaber11
User
User
Posts: 48
Joined: Sat Apr 13, 2019 12:17 pm

Re: 3dtext

Post 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 .
pfaber11
User
User
Posts: 48
Joined: Sat Apr 13, 2019 12:17 pm

Re: 3dtext

Post by pfaber11 »

Found out how to increase the size of the text with loadfont() . Thanks for your help.
Post Reply