Re: [PyOpenGL-Users] generating textures
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2003-12-22 19:39:27
|
Fulko van Westrenen wrote: >On Mon, Dec 22, 2003 at 10:04:07AM -0500, Mike C. Fletcher wrote: > > ... >> * You currently have OpenGL code that renders the map as geometric >> primitives (lines, triangles & such) >> * You want to render this geometry into a texture to allow for >> faster rendering and transformation >> >> >This is very correct. I'm clearly not a programmer, let alone a graphics >programmer. > > Hey, I'm a designer by training, so I'll never say boo on that grounds ;) . >>See the demo OpenGLContext/tests/saveimage.py, which demonstrates the >>use of glReadPixels to read data back from the OpenGL buffers into an >>image (which can then be turned into a texture in the same way as you >>see done in all the "load from image file" demos). >> >> >> >I checked my pyopengl 1.5.7, but no luck. Stop >OpenGLContext! I will download that right now. > > You should likely also download PyOpenGL 2.0.1, as 1.5.7 is over two years old, and playing with OpenGLContext is going to require that you use 2.0.x. >It was my hope that it would be possible to render the map in the >background. Using glReadPixels looks like it can only be used for an >image that is rendered for displaying. > > Easiest (and most reliably available) thing to do is this: * During setup (or whenever you can handle a 1/2 second delay in screen rendering), render your map to the back buffer (i.e. render as normal), do the glReadPixels, then call glClear(...) again and render the next frame of your game. Within Mesa, and other implementations, there are ways to create other off-screen buffers (there's also the "pbuffer" mechanism which is, IIRC done through an OpenGL extension) for this type of work, but none of those are particularly portable AFAIK. >>It's also possible to generate bitmaps using such things as setting >>values in Numpy arrays (particularly useful for creating fractals), >>using PyGame/wxPython to draw into in-memory surfaces/DCs (simple >>device-context-based drawing systems), or other mechanisms, btw. Images >>are just data to be manipulated, and the number of ways you can >>manipulate/create them is pretty large. >> >> > >This is a hard one. I do understand what you want to say, but for an >inexperienced programmer as myself this needs some serious studying >and experimenting. > > Well, rendering it with PyOpenGL and glReadPixels should work fine if you can handle the one-time 1/2 second "hiccup" in rendering. >Just to be complete: my map is a maritime map with coastlines, >depthlines, altitudelines, etc. > > Cool. >I hope I can figure it out tonight. > > Good luck, Mike PS: copied to PyOpenGL-Users for posterity :) _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/ |