我正在尝试使用 OpenGL ES 和 GLKit 绘制这样的东西
但我得到了这个
虽然纹理是透明的,但模型的上层替换了下面的纹理而不是混合。有可能以某种方式修复它吗?
- (void)setup {
self.effect = [[GLKBaseEffect alloc] init];
NSURL *textureURL = [[NSBundle mainBundle] URLForResource:@"portalTexture_ALIENS" withExtension:@"png"];
texture = [GLKTextureLoader textureWithContentsOfURL:textureURL options:nil error:nil];
if (texture != nil) {
self.effect.texture2d0.enabled = GL_TRUE;
self.effect.texture2d0.envMode = GLKTextureEnvModeReplace;
self.effect.texture2d0.target = GLKTextureTarget2D;
self.effect.texture2d0.name = texture.name;
}
glEnableVertexAttribArray(GLKVertexAttribPosition);
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 0, texturedPortalVerts);
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 0, texturedPortalTexCoords);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- (void)draw {
[self.effect prepareToDraw];
glDrawArrays(GL_TRIANGLES, 0, texturedPortalNumVerts);
}
谢谢你。