Hi all !
I would like to draw some JPanel in my GLJPanel. In order to draw a lot of them with correct performances I think creating texture of the panels is better than add the panels to the GLJPanel. I don't need the Swing Events so it is not a problem.
I've succeeded to draw some Java2D in texture but I can't see anything with the panels. I've tried this :
1 2 3 4 5 6 7 8 9 10 11 12 13
| TextureRenderer renderer = new TextureRenderer(64,64, true); Graphics2D g2 = renderer.createGraphics();
JPanel panel = new JPanel(); JLabel label = new JLabel("test"); panel.add(label); panel.setPreferredSize(new Dimension(64, 64)); panel.paint(g2); g2.dispose(); Texture t = renderer.getTexture(); |
So if I replace
panel.paint(g2) by
g2.fillOval(0, 0, 64, 64) it is working well I can see the shape.
And after I draw the texture on a rectangle like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| texture.enable(); gl.glBegin(GL.GL_TRIANGLE_STRIP); texture.bind(); gl.glTexCoord2d(1, 1); gl.glVertex3f(w, h, 0); gl.glTexCoord2d(0, 1); gl.glVertex3f(-w, h,0); gl.glTexCoord2d(1, 0); gl.glVertex3f(w, -h, 0); gl.glTexCoord2d(0, 0); gl.glVertex3f(-w,-h, 0); gl.glEnd(); texture.disable(); |
What I'm doing wrong ? Thank a lot
