JOGL中PNG图像中的白色阴影

时间:2017-07-24 05:01:56

标签: opengl jogl

我正在使用JAVA(jogl)的OpenGL绑定,我正在尝试将png图像加载到我用Photoshop创建的圆圈中。这工作正常,但问题是当我在圆圈中呈现白色阴影时。任何人都可以帮助我,为什么这是因为?

我的代码在这里,

private static void drawCircleUsingPoly(float x, float y, float r, GL2 gl,String fileName){
    gl.glEnable(GL2.GL_TEXTURE_2D);
    File file = new File(System.getProperty("user.dir") + File.separator +"assets"+ File.separator + fileName);
    try {
        textureId = TextureIO.newTexture(file, true).getTextureObject(gl);
    } catch (GLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    gl.glBindTexture(GL2.GL_TEXTURE_2D, textureId);
    gl.glBegin(GL2.GL_POLYGON);
    for (float angle=0.0f; angle<360.0; angle+=2.0){
        float radian = angle * (3.1415926f/180.f);
        float xcos = (float)Math.cos(radian);
        float ysin = (float)Math.sin(radian);

        float vx = xcos * r + x;
        float vy = ysin * r + y;

        float tx = xcos * 0.5f + 0.5f;
        float ty = ysin * 0.5f + 0.5f;
        gl.glTexCoord2f(tx, ty);
        gl.glVertex2f(vx, vy);

    }
    gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA);
    gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE,GL2.GL_MODULATE);
    gl.glDepthMask(true);
    gl.glPopMatrix();
    gl.glEnd();
}

screen shot attaching here

0 个答案:

没有答案