OpenGL使用glDrawPixels绘制图像,其中一个参数是GLenum format,请问假使已经将一个256色的单波段的灰度图像的像素值读入缓存,那么这个GLenum format要设置为哪个值呢?我发现并没有合适的值啊!

解决方案 »

  1.   

    灰度图像的一个像素就是一个字节(即八位),使用unsigned char *pBuffer进行存贮。
      

  2.   

    GL_LUMINANCE 
    Each pixel is a single luminance component. 
    The glDrawPixels function converts this component to the internal floating-point format in the same way that the red component of an RGBA pixel is, and then converts it to an RGBA pixel with red, green, and blue set to the converted luminance value, and alpha set to 1.0. After this conversion, the pixel is treated just as if it had been read as an RGBA pixel. GL_UNSIGNED_BYTE
      

  3.   

    感谢syy64(太平洋) 大侠,你是对的。