Login  Register

Re: glClear issue

Posted by gouessej on May 04, 2020; 6:52am
URL: https://forum.jogamp.org/glClear-issue-tp4040576p4040587.html

caderape wrote
GLG2D, this totally can do it for the 2D draw, but for the 3D ?
Yes but if you need much more information about this API, contact its maintainer. It's even possible to use an overlay above a JOGL drawable to use both JOGL and Graphics2D but it's not optimal.

caderape wrote
I can't store each draw made by each display, and repaint it everytime.
It's not what I meant. You can simply let JOGL draw your scene as trivially as possible, convert each new mouse positions into geometries (circles in your case), store their coordinates into a VBO and draw them with the rest of your scene. It's the easiest solution in my humble opinion.

caderape wrote
Or may be store the GL2 object in a global variable at the init() then get that objet in an external loop for draw.
No, don't do that, storing a GL instance is a bad practice (except locally for a local use) because you can be tempted to use it on the wrong thread, on the right thread but when the OpenGL isn't current or when the GL instance is no longer valid.

caderape wrote
the question is, can we draw outside of the display() method ?
Yes, it's possible but it's a bit tricky and probably not the way to go in your case.

caderape wrote
Okay, i found a solution. A tricky one with double condition, but the point is, it work as i want.

The display is called two time at begining, so we have to skip the first frame, and clear the surface at the second display.
Then we can keep the background color and not have a flip between the black screen and the colored screen, and we can save old draws.

https://pastebin.com/d1uV2hmX

edit: nvm, when i change the color of the background while running, it start flipping with the old color. I will just give up. Thx for the help, i'm gonna try javaFX
You didn't really try my suggestion.
Julien Gouesse | Personal blog | Website