Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with GL_LUMINANCE and ATI
    primarykey
    data
    text
    <p>I'm trying to use luminance textures on my ATI graphics card. </p> <p><em>The problem</em>: I'm not being able to correctly retrieve data from my GPU. Whenever I try to read it (using glReadPixels), all it gives me is an 'all-ones' array (1.0, 1.0, 1.0...).</p> <p>You can test it with this code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;GL/glew.h&gt; #include &lt;GL/glut.h&gt; static int arraySize = 64; static int textureSize = 8; //static GLenum textureTarget = GL_TEXTURE_2D; //static GLenum textureFormat = GL_RGBA; //static GLenum textureInternalFormat = GL_RGBA_FLOAT32_ATI; static GLenum textureTarget = GL_TEXTURE_RECTANGLE_ARB; static GLenum textureFormat = GL_LUMINANCE; static GLenum textureInternalFormat = GL_LUMINANCE_FLOAT32_ATI; int main(int argc, char** argv) { // create test data and fill arbitrarily float* data = new float[arraySize]; float* result = new float[arraySize]; for (int i = 0; i &lt; arraySize; i++) { data[i] = i + 1.0; } // set up glut to get valid GL context and // get extension entry points glutInit (&amp;argc, argv); glutCreateWindow("TEST1"); glewInit(); // viewport transform for 1:1 pixel=texel=data mapping glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, textureSize, 0.0, textureSize); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glViewport(0, 0, textureSize, textureSize); // create FBO and bind it (that is, use offscreen render target) GLuint fboId; glGenFramebuffersEXT(1, &amp;fboId); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboId); // create texture GLuint textureId; glGenTextures (1, &amp;textureId); glBindTexture(textureTarget, textureId); // set texture parameters glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP); // define texture with floating point format glTexImage2D(textureTarget, 0, textureInternalFormat, textureSize, textureSize, 0, textureFormat, GL_FLOAT, 0); // attach texture glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, textureTarget, textureId, 0); // transfer data to texture //glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); //glRasterPos2i(0, 0); //glDrawPixels(textureSize, textureSize, textureFormat, GL_FLOAT, data); glBindTexture(textureTarget, textureId); glTexSubImage2D(textureTarget, 0, 0, 0, textureSize, textureSize, textureFormat, GL_FLOAT, data); // and read back glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); glReadPixels(0, 0, textureSize, textureSize, textureFormat, GL_FLOAT, result); // print out results printf("**********************\n"); printf("Data before roundtrip:\n"); printf("**********************\n"); for (int i = 0; i &lt; arraySize; i++) { printf("%f, ", data[i]); } printf("\n\n\n"); printf("**********************\n"); printf("Data after roundtrip:\n"); printf("**********************\n"); for (int i = 0; i &lt; arraySize; i++) { printf("%f, ", result[i]); } printf("\n"); // clean up delete[] data; delete[] result; glDeleteFramebuffersEXT (1, &amp;fboId); glDeleteTextures (1, &amp;textureId); system("pause"); return 0; } </code></pre> <p>I also read somewhere on the internet that ATI cards don't support luminance yet. Does anyone know if this is true?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload