Quantcast

Rendering semi-transparent, antialiased triangles with jogl

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Rendering semi-transparent, antialiased triangles with jogl

ManuelBrotz
Hi

I made a little Eclipse project to help me compare different methods of rendering triangles in Java. I implemented a version for Java2D BufferedImage, Java2D VolatileImage and Jogl AutoDrawable offscreen. The goal is to have every version support semitransparent / opaque triangles, translucent / solid (opaque) images and turning antialiasing on / off. Everything works fine with buffered images and volatile images. However, i have trouble getting antialiasing to work with jogl. I have googled a lot in the past weeks and found many infos on the subject, but nothing seems to work. I have tested my code on several different systems with different GPUs and different operating systems.

When i use gl.glEnable(GL2.GL_POLYGON_SMOOTH), nothing happens. And when i use caps.setSampleBuffers(true), the generated image is simply empty.

I have attached the eclipse project. Can somebody please take a look at it? You find the code in the class PerfTestJogl and the main method in the class TestRunner. The class StaticSettings contains some static settings used to control the behavior of the tests. Every test stores an image file in the ./out/ folder, so you can check the results.

In the class PerfTestJogl you may need to comment / uncomment the code for antialiasing.

If you run the tests under linux don't forget to add the vm argument -Dsun.java2d.opengl=true to activate hardware acceleration for volatile images.

Any help is appreciated!

Manuel Brotz

TrianglePerfTest.zip
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

gouessej
Administrator
Hi

Have you looked at our use of anti aliasing in the unit tests and in several APIs based on JOGL? As far as I remember, you have to choose a number of samples too.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

ManuelBrotz
No, not yet. I will take a look at the unit tests as soon as i can. I don't know of any APIs, though... Can you provide a link?
In my code, i am choosing a number of samples. The result is an empty image, no matter, what i choose.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

elect
In reply to this post by ManuelBrotz
Don't use GL_POLYGON_SMOOTH, it's deprecated, use multisampling instead

Set your own framebuffer and specify a number of samples for your attached textures
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

ManuelBrotz
Thanks for your answer! Unfortunately, i've got absolutly no idea how to do that... I forgot to mention, that i have no experience with opengl.

So, you are saying, it's not as simple as activating some switches and then everything happens automatically? I hoped, i just have to enable multisampling and then the polygons will be rendered smoothly. Also, i am not using any textures...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

ManuelBrotz
Here i have created an example image with several renderings. The checkerboard background serves to indicate translucency / transparency.

The left column was rendered using buffered image, the right column using jogl.

left column : buffered image
right column: jogl rendering
------------------------------------------------------------
1. row : no translucency | no transparency | no antialiasing
2. row : no translucency |    transparency | no antialiasing
3. row :    translucency |    transparency | no antialiasing
4. row :    translucency |    transparency |    antialiasing

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

elect
In reply to this post by ManuelBrotz
ManuelBrotz wrote
Thanks for your answer! Unfortunately, i've got absolutly no idea how to do that... I forgot to mention, that i have no experience with opengl.

So, you are saying, it's not as simple as activating some switches and then everything happens automatically? I hoped, i just have to enable multisampling and then the polygons will be rendered smoothly. Also, i am not using any textures...
Unfortunately it's not that simple, you should invest some time in order to understand how to write a basic sample. You can take inspiration from this one of mine

Some additional resources:

- https://www.khronos.org/opengl/wiki/Multisampling

- https://learnopengl.com/#!Advanced-OpenGL/Anti-Aliasing
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rendering semi-transparent, antialiased triangles with jogl

ManuelBrotz
Thank you very much for the links! I will try to understand your example. 

Am 21.02.2017 um 21:26 schrieb elect [via jogamp] <[hidden email]>:

ManuelBrotz wrote
Thanks for your answer! Unfortunately, i've got absolutly no idea how to do that... I forgot to mention, that i have no experience with opengl.

So, you are saying, it's not as simple as activating some switches and then everything happens automatically? I hoped, i just have to enable multisampling and then the polygons will be rendered smoothly. Also, i am not using any textures...
Unfortunately it's not that simple, you should invest some time in order to understand how to write a basic sample. You can take inspiration from this one of mine

Some additional resources:

- https://www.khronos.org/opengl/wiki/Multisampling

- https://learnopengl.com/#!Advanced-OpenGL/Anti-Aliasing


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Rendering-semi-transparent-antialiased-triangles-with-jogl-tp4037649p4037661.html
To unsubscribe from Rendering semi-transparent, antialiased triangles with jogl, click here.
NAML
Loading...