Is it possible to render in RGB888 with OpenGL?

前端 未结 2 965
渐次进展
渐次进展 2020-12-25 09:08

I have played for a while with OpenGL on Android on various devices. And unless I\'m wrong, the default rendering is always performed with the RGB565 pixel format.

I

相关标签:
2条回答
  • 2020-12-25 09:32

    On newer devices, most of them should support RGBA8888 as a native format. One way to force RGBA color format is to set the translucency of the surface, you'd still want to pick the EGLConfig to best guess the config for the channels in addition to the depth and stencil buffers.

    setEGLConfigChooser(8, 8, 8, 8, 0, 0);
    getHolder().setFormat(PixelFormat.RGBA_8888); 
    

    However, if I read your question correctly you're asking for RGB888 support (alpha don't care) in other words, RGBX8888 which might not be supported by all devices (driver vendor limitation).

    Something to keep in mind about performance though, since RGBA8888 is the color format natively supported by most GPUs hardware it's best to avoid any other color format (non natively supported) since that usually translate into a color conversion underneath adding non necessary work load to the GPU.

    0 讨论(0)
  • 2020-12-25 09:36

    This is how I do it;

    {
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    // cocos2d will inherit these values
    [window setUserInteractionEnabled:YES]; 
    [window setMultipleTouchEnabled:NO];
    
    // must be called before any othe call to the director
    [Director useFastDirector];
    [[Director sharedDirector] setDisplayFPS:YES];
    
    // create an openGL view inside a window
    [[Director sharedDirector] attachInView:window];
    
    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
    // You can change anytime.
    [Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_];  
    
    glClearColor(0.7f,0.7f,0.6f,1.0f);
    //glClearColor(1.0f,1.0f,1.0f,1.0f);
    
    [window makeKeyAndVisible];
    
    [[Director sharedDirector] runWithScene:[GameLayer node]];
    

    }

    I hope that helps!

    0 讨论(0)
提交回复
热议问题