i've found this link (
http://pyglet.googlecode.com/svn/trunk/examples/fixed_resolution.py ),
but it seems to be meant to achieve the opposite i want (enlarged
texture), and the way it's coded doesn't help me much (although i may
not have well understood it).
i've found that i can use pyglet.image.Texture to manipulate data that
isn't the window's size, but i'm not sure i understood it well.
here's my "screenshot" method:
def save(self,filename):
texture=pyglet.image.Texture.create(1600,1200,rectangle=True)
src=pyglet.image.get_buffer_manager().get_color_buffer().get_texture().image_data
texture.blit_into(src,0,0,0)
texture.save(filename)
the problem is that the output picture has the window resolution, not
the texture's one. i need something to stretch up while
'blit_into-ing', but can't find it in the doc.
anything i missed ?
In general OpenGL isn't suitable for this sort of work -- it's
designed for real-time (on-screen) compositing. There are some GPU
Gems articles around that describe how to composite into massive
images by dividing the final image into a series of 1024x1024 "tiles"
and rendering each one separately. The final stitching of the tiles
must be done in software though (e.g., you could use PIL).
> i've found this link (
> http://pyglet.googlecode.com/svn/trunk/examples/fixed_resolution.py ),
> but it seems to be meant to achieve the opposite i want (enlarged
> texture), and the way it's coded doesn't help me much (although i may
> not have well understood it).
Not really a relevant example for your problem.
> i've found that i can use pyglet.image.Texture to manipulate data that
> isn't the window's size, but i'm not sure i understood it well.
>
> here's my "screenshot" method:
>
> def save(self,filename):
> texture=pyglet.image.Texture.create(1600,1200,rectangle=True)
> src=pyglet.image.get_buffer_manager().get_color_buffer().get_texture().image_data
> texture.blit_into(src,0,0,0)
> texture.save(filename)
>
> the problem is that the output picture has the window resolution, not
> the texture's one. i need something to stretch up while
> 'blit_into-ing', but can't find it in the doc.
You can't stretch with blit_into, as it's just a data copy operation.
You need to have something you can composite into in order to scale
with OpenGL, such as a framebuffer. Since on-screen framebuffers are
(more or less) limited to your screen resolution, you'll need a
texture framebuffer (FBO with texture attachment). pyglet doesn't
have any support for this, you'll need to delve into the OpenGL calls
yourself. I believe the cocos2d people use FBOs in this way, there's
probably some sample code there.
Alex.