I have an applet that uses a GLCanvas. I'd like to put an awt Panel over part of the canvas. So far, it looks like I can't get other awt components to appear over the canvas. (But I could just be doing something wrong.)
Before I go too much farther, I figure I should stop and find out if what I'm trying to do is even possible. Thanks, -John |
Administrator
|
On Wednesday, May 19, 2010 01:25:23 John V. [via jogamp] wrote:
> > I have an applet that uses a GLCanvas. I'd like to put an awt Panel over > part of the canvas. So far, it looks like I can't get other awt components > to appear over the canvas. (But I could just be doing something wrong.) > > Before I go too much farther, I figure I should stop and find out if what > I'm trying to do is even possible. John .. GLCanvas is just like an AWT Canvas, hence not a AWT Container, ie you cannot put things in .. Well .. you could have a window on top of the GLCanvas (or whatever) sure .. Maybe you like to try NEWT ? With it's new parenting mechanism .. you could do things like that, but I don't really see the necessity for such a thing, since you could achieve many feature via GL rendering, viewport, stencil buffer, scissors .. ~Sven |
Hi Sven,
Thanks for the response. I looked into this issue some more. I can't get awt components to appear above a GLCanvas on OS X. But I can get it to work on Linux and Windows. Here is a test case: import java.awt.*; import java.awt.event.*; import javax.media.opengl.*; import javax.media.opengl.awt.*; import com.sun.opengl.util.*; public class Test extends Frame implements GLEventListener { Test(boolean useGLCanvas) { super("Test"); this.setLayout(null); final Label label1 = new Label("Hello, World (1)."); label1.setBounds(150, 100, 100, 50); this.add(label1); if (useGLCanvas) { final GLCanvas glCanvas = new GLCanvas(); glCanvas.addGLEventListener(this); glCanvas.setBounds(0, 0, 400, 400); this.add(glCanvas); } else { final TestCanvas testCanvas = new TestCanvas(); testCanvas.setBounds(0, 0, 400, 400); this.add(testCanvas); } // Add a second label just in case z-ordering is mysteriously reversed somehow. final Label label2 = new Label("Hello, World (2)."); label2.setBounds(150, 300, 100, 50); this.add(label2); this.setSize(400, 400); this.setVisible(true); } public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0, 1.0); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glColor3f(0.6f, 0.5f, 0.5f); gl.glRectf(-0.5f, -0.5f, 0.5f, 0.5f); gl.glFlush(); } public void dispose(GLAutoDrawable drawable) {} public void init(GLAutoDrawable drawable) {} public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} public static void main(String[] args) { // If the argument is true, the frame will create a GLCanvas. // Otherwise it will create a TestCanvas (for comparison). Test test = new Test(true); } } class TestCanvas extends Canvas { public void paint(Graphics g) { // Draw some random stuff. g.drawLine(0, 0, 400, 400); g.drawLine(0, 400, 400, 0); g.fillRect(150, 150, 100, 100); } } I would expect at least one of the labels to be visible, but neither one shows up on OS X. I ran a similar test case on Linux and Windows, and the first label is visible (which is expected). Am I making a mistake in this test case? Is there some extra setting I need to change to make this work on OS X? Is this an OS X bug? (I tried two different Apple machines, and both exhibited the same behavior.) > I don't really see the necessity for such a thing, > since you could achieve many feature via GL rendering, viewport, stencil > buffer, scissors .. In my applet, I'd like to use java.awt components like buttons and labels and text areas. And I'd like those components to appear over part of a GLCanvas. If I can't use java.awt on OS X, I guess I'll look for a library that has implemented similar components in GL. Any suggestions? > Maybe you like to try NEWT ? It doesn't look like NEWT has general UI components like the java.awt components, but I could be missing something. Thanks, -john. |
Hi,
Perhaps my previous question got lost in the shuffle, or maybe my post was too long. I understand that everyone is very busy. Here is a short version: Is it possible to put java.awt components on top of a GLCanvas in OS X? For some reason I can't get this to work on OS X, but I can get it to work on Linux and Windows. Thanks, -John. |
sorry John but we don't know.
We do nothing special inside GLCanvas which would force overdraw or something like that. It could be even a driver issue. -michael
|
Administrator
|
In reply to this post by John V.
On Wednesday, May 26, 2010 16:42:02 John V. [via jogamp] wrote:
> > Hi, > > Perhaps my previous question got lost in the shuffle, or maybe my post was > too long. I understand that everyone is very busy. > > Here is a short version: Is it possible to put java.awt components on top > of a GLCanvas in OS X? For some reason I can't get this to work on OS X, > but I can get it to work on Linux and Windows. John, why don't you just commit a junit test for your feature ? Eg in jogl/src/junit/com/jogamp/test/junit/jogl/awt/ Maybe com.jogamp.test.junit.jogl.awt.TestAWTComponentOverGLCanvas ? Fork my jogl github branch, commit in your branch, send us a pull request email with some notes if appropriate. Then we have something real here ... Thank you, Sven > > Thanks, > -John. > > > ______________________________________ > View message @ http://jogamp.762907.n3.nabble.com/Can-I-put-awt-components-over-part-of-a-GLCanvas-tp827759p845035.html > To start a new topic under jogamp, email [hidden email] > To unsubscribe from jogamp, click http://jogamp.762907.n3.nabble.com/subscriptions/Unsubscribe.jtp?code=c2dvdGhlbEBqYXVzb2Z0LmNvbXw3NjI5MDd8MzkxNDI4MzU5 > -- health & wealth mailto:[hidden email] ; www : http://www.jausoft.com ; pgp: http://www.jausoft.com/gpg/ land : +49 (471) 4707742 ; cell: +49 (151) 28145941 Timezone CET: PST+9, EST+6, UTC+1 |
problem is... its a "visual" issue. The components are in wrong z-order on mac. (i am even not sure if a z order for awt even exists in the spec)
-michael
|
Administrator
|
On Wednesday, May 26, 2010 22:11:53 Michael Bien [via jogamp] wrote:
> > problem is... its a "visual" issue. The components are in wrong z-order on > mac. (i am even not sure if a z order for awt even exists in the spec) > I understand this issue, ie maybe hard to test automatically. However .. if we have a junit test .. we can work on it and know what we are actually talking about. I like to recommend this for all isssues in this ML .. ~Sven > -michael > > > Sven Gothel wrote: > > > > On Wednesday, May 26, 2010 16:42:02 John V. [via jogamp] wrote: > >> > >> Hi, > >> > >> Perhaps my previous question got lost in the shuffle, or maybe my post > >> was > >> too long. I understand that everyone is very busy. > >> > >> Here is a short version: Is it possible to put java.awt components on > >> top > >> of a GLCanvas in OS X? For some reason I can't get this to work on OS X, > >> but I can get it to work on Linux and Windows. > > > > John, why don't you just commit a junit test for your feature ? > > Eg in jogl/src/junit/com/jogamp/test/junit/jogl/awt/ > > Maybe com.jogamp.test.junit.jogl.awt.TestAWTComponentOverGLCanvas ? > > > > Fork my jogl github branch, commit in your branch, send us a pull request > > email with some notes if appropriate. > > > > Then we have something real here ... > > > > Thank you, Sven > >> > >> Thanks, > >> -John. > >> > >> > >> ______________________________________ > >> View message @ > >> http://jogamp.762907.n3.nabble.com/Can-I-put-awt-components-over-part-of-a-GLCanvas-tp827759p845035.html > >> To start a new topic under jogamp, email > >> [hidden email] > >> To unsubscribe from jogamp, click (link removed) > >> > > > > > > > ______________________________________ > View message @ http://jogamp.762907.n3.nabble.com/Can-I-put-awt-components-over-part-of-a-GLCanvas-tp827759p845970.html > To start a new topic under jogamp, email [hidden email] > To unsubscribe from jogamp, click http://jogamp.762907.n3.nabble.com/subscriptions/Unsubscribe.jtp?code=c2dvdGhlbEBqYXVzb2Z0LmNvbXw3NjI5MDd8MzkxNDI4MzU5 > -- health & wealth mailto:[hidden email] ; www : http://www.jausoft.com ; pgp: http://www.jausoft.com/gpg/ land : +49 (471) 4707742 ; cell: +49 (151) 28145941 Timezone CET: PST+9, EST+6, UTC+1 |
From what I've observed and the discussion I've had with other folks the GLCanvas is the only truly heavyweight window in the AWT hierarchy on mac. All other Windows - though they are heavyweight on other platforms - are not heavyweight on mac.
What happens when you put an AWT component over a GLCanvas on Windows and Linux is that AWT puts a heavyweight OS window on the screen and then draws into it. Since AWT does not put any heavyweight components on the screen on Mac, the GLCanvas always stays on top. Hope this helps. Bill |
Hi everyone,
I have a similar problem between Mac OS and Windows using SWT and Jogl 2.0. I can put a SWT Composite above a GLCanvas on Windows 7 but not on Mac OS 10.6.8 I'm just wondering if there has been any progress on this issue? Cheers Sina |
Administrator
|
Use the experimental SWT heavyweight GLCanvas of JOGL 2.0 to work around this problem, 2 implementations are available. As Composite and javax.media.opengl.swt.GLCanvas are both heavyweight, it will work as expected.
Another option consists in using NEWT GLWindow instead of javax.media.opengl.awt.GLCanvas.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |