0

I'm doing some GPGPU programming with OpenGL.

I want to be able to write all my data to one-dimensional textures with the format GL_R8, so that I basically can treat it as an std:array object.

Then during rendering I would like to be able to set how the GPU should read the image, e.g. "cast" it to 1024x1024 BGRA.

Is this possible?

e.g. what I want to be able to do:

gpu::array<uint8_t> data(GL_R8, width*height*4);
gpu::bind(data, GL_TEXTURE0, gpu::format::bgra, width, height); 
ronag
  • 49,529
  • 25
  • 126
  • 221

1 Answers1

2

Then use a buffer texture. There's no rule (that I know of) that says you can't hook the same buffer up to multiple different textures. That would allow one texture to use it with the GL_R8 internal format. And another texture could use it with the GL_RGBA8 format.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Couldn't he just set a texture swizzle from R to RGBA? `glTexParameteri(GL_TEXTURE_..., GL_TEXTURE_SWIZZLE_{R,G,B,A}, GL_RED);` – datenwolf Jan 20 '12 at 10:36
  • 2
    @datenwolf: That wouldn't actually do what he wants. It would broadcast the red to all four components. What he wants is for every four consecutive red components to become the RGBA components. That is, to be able to write one component at a time, but *read* four components at a time. – Nicol Bolas Jan 20 '12 at 10:47