Archived

This topic is now archived and is closed to further replies.

siddim

dynamic texture

Recommended Posts

siddim    122
hi, I want to use a array of integer to create a texture, but this array will be pretty big ( 2048*2048) and will probably change at every frame. What''s the best way to do that? Should I delete and recreate the textures at everyframe? siddim

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
does each integer stand for 4 btyes (red,green,blue,alpha) or does each integer stand for a single color? Cus if each integer stands for a color, then you will have to convert the integer array into a character array & then you can do pixel operations with it.

I''m sure there is a symetric function to glreadpixels()
(I think thats what its called) where you can feed it a stream of bytes & it will create a texture for you. so look for glwritepixels() or something stupid like that.

Share this post


Link to post
Share on other sites
siddim    122
Read\write pixel directly on the backbuffer is a solution, but I am reading on the net that it''s not really fast.
let say i have my array of integer (4 integer for one color) = data
I create my texture and pass the array directly:
gluBuild2DMipmaps (GL_TEXTURE_2D, GL_RGBA, 2048, 2048, GL_RGBA, GL_UNSIGNED_BYTE, data);
and now on the next frame, I want to change a few pixel of that texture, if I change the integer in the data array, it won''t change the texture right? I will have to recreate the texture is''n?

Share this post


Link to post
Share on other sites
Monder    993
why do you need it at 2048x2048? At that size it either won''t all fit on the screen or be smaller that it''s true size. Which means you can split it up into smaller textures and make smaller versions of it, so only have to update one of the smaller textures (which may be a part of the larger texture or a smaller version of it) and hence will be faster.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Also, I''m not sure you wanna use the GL_UNSIGNED_BYTE flag if you are passing in the integer array, because a byte is 8 bits & an integer is 32 bits (on most machines). If it does what I think it will do... you will end up using only 1/4 of your array, because each integer will count for 3 colors & the alpha value. Good luck !!! : )

Share this post


Link to post
Share on other sites