Robert Bragg
unread,Nov 22, 2011, 6:25:04 AM11/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cog...@googlegroups.com
Hi Bibhas,
Good question; I think there are a few things going on here...
The first thing to note here is that setting the size of the ClutterTexture actor won't affect the size of any underlying texture, rather it will just result in the texture being scaled when painted. I get the impression you're expecting:
clutter_actor_set_size(texture, WIDTH, HEIGHT);
to set the size of the texture but that isn't the case.
When a ClutterTexture is first instantiated I don't think it will have an associated CoglTexture. I haven't tried running your test, so I'm not really sure what happens when you call clutter_texture_get_cogl_texture() but my expectation is that you get NULL here, or a reference to a dummy 1x1 internal texture.
If you want to update a sub region of a ClutterTexture this way you could first either load a texture via clutter_texture_new_from_file() or perhaps use cogl_texture_new_with_size() to create a texture with a certain size but no content followed by clutter_texture_set_cogl_texture()
Another problem I see is definitely as a result of bad documentation for cogl_texture_set_region(). This API is really quite old and on the list of APIs that really needs a replacement with better documentation. The documentation implies that you can set a sub-region of texture from a smaller source region because it lets you specify the source width/height separately from the dest width/height. Actually you can only set a region as large or smaller than the source region, so it won't work to try and repeat your 2x2 greenish source across the whole texture, you actually need to generate data for the whole texture and set that.
Do you really want to fill a region with a small source region, or did you just do try that for testing purposes? If you do need to do that I can explain how you could do it by binding the larger texture into an offscreen framebuffer and then painting the smaller source using cogl_rectangle() which will be able the repeat the source, but this approach will be a bit more involved than what you are doing currently.
I hope that helps a bit.
I'll at least aim to update the documentation for cogl_texture_set_sub_region() to explain this isn't supported - sorry about that.
kind regards,
- Robert