Accessing Texture Data

Started by
3 comments, last by eldee 21 years, 9 months ago
How would one go about accessing texture data once it''s been generated in OpenGL? I''m fairly sure it''s possible what with procedural textures and whatnot (or are they precalculated?). At any rate, im doing a simple 2D game with deformable terrain, and i''ve decided that altering the alpha data of my texture is probably the best way to go about doing it. Thanks in advance for any input. -eldee ;another space monkey; [ Forced Evolution Studios ]

::evolve::

-eldee;another space monkey;[ Forced Evolution Studios ]
Advertisement
When you create the texture in the first place, you have to create some image and pass a pointer (let''s call it imgPtr) in to glTexImage2D()... Now, if you want to change that image, here''s what you have to do:

1. First go ahead and modify the raw pixel data pointed to by imgPtr.

2. Use glTexSubImage2D() to tell OpenGL you''ve changed the texture.

Rajan
Hey just a little extending question, is there a fast way to get texture info out of internal opengl like if you do render to a texture so it can be modified?
No, once its across the bus and onboard the video card it''s not for you to mess with anymore directly. You can use render_to_texture and use gl calls on it, but you can''t fiddle with it with the CPU and expect any kind half decent speed in most circumstances.

------------
- outRider -
ok!

This topic is closed to new replies.

Advertisement