AntonioCS / pong_clone

A (very basic) clone of the classic game of pong in C with SDL2
GNU Lesser General Public License v3.0
1 stars 0 forks source link

Font reuse texture when text did not change #11

Closed AntonioCS closed 8 years ago

AntonioCS commented 8 years ago

When I call the function write from the GameEngine_Font struct I will always create a texture from the text that is set. This always happens even if there have been no changes in the text.

So I propose to change this by storing (in memory only) the generated texture and when the write method gets called it will check if the text is different from the one given for the texture.

This could possibly be implemented as a hash map and could even be a static variable so it could be reused by other fonts (if they have the same font and size of course)

AntonioCS commented 8 years ago

Done in https://github.com/AntonioCS/pong_clone/commit/a4753365e0945acb4d56c2b33d32d9480066be3f