Last active
December 14, 2019 04:00
-
-
Save Jakz/001b7d7a0ad4d01abbed347950746981 to your computer and use it in GitHub Desktop.
SDL2 basic blitting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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