// ----------------------------------------------------------------------------- // https://dataswamp.org/~incal/emacs-init/draw/new.c // ----------------------------------------------------------------------------- #include "new.h" #include #include /* ----------------------------------------------------------------------------- */ SDL_Renderer* new_renderer(SDL_Window* win) { SDL_Renderer* rend = SDL_GetRenderer(win); if (!rend) { printf("[renderer] error\n"); exit(1); } return rend; } SDL_Surface* new_screen(SDL_Window* win) { SDL_Surface* screen = SDL_GetWindowSurface(win); if (!screen) { printf("[screen] error\n"); exit(1); } return screen; } SDL_Surface* new_surface(int w, int h) { SDL_Surface* sur = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 0); if (!sur) { printf("[surface] error\n"); exit(1); } return sur; } SDL_Thread* new_thread(char* name, SDL_ThreadFunction fun) { SDL_Thread* thr = SDL_CreateThread(fun, name, NULL); if (!thr) { printf("[thread] error\n"); exit(1); } return thr; } SDL_Window* new_window(char* name, int w, int h) { int pos = SDL_WINDOWPOS_CENTERED; SDL_Window* win = SDL_CreateWindow(name, pos, pos, w, h, SDL_WINDOW_SHOWN); if (!win) { printf("[window] error\n"); exit(1); } return win; } SDL_mutex* new_mutex() { SDL_mutex* mtx = SDL_CreateMutex(); if (!mtx) { printf("[mutex] error\n"); exit(1); } return mtx; }