Can I Use A Grayscale Image With The OpenGL GlTexImage2D Function?


Answer :

Change it to GL_LUMINANCE. See https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml


in the FragmentShader, you can write:

uniform sampler2D A; vec3 result = vec3(texture(A, TexCoord).r); 

in the cpp file,you can write:

glTexImage2D(     GL_TEXTURE_2D, 0, GL_RED,     dicomImage->GetColumns(), dicomImage->GetRows(),     0, GL_RED, GL_UNSIGNED_BYTE, pixelArrayPtr); 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable