MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / initializeTexture

Function initializeTexture

deps/SDL2/Xcode-iOS/Demos/src/happy.c:105–127  ·  view source on GitHub ↗

loads the happyface graphic into a texture */

Source from the content-addressed store, hash-verified

103 loads the happyface graphic into a texture
104*/
105void
106initializeTexture(SDL_Renderer *renderer)
107{
108 SDL_Surface *bmp_surface;
109 /* load the bmp */
110 bmp_surface = SDL_LoadBMP("icon.bmp");
111 if (bmp_surface == NULL) {
112 fatalError("could not load bmp");
113 }
114 /* set white to transparent on the happyface */
115 SDL_SetColorKey(bmp_surface, 1,
116 SDL_MapRGB(bmp_surface->format, 255, 255, 255));
117
118 /* convert RGBA surface to texture */
119 texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
120 if (texture == 0) {
121 fatalError("could not create texture");
122 }
123 SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
124
125 /* free up allocated memory */
126 SDL_FreeSurface(bmp_surface);
127}
128
129int
130main(int argc, char *argv[])

Callers 1

mainFunction · 0.70

Calls 6

fatalErrorFunction · 0.85
SDL_SetColorKeyFunction · 0.85
SDL_MapRGBFunction · 0.85
SDL_SetTextureBlendModeFunction · 0.85
SDL_FreeSurfaceFunction · 0.85

Tested by

no test coverage detected