From c2aa9c0f3199dda62f7a2e6dc44c3c3700aeb180 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 30 Jun 2023 01:46:12 +0200 Subject: [PATCH] add sdl to project --- .gitmodules | 3 +++ gui/3rdparty/sdl | 1 + gui/CMakeLists.txt | 3 +++ gui/src/main.cpp | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 .gitmodules create mode 160000 gui/3rdparty/sdl diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5582402 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "gui/3rdparty/sdl"] + path = gui/3rdparty/sdl + url = git@github.com:libsdl-org/SDL.git diff --git a/gui/3rdparty/sdl b/gui/3rdparty/sdl new file mode 160000 index 0000000..675fc8c --- /dev/null +++ b/gui/3rdparty/sdl @@ -0,0 +1 @@ +Subproject commit 675fc8c38f3f5685d177f0ecf7f43d57a109992e diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index ffb63c2..64cc2d0 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -1,7 +1,10 @@ +add_subdirectory(3rdparty/sdl) + add_executable(netsim "src/main.cpp" ) target_link_libraries(netsim PRIVATE libnetsim + SDL3::SDL3 ) \ No newline at end of file diff --git a/gui/src/main.cpp b/gui/src/main.cpp index c364e37..a01c1f8 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -1,8 +1,16 @@ #include +#include #include "Netsim.hpp" int main(int argc, char** argv) { + SDL_Init(SDL_INIT_VIDEO); + + SDL_Window* window; + SDL_Renderer* renderer; + SDL_CreateWindowAndRenderer(1000, 1000, NULL, &window, &renderer); + SDL_SetWindowTitle(window, "netsim"); + Network network("Testnet"); network.addDevice(Device::create("FA:56:A7:12:04:ED")); @@ -10,5 +18,29 @@ int main(int argc, char** argv) { std::cout << network << std::endl; + bool shouldClose = false; + SDL_Event event; + + while (!shouldClose) { + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_EVENT_WINDOW_CLOSE_REQUESTED: + case SDL_EVENT_QUIT: + shouldClose = true; + break; + } + } + + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderClear(renderer); + + SDL_RenderPresent(renderer); + } + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + + SDL_Quit(); + return 0; } \ No newline at end of file