Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi All,
I am new to JOGL & trying to develop application. I have this specific requirement where I should be able to draw some 2D stuff on the 3D screen (drawing 3D using canvas). I am using the Overlay to do so. But I am facing issue with the Overlay. Every time it draws the new object but without clearing old ones. So on the overlay it creates to much mess. It can be seen in the below image. ![]() public void init(GLAutoDrawable autoDrawable) { //configurations overlay = new Overlay(autoDrawable); /other code } @Override public void display(GLAutoDrawable drawable) { clearCanvas(); //3D drawing code Graphics2D g2d = overlay.createGraphics(); number = random.nextInt() + 1; overlay.beginRendering(); g2d.setColor(Color.RED); g2d.drawRect(number % 400, 0, 50, 50); overlay.draw(0, 0, width, height); overlay.markDirty(0, 0, width, height); overlay.endRendering(); g2d.dispose(); } To solve this I have tried creating new Overlay object each time it comes in display method. It worked but the CPU usage went to much high. Also after some time it has thrown virtual memory full error. So can any one please help me out for solving this problem. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Hi
Please show a SSCCE, what do you do in the method clearCanvas()?
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
This post was updated on Jan 30, 2016; 6:16am.
Hi Gouessej,
gl2.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl2.glLoadIdentity(); This are the two statements which are there in my clearCanvas method. Some how it is not clearing the overlay colors. Is there anything more which I needs to clear to achieve the overlay cleanup? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
You shouldn't have to do anything else for the cleanup, the culprit is probably elsewhere in your code. Feel free to provide a full test case as I suggested in my previous post.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi Gouessej,
Thanks for reply. TestRenderer.java is the complete code which I have developed to for the 3D view and overlay on it. ![]() This is how it is looking. Overlay gets cleared & starts fresh when I am re-sizing the window. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Thanks. I'll give it a try in a few hours. I see no obvious error. I'll try with a simpler animator (Animator) and without Swing to see if there is a difference.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Yogesh Mevada
I can't compile your example, the class "Camera" is missing.
By the way, rather use GLG2D with JOGL. The overlay utility is not very capable, it works only with GL2 under the hood.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In reply to this post by gouessej
Hey Gouessej,
Sorry for bothering you. Have you checked the code? If you have then can you please suggest some modification or solution to my problem. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Hi
In my humble opinion, you should only keep the source code demonstrating the bug/problem in your example and you should replace new GLU() by GLU.createGLU(). I haven't found a solution yet, you seem to be using the overlay correctly. I will run your example as soon as possible.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Yogesh Mevada
Ok I have spent some time in reading again and again the source code of the texture renderer used in the overlay. Actually, it doesn't clear the image used internally to store the results of the Java2D drawing.
I advise you to look at the documentation of Overlay.contentsLost(). If it returns false, there is still something in the overlay which is the expected behaviour but not what you want.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Yogesh Mevada
If you only use the overlay to draw a red rectangle, I advise you to "clear" the overlay by redrawing the previous rectangle in black before using it with the new rectangle.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |