How to draw a 3D line in OpenGL within JUCE?

Hi everyone.

Can someone show me how to draw a 3D line in OpenGL within JUCE? I’ve looked through a lot of articles but none seem to even work, perhaps because it is code meant for older OpenGL versions.

All I want to know is how to draw a line from (0, 0, 0) to (1, 1, 1). I have an OpenGL scene set up already.

Thanks

Its not easy, you pretty much have to learn openGl from ground up. You first have to write a shader program that can draw lines. Which will require the geometry shader, because the lines need to be transformed into a screen space rectangle. Then you need to create vao and a vbo, upload your points, then bind everything and call draw.

If you dont want to learn opengl i would suggest trying to link in a library which wraps opengl, so have functions like drawLine() a few examples are Cinder https://libcinder.org/ , OpenScene Graph http://www.openscenegraph.org/, and VTK https://www.vtk.org/.

4 Likes

I guess you could also just draw a 2-D line with JUCE using some kind of 3D-projection.

I used OpenGL 15 years ago, that was OpenGL 1.4. Shaders just about to come, so everything worked without shaders. So is it no longer possible to do OpenGL graphics without shaders?

Just out of curiosity…

OpenGL’s fixed function pipeline is long since deprecated (lots of stuff pre 3.1). Shaders are the way to go for most aspects of it.

Bugger, I will have to start from scratch then…
Well, you can’t expect knowledge from 15 years back to be worth a penny, I guess…

Thanks!