ok, what i want to do seems very simple: i just want to use my Frame object’s paint or repaint method on top of the jogl-rendered scene, for purposes of a control box at the bottom of the screen. I’m very set on using awt, I don’t want to use a bunch of openGL polygons or anything, I like my graphics2D and i’m sticking with it :-
).
so i tried making a paint(Graphics g) and calling repaint() as usual, but it just doesn’t show up in the window, bc my Animator object (or possibly my GLEventListener object, I’m not sure which is to blame) takes “control” of rendering the whole window. how can I use awt to draw on top of the jogl window??
Topic: ? Widgets that overlap the GLCanvas…
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=jogl;action=display;num=1071330530
that page didnt really give me a clear idea of how to separate the screen into gl area and control panel. I need the gl area to ignore the bottom 150 or so scanlines, or I need to get the control panel to print on top. if the glcanvas is heavyweight how is this possible? i tried setting the glcanvas to a smaller height but it seems to ignore this. help, anyone?
Frame f;
GLCanvas g;
Component controlPanel;
f.setLayout(new BorderLayout);
f.add(g, BorderLayout.CENTER);
f.add(controlPanel, BorderLayout.SOUTH);
?
I ran into a similar problem. I tried to add an awt/swing slider to the top of my GL window. It worked ok on WK2000, but in the Mac OS X, the GL canvas kept over-writing the slider, even when I used the boarder layout north on the slider and south on the canvas.
My workaround was to have the slider in it’s own separate frame.
-j
nope, with the BorderLayout code the GLCanvas still takes up the entire screen, even covering the taskbar. It’s not in full-screen mode either.
ok, well, the only way I’ve found around the problem is to create my own class extending LayoutManager and physically separate the GLCanvas from the control panel Canvas. This worked but now I still have a strange repaint problem: I have been trying to call repaint (for the control panel) at the end of the display method for the GLCanvas, so that each one is updated consecutively, but (according to System.out.println) the paint method never ends up actually being called. The only way I’ve gotten my control panel’s paint to be actually called was to put a while(true) loop in my main calling paint(Graphics g) itself. Even then paint is only called when the window is moved (don’t ask me why) and the image in the window isn’t updated for the control panel even when paint IS called. ??? ??? ??? Please help me get my control panel to repaint properly!
What about using a null layout for the frame and setting the size / location of your components explicitly?
Just curious…
I didn’t know you could set a null layout safely, but I don’t think it would make a difference since the Layout class I made lets you do exactly that, it just leaves the components where you first tell it to. And they do appear there correctly, but the control panel (which is a canvas) does not update itself even when paint is called… paint is called very erratically, im not sure why moving the window would call it… but according to System.out.println that’s the only time the calls actually reach it even though I’ve tried infinite loops constantly telling it to repaint or paint. sigh…
(breath of mixed relief)… now the canvas control bar DOES repaint properly, I’m not sure which one of my tinkerings fixed it, but it’s causing some new annoyances. The control bar, each time it repaints, just draws one image (that of the actual controls) on the screen, but it takes so frickin’ long… The image is 1024x158, which shouldn’t take long to draw once, and it is told to do this after every openGL screen refresh. OpenGL was rendering 10,000 textured-with-lighting polygons at 38 fps, but just drawing this ONE IMAGE at every repaint cuts it to 10 fps! The [double-buffered] canvas also flickers wildly. Any clues?
[quote]The [double-buffered] canvas also flickers wildly. Any clues?
[/quote]
I assume you have remembered to override update?
public void update(Graphics g) {paint(g);}
awt is slow compared to opengl. You might want to consider running the control panel at a lower fps. How much animation do you have in the control panel anyway?
update? d’oh!
(sheepish grin-- THAT would explain it…)
I don’t plan on having much animation in the control panel, a lower fps would be possible unless you see ever-so-slight pauses in the GL animation whenever the control bar is updated. I’ll try it, thanks.
…
(edit)
I actually do still see slowdown with a 5-times-slower repaint rate, any lower than that and the control panel itself would have unacceptably jerky animation. Is there any way in OpenGL to maybe draw an image to a canvas, just like in awt only faster? I guess it’s just wishful thinking…