* Load an image from disk. */
| 48 | * Load an image from disk. |
| 49 | */ |
| 50 | bool LoadTexture(Texture &texture) |
| 51 | { |
| 52 | // Load the texture with stb_image (require 4 component RGBA) |
| 53 | texture.pixels = stbi_load(texture.filepath.c_str(), &texture.width, &texture.height, &texture.stride, STBI_rgb_alpha); |
| 54 | texture.stride = 4; |
| 55 | if (!texture.pixels) |
| 56 | { |
| 57 | std::string msg = "Error: failed to load texture: \'"; |
| 58 | msg.append(texture.name); |
| 59 | msg.append("\'"); |
| 60 | MessageBox(NULL, msg.c_str(), "Error", MB_OK); |
| 61 | return false; |
| 62 | } |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Release texture memory. |
no outgoing calls
no test coverage detected