2022-10-29 00:22:23 -06:00
|
|
|
#ifdef ARC_SDL
|
|
|
|
|
#include "arc/graphics/window.h"
|
2022-10-29 16:08:41 -06:00
|
|
|
#include "arc/graphics/sdl/window.h"
|
2022-10-29 00:22:23 -06:00
|
|
|
|
2022-10-29 16:08:41 -06:00
|
|
|
#include <SDL.h>
|
|
|
|
|
#include "arc/std/errno.h"
|
2022-10-29 00:22:23 -06:00
|
|
|
|
2022-10-29 16:08:41 -06:00
|
|
|
void ARC_Window_Create(ARC_Window **window, ARC_WindowInfo *info){
|
|
|
|
|
if(!info){
|
2022-10-29 00:22:23 -06:00
|
|
|
arc_errno = ARC_ERRNO_NULL;
|
2022-10-29 16:08:41 -06:00
|
|
|
ARC_DEBUG_ERR("ARC_Window_Create(**window, NULL)");
|
2022-10-29 00:22:23 -06:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 01:15:33 -07:00
|
|
|
if(SDL_Init(SDL_INIT_VIDEO) < 0){
|
|
|
|
|
arc_errno = ARC_ERRNO_INIT;
|
|
|
|
|
printf("Error: initializing SDL\nSDL Error: %s\n", SDL_GetError());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-10 17:34:22 -07:00
|
|
|
*window = (ARC_Window *)SDL_CreateWindow((const char *)info->title, info->x, info->y, info->w, info->h, info->flags);
|
2022-10-29 00:22:23 -06:00
|
|
|
|
2023-03-10 17:34:22 -07:00
|
|
|
if(!*window){
|
2022-10-29 00:22:23 -06:00
|
|
|
arc_errno = ARC_ERRNO_NULL;
|
|
|
|
|
ARC_DEBUG_LOG(arc_errno, "SDL_CreateWindow(%s, %d, %d, %d, %d, %x);", info->title, info->x, info->y, info->w, info->h, info->flags);
|
2022-11-11 01:15:33 -07:00
|
|
|
free(window);
|
2022-10-29 00:22:23 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ARC_Window_Destroy(ARC_Window *window){
|
2023-03-10 17:34:22 -07:00
|
|
|
SDL_DestroyWindow((SDL_Window *) window);
|
2022-10-29 00:22:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif //ARC_SDL
|