Create a new texture, discard previous one
| 3941 | |
| 3942 | // Create a new texture, discard previous one |
| 3943 | ImTextureData* ImFontAtlasTextureAdd(ImFontAtlas* atlas, int w, int h) |
| 3944 | { |
| 3945 | ImTextureData* old_tex = atlas->TexData; |
| 3946 | ImTextureData* new_tex; |
| 3947 | |
| 3948 | // FIXME: Cannot reuse texture because old UV may have been used already (unless we remap UV). |
| 3949 | /*if (old_tex != NULL && old_tex->Status == ImTextureStatus_WantCreate) |
| 3950 | { |
| 3951 | // Reuse texture not yet used by backend. |
| 3952 | IM_ASSERT(old_tex->TexID == ImTextureID_Invalid && old_tex->BackendUserData == NULL); |
| 3953 | old_tex->DestroyPixels(); |
| 3954 | old_tex->Updates.clear(); |
| 3955 | new_tex = old_tex; |
| 3956 | old_tex = NULL; |
| 3957 | } |
| 3958 | else*/ |
| 3959 | { |
| 3960 | // Add new |
| 3961 | new_tex = IM_NEW(ImTextureData)(); |
| 3962 | new_tex->UniqueID = atlas->TexNextUniqueID++; |
| 3963 | atlas->TexList.push_back(new_tex); |
| 3964 | } |
| 3965 | if (old_tex != NULL) |
| 3966 | { |
| 3967 | // Queue old as to destroy next frame |
| 3968 | old_tex->WantDestroyNextFrame = true; |
| 3969 | IM_ASSERT(old_tex->Status == ImTextureStatus_OK || old_tex->Status == ImTextureStatus_WantCreate || old_tex->Status == ImTextureStatus_WantUpdates); |
| 3970 | } |
| 3971 | |
| 3972 | new_tex->Create(atlas->TexDesiredFormat, w, h); |
| 3973 | atlas->TexIsBuilt = false; |
| 3974 | |
| 3975 | ImFontAtlasBuildSetTexture(atlas, new_tex); |
| 3976 | |
| 3977 | return new_tex; |
| 3978 | } |
| 3979 | |
| 3980 | #if 0 |
| 3981 | #define STB_IMAGE_WRITE_IMPLEMENTATION |
no test coverage detected