Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualEnder1618

Posted 05 April 2013 - 08:56 PM

I am trying to create a 1 channel texture, and update on the fly with a 1 channel image buffer. Im trying to render the texture at its native black and white.

 

I am creating the storage like so:

glTexStorage2D (
    GL_TEXTURE_2D,
    1,
    GL_R8,
    width,
    height
);

 

And filling it like so (where data is a single channel image buffer):

glTexSubImage2D (
    GL_TEXTURE_2D,
    0,
    0,
    0,
    width,
    height,
    GL_RED,
    GL_UNSIGNED_BYTE,
    data
);

When rendering I am getting a red version of my b/w image.

 

My intention was that the other channels would get duplicates of the red channel (other than alpha which would get 1,0).

 

My shader is generic for any type of texture, and I dont want to have a custom one for greyscale images, as i am also showing non-greyscale images.

 

I was under the impression that GL_LUMINACE would do what I intended, but I thought that was deprecated.

 

I would rather not use a BGRA texture and fill the B G R with the same value coming from my data. Im trying to fill this as fast as possible from a decoded b/w video, and at the same time minimize use of texture memory. I also get RGB video, that i am uploading as BGRA8, which works fine (swizzling and adding A before the upload), but I want to use the same shader.

 

I must be doing something silly, and misunderstanding something.

 

How would I accomplish this?

 

Thanx for any help.


#3Ender1618

Posted 05 April 2013 - 08:10 PM

I am trying to create a 1 channel texture, and update on the fly with a 1 channel image buffer. Im trying to render the texture at its native black and white.

 

I am creating the storage like so:

glTexStorage2D (
    GL_TEXTURE_2D,
    1,
    GL_R8,
    width,
    height
);

 

And filling it like so (where data is a single channel image buffer):

glTexSubImage2D (
    GL_TEXTURE_2D,
    0,
    0,
    0,
    width,
    height,
    GL_RED,
    GL_UNSIGNED_BYTE,
    data
);

When rendering I am getting a red version of my b/w image.

 

My intention was that the other channels would get duplicates of the red channel (other that alpha which would get 1,0).

 

My shader is generic for any type of texture, and I dont want to have a custom one for greyscale images, as i am also showing non-greyscale images.

 

I was under the impression that GL_LUMINACE would do what I intended, but I thought that was deprecated.

 

I would rather not use a BGRA texture and fill the B G R with the same value coming from my data. Im trying to fill this as fast as possible from a decoded b/w video, and at the same time minimize use of texture memory. I also get RGB video, that i am uploading as BGRA8, which works fine (swizzling and adding A before the upload), but I want to use the same shader.

 

I must be doing something silly, and misunderstanding something.

 

How would I accomplish this?

 

Thanx for any help.


#2Ender1618

Posted 05 April 2013 - 07:58 PM

I am trying to create a 1 channel texture, and update on the fly with a 1 channel image buffer. Im trying to render the texture at its native black and white.

 

I am creating the storage like so:

glTexStorage2D (
    GL_TEXTURE_2D,
    1,
    GL_R8,
    640,
    480
);

 

And filling it like so (where data is a single channel image buffer):

glTexSubImage2D (
    GL_TEXTURE_2D,
    0,
    0,
    0,
    640,
    480,
    GL_RED,
    GL_UNSIGNED_BYTE,
    data
);

When rendering I am getting a red version of my b/w image.

 

My intention was that the other channels would get duplicates of the red channel (other that alpha which would get 1,0).

 

My shader is generic for any type of texture, and I dont want to have a custom one for greyscale images, as i am also showing non-greyscale images.

 

I was under the impression that GL_LUMINACE would do what I intended, but I thought that was deprecated.

 

I would rather not use a BGRA texture and fill the B G R with the same value coming from my data. Im trying to fill this as fast as possible from a decoded b/w video. At the same time I can get RGB video, that i am uploading as BGRA8, which works fine, but I want to use the same shader.

 

I must be doing something silly, and misunderstanding something.

 

How would I accomplish this?

 

Thanx for any help.


#1Ender1618

Posted 05 April 2013 - 07:57 PM

I am trying to create a 1 channel texture, and update on the fly with a 1 channel image buffer. Im trying to render the texture at its native black and white.

 

I am creating the storage like so:

glTexStorage2D (
    GL_TEXTURE_2D,
    1,
    GL_R8,
    640,
    480
);

And filling it like so (where data is a single channel image buffer):

glTexSubImage2D (
    GL_TEXTURE_2D,
    0,
    0,
    0,
    640,
    480,
    GL_RED,
    GL_UNSIGNED_BYTE,
    data
);

When rendering I am getting a red version of my b/w image.

 

My intention was that the other channels would get duplicates of the red channel (other that alpha which would get 1,0).

 

My shader is generic for any type of texture, and I dont want to have a custom one for greyscale images, as i am also showing non-greyscale images.

 

I was under the impression that GL_LUMINACE would do what I intended, but I thought that was deprecated.

 

I would rather not use a BGRA texture and fill the B G R with the same value coming from my data. Im trying to fill this as fast as possible from a decoded b/w video. At the same time I can get RGB video, that i am uploading as BGRA8, which works fine, but I want to use the same shader.

 

I must be doing something silly, and misunderstanding something.

 

How would I accomplish this?

 

Thanx for any help.


PARTNERS