| 3115 | static SDL_Texture *SDLTest_CharTextureCache[256]; |
| 3116 | |
| 3117 | int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c) |
| 3118 | { |
| 3119 | const Uint32 charWidth = FONT_CHARACTER_SIZE; |
| 3120 | const Uint32 charHeight = FONT_CHARACTER_SIZE; |
| 3121 | const Uint32 charSize = FONT_CHARACTER_SIZE; |
| 3122 | SDL_Rect srect; |
| 3123 | SDL_Rect drect; |
| 3124 | int result; |
| 3125 | Uint32 ix, iy; |
| 3126 | const unsigned char *charpos; |
| 3127 | Uint8 *curpos; |
| 3128 | Uint8 patt, mask; |
| 3129 | Uint8 *linepos; |
| 3130 | Uint32 pitch; |
| 3131 | SDL_Surface *character; |
| 3132 | Uint32 ci; |
| 3133 | Uint8 r, g, b, a; |
| 3134 | |
| 3135 | /* |
| 3136 | * Setup source rectangle |
| 3137 | */ |
| 3138 | srect.x = 0; |
| 3139 | srect.y = 0; |
| 3140 | srect.w = charWidth; |
| 3141 | srect.h = charHeight; |
| 3142 | |
| 3143 | /* |
| 3144 | * Setup destination rectangle |
| 3145 | */ |
| 3146 | drect.x = x; |
| 3147 | drect.y = y; |
| 3148 | drect.w = charWidth; |
| 3149 | drect.h = charHeight; |
| 3150 | |
| 3151 | /* Character index in cache */ |
| 3152 | ci = (unsigned char)c; |
| 3153 | |
| 3154 | /* |
| 3155 | * Create new charWidth x charHeight bitmap surface if not already present. |
| 3156 | */ |
| 3157 | if (SDLTest_CharTextureCache[ci] == NULL) { |
| 3158 | /* |
| 3159 | * Redraw character into surface |
| 3160 | */ |
| 3161 | character = SDL_CreateRGBSurface(SDL_SWSURFACE, |
| 3162 | charWidth, charHeight, 32, |
| 3163 | 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); |
| 3164 | if (character == NULL) { |
| 3165 | return (-1); |
| 3166 | } |
| 3167 | |
| 3168 | charpos = SDLTest_FontData + ci * charSize; |
| 3169 | linepos = (Uint8 *)character->pixels; |
| 3170 | pitch = character->pitch; |
| 3171 | |
| 3172 | /* |
| 3173 | * Drawing loop |
| 3174 | */ |
no test coverage detected