绘制透明的纹理

时间:2014-02-04 10:04:55

标签: c++ opengl textures

我有一个带透明度的png文本,我使用wxwidgets以这种方式加载它 wiki.wxwidgets.org/Using_wxImage_to_load_textures_for_OpenGL

我试图在另一个纹理上绘制它,但我得到的是黑色,它应该是透明的,

 glEnable(GL_DEPTH_TEST);
    glColor4f(1, 1, 1, 1);
   glEnable (GL_BLEND);

   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


    showflags = true;
    if (showflags)
    {
    //render flags
    glEnable(GL_TEXTURE_2D);
    for(int i=0;i<DrawnFlagsNum;i++)
    {
        glPushMatrix();
        glTranslated(DrawnFlags[i].x,DrawnFlags[i].y,0);
        switch(DrawnFlags[i].t)
        {
        case blue: blueflag->render();break;
        case yellow: yellowflag->render();break;
        case green: greenflag->render();break;
        }
        glPopMatrix();
    }
 glDisable(GL_TEXTURE_2D);
    }
glColor4f(1, 1, 1, 1);
    if (VideoTexture != 0)
    {
        glEnable(GL_TEXTURE_2D);
        glPushMatrix();
        glBindTexture(GL_TEXTURE_2D, VideoTexture);
        glBegin(GL_QUADS);
        glTexCoord2i(0, 0); glVertex2i(0, 0);
        glTexCoord2i(1, 0); glVertex2i(Width, 0);
        glTexCoord2i(1, 1); glVertex2i(Width, Height);
        glTexCoord2i(0, 1); glVertex2i(0, Height);
        glEnd();
        glPopMatrix();
        glDisable(GL_TEXTURE_2D);
    }



    //renderFirstFrame();
    glFlush();
    SwapBuffers();

标志是顶部纹理;

0 个答案:

没有答案