iDevGames Forums
grayscale loaded as gl_alpha: all texture is white - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: grayscale loaded as gl_alpha: all texture is white (/thread-8550.html)



grayscale loaded as gl_alpha: all texture is white - sefiroths - Jan 17, 2011 09:37 AM

based on this source code,
http://www.71squared.com/2009/03/iphone-game-programming-tutorial-1/

i had tried to load a grayscale and loading as alpha...
what i have changed is:
in eglview, in init functions i have loaded 2 images, one grayscale, and rendered them with this gl init
PHP Code:
    glBlendFunc(GL_SRC_ALPHAGL_ONE_MINUS_SRC_ALPHA);
        
glEnable(GL_BLEND);
        
        
glEnable(GL_TEXTURE_2D);
//        glDisable(GL_DEPTH_TEST);
        
glTexEnvi(GL_TEXTURE_ENVGL_TEXTURE_ENV_MODEGL_BLEND_SRC); 
in texture2d:
PHP Code:
    CGColorSpaceRef imref=CGColorSpaceCreateDeviceRGB();
    if(!
CFEqual(imref,CGImageGetColorSpace(image)))pixelFormat kTexture2DPixelFormat_A8
but what is displayed is a rectangle all white
do someone have an example od loading grayscale as alpha or can someone look this code?
example
i'm not able to find the error
thanks


RE: grayscale loaded as gl_alpha: all texture is white - AnotherJake - Jan 17, 2011 03:31 PM

I don't know, but the first thing you should do is get rid of that texEnv call. The default is

Code:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

and I can't imagine why you'd use anything else.


RE: grayscale loaded as gl_alpha: all texture is white - sefiroths - Jan 18, 2011 12:34 AM

thanks for the fast reply.
i have putted glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND_SRC);
because in other threads around the web i have found it as a fix for this problem.
however, i tried glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); and doesn't solve this problem.

strange thing:
if i load the image as a rgb without alpha, the image is displayed correcly...
i gave managed the image in photoshop, and it results (as it say) grayscale/8.
i have opened windows paint and copy/paste the image and saved as bmp, nothing changed