2

我有一个透明的纹理(带有该照明信息的白色三角形),只是不能让它成为 alpha 变量

替代文字 http://gotoandplay.freeblog.hu/files/alpha_help.png

绘图代码,缺少一块:

  //Place polygon vertices to the bottom left within the view.
  glLoadIdentity();
  glTranslatef(centerX, centerY, 0);

  //Draw "diffuse" layer.
  glBindTexture(GL_TEXTURE_2D, spriteTexture[0]); //Bind.
  glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

  //Offset during development only.
  glLoadIdentity();
  glTranslatef(centerX-10, centerY+10, 0); 

  //Draw "specular" layer.
  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_2D, spriteTexture[1]); //Bind.

  //Some smart alpha scaling code needs here...

  glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 

有人可以用适当的代码行帮助我吗? 一些glBlendFunc,或者我想可能是glTextEnvi的东西。

4

1 回答 1

0

好的,即使我不明白我到底做了什么,我也明白了。

    //Place polygon vertices to the bottom left within the view.
    glLoadIdentity();
    glTranslatef(centerX, centerY, 0);

//--1   

        //Draw "diffuse" layer.
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, spriteTexture[0]); //Bind.

            //Blending.
            glBlendFunc(GL_ONE, GL_ONE);

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);  

//--2   

        //Draw "specular" layer.
        glBindTexture(GL_TEXTURE_2D, spriteTexture[1]); //Bind.

            //Blending.
            glColor4f(opacity, opacity, opacity, opacity);
            glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);

        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

我之前试过另一种方法...

glColor4f(1.0f, 1.0f, 1.0f, opacity);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

...但是第二张地图在某种程度上“较弱”。

于 2010-02-04T00:05:30.513 回答