
2D游戲動画幀, 由多幅關鍵幀(keyFrame) 組成. 逐幀渲染產生動画卡通.『幀動画』亦哎呌『紋理』texture. 将多幅『幀動画』存放係單壹紋理.OpenGL可提高渲染速度, 係显存記憶體1MB年代可能冇用. 事因渲染皆係電脑記憶體運作.
係显存記憶體大幅增長, OpenGL渲染係显存記憶體完成. 减小『紋理』載入量, 單壹紋理存放多幅『幀動画』,可提高渲染速度.
係3D游戲亦可用相同技術提飛渲染效率.
| void zoom_textcoord_model3D(TEXTURE_PTR texture,int index,int size,VECTOR2D_PTR dest,VECTOR2D_PTR sour,int count,int flag) |
| texture | 紋理 |
| index | 關鍵幀索引 |
| size | 關鍵幀寬高解像 |
| dest | 纹理隊列 |
| sour | 原始纹理隊列 |
| count | 纹理頂點量 |
計單元格
| int cell = texture->width / size; |
計索引
| int i = index % cell;// 橫索引 |
| int j = index / cell;// 行索引 |
計缩放率0.0f < zoom < 1.0f
| float zoom = (float)size / (float)texture->width; |
計『幀』偏移.
| float offsetX = (float)zoom * (float)i; |
| float offsetY = (float)zoom * (float)j; |
遍歴UV紋理頂㸃
| for (int p = 0; p < count; ++p){ |
缩細後移動
| dest[p].u = sour[p].u * zoom + offsetX ; |
| dest[p].v = sour[p].v * zoom + offsetY; |
纹理返转
| if (flag & MODEL3D_TEXTURE_FLIP)
dest[p].v = 1 – (sour[p].v * zoom + offsetY);} |
