[Cogl] Creating sliced textures from data and framebuffer

Tobias Hansen Tobias.Hansen at physik.uni-hamburg.de
Mon Jan 23 14:02:48 PST 2012


Am 23.01.2012 14:52, schrieb Neil Roberts:
> Hi
> 
> Just wondering, why do you need sliced textures? If it is to work around
> non-power-of-two restrictions rather than to work around the maximum
> texture size limits then it may make more sense to use an atlas texture
> instead of a sliced texture. An atlas texture will combine multiple
> images into a single GL texture. You might find that you get better
> performance this way because there will be less state changes per frame
> if there are less GL textures used. If you create a texture using the
> cogl_texture_new_* API it will actually by default just create an atlas
> texture unless you pass the COGL_TEXTURE_NO_ATLAS flag.

It's to work around the maximum texture size limits. There are existing
games in 1024x768 and the largest textures are even larger (in some
cases backgrounds of scrolling scenes are more that 2048 pixels wide,
it's a 2D adventure engine). On the other hand hardware like the Pandora
handheld gaming console only supports textures up to 512x512 pixels.

> 
>> Another thing I need is multitexturing... Does Cogl support that in
>> any form? (I still have to consider switching to Cogl entirely, if it
>> can do everything I need. Would be nice, but quite much work.)
> 
> Cogl has good support for multitexturing. Everything in Cogl is rendered
> by creating a CoglPipeline object to represent the drawing state of any
> primitives. You can add multiple textures to a CoglPipeline using
> cogl_pipeline_set_layer_texture¹. You can then set how these textures
> are combined using cogl_pipeline_set_layer_combine² instead of glTexEnv.
> 
> Alternatively if you are only targetting programmable hardware you can
> use the CoglSnippet³ API to describe texture combining in GLSL.
> 
>> Otherwise... Do you see another reasonable way to use multiple sliced
>> textures for multitexturing than a cogl_meta_texture_foreach_in_region
>> variant that accepts multiple CoglMetaTextures and sets of texture
>> coordinates and iterates over regions that don't cross borders of any of
>> the native GL textures involved?
> 
> Cogl doesn't currently support multi-texturing on textures that are
> composed of multiple GL textures. So if you are trying to use sliced
> textures to circumvent the maximum texture size limits (ie, it actually
> needs slicing) then you won't be able to use Cogl's multi-texturing
> support. I think this is a fairly tricky problem to solve. However if
> you are just trying to create non-power-of-two textures then they can be
> represented as either a single texture with padding or can be put in an
> atlas so either way it will be a single GL texture so multi-texturing
> should work fine.

What do you think about my suggestion about a new "foreach" function?
Should it not be possible to use that to allow multitexturing with
sliced textures?

> 
> Is the game engine open source? I'd be really interested to see the
> results if you are able to share them.

Yes its open source: http://opensludge.sourceforge.net
I spent quite some time to make it GLES2 compatible, so I'm hesistant to
change that all again to use Cogl completely.

Best regards,
Tobias


More information about the Cogl mailing list