Start working on new architecture
This commit is contained in:
66
project/src/backend/sdl/SDLApplication.cpp
Normal file
66
project/src/backend/sdl/SDLApplication.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "SDLApplication.h"
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
SDLApplication::SDLApplication () {
|
||||
|
||||
SDL_Init (SDL_INIT_VIDEO);
|
||||
|
||||
}
|
||||
|
||||
|
||||
SDLApplication::~SDLApplication () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int SDLApplication::Exec () {
|
||||
|
||||
SDL_Event event;
|
||||
bool active = true;
|
||||
|
||||
while (active) {
|
||||
|
||||
while (active && SDL_WaitEvent (&event)) {
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
|
||||
active = false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (active && SDL_PollEvent (&event)) {
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE) {
|
||||
|
||||
active = false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SDL_Quit ();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Application* CreateApplication () {
|
||||
|
||||
return new SDLApplication ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
project/src/backend/sdl/SDLApplication.h
Normal file
27
project/src/backend/sdl/SDLApplication.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef LIME_SDL_APPLICATION_H
|
||||
#define LIME_SDL_APPLICATION_H
|
||||
|
||||
|
||||
#include <SDL.h>
|
||||
#include "Application.h"
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class SDLApplication : public Application {
|
||||
|
||||
public:
|
||||
|
||||
SDLApplication ();
|
||||
~SDLApplication ();
|
||||
|
||||
virtual int Exec ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
30
project/src/backend/sdl/SDLRenderer.cpp
Normal file
30
project/src/backend/sdl/SDLRenderer.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "SDLWindow.h"
|
||||
#include "SDLRenderer.h"
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
SDLRenderer::SDLRenderer (Window* window) {
|
||||
|
||||
currentWindow = window;
|
||||
sdlRenderer = SDL_CreateRenderer (((SDLWindow*)window)->sdlWindow, -1, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
SDLRenderer::~SDLRenderer () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Renderer* CreateRenderer (Window* window) {
|
||||
|
||||
return new SDLRenderer (window);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
project/src/backend/sdl/SDLRenderer.h
Normal file
27
project/src/backend/sdl/SDLRenderer.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef LIME_SDL_RENDERER_H
|
||||
#define LIME_SDL_RENDERER_H
|
||||
|
||||
|
||||
#include <SDL.h>
|
||||
#include "Renderer.h"
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class SDLRenderer : public Renderer {
|
||||
|
||||
public:
|
||||
|
||||
SDLRenderer (Window* window);
|
||||
~SDLRenderer ();
|
||||
|
||||
SDL_Renderer* sdlRenderer;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
30
project/src/backend/sdl/SDLWindow.cpp
Normal file
30
project/src/backend/sdl/SDLWindow.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "SDLWindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
SDLWindow::SDLWindow (Application* application) {
|
||||
|
||||
currentApplication = application;
|
||||
sdlWindow = SDL_CreateWindow ("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
SDLWindow::~SDLWindow () {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Window* CreateWindow (Application* application) {
|
||||
|
||||
return new SDLWindow (application);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
project/src/backend/sdl/SDLWindow.h
Normal file
27
project/src/backend/sdl/SDLWindow.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef LIME_SDL_WINDOW_H
|
||||
#define LIME_SDL_WINDOW_H
|
||||
|
||||
|
||||
#include <SDL.h>
|
||||
#include "Window.h"
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class SDLWindow : public Window {
|
||||
|
||||
public:
|
||||
|
||||
SDLWindow (Application* application);
|
||||
~SDLWindow ();
|
||||
|
||||
SDL_Window* sdlWindow;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user