39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#include "window.hpp"
|
|
|
|
// Variables
|
|
float main_scale;
|
|
SDL_Window* window;
|
|
SDL_Event event;
|
|
int window_width = 850; // Default window width
|
|
int window_height = 850; // Default window height
|
|
|
|
// Functions
|
|
int initialize_sdl() {
|
|
// Initialize SDL
|
|
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
|
std::cerr << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl;
|
|
return 1; // Initialization failed
|
|
}
|
|
|
|
main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
|
window = SDL_CreateWindow("Untitled", (int)(window_width * main_scale), (int)(window_height * main_scale), window_flags);
|
|
if (!window) {
|
|
std::cerr << "Window could not be created! SDL_Error: " << SDL_GetError() << std::endl;
|
|
SDL_Quit();
|
|
return 1; // Window creation failed
|
|
}
|
|
|
|
return 0; // Initialization successful
|
|
}
|
|
|
|
void cleanup_sdl() {
|
|
if (window) {
|
|
// Destroy window
|
|
SDL_DestroyWindow(window);
|
|
window = nullptr;
|
|
}
|
|
|
|
// Quit SDL
|
|
SDL_Quit();
|
|
std::cout << "SDL cleanup successful." << std::endl;
|
|
} |