Home Game Development sdl2 – Creating texture and palette modification

sdl2 – Creating texture and palette modification

0
sdl2 – Creating texture and palette modification

[ad_1]

I must create a texture from a floor with listed colour palette and alter the colours. However, after I set new colours, the rendered texture will get clean.

int primary(int argc, char** argv)
{
    init();

    gSurface = TTF_RenderText_Solid(gFont, "textual content", fg1);

    // textual content is rendered correctly, with out following line
    SDL_SetPaletteColors(gSurface->format->palette, &fg2, 1, 1);

    gTexture = SDL_CreateTextureFromSurface(gRenderer, gSurface);

    SDL_SetRenderDrawColor(gRenderer, 255, 255, 255, 255);
    SDL_RenderClear(gRenderer);

    SDL_RenderCopy(gRenderer, gTexture, NULL, NULL);
    SDL_RenderPresent(gRenderer);

    SDL_Delay(1000);

    give up();
}

I examined this code with software program rendering utilizing window floor as a substitute of renderer and pallete altering labored.
Could somebody clarify me why does it happed and the right way to repair it?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here