iDevGames Forums
png without alpha fine, png with alpha, nothing - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: png without alpha fine, png with alpha, nothing (/thread-5434.html)



png without alpha fine, png with alpha, nothing - dave05 - Jun 9, 2005 07:57 PM

hmm, now I'm having a different problem... (the alpha's working finally, phew!)

all my textures are displaying the same, despite the fact that I'm binding them to unique GLuints. Interestingly, it's the last texture image that's loaded that's displayed in place of all textures, rather than the last one drawn (which is what I initially assumed).

So now I believe the problem must be in my loading code... I've revised it quite a bit i believe, so here's the most up to date version

Code:
glPixelStorei(GL_UNPACK_ROW_LENGTH, image_size.width);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures (1, &texImage_ref);
glBindTexture (GL_TEXTURE_RECTANGLE_EXT, texImage_ref);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_size.width, image_size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_buffer);

I call the following routine, which loads all the individual images (i'm just trying to get the title screen up and running for the time being):

Code:
void OGL_LoadGraphics(void)
{
    titleImg = OGL_LoadImage(CFSTR("title.png"));
    button_start = OGL_LoadImage(CFSTR("button1_start.png"));
    button_options = OGL_LoadImage(CFSTR("button2_options.png"));
    button_help = OGL_LoadImage(CFSTR("button3_help.png"));
    button_quit = OGL_LoadImage(CFSTR("button4_quit.png"));
}

and the 5 variables are given tex_image_ref #s 1,2,3,4, and 5 respectively, as I would expect.

then i bind glBindTexture( GL_TEXTURE_2D, img ) for each of the 5 textures, onto different rectangles on the screen. they all display correctly in terms of position, but they all display the quit button! yahoo!


png without alpha fine, png with alpha, nothing - dave05 - Jun 9, 2005 10:04 PM

as an update, it does seem to be the background color that's drawn in place of what I'm trying to draw. ie, nothing is drawn at all. or it's 100% destination. or something.


png without alpha fine, png with alpha, nothing - Leisure Suit Lurie - Jun 9, 2005 11:06 PM

I believe you also need to set these:

Code:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);



png without alpha fine, png with alpha, nothing - Andrew - Jun 10, 2005 04:29 AM

See 15.080 here for a few more details:
http://www.opengl.org/resources/faq/technical/transparency.htm


png without alpha fine, png with alpha, nothing - dave05 - Jun 10, 2005 09:30 AM

hmm, now I'm having a different problem... (the alpha's working finally, phew!)

all my textures are displaying the same, despite the fact that I'm binding them to unique GLuints. Interestingly, it's the last texture image that's loaded that's displayed in place of all textures, rather than the last one drawn (which is what I initially assumed).

So now I believe the problem must be in my loading code... I've revised it quite a bit i believe, so here's the most up to date version

Code:
glPixelStorei(GL_UNPACK_ROW_LENGTH, image_size.width);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        
        glGenTextures (1, &texImage_ref);
        
        glBindTexture (GL_TEXTURE_RECTANGLE_EXT, texImage_ref);
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
        glTexImage2D(GL_TEXTURE_2D,
                      0,
                      GL_RGBA,
                      image_size.width,
                      image_size.height,
                      0,
                      GL_RGBA,
                      GL_UNSIGNED_BYTE,
                      data_buffer);

I call the following routine, which loads all the individual images (i'm just trying to get the title screen up and running for the time being):

Code:
void    OGL_LoadGraphics(void)
{
    titleImg        = OGL_LoadImage(CFSTR("title.png"));
    button_start    = OGL_LoadImage(CFSTR("button1_start.png"));
    button_options    = OGL_LoadImage(CFSTR("button2_options.png"));
    button_help        = OGL_LoadImage(CFSTR("button3_help.png"));
    button_quit        = OGL_LoadImage(CFSTR("button4_quit.png"));
}

and the 5 variables are given tex_image_ref #s 1,2,3,4, and 5 respectively, as I would expect.

then i bind glBindTexture( GL_TEXTURE_2D, img ) for each of the 5 textures, onto different rectangles on the screen. they all display correctly in terms of position, but they all display the quit button! yahoo!


png without alpha fine, png with alpha, nothing - arekkusu - Jun 10, 2005 06:40 PM

One of these things is not like the other:
glBindTexture (GL_TEXTURE_RECTANGLE_EXT, texImage_ref);
glTexImage2D(GL_TEXTURE_2D,


png without alpha fine, png with alpha, nothing - dave05 - Jun 11, 2005 10:31 AM

you rule! alllright