added namespaces

This commit is contained in:
Bob Polis 2020-10-23 13:55:57 +02:00
parent 3de586a516
commit c6e6333f9a
6 changed files with 49 additions and 31 deletions

View File

@ -10,6 +10,8 @@
#include <stdexcept> #include <stdexcept>
#include "SDLImageWrapper.hpp" #include "SDLImageWrapper.hpp"
using namespace sc::gui;
SDLImageWrapper::SDLImageWrapper() { SDLImageWrapper::SDLImageWrapper() {
int flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF; int flags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF;
int result = IMG_Init(flags); int result = IMG_Init(flags);

View File

@ -9,6 +9,8 @@
#ifndef __SDLIMAGEWRAPPER_H_ #ifndef __SDLIMAGEWRAPPER_H_
#define __SDLIMAGEWRAPPER_H_ #define __SDLIMAGEWRAPPER_H_
namespace sc {
namespace gui {
struct SDLImageWrapper { struct SDLImageWrapper {
SDLImageWrapper(); SDLImageWrapper();
~SDLImageWrapper(); ~SDLImageWrapper();
@ -19,5 +21,7 @@ struct SDLImageWrapper {
SDLImageWrapper(SDLImageWrapper&&) = delete; SDLImageWrapper(SDLImageWrapper&&) = delete;
SDLImageWrapper& operator=(SDLImageWrapper&&) = delete; SDLImageWrapper& operator=(SDLImageWrapper&&) = delete;
}; };
}
}
#endif // __SDLIMAGEWRAPPER_H_ #endif // __SDLIMAGEWRAPPER_H_

View File

@ -9,6 +9,8 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "SDLWrapper.hpp" #include "SDLWrapper.hpp"
using namespace sc::gui;
SDLWrapper::SDLWrapper() { SDLWrapper::SDLWrapper() {
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
} }

View File

@ -9,6 +9,8 @@
#ifndef __SDLWRAPPER_H_ #ifndef __SDLWRAPPER_H_
#define __SDLWRAPPER_H_ #define __SDLWRAPPER_H_
namespace sc {
namespace gui {
struct SDLWrapper { struct SDLWrapper {
SDLWrapper(); SDLWrapper();
~SDLWrapper(); ~SDLWrapper();
@ -19,5 +21,7 @@ struct SDLWrapper {
SDLWrapper(SDLWrapper&&) = delete; SDLWrapper(SDLWrapper&&) = delete;
SDLWrapper& operator=(SDLWrapper&&) = delete; SDLWrapper& operator=(SDLWrapper&&) = delete;
}; };
}
}
#endif // __SDLWRAPPER_H_ #endif // __SDLWRAPPER_H_

View File

@ -10,6 +10,8 @@
#include <cmath> #include <cmath>
#include "Window.hpp" #include "Window.hpp"
using namespace sc::gui;
Window::Window(const char* title) : _path {title} { Window::Window(const char* title) : _path {title} {
SDL_Window* win = SDL_CreateWindow(title, SDL_Window* win = SDL_CreateWindow(title,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,

View File

@ -14,6 +14,8 @@
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
namespace sc {
namespace gui {
class Window { class Window {
public: public:
Window(const char* title); Window(const char* title);
@ -30,5 +32,7 @@ class Window {
std::unique_ptr<SDL_Renderer, void(*)(SDL_Renderer*)> _r {nullptr, SDL_DestroyRenderer}; std::unique_ptr<SDL_Renderer, void(*)(SDL_Renderer*)> _r {nullptr, SDL_DestroyRenderer};
std::unique_ptr<SDL_Texture, void(*)(SDL_Texture*)> _t {nullptr, SDL_DestroyTexture}; std::unique_ptr<SDL_Texture, void(*)(SDL_Texture*)> _t {nullptr, SDL_DestroyTexture};
}; };
}
}
#endif // __WINDOW_H_ #endif // __WINDOW_H_