add sdl to project

This commit is contained in:
Robert 2023-06-30 01:46:12 +02:00
parent 8f840ff1fe
commit c2aa9c0f31
4 changed files with 39 additions and 0 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "gui/3rdparty/sdl"]
path = gui/3rdparty/sdl
url = git@github.com:libsdl-org/SDL.git

1
gui/3rdparty/sdl vendored Submodule

@ -0,0 +1 @@
Subproject commit 675fc8c38f3f5685d177f0ecf7f43d57a109992e

View file

@ -1,7 +1,10 @@
add_subdirectory(3rdparty/sdl)
add_executable(netsim
"src/main.cpp"
)
target_link_libraries(netsim PRIVATE
libnetsim
SDL3::SDL3
)

View file

@ -1,8 +1,16 @@
#include <iostream>
#include <SDL.h>
#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;
}