[PyOpenGL-Users] More difficulties with framebuffers
Brought to you by:
mcfletch
From: Derakon <de...@gm...> - 2010-12-16 23:15:23
|
After my previous success in getting framebuffers to run at all in my program, I spent some time getting them to work *properly*...and I'm stumped. To recap: I have a program that uses a camera to take images of the contents of a microscope slide. These images are tiled in a mosaic viewer, and the user can pan and zoom about in the viewer. Once we get a few thousand tiles, the viewer starts bogging down because it has to try to draw all of those tiles when the user is zoomed out. I want to modify the viewer to pre-render the tiles using framebuffers at a low level of detail (packing many tiles onto each pre-rendered megatile); then, when the user zooms out, I can switch from rendering each tile individually to using the pre-rendered megatiles with no apparent loss of detail but a reduction in orders of magnitude of the number of textures that OpenGL has to deal with. Unfortunately, I'm running into some scaling and offsetting issues -- the megatiles render too small; I need to scale them up by a factor of about 1.958 to get them close to the right size. Obviously they should be rendering in exactly the right spot, but since I don't know why their scale is off I don't know what the proper fix is (the 1.958 is just a hack to get them approximately right). I've uploaded a standalone app that shows off the problem here: http://derakon.dyndns.org/~chriswei/temp/mosaicapp.tgz It depends on PyOpenGL, wx, and numpy. I'm using the framebuffers in GL.EXT here (old version of OpenGL). Controls: Left-click: prints out location of click in canvas space. Alt-left-click: pan Shift-alt-left-click: zoom Right-click: spawn a new tile The megatiles include some debugging rendering; every 400 units of canvas space, they render some text marking the location, as well as a single pixel marking the exact location. If you zoom in on some text you should see the point to the left of the left parenthesis; you can click on that to compare what the megatile thinks the location is to what the canvas knows the location is. As far as code is concerned, mosaicViewer.GLViewer.OnPaint(), mosaicTile.MegaTile.prerenderTiles(), and mosaicTile.MegaTile.render() should have everything; the rest is just infrastructure. I've uploaded just those three functions to a pastebin here: http://paste.ubuntu.com/544652/ This is a mishmash of very old code and code I've written myself; sorry about the style clash. I'm doing my best to clean things up as I come to understand what they are. If any of you have any ideas about what could be going wrong, I'd love to hear them. -Chris |