P3D and noSmooth(), points disappear

Hi everyone - I am having a strange bug, and I hope I’m just overlooking something really simple. I’m using the P3D renderer to do opengl-like calls, and I’m not a fan of the antialiasing. However, if I use noSmooth, points fail to draw. Lines still draw.

Here’s a minimal example:

void setup() {
  size(640, 640, P3D);
  //noSmooth();
}

void draw() {
  beginShape(POINTS);
    vertex(10,10);
    vertex(100,100);
  endShape(POINTS);
}

uncomment noSmooth(), and the points fail to draw. Thanks!

Hi, @jimyoung
True. When testing I discovered that this also is the case using point().
It seems that when using P3D mode you have to give a minimal strokeWeight(1.5);

and a quick followup. Man POINTS is slow in processing. I’m testing a line algorithm, and the exact same code is about 30x faster on JOGL than on P3D (!!).

That sounds about right - you testing JOGL by itself or using beginPGL()?

I was using JOGL in straight Java (without linking to Processing).

I’ve since found how I can access OpenGL 2 context in Processing 3, and that approach brings the processing speed up to what I’d expect. I didn’t realize that Processing only simulates OpenGL 2 in the current version.

Not sure what you mean there?! The renderer has overhead in certain scenarios - it’s not simulating anything - but it’s not the same as working directly with raw GL either. I’m not sure why you’re mentioning OpenGL 2 rather than OpenGL 3, but it’s definitely possible to make performant point clouds using beginPGL() for low level OpenGL without directly accessing JOGL classes. Check out eg. GitHub - kessoning/processing_opengl_demonstration_pogl: OpenGL implementation in Processing using vertex and fragment shaders, by sharing the float buffer from Processing to OpenGL through NIO.

1 Like

Sorry Neil - rushing between tasks and my comments are a little underspecified.

I’ve struggled to find clear documentation on using OpenGL in Processing, so your link is certainly helpful. There seems to be several ways about it, and the documentation online is mixed to say the least.

My requirements are that I need to use immediate mode OpenGL, which was the standard in OpenGL2. You know, the glBegin, glEnd, etc etc.

I read somewhere (I can’t find the link currently) that in Processing 3., the OpenGL hooks for immediate mode were removed, and processing just emulates that functionality when we use the beginShape/endShape, vertex, etc., calls. This certainly would explain my performance issue.

I found that I can set the OpenGl profile to a lower value which enables me to get the GL2 context
(PJOGL.profile = 1; … PJOGL pgl = (PJOGL) beginPGL(); gl2 = pgl.gl.getGL2():wink: and then I can use that with my immediate mode functions.

2 Likes

True, except for the idea that it explains your performance issue! :smile:

You might be thinking of Advanced OpenGL · processing/processing Wiki · GitHub