Login  Register

Re: How to Draw a Smooth Curve through a Set of 2D Points

Posted by Xerxes Rånby on Mar 01, 2017; 5:12am
URL: https://forum.jogamp.org/How-to-Draw-a-Smooth-Curve-through-a-Set-of-2D-Points-tp4037677p4037692.html

Can you run the com.jogamp.newt.opengl.GLWindow class it will list what
OpenGL driver is in use on your windows system.
java -cp jogamp-fat.jar com.jogamp.newt.opengl.GLWindow

On my linux system it looks like this
-----------------------------------------------------------------------------------------------------
X11GraphicsDevice[type .x11, connection :0]: 
	Natives
		GL4bc 	true [4.5 (Compat profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GL4 	true [4.5 (Core profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GLES3 	true [3.2 (ES profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GL3bc 	true [4.5 (Compat profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GL3 	true [4.5 (Core profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GL2 	true [4.5 (Compat profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GLES2 	true [3.2 (ES profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware)]
		GLES1 	true [1.1 (ES profile, arb, compat[FP32], hardware)]
		Count	8 / 8
	Common
		GL4ES3 	true
		GL2GL3 	true
		GL2ES2 	true
		GL2ES1 	true
	Mappings
		GL3bc 	GLProfile[GL3bc/GL4bc.hw]
		GL2 	GLProfile[GL2/GL4bc.hw]
		GLES3 	GLProfile[GLES3/GLES3.hw]
		GL4 	GLProfile[GL4/GL4.hw]
		GL3 	GLProfile[GL3/GL4.hw]
		GL2GL3 	GLProfile[GL2GL3/GL4bc.hw]
		GLES1 	GLProfile[GLES1/GLES1.hw]
		GLES2 	GLProfile[GLES2/GLES3.hw]
		GL2ES1 	GLProfile[GL2ES1/GL4bc.hw]
		GL4ES3 	GLProfile[GL4ES3/GL4.hw]
		GL2ES2 	GLProfile[GL2ES2/GL4.hw]
		GL4bc 	GLProfile[GL4bc/GL4bc.hw]
		default GLProfile[GL4bc/GL4bc.hw]
		Count	12 / 12

Swap Interval  1
GL Profile     GLProfile[GL4bc/GL4bc.hw]
GL Version     4.5 (Compat profile, arb, compat[ES2, ES3, ES31, ES32], FBO, hardware) - 4.5.0 NVIDIA 367.57 [GL 4.5.0, vendor 367.57.0 (NVIDIA 367.57)]
Quirks         [NoSurfacelessCtx]
Impl. class    jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR      NVIDIA Corporation
GL_RENDERER    GeForce GTX 580/PCIe/SSE2
GL_VERSION     4.5.0 NVIDIA 367.57
GLSL           true, has-compiler-func: true, version: 4.50 NVIDIA / 4.50.0
GL FBO: basic true, full true
GL_EXTENSIONS  315
GLX_EXTENSIONS 34
-----------------------------------------------------------------------------------------------------
Requested: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]]
Chosen   : GLCaps[glx vid 0x27, fbc 0x10d: rgba 8/8/8/0, opaque, accum-rgba 16/16/16/16, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]]
GL impl. class jogamp.opengl.gl4.GL4bcImpl
GL4ES3 retrieved, impl. class jogamp.opengl.gl4.GL4bcImpl
GL3 retrieved, impl. class jogamp.opengl.gl4.GL4bcImpl

2017-03-01 4:54 GMT+01:00 mahesh [via jogamp] <
ml-node+s762907n4037691h84@n3.nabble.com>:

> Thankyou very much for the code..
> But when i run the code in eclipse(with latest jogl-fat.jar) it does't
> display anything (neither it gives any error except red coloured info shown
> in the image below).

I suspect that you are using an OpenGL driver that do not support shaders or the shaders have ailed to compile for some reason.
It is common for people with Intel graphics cards to have to install an OpenGL driver manually from Intel's homepage in order to get modern OpenGL support. Windows only ship with old OpenGL drivers that only support the fixed function pipeline and all shader based code will not work using Microsofts OpenGL driver.


> BTW how to create control points automatically for smooth spline through
> set of N points (all are on curve).

If you have all N points on curve for nurbs then it will be no bends.
If you have even points on curve and odd points off curve then you will get something more towards what you want.

> Actually I am working on 2D physics simulator, where I want to display
> position/speed time graph for object by collecting values over regular
> interval of time (roughly 60 times a second). To make this curve smooth and
> fast I an thinking of spline.

If you have a lot of datapoints then you can consider using a vertex buffer
https://wadeawalker.wordpress.com/2010/10/17/tutorial-faster-rendering-with-vertex-buffer-objects/

> Also I need to recreate curve every frame (or just pop and push new data
> obtained in new frame).
>
> Any suggestion??
> Regards
> mahesh