LineXY needs 3D???

Just starting out? Need help? Post your questions and find answers here.
Carm3D
Enthusiast
Enthusiast
Posts: 118
Joined: Mon Feb 17, 2025 10:04 am

LineXY needs 3D???

Post by Carm3D »

Why is using LineXY() causing PB to crash out, telling me I need to use InitEngine3D()?? It's a 2D drawing command in the 2D drawing index.
Carm3D
Enthusiast
Enthusiast
Posts: 118
Joined: Mon Feb 17, 2025 10:04 am

Re: LineXY needs 3D???

Post by Carm3D »

I guess it will remain a mystery. I managed to draw the lines I wanted with zoomed sprites and a bunch of fancy math to rotate them. Heck of a workaround.
Fred
Administrator
Administrator
Posts: 18353
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: LineXY needs 3D???

Post by Fred »

LineXY() doesn't need 3D, please post a code
Carm3D
Enthusiast
Enthusiast
Posts: 118
Joined: Mon Feb 17, 2025 10:04 am

Re: LineXY needs 3D???

Post by Carm3D »

Fred wrote: Mon Oct 27, 2025 1:23 pm LineXY() doesn't need 3D, please post a code
Here's the code that caused the issue.

Code: Select all

Procedure Screen_Game()

	DrawToGame()
	DrawingMode(#PB_2DDrawing_Default)
	Protected InFrame.a
	Protected LensX.w, LensY.w
	Protected DustIntense.w
	Protected DustR.a, DustG.a, DustB.a
	Protected TurClipX.a, TurClipY.a DustOpacity = 0.0
	Select GameRezSize
		Case 0 : Box(CornerX, CornerY, 1280, 720, RGB(0, 0, 0))
		Case 1 : Box(CornerX, CornerY, 1920, 1080, RGB(0, 0, 0))
	EndSelect
	LineXY(NodeX(0), NodeY(0), NodeX(0), 720, RGB(160, 160, 160))

	EndDrawing()
Carm3D
Enthusiast
Enthusiast
Posts: 118
Joined: Mon Feb 17, 2025 10:04 am

Re: LineXY needs 3D???

Post by Carm3D »

I discovered what the problem was... I was not using the proper variable name. The NodeX was inside a structure, and when I changed it to this it worked:

Code: Select all

LineXY(Rope\NodeX(0), Rope\NodeY(0), Rope\NodeX(0), 720, RGB(160, 160, 160))
For some reason the error reported was not that the variable doesn't exist, but 3D was required.
Little John
Addict
Addict
Posts: 4807
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: LineXY needs 3D???

Post by Little John »

Carm3D wrote: Mon Oct 27, 2025 11:25 pm For some reason the error reported was not that the variable doesn't exist, but 3D was required.
We cannot reproduce that, as the code you posted to show the issue is not executable.
Perhaps using ‘EnableExplicit’ in your code would have helped.
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: LineXY needs 3D???

Post by Samuel »

Carm3D wrote: Mon Oct 27, 2025 11:25 pm For some reason the error reported was not that the variable doesn't exist, but 3D was required.
It's because NodeX() and NodeY() are 3D functions. https://www.purebasic.com/documentation/node/nodex.html
The compiler was seeing the 3D functions within your LineXY call, which is why you where getting the InitEngine3D() error.
Carm3D
Enthusiast
Enthusiast
Posts: 118
Joined: Mon Feb 17, 2025 10:04 am

Re: LineXY needs 3D???

Post by Carm3D »

Samuel wrote: Tue Oct 28, 2025 1:49 amIt's because NodeX() and NodeY() are 3D functions. https://www.purebasic.com/documentation/node/nodex.html
The compiler was seeing the 3D functions within your LineXY call, which is why you where getting the InitEngine3D() error.
Ahhhhh! Brilliant. :)
Post Reply