Issue with CreateLine3D return value and use with an entity

All bugs related to the 3D engine
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Issue with CreateLine3D return value and use with an entity

Post by Axeman »

According to its documentation, CreateLine3D should return a non-zero value on success and the mesh should be able to be attached to an entity (based on the code example).

The command returns zero on success if a mesh number is specified. If #PB_Any is used then it returns the generated mesh number, but that number is not usable with an entity. If you try and use it, the entity creation fails with a zero returned.

This is with PureBasic 5.73 LTS (Windows - x64) using the OpenGL subsystem on a windowed screen.

As much as I enjoy coding in PureBasic, this sort of thing is really annoying. The vague documentation for many of the 3D library commands coupled with buggy commands leads to a huge waste of time that could be far better spent.

Code: Select all

InitEngine3D() 
InitSprite() 

#LINE = 0
#ENT = 0

OpenWindow(0, 0, 0, 640, 480, "Line3D example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)

; Light
CreateLight(#PB_Any, RGB(25, 25, 180), -5, 10, 5, #PB_Light_Point)

; Camera
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 2, 1, 3, #PB_Absolute | #PB_Local)
CameraLookAt(0, 0, 0, 0)

; Create the line and attach it to the scene
Debug "#LINE: " + Str( CreateLine3D( #LINE, 0, 0, 0, RGB( 255, 0, 0 ), 1, 1, 1, RGB( 0, 0, 255 ) ) )
Debug "#ENT: " + Str( CreateEntity( #ENT, MeshID( #LINE ), #PB_Material_None ) )

line_mesh = CreateLine3D( #PB_Any, 0, 0, 0, RGB(255, 0, 0), -1, 1, 1, RGB(0, 0, 255))
Debug "#PB_Any - line_mesh: " + Str( line_mesh )
Debug "IsMesh: " + Str( IsMesh( line_mesh ) )
line_ent = CreateEntity( #PB_Any, MeshID( line_mesh ), #PB_Material_None)
Debug "#PB_Any - line_ent: " + Str( line_ent )


Repeat
  RenderWorld()
  FlipBuffers()
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
User avatar
pf shadoko
Enthusiast
Enthusiast
Posts: 285
Joined: Thu Jul 09, 2015 9:07 am

Re: Issue with CreateLine3D return value and use with an entity

Post by pf shadoko »

no need to create a mesh with line3d
the doc is incorrect
Post Reply