| 115 | } |
| 116 | |
| 117 | struct sth_stash* sth_create(int cachew, int cacheh, RenderCallbacks* renderCallbacks) |
| 118 | { |
| 119 | struct sth_stash* stash = NULL; |
| 120 | struct sth_texture* texture = NULL; |
| 121 | |
| 122 | // Allocate memory for the font stash. |
| 123 | stash = (struct sth_stash*)malloc(sizeof(struct sth_stash)); |
| 124 | if (stash == NULL) |
| 125 | { |
| 126 | assert(0); |
| 127 | return NULL; |
| 128 | } |
| 129 | memset(stash, 0, sizeof(struct sth_stash)); |
| 130 | |
| 131 | stash->m_renderCallbacks = renderCallbacks; |
| 132 | |
| 133 | // Allocate memory for the first texture |
| 134 | texture = (struct sth_texture*)malloc(sizeof(struct sth_texture)); |
| 135 | if (texture == NULL) |
| 136 | { |
| 137 | assert(0); |
| 138 | free(stash); |
| 139 | } |
| 140 | memset(texture, 0, sizeof(struct sth_texture)); |
| 141 | |
| 142 | // Create first texture for the cache. |
| 143 | stash->tw = cachew; |
| 144 | stash->th = cacheh; |
| 145 | stash->itw = 1.0f / cachew; |
| 146 | stash->ith = 1.0f / cacheh; |
| 147 | stash->textures = texture; |
| 148 | |
| 149 | stash->m_renderCallbacks->updateTexture(texture, 0, stash->tw, stash->th); |
| 150 | |
| 151 | return stash; |
| 152 | } |
| 153 | |
| 154 | int sth_add_font_from_memory(struct sth_stash* stash, unsigned char* buffer) |
| 155 | { |
no test coverage detected