modifying bitmap on the fly

Started by
10 comments, last by pucko 22 years, 1 month ago
Hi. I have a stupid idea of having textures that is "modified on the fly". Example: I have a bitmap which I draw alot of lines and points on during the execution of the program. And I want this this bitmap on the sides of a cube which spins. I know it is possible to do, but the problem is that I don''t know how to begin. Which is the best approach and is there any tutorials/guides who might show this? (I have only started looking at OGL)
/pucko
Advertisement
I am not sure, but NeHe''s tutorial 36 or 37 (not sure) could be the thing you are looking for!

Greetz,

SnAkE''s Programming Resources
yeah, i''m pretty sure it''s the playing the avi one.
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
Hey SnAkE, I didn''t know you were here !
well, erm, back on topic...

Yes you can create a texture on-the-fly.

But do you want to do ?
1- do you want to create your own picture instead of reading a file from disk ?
2- and/or do you want to create a texture and change it in real-time (eg an animated texture) ?
vincoof.

I do want to create a picture in memory which I draw lines and dots on while the cube is spinning.

The pictures are not static in any way, but as you write, modified in realtime.
So creating a looping animation is not an option. :/

-----------
Yes you can create a texture on-the-fly.

But do you want to do ?
1- do you want to create your own picture instead of reading a file from disk ?
2- and/or do you want to create a texture and change it in real-time (eg an animated texture)
/pucko
Ive experemented with this some, I want to do a minimap for my RTS game, the only way I could do it was VERY slow.

If you could modify the texture data after its sent to OpenGL it might work, but that would mean accessing video ram, which will still have a performance hit.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
Look at the tut about doing radial blur. It takes a picture of the screen, stores it in memory, and then redisplays it again to perform the blur. If all you want is the texture code, then just look at that part.

If you don''t have anything to say, then don''t say it at all.
If you don't have anything to say, then don't say it at all.
pucko.

I guess the texture animation is NOT predicatble. That''s where the problem becomes interesting

First of all, remember that your texture MUST BE a "power-of-two".

Then IMO the fastest method (and probably the easiest) is to draw your texture via OpenGL and get it directly from OpenGL''s framebuffer according to glCopyTexImage (the method used in NeHe''s radial blur tutorial, as BurningGoat noticed).

The only problem is that you have to make sure that the texture size is lower or equal than the window size (otherwise it''s a bit (lot?) more complicated).
Creating new textures on the fly is VERY slow, if I remember right... So it might be a problem to solve your task, if it depends on speed! But give it a try.

SnAkE''s Programming Resources
SnAkE: it''s not that slow if (i) the texture is built from glCopyTexImage and (ii) the image size is not very big (say, less than 256x256)

This topic is closed to new replies.

Advertisement