Created
March 23, 2018 21:57
-
-
Save nothings/f37d19dd99f0922dec53cf8499a4c3bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What I'm trying to do: store a 1-byte alpha texture: | |
GLenum swizzle[4] = { GL_ONE, GL_ONE, GL_ONE, GL_RED }; | |
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width,height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); | |
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); | |
// above draws (1,1,1,1) | |
// works as expected: storing to red channel of an RGBA texture and using swizzle into the alpha | |
GLenum swizzle[4] = { GL_ONE, GL_ONE, GL_ONE, GL_RED }; | |
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width,height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); | |
// ^^^^^^^^ | |
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); | |
// displays as (1,1,1,r) as expected | |
// works as expected: using GL_RED in R,G,B channels of R8 | |
GLenum swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE }; | |
// ^^^^^^ ^^^^^^ ^^^^^^ ^^^^^^ | |
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width,height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); | |
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); | |
// draws as (r,r,r,1) | |
// doesn't work: setting alpha swizzle to 0 in R8 | |
GLenum swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ZERO }; | |
// ^^^^^^^ | |
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, width,height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); | |
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); | |
// draws same as previous, (r,r,r,1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment