From 915c18b874c0fd4fab5da60e416ecf405512a8f7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 11 Nov 2022 19:41:28 +0000 Subject: Extract SDL_Application helper into libilt --- ui/applicationBase.cpp | 24 ++++++++++++++++++++++++ ui/applicationBase.h | 12 ++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 ui/applicationBase.cpp create mode 100644 ui/applicationBase.h (limited to 'ui') diff --git a/ui/applicationBase.cpp b/ui/applicationBase.cpp new file mode 100644 index 0000000..5c87359 --- /dev/null +++ b/ui/applicationBase.cpp @@ -0,0 +1,24 @@ +#include "applicationBase.h" +#include + +ApplicationBase::ApplicationBase() +{ + SDL_Init(SDL_INIT_EVERYTHING); + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5); +} + +ApplicationBase::~ApplicationBase() +{ + SDL_Quit(); +} diff --git a/ui/applicationBase.h b/ui/applicationBase.h new file mode 100644 index 0000000..57995ca --- /dev/null +++ b/ui/applicationBase.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +class ApplicationBase { +public: + ApplicationBase(); + virtual ~ApplicationBase(); + + NO_COPY(ApplicationBase); + NO_MOVE(ApplicationBase); +}; -- cgit v1.2.3