Skip to main content
GameDev.net gamedev.net
🔒 Locked

Pointer to texture values

Started by aewarnick Mar 22, 2005 at 7:24 AM 9 replies 600+ views
Original Post
aewarnick
aewarnick
How can I write and read from the texture directly, pixel by pixel? I saw glGetTexImage but that copies the pixels to a buffer.
C++->
ff8
ff8
you can draw your texture directly by using glDrawPixels();
"check the blue book for more details"
Aeluned
Aeluned
You can't access a specific byte of VRAM.
you need to download the texture to system memory (glGetTexImage) and do any postprocessing on the texture pixel by pixel there. Or draw a quad with the texture and do the processing in a fragment shader.
aewarnick
aewarnick
fragment shader, would that involve no extra memory usage?
C++->
Aeluned
Aeluned
No extra system memory, but the program is uploaded to VRAM.

It's unclear what you're trying to do...are your memory restrictions that severe?

could you explain your problem in a little greater detail?
aewarnick
aewarnick
I am just trying to preserve as much memory as possible to deal with huge images (high resoluton). I'm not making a game right now.
vram, what exactly is that?
C++->
Aeluned
Aeluned
It's the video ram; the memory used by your video adapter.
aewarnick
aewarnick
So the user will see the changes as they are made?
C++->
Aeluned
Aeluned
No.
What I'm trying to say is that there are 2 ways (AFAIK) of accessing an image
pixel by pixel.

Either you have to get the image into system memory where you can access each
byte of the image or render the image and hijack the fragment processing unit
via a fragment shader and do your fragment processing there.



There's not much you can do with a texture if it's stored on your video board,
since the board doesn't let you manipulate memory addresses - you can only
upload and download bytes to your boards memory.


If you manipulate the image in system memory pixel by pixel, then you need to
upload it to the video board again.

using a fragment shader, the image will be manipulated 'in place' and the
updated image will be in your frame buffer after it gets rendered. Note that
this doesn't replace the original image stored in texture memory. To replace
that you need to do a glTexSubImage to upload the new image from the frame buffer to texture memory.

I don't know how clear that all is. sorry.
aewarnick
aewarnick
I think I understand. Thank you.
C++->

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.