TextRender only work after reshape with GL_TEXTURE2 binding

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

TextRender only work after reshape with GL_TEXTURE2 binding

yaqiang
I am developing volume 3D visulization functions in MeteoInfo reference the code from https://github.com/RolandR/VolumeRayCasting and https://github.com/mahdilamb/VolumeRendering. For specular ray casting, there are three textures of volume data, colormap and normals. I am facing the problem that rendering the data first time the texts were not plotted until I changed the size of the plot frame which tricks reshape event.

Create the frame and plot specular volume first time. The texts were not plotted.


The texts were plotted when I change the size of the frame.


The texts were plotted using TextRender. It seems that the problem is related with the GL_TEXTURE2 binding because it is ok when the third texture of normals was not used.

The shader of specular volume: https://github.com/meteoinfo/MeteoInfo/blob/master/meteoinfo-chart/src/main/resources/shaders/volume/specular.frag

The code for volume rendering: https://github.com/meteoinfo/MeteoInfo/blob/master/meteoinfo-chart/src/main/java/org/meteoinfo/chart/render/jogl/VolumeRender.java

Any idea of this problem? Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

Martin
Hi,

One thing I did not had time to mention on our discussion related to TextRenderer is that this class curiously needs to have the polygon mode configuration reset to work properly.

glPolygonMode(PolygonMode.FRONT_AND_BACK, PolygonFill.FILL);
TextRenderer renderer = new TextRenderer(...);
renderer.beginRendering(...)

This an example of this in my code.

If you don't do this, then the ability to draw the text depends on how your scenegraph / application did configure the polygon mode. May this solve your problem?


Now about volume rendering : Jzy3D also has a volume rendering tool. It works great but there are two limitations that may be worth knowing
- I have not been able to mix volume rendering with legacy polygon rendering properly.
- I encountered inconsistent coloring across OS.

I would be pleased to get your feedback on this :)


 
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

yaqiang
Thanks for your information! Polygon mode configuration is not the reason of this problem. All the texts were rendered well except the render form displayed first time. Resize the render form will make the problem disappear. And the problem only occurred when GL_TEXTURE2 binding. The test code of the problem: https://github.com/meteoinfo/MeteoInfo/blob/master/meteoinfo-chart/src/test/java/VolumeTest.java.

In MeteoInfo, I didn't have the problem with the mixing volume and polygon rendering. The following example renders country polygons and the volume of w of wind field. The polygons were rendered well behind the volume. The problem of it is that I have to resize the figure dockable region to make the texts plotted.
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

Martin
Thanks for your feedback on volume and polygons.

I am myself working on texts currently so I ll try to reproduce your problem with your sample code next week.

By the way, what do you mean by “render form”?
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

yaqiang
Render form is just a JFrame object contains a GLJPanel to render the data. Sorry for my poor English!
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

yaqiang
By the way, I just release MeteoInfo 3.3.0 beta1 version: http://www.meteothink.org/downloads/index.html. And there are some example volumeplot scripts online: http://www.meteothink.org/docs/meteoinfolab/plot/axes3dgl/volumeplot.html. The sagittal.png file can be downloaded from here: http://www.meteothink.org/downloads/data.html.
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

Martin
I reproduce your issue. I don't have explanations for now, but I noticed you can cheat with the resize requirement by invoking

canvas.setSize(600, 400);

right after making the frame visible - which resize to the current size and imply a reshape event without making anything visible.

 
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

yaqiang
Add canvas.setSize(600, 400) after frame.setVisible(true)  will not solve the problem. The texts only plotted after adjust the frame size by mouse.
Reply | Threaded
Open this post in threaded view
|

Re: TextRender only work after reshape with GL_TEXTURE2 binding

yaqiang
In reply to this post by Martin
The following code in VolumeTest.java can plot the texts, but I don't know why and of course it's not a good solution.

public static void main(String[] args) throws IOException {
        VolumeTest test = new VolumeTest();
        test.readData();
        test.readColorMap();
        VolumeGraphics graphics = test.createGraphics();
        graphics.setRayCastingType(RayCastingType.SPECULAR);
        JFrame frame = new JFrame("Volume Test");
        Plot3DGL plot = new Plot3DGL();
        plot.setOrthographic(false);
        plot.setClipPlane(false);
        //plot.setBackground(Color.black);
        //plot.setForeground(Color.blue);
        plot.setDrawBoundingBox(false);
        plot.setDrawBase(false);
        plot.setBoxed(false);
        plot.getGridLine().setDrawXLine(false);
        plot.getGridLine().setDrawYLine(false);
        plot.getGridLine().setDrawZLine(false);
        GLChartPanel canvas = new GLChartPanel(plot);
        plot.addGraphic(graphics);
        frame.getContentPane().add(canvas);
        frame.pack();
        frame.setSize(600, 400);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        int width = canvas.getWidth();
        int height = canvas.getHeight();
        canvas.setSize(width, height + 1);
        canvas.setSize(width, height);
        //frame.setSize(600, 401);
    }