GUI trials and tribulations

Having gotten fairly far along in implementing the BUI toolkit, I'm now much more aware of what a giant pain in the neck it is to try to map what is normally a bunch of 2D graphics rendering onto a scene graph. At this point, I'm looking at the way the Widget toolkit does things and wishing I could do the same myself. Specifically in with regard to:



  • Viewports: being able to call glViewport() and set a clipping mode is way easier than the crazy fiddling that I've been doing with pbuffers to try to allow a widget to only display part of itself and be scrollable.

  • Image rendering: I have still been unable to get JME to render an image to the screen pixel for pixel with no weird artifacts. It inevitably ends up scaling or filtering or something is going haywire and it's ridiculous that I'm creating a quad, texture mapping it, doing a bunch of complicated projections for every pixel when OpenGL has a mechanism (glBitmap and glDrawPixels) to just draw the image to the screen pixel for pixel just how I need it, circumventing all this fooling around.



It seems like all that would be needed is the additon of a few sensible methods to Renderer to support 2D rendering like setting the viewport and clipping mode (only probably useful in ortho mode but Rendered already supports ortho mode) and a view variations on drawImage(), specifically:


  • setClip(int x, int y, int width, int height) would call glViewport() and glEnable(GL_SCISSOR_TEST) and glScissor()

  • clearClip() turns off the scissor test (it can't really restore the viewport, only the Camera can do that AFAIK)

  • draw(Image image, int x, int y) draw the supplied image at the specified screen coordinates.

  • draw(Image image, int sx, int sy, int swidth, int sheight, int tx, int ty) draw the specified region of the supplied image at the specified screen coordinates

  • [li]draw(Image image, int sx, int sy, int swidth, int sheight, int tx, int ty, int twidth, int theight) draw the specified region of the supplied image at the specified screen coordinates and scaled to the specified dimensions


Indeed, now that I've thought about what I really need, maybe I should just add it and then I can submit a patch instead of just complaining. Given that I need to do something like this to get BUI to do what I need, I suppose I'd just like to hear whether or not this totally flies in the face of some project-defining principles or if it seems like a reasonable idea that might get accepted into the main code.

Those additions sound perfectly reasonable. Please don't let their absense lead you to believe that they were intentionally left out. When I was writing the core framework, I had 3D graphics in mind, and didn't really think of 2D ortho rendering so anything that would help you there basically fell behind. The addition of those methods would be beneficial across the board for everyone including those who are using BUI. If you write the patch, I can put it in pretty quickly. Otherwise, I'll work on adding these in, but it may take awhile.

Good to hear. I'll proceed with my conversion to a more sensible rendering structure and add what I need as I go along and then I can supply a patch for inspection and consideration.