Archived

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

modifying bitmap on the fly

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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) ?

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
it might also help if you could find a way to keep the texture in the vid cards memory, that way you wont incure the performance hit of reading back from the frame buffer (thats assuminng you need to adjust the image on teh fly in real time), however I dont think all cards support this (I know Nvidia ones do via an extension)

Share this post


Link to post
Share on other sites