grayscale loaded as gl_alpha: all texture is white

Member
Posts: 164
Joined: 2010.10
Post: #1
based on this source code,
http://www.71squared.com/2009/03/iphone-...utorial-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
Quote this message in a reply
Moderator
Posts: 3,573
Joined: 2003.06
Post: #2
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.
Quote this message in a reply
Member
Posts: 164
Joined: 2010.10
Post: #3
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
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  grayscale loaded as gl_alpha: the opaque image can be only white? sefiroths 2 5,813 Jan 14, 2011 08:06 AM
Last Post: sefiroths
  Drawing a subview loaded from a bundle Joseph Duchesne 8 5,303 Feb 14, 2006 08:32 PM
Last Post: PowerMacX
  NSView loaded from bundle won't draw... Joseph Duchesne 1 3,488 Feb 12, 2006 03:33 AM
Last Post: Cochrane