2011-12-16 7 views
0

私はAppleのGLKitの手でOpenGLを起動しています。スプライトを正しく表示するためにいくつかの問題があります。問題は、すべてが細い暗い線で囲まれていることです。下のスクリーンショットは、透明(明らかに)を含むpngイメージテクスチャを持つ2つの長方形を示しています。私のスプライトは、テクスチャを囲む暗い影/線/枠を持っているのはなぜですか?

enter image description here

それらを囲む黒い影が、間違いなくPNG画像の一部ではありません。緑色の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); 
    } 
} 

任意のアイデア誰ですか?ありがとうございました。

答えて

-3

stackoverflowersに来て、14時間無回答;-)。 gamedevでダビデにthis great answerを与えるのに14分かかった。彼に投票してください!

1

これが私の仕事:

glEnable(GLES20.GL_BLEND); 
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 
+0

を、これはgamedevに答えたものである(下記参照します) –

関連する問題