iOS: playing a frame-by-frame greyscale animation in a custom colour

前端 未结 2 854
生来不讨喜
生来不讨喜 2021-01-16 04:56

I have a 32 frame greyscale animation of a diamond exploding into pieces (ie 32 PNG images @ 1024x1024)

my game consists of 12 separate colours, so I need to perfor

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-16 05:39

    If something higher performance than (B) is needed, it looks like the key is glTexSubImage2D http://www.opengl.org/sdk/docs/man/xhtml/glTexSubImage2D.xml

    Rather than pull across one frame at a time from memory, we could arrange say 16 512x512x8-bit greyscale frames contiguously in memory, send this across to GL as a single 1024x1024x32bit RGBA texture, and then split it within GL using the above function.

    This would mean that we are performing one [RAM->VRAM] transfer per 16 frames rather than per one frame.

    Of course, for more modern devices we could get 64 instead of 16, since more recent iOS devices can handle 2048x2048 textures.

    I will first try technique (B) and leave it at that if it works ( I don't want to over code ), and look at this if needed.

    I still can't find any way to query how many GL textures it is possible to hold on the graphics chip. I have been told that when you try to allocate memory for a texture, GL just returns 0 when it has run out of memory. however to implement this properly I would want to make sure that I am not sailing close to the wind re: resources... I don't want my animation to use up so much VRAM that the rest of my rendering fails...

提交回复
热议问题