From: <dom...@so...> - 2003-01-08 09:39:31
|
Hi there, I've two questions about GLCanvas and Selection. 1. Instead of having the Canvas keeps redrawing itself (that's why I'm not using GLAnimCanvas), I want to take over the control of the rendering process so that it only redraws when I ask it to (e.g. when the mouse or keyboard is pressed). I've done this successfully in GLUT, where I only call glutPostRedisplay() when mouse/keyboard events are triggered. In GL4Java, I tried to archieve this by using a GLEventListener attached to GLCanvas. I attach my mouse and keyboard listener classes to glDrawable under the init function of my GLEventLister, and try to see if any control is pressed in the postDisplay() function. If so, glDrawable.repaint() is called to redraw the window. The problem is that it only listen to events when I left click on the mouse! For example, I setup the 'up' key to scroll the screen upwards. The canvas only starts redrawing when I press/hold the key and click the mouse once. What is the problem of this? Would subclassing GLCanvas instead of using GLEventListener help? 2. I have a selection routine and it works well with GLAnimCanvas. Once I switched to GLCanvas (I'm using GLEventListener, therefore the only change to code by this is the line that declaring the canvas, plus some GLAnimCanva specific code such as setFpsSleep()), the selection no longer works. I tracked the variables and found that in my selection routine, the viewport values got by glGetIntegerv are all zero! Where I tested it in the reshape function and the values are correct. Again, what's the problem causing this? Would that subclassing stuff help again? Thank you very much! Regards, Dominic |