DrawText doing nothing

Started by Pfaber11, May 20, 2022, 08:57:28

Previous topic - Next topic

Pfaber11

I am trying to use DrawText to put some text onto the screen but it just isn't working . I'm gonna put the code up here and if someone can take a look I would be very grateful. The sprite is also doing the same .

InitEngine3D()
InitSprite()
InitKeyboard()
;InitMouse()
UsePNGImageDecoder()
UsePNGImageEncoder()
Add3DArchive("3darchive", #PB_3DArchive_FileSystem)

OpenScreen(1920,1080,16,"3cb",#PB_Screen_NoSynchronization ,60)


RenderWorld()
FlipBuffers()
LoadMesh(1,"window_dae.mesh")
;LoadTexture(1,"hellow1.png")
CreateMaterial(1,LoadTexture(1,"hellow1.png"))
CreateEntity(1,MeshID(1),MaterialID(1))
CreateCamera(1,0,0,100,100)
CreateLight(1,RGB(255,255,255),10,10,1)
CameraRange(1,1,100)
CameraBackColor(1,#Green)

MoveEntity(1,4,11,10,#PB_Absolute)
CameraLookAt(1,2,8,10)


a=1
b=1
c=1
LoadSprite(1,"sprite1.png")
StartDrawing(ScreenOutput())
DisplaySprite(1,300,300)
StopDrawing()
RenderWorld()
FlipBuffers()

Repeat


   a=a+1
  If a >=360
    a=1
  EndIf
  b=b+3
  If b>=360
    b=1
    EndIf
    c=c+2
    If c >= 360
      c=1
    EndIf
    StartDrawing(ScreenOutput())
    RotateEntity(1,b,a,c)
    DrawText(10,10,"Hello",#Red)
    StopDrawing()
ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    End
  EndIf

 
RenderWorld()
FlipBuffers()

ForEver
End
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz
HP Desktop AMD 3700 16GB ram 2 GB graphics card windows 10

3DzForMe

Years ago I'd an issue where DrawText failed on my laptop, however it worked on a desktop PC with a dedicated Gfx card - could be graphics card dependent?
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

Pfaber11

Hmm that could be the issue. I'm just trying to get some demos together for a bit of practice at the moment so need to test a few things out . Gonna try adjusting my graphics.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz
HP Desktop AMD 3700 16GB ram 2 GB graphics card windows 10

Pfaber11

I'm using intergrated graphics.
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz
HP Desktop AMD 3700 16GB ram 2 GB graphics card windows 10

Coder Apprentice

#4
What's important here is to understand that PureBasic's sprite library and everything that needs StartDrawing() StopDrawing() is a separate drawing/sprite library from the Engine3D. Therefore you have to place your "drawing" between RenderWorld() and FlipBUffers(). If speed is important, you might want to check out the native sprites to Engine3D/Ogre and those are called billboards.

Rest of your code. You only need to load the PNG encoder if you want to save an image in PNG format, you only need the decoder to load. RenderWorld() and FlipBuffers() those right after OpenScreen() and before LoadMesh() are not needed. There is nothing to render...



Quote from: Pfaber11 on May 20, 2022, 08:57:28
I am trying to use DrawText to put some text onto the screen but it just isn't working . I'm gonna put the code up here and if someone can take a look I would be very grateful. The sprite is also doing the same .

InitEngine3D()
InitSprite()
InitKeyboard()
;InitMouse()
UsePNGImageDecoder()
UsePNGImageEncoder()
Add3DArchive("3darchive", #PB_3DArchive_FileSystem)

OpenScreen(1920,1080,16,"3cb",#PB_Screen_NoSynchronization ,60)


RenderWorld()
FlipBuffers()
LoadMesh(1,"window_dae.mesh")
;LoadTexture(1,"hellow1.png")
CreateMaterial(1,LoadTexture(1,"hellow1.png"))
CreateEntity(1,MeshID(1),MaterialID(1))
CreateCamera(1,0,0,100,100)
CreateLight(1,RGB(255,255,255),10,10,1)
CameraRange(1,1,100)
CameraBackColor(1,#Green)

MoveEntity(1,4,11,10,#PB_Absolute)
CameraLookAt(1,2,8,10)


a=1
b=1
c=1
LoadSprite(1,"sprite1.png")
StartDrawing(ScreenOutput())
DisplaySprite(1,300,300)
StopDrawing()
RenderWorld()
FlipBuffers()

Repeat


   a=a+1
  If a >=360
    a=1
  EndIf
  b=b+3
  If b>=360
    b=1
    EndIf
    c=c+2
    If c >= 360
      c=1
    EndIf
    StartDrawing(ScreenOutput())
    RotateEntity(1,b,a,c)
    DrawText(10,10,"Hello",#Red)
    StopDrawing()
ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    End
  EndIf

 
RenderWorld()
FlipBuffers()

ForEver
End


Pfaber11

#5
I am currently using Directx9 with 5.73 and seems this may be the way to go as when using OpenGL some things don't seem to work . In the PB 6 beta 7 there is the directx9 subsystem and I pasted it into the 5.73 and works better than the OpenGL  I hope . What settings are you guys using and are you managing to get 2d and 3d on the screen at the same time .
I'm using windows 11 and looking forward to using PB 6 when it is ready. Hopefully this will tie up a few loose ends . Any suggestions like buy a new computer might be helpful. I would downgrade to windows ten but think that would be a waste of time .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz
HP Desktop AMD 3700 16GB ram 2 GB graphics card windows 10

Coder Apprentice

#6
One more thing to your previous code. Don't use 16bit screen. You won't gain anything but can cause problems. Like your program will freeze when tries to create a screen.

There was a bug in PureBasic until the latest v6 beta 8 where you had to put a WindowEvent() in the main loop if you used Engine3D() with OpenGL even if it wasn't a window you opened but a screen with the OpenScreen() command.

Also, if you're using v5.7x/pre v6 don't even try Engine3D() with OpenGL and 2D sprite together. They didn't work together. Of course you can test things with DX9 what is the default system on pre v6 when you use Engine3D(). Before v6 Engine3D had quite a few issues and I don't think many used it in OpenGL mode. Now the whole thing is getting cleaned up hopefully and we get a stable OpenGL Ogre3D.

Here is a working code. Took out the unused stuff. Tested with v6 beta 8 on an integrated intel HD GPU.

    InitEngine3D()
    InitSprite()
    InitKeyboard()

    OpenScreen(1366,768,32,"")

    CreateCube(1,2)

    CreateEntity(1,MeshID(1),MaterialID(1))
    CreateCamera(1,0,0,100,100)
    MoveCamera(1,0,0,-10)
    CreateLight(1,RGB(255,255,255),10,10,1)
    CameraRange(1,1,100)
    CameraBackColor(1,#Green)

    CameraLookAt(1,0,0,0)

    CreateSprite(1,355,20)
    SpriteQuality(#PB_Sprite_BilinearFiltering)
    ZoomSprite(1,1065,60)
   
     
     Repeat
     
     ExamineKeyboard()
       
     a=a+1
     
      If a >=360
        a=1
      EndIf
     
     b=b+3
     
      If b>=360
        b=1
      EndIf
     
     c=c+2
     
      If c >= 360
        c=1
      EndIf
       
      RotateEntity(1,b,a,c)

      spritelocation=spritelocation+1
     
      If spritelocation>800
        spritelocation=-60
      EndIf
     
      RenderWorld()
     
      DisplaySprite(1,spritelocation,spritelocation)

      StartDrawing(SpriteOutput(1))
        DrawingMode(#PB_2DDrawing_Default)
        DrawText(5,0,"This is a 2D sprite over the 3D engine render screen! ",RGB(255,255,255))
      StopDrawing()
     
      FlipBuffers()
     
      Until KeyboardPushed(#PB_Key_Escape)






Pfaber11

#7
Hey Kris thanks for that. It is working as it should now and I now have 2d and 3d working at the same time which has alluded me for the last week. Was starting to think this really is not good . As you said between renderworld() and flipbuffers().  I have made quite a bit of progress and hopefully in a few weeks I'll be able to start producing something. I was a little concerned that this would not work out but I'll get there . Was starting to think I'd made a big mistake but I can see the potential and when PB 6 is out there finished all will be good .

I just tried it out with sprites as well and all working . 
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz
HP Desktop AMD 3700 16GB ram 2 GB graphics card windows 10

Pfaber11

I'm feeling quite positive about PureBasic 6 as have been using beta 8 since yesterday and really hope it gets it's official release soon. I had problems with 5.73 then went to beta 8 and all good . It must be a year now that they have been working on it but I have a feeling it will not be much longer. Anyway it's looking good at the moment knock on wood. Have a nice evening .
HP 15s i3 1.2 upto 3.4 ghz 128 gb ssd 16 gb ram 15.6 inch screen. Windows 11 home edition .  2Tb external hard drive dedicated to Linux Mint .
  PureBasic 6 and AppGameKit studio
ASUS Vivo book 15 16gb ram 256gb storage  cpu upto 4.1 ghz
HP Desktop AMD 3700 16GB ram 2 GB graphics card windows 10