IPhone OpenGLES Textures - Colors

I have a problem with openGL on the iPhone, which I am sure should have a simple solution!

When I load a texture and show it, I get a lot of what, in my opinion, is called “Color Rendering”, as a result of which the colors, especially on the gradients, seem automatically “optimized”.

Just to demonstrate that it wasn’t something wrong with my own code, I downloaded the iPhone Crashlanding app and replaced the background image, and, as you can see in the image below (taken from the simulator), the exact same thing happens. The image on the left is the original PNG, and on the right is the game. It is almost as if the palette was reduced to 256-color.

Screen shot

I am sure that this is due to the format in which I save the image, although this happens not only with PNG, but it seems to happen regardless of which image format I chose.

My head! If you want to recreate this, just download the collision loading app and replace the background. Thanks so much for any help.

+3
source share
2 answers

iPhone does not support 24-bit color format (8 bits per color) . It supports (uncompressed):

  • 565, red = 5 bits, green = 6 bits, blue = 5 bits
  • 5551 format, red = 5 bits, green = 5 bits, blue = 5 bits, alpha (transparency) - 1 bit
  • 4444, 4 bits for red / green / blue / transparent.

, 0 255 , 256 24- , 32 565/5551 16 4444 . 24- " ", , , .

.

/ OpenGL ES 1.0, 2.0/

: . iPhone (8888), , , ?

2: , cocos2d. ( ) . Cocos2d 565. , cocos2d, "" , .

+1

Cocos2d GLView. .

Cocos2d , AppDelegate.m. :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

:

CCGLView *glView = [CCGLView viewWithFrame:[_window bounds]
                               pixelFormat:kEAGLColorFormatRGB565
                               depthFormat:0
                        preserveBackbuffer:NO
                                sharegroup:nil
                             multiSampling:NO
                           numberOfSamples:0];

( Cocos2d. Mine is 2.1)

pixelFormat kEAGLColorFormatRGB565 (, , 5, 6 5 ) kEAGLColorFormatRGBA8 (, , - 8 ). , (16 24 ) , , .

0

Source: https://habr.com/ru/post/1745855/


All Articles