Files
WickedEngine/Tests/main_SDL2.cpp
T
Matteo De Carlo 3cd9e77889 WIP: Initial linux support using SDL (#136)
* Initial linux support using SDL

* fixed link error and gitignore

* fix in working directory initialization (windows side)

* Added README_Linux and fixed a few compilation issues in ubuntu

* Rename main to main_Windows in Tests

* Better default renderering backend selector

* Added backlog terminal output on linux

* added asserts on all missing vulkan function call results

* added portable file dialogs

also small tests update and cleanup

* Added Editor compile target

* linux ci

* linux ci

* cmake update

* cmake update?

* cmake

* Editor_Windows fix

* build test

* make

* build tools?

* update

* ubuntu 20.04

* fix?

* cmake

* build

* build?

* package linux build

* updates, bump version

* backslash to forward slash, eof newlines, add portable-file-dialogs license

* xcopy needs backslash duh; update readme;

* copy fix

* updated readme

* readme update

* updated readme

* updated readme

* fix incorrect file encoding linux

* paint tool fix

* linux: add missing shaders

* packaging update

Co-authored-by: Turánszki János <turanszkij@users.noreply.github.com>
Co-authored-by: Turanszki Janos <turanszkij@gmail.com>
2020-10-05 00:03:22 +02:00

79 lines
1.9 KiB
C++

// WickedEngineTests.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <SDL2/SDL.h>
#include "sdl2.h"
int sdl_loop(Tests &tests)
{
SDL_Event event;
bool quit = false;
while (!quit)
{
SDL_PumpEvents();
tests.Run();
// int ret = SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
int ret = SDL_PollEvent(&event);
if (ret < 0) {
std::cerr << "Error Peeping event: " << SDL_GetError() << std::endl;
std::cerr << "Exiting now" << std::endl;
return -1;
}
if (ret > 0) {
if (event.type == SDL_WINDOWEVENT) {
switch (event.window.event) {
case SDL_WINDOWEVENT_CLOSE: // exit game
//tests.Quit();
quit = true;
default:
break;
}
}
// else if (event.type == SDL_KEYDOWN) {
// switch (event.key.keysym.scancode) {
// case SDL_SCANCODE_SPACE:
// tests.SetSelected(tests.GetSelected()+1);
// }
// }
}
}
return 0;
}
int main(int argc, char *argv[])
{
Tests tests;
// TODO: Place code here.
wiStartupArguments::Parse(argc, argv);
sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
if (!system) {
throw sdl2::SDLError("Error creating SDL2 system");
}
sdl2::window_ptr_t window = sdl2::make_window(
"Wicked Engine Tests",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
1280, 800,
SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN);
if (!window) {
throw sdl2::SDLError("Error creating window");
}
tests.SetWindow(window.get());
int ret = sdl_loop(tests);
SDL_Quit();
return ret;
}