Add windows specific changes

This commit is contained in:
zvon 2020-09-12 13:09:20 +02:00
parent dc819016a6
commit 99c5c7fb9e
3 changed files with 22 additions and 0 deletions

View File

@ -1,6 +1,10 @@
#include "sdlpp.hpp" #include "sdlpp.hpp"
#ifdef _WIN32
#include "SDL2/SDL_image.h"
#else
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
#endif
#include <iostream> #include <iostream>
bool SDLPP::init() { bool SDLPP::init() {

View File

@ -2,9 +2,15 @@
#ifndef SDLPP_HPP #ifndef SDLPP_HPP
#define SDLPP_HPP #define SDLPP_HPP
#ifdef _WIN32
#include "SDL2/SDL.h"
#include "SDL2/SDL_image.h"
#include "SDL2/SDL_ttf.h"
#else
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h> #include <SDL2/SDL_ttf.h>
#endif // UNIX
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>

View File

@ -7,7 +7,14 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include <mutex> #include <mutex>
#ifdef _WIN32
#include "../SDL2/SDL2_framerate.h"
#include <ctime>
#include <string>
#include <windows.h>
#else
#include <SDL2/SDL2_framerate.h> #include <SDL2/SDL2_framerate.h>
#endif // UNIX
std::vector< std::shared_ptr< SDLPP::RenderObject > > line_coliders{}; std::vector< std::shared_ptr< SDLPP::RenderObject > > line_coliders{};
@ -35,7 +42,11 @@ void prepareShadowColider(std::shared_ptr<SDLPP::Renderer> r) {
g_shadow_colider->centerX(); g_shadow_colider->centerX();
} }
#ifdef _WIN32
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR szCmdLine, int nCmdShow) {
#else
int main() { int main() {
#endif
SDLPP::init(); SDLPP::init();
SDLPP::Window w( "Tetris clone!" ); SDLPP::Window w( "Tetris clone!" );
w.setResizable(true); w.setResizable(true);
@ -74,6 +85,7 @@ int main() {
g_input_functions.push_back(mainSceneInput); g_input_functions.push_back(mainSceneInput);
while ( !g_quit ) { while ( !g_quit ) {
SDL_PumpEvents();
SDL_framerateDelay( &gFPS ); SDL_framerateDelay( &gFPS );
if ( !g_cur_object && g_checked_line ) { if ( !g_cur_object && g_checked_line ) {
std::lock_guard< std::mutex > guard( g_movement_mutex ); std::lock_guard< std::mutex > guard( g_movement_mutex );