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.