1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| SDL_Texture* transforme_image_TGA_24_en_texture_SDL (image I, GLOBAL G)
{
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
SDL_Surface* S = SDL_CreateRGBSurfaceFrom ((void*) I->pixel,
I->w,
I->h,
32,
I->w * sizeof(Uint32),
rmask,
gmask,
bmask,
amask);
SDL_Texture* T = SDL_CreateTextureFromSurface(G->R, S);
return T;
}
void copie_une_texture_sur_un_renderer (GLOBAL G, image I, SDL_Texture* T, int src_x, int src_y, int src_w, int src_h,
int dst_x, int dst_y, int dst_w, int dst_h )
{
SDL_UpdateTexture(T, NULL, (void*) I->pixel, I->w * sizeof (Uint32));
/*SDL_Rect src = {src_x, src_y, src_w, src_h}; */
SDL_Rect dst = {dst_x, dst_y, dst_w, dst_h};
SDL_RenderCopy (G->R, T, /*&src*/NULL, &dst);
}
void affiche_a_l_ecran (GLOBAL G)
{
SDL_RenderPresent(G->R);
} |
Partager