3D Lines using GL_LINE?

BlitzMax Modules Forums/MiniB3D/3D Lines using GL_LINE?

Simon you're the best. Here's the code for anyone else who may want to do this.

SuperStrict

Import "minib3d.bmx"

Graphics3D 1024, 768, 32, 2, 0
SetGraphicsDriver GLMax2DDriver()
SetBlend ALPHABLEND
SetBlend LIGHTBLEND
glEnable(GL_LINE_SMOOTH)
HideMouse()

Global cam:TCamera = CreateCamera()
CameraRange cam, 0.01, 1000
MoveEntity cam, 0, 0, - 10

'/////////////// CREATE 2 POINTS WHICH WE WANT TO CONNECT
Global startPivot:tmesh = CreateSphere()
ScaleEntity startPivot, 0.2, 0.2, 0.2
EntityColor startPivot, 255, 0, 0
MoveEntity startPivot, 5, 0, 0

Global endPivot:tmesh = CreateSphere()
ScaleEntity endPivot, 0.2, 0.2, 0.2
EntityColor endPivot, 0, 255, 0
MoveEntity endPivot, - 5, 0, 0

Global centerPivot:tpivot = CreatePivot()
EntityParent startPivot, centerPivot
EntityParent endPivot, centerPivot
TurnEntity centerPivot, 0, 0, 20

While Not KeyDown(KEY_ESCAPE)
	
	TurnEntity centerPivot, 0, 1, 0
	
	RenderWorld
	glBegin(GL_LINES)
	    glVertex3f(EntityX(startPivot, 1), EntityY(startPivot, 1), - EntityZ(startPivot, 1))
    	glVertex3f(EntityX(endPivot, 1), EntityY(endPivot, 1), - EntityZ(endPivot, 1))
  	glEnd()

	If KeyDown(KEY_Q) Then MoveEntity cam, 0, 0, 0.1
	If KeyDown(KEY_A) Then MoveEntity cam, 0, 0, - 0.1
	Flip 1
	
Wend


Be careful though. I had this code written last week, but there was one mistake. I was using glBegin(GL_LINE) and not glBegin(GL_LINES). That S makes all the difference.

Cheers,


Unc