0

AppleのGLKitハンドでOpenGLを開始していますが、スプライトを正しく表示するのに問題があります。問題は、それらがすべて細い暗い線で囲まれていることです。以下のスクリーンショットは、透明度を含むpng画像テクスチャを持つ2つの長方形を示しています(明らかに)。

ここに画像の説明を入力してください

それらを囲む黒い影は、間違いなくpngSの一部ではありません。緑のpngはアンチエイリアスなしで実行され、青のpngにはアンチエイリアスの境界線があります。スプライトを1つだけ描画すると、黒い境界線もはっきりとわかります。

コードの関連部分(そう願っています...)は次のとおりです。

//render the scene
-(void)render
{
    glClearColor(69./255., 115./255., 213./255., 1.);
    glClear(GL_COLOR_BUFFER_BIT);
    [shapes enumerateObjectsUsingBlock:^(AAAShape *shape, NSUInteger idx, BOOL *stop)   
     {
         [shape renderInScene:self];
     }];
}

//creating and storing the effect inside shape class
-(GLKBaseEffect *)effect
{
    if(!effect)
    {
        effect = [[GLKBaseEffect alloc] init];
    } 
    return effect;
}

//rendering the shape (including effect configuration)   
-(void)renderInScene:(AAAScene *)scene 
{
    //TODO: Storing vertices in Buffer
    self.effect.transform.projectionMatrix = scene.projectionMatrix; 
    self.effect.transform.modelviewMatrix = self.objectMatrix; 
    if(texture)
    {
        self.effect.texture2d0.enabled = GL_TRUE;
        self.effect.texture2d0.envMode = GLKTextureEnvModeReplace;
        self.effect.texture2d0.target = GLKTextureTarget2D;
        self.effect.texture2d0.name = texture.name;
    }
    [self.effect prepareToDraw];

    if(texture)
    {
        glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
        glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, self.textureCoordinates);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }

    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, 0, self.vertices);
    glDrawArrays(GL_TRIANGLE_FAN, 0, self.vertexCount);
    glDisableVertexAttribArray(GLKVertexAttribPosition);

    if(texture)
    {
        glDisableVertexAttribArray(GLKVertexAttribTexCoord0);
        glDisable(GL_BLEND);
    }
}

誰かアイデアはありますか?ありがとうございました。

4

2 に答える 2

1

これは私のために働いた:

glEnable( GLES20.GL_BLEND );
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
于 2013-12-31T05:56:41.393 に答える
-3

stackoverflowers に来てください、14 時間、答えはありません ;-)。gamedev では、David がこのすばらしい答えを出すのに 14 分かかりました。彼に投票してください!

于 2011-12-16T23:22:19.073 に答える