Skip to content

Instantly share code, notes, and snippets.

@Jakz
Last active December 14, 2019 04:00
Show Gist options
  • Save Jakz/001b7d7a0ad4d01abbed347950746981 to your computer and use it in GitHub Desktop.
Save Jakz/001b7d7a0ad4d01abbed347950746981 to your computer and use it in GitHub Desktop.
SDL2 basic blitting
void init() // once
{
constexpr int WIDTH = XXX;
constexpr int HEIGHT = XXX;
SDL_Surface* _output = SDL_CreateRGBSurface(0, WIDTH, HEIGHT, 32, format->Rmask, format->Gmask, format->Bmask, format->Amask);
SDL_Texture* _outputTexture = SDL_CreateTexture(renderer, format->format, SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
}
void render()
{
SDL_RenderClear(renderer);
emulator.blitOnSurface(_output);
SDL_UpdateTexture(_outputTexture, nullptr, _output->pixels, _output->pitch);
SDL_RenderCopy(renderer, _outputTexture, nullptr, &dest);
SDL_RenderPresent(renderer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment