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

Function loadFont

deps/SDL2/Xcode-iOS/Demos/src/keyboard.c:163–196  ·  view source on GitHub ↗

this function loads our font into an SDL_Texture and returns the SDL_Texture */

Source from the content-addressed store, hash-verified

161
162/* this function loads our font into an SDL_Texture and returns the SDL_Texture */
163SDL_Texture*
164loadFont(void)
165{
166 SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
167
168 if (!surface) {
169 printf("Error loading bitmap: %s\n", SDL_GetError());
170 return 0;
171 } else {
172 /* set the transparent color for the bitmap font (hot pink) */
173 SDL_SetColorKey(surface, 1, SDL_MapRGB(surface->format, 238, 0, 252));
174 /* now we convert the surface to our desired pixel format */
175 int format = SDL_PIXELFORMAT_ABGR8888; /* desired texture format */
176 Uint32 Rmask, Gmask, Bmask, Amask; /* masks for desired format */
177 int bpp; /* bits per pixel for desired format */
178 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask,
179 &Amask);
180 SDL_Surface *converted =
181 SDL_CreateRGBSurface(0, surface->w, surface->h, bpp, Rmask, Gmask,
182 Bmask, Amask);
183 SDL_BlitSurface(surface, NULL, converted, NULL);
184 /* create our texture */
185 texture = SDL_CreateTextureFromSurface(renderer, converted);
186 if (texture == 0) {
187 printf("texture creation failed: %s\n", SDL_GetError());
188 } else {
189 /* set blend mode for our texture */
190 SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
191 }
192 SDL_FreeSurface(surface);
193 SDL_FreeSurface(converted);
194 return texture;
195 }
196}
197
198void
199draw()

Callers 1

mainFunction · 0.85

Calls 7

SDL_GetErrorFunction · 0.85
SDL_SetColorKeyFunction · 0.85
SDL_MapRGBFunction · 0.85
SDL_CreateRGBSurfaceFunction · 0.85
SDL_SetTextureBlendModeFunction · 0.85
SDL_FreeSurfaceFunction · 0.85

Tested by

no test coverage detected