50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <SDL2/SDL.h>
|
|
#include "include/logger.h"
|
|
|
|
int main() {
|
|
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
|
|
Logger::error("Cannot initialize SDL:", SDL_GetError());
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
SDL_Window* window = SDL_CreateWindow("Chip8 Emulator", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1024, 512, SDL_WINDOW_SHOWN);
|
|
|
|
if (window == nullptr) {
|
|
Logger::error("Cannot create SDL window:", SDL_GetError());
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
|
|
|
if (renderer == nullptr) {
|
|
Logger::error("Cannot create SDL renderer:", SDL_GetError());
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
bool run = true;
|
|
SDL_Event e;
|
|
|
|
while (run) {
|
|
while (SDL_PollEvent(&e) != 0) {
|
|
if (e.type == SDL_QUIT) {
|
|
run = false;
|
|
}
|
|
else if (e.type == SDL_KEYDOWN) {
|
|
if (e.key.keysym.sym == SDLK_ESCAPE) {
|
|
run = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
|
SDL_RenderClear(renderer);
|
|
SDL_RenderPresent(renderer);
|
|
}
|
|
|
|
SDL_DestroyRenderer(renderer);
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
return 0;
|
|
}
|