[Cogl] Creating sliced textures from data and framebuffer
neil at linux.intel.com
Mon Jan 23 05:52:35 PST 2012
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.
In future I think we want to create a cogl_atlas_texture_new function so
that applications can explicitly specify that they want an atlas texture
rather than the cogl_texture_new functions which just do magic behind
> 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.
Is the game engine open source? I'd be really interested to see the
results if you are able to share them.
More information about the Cogl