나는 단순한 16x16 입자를 가지고있어서 불투명에서 투명으로 변합니다. 불행히도 내 아이폰 포트에 다른 나타납니다 및 코드의 차이점을 볼 수 없습니다. 대부분의 코드는 본질적으로 동일합니다.OpenGL ES/iPhone의 투명성/블렌딩 문제
가 나는 문제를
왼쪽에있는 입자가 잘못 렌더링 아이폰 버전이며 권리가 Mac과 Windows에 표시하는 방법입니다 보여 here에 이미지를 업로드했습니다. 그냥 간단한 RGBA .png 파일입니다.
나는 수많은 블렌드 함수와 glTexEnv 설정을 시도했지만 같은 것으로 보이지 않습니다.
그냥 철저하기는 아이폰에 내 텍스처 로딩 코드는 내가 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 인 사용 다음
GLuint TextureLoader::LoadTexture(const char *path)
{
NSString *macPath = [NSString stringWithCString:path length:strlen(path)];
GLuint texture = 0;
CGImageRef textureImage = [UIImage imageNamed:macPath].CGImage;
if (textureImage == nil)
{
NSLog(@"Failed to load texture image");
return 0;
}
NSInteger texWidth = CGImageGetWidth(textureImage);
NSInteger texHeight = CGImageGetHeight(textureImage);
GLubyte *textureData = new GLubyte[texWidth * texHeight * 4];
memset(textureData, 0, texWidth * texHeight * 4);
CGContextRef textureContext = CGBitmapContextCreate(textureData, texWidth, texHeight, 8, texWidth * 4, CGImageGetColorSpace(textureImage), kCGImageAlphaPremultipliedLast);
CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)texWidth, (float)texHeight), textureImage);
CGContextRelease(textureContext);
//Make a texture ID, bind it, create it
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
delete[] textureData;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
return texture;
}
블렌드 기능과 같습니다;
저는 사람들이 저에게 던져주는 아이디어를 시도 할 것입니다. 왜냐하면 이것은 저에게 신비로움을주기 때문입니다.
건배.
왼쪽 이미지가 시뮬레이터에서 렌더링 되었습니까, 아니면 실제 하드웨어에 있습니까? –