Hello, i come here cuz i have a problem, and after hours of research, i can't find a solution.
I want to keep my previous draws and not clear all the canvas every time in the display() method. So i tried to remove the 'gl.glClear(GL2.GL_COLOR_BUFFER_BIT);' But when i do that, the frame keep switching between the color i want, and the default color, black. How can i fix it ? Thx code on pastebin |
Administrator
|
Hello
You should call https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GLAutoDrawable.html#setAutoSwapBufferMode(boolean), pass "false".
Julien Gouesse | Personal blog | Website
|
hey, thx for reply.
I tried differents ways to swap buffers for make it work, but i keep getting a white screen with nothing. And somtimes i get the red screen as wanted, but no draw on it. NB: the captcha is insane here. Took me like 2 minuts for confirm i'm not a bot.. |
Administrator
|
If you want to paint only on demand, you will have to stop using an animator too and call GLAutoDrawable.display() by yourself.
Julien Gouesse | Personal blog | Website
|
Still doesn't work, the double buffered keep annoy me when i invoke the display() method, and when i turn the double buffering to false, there's no draw on the screen.
What i want to do, for resume, it's create a circle to the mouse position, and if the mouse move, i create a new circle at the new postition, but not removing the circle from the old position. In graphics2D, it's such a basic function, and i don't want to store every draw into a list for draw it again. Look like a waste of ressource. |
Administrator
|
It's doable in JOGL as a Graphics2D implementation based on JOGL exists:
https://github.com/brandonborkholder/glg2d In my humble opinion, you could redraw everything at each frame and convert the mouse positions into geometries instead.
Julien Gouesse | Personal blog | Website
|
GLG2D, this totally can do it for the 2D draw, but for the 3D ?
I can't store each draw made by each display, and repaint it everytime. Or may be store the GL2 object in a global variable at the init() then get that objet in an external loop for draw. the question is, can we draw outside of the display() method ? |
This post was updated on .
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 |
Administrator
|
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. 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. 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. Yes, it's possible but it's a bit tricky and probably not the way to go in your case. You didn't really try my suggestion.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |