#include #include "config.h" static SDL_Window *window; static SDL_Renderer *renderer; static SDL_Texture *texture; void initWindow(){ if (SDL_Init(SDL_INIT_VIDEO)){ printf("Could not init SDL: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } atexit(SDL_Quit); window = SDL_CreateWindow("LS7 Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if (window == NULL){ printf("Fatal! Could not create SDL Window: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } renderer = SDL_CreateRenderer(window, -1, 2); if (renderer == NULL){ printf("Fatal! Could not create SDL Renderer: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_WIDTH, SCREEN_HEIGHT); if (texture == NULL){ printf("Fatal! Could not create SDL Texture: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } if (SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE)){ printf("Fatal! Could not set SDL blend mode: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } } void clearScreen(uint32_t pixels[], uint32_t color){ for (uint32_t i = 0; i < SDL_X_SIZE * SDL_Y_SIZE; i++) pixels[i] = color; }