-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
74 lines (63 loc) · 2.07 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_net.h>
#include <SDL_image.h>
#include <thread>
#include <string>
#include "System.hpp"
#include "Textures.hpp"
#include "Logging.hpp"
#include "DisplaySettings.hpp"
#include "Display.hpp"
/// @brief entry point
/// @return 0 upon success, other status on failure
int main() {
// Initialize the SDL and logging subsystems
auto system = BaumNetwork::System();
system.init();
globalLogger->log(std::string("Version info:\n" + BaumNetwork::System::getSdlVersions()),
BaumNetwork::LogSeverity::DEBUG);
// Load the settings
BaumNetwork::DisplaySettings ds;
if (!ds.loadSettings("/home/mbaum/forever_land/assets/DisplaySettings.json")) {
globalLogger->log(std::string("Could not load display settings"),
BaumNetwork::LogSeverity::ERROR);
return -1;
}
// Create the display
auto display = new BaumNetwork::Display(std::string("Demo"), ds.getSettings());
display->initDisplay();
auto renderer = display->getRenderer();
globalLogger->log(std::string("Done with subsystem setup"), BaumNetwork::LogSeverity::DEBUG);
/////////////////////////
/// Debug code starts ///
/////////////////////////
// Load test image
SDL_Texture * texture = BaumNetwork::Textures::loadImageFromFile(renderer,
"/home/mbaum/forever_land/assets/image.png");
//Event handler
SDL_Event e;
//While application is running
bool quit{false};
while( !quit ) {
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 ) {
//User requests quit
if( e.type == SDL_QUIT ) {
quit = true;
}
}
//Clear screen
SDL_RenderClear(renderer);
//Render texture to screen
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
//Update screen
SDL_RenderPresent(renderer);
}
/////////////////////////
/// Debug code ends ///
/////////////////////////
delete display;
system.shutdown();
return 0;
}