feat(network): add and initialize SDL_net lib
This commit is contained in:
parent
a9a0393066
commit
7e4dc00d71
@ -5,6 +5,7 @@ set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
find_package(SDL3 CONFIG REQUIRED)
|
||||
find_package(SDL3_net REQUIRED)
|
||||
|
||||
set(IMGUI_DIR "thirdparty/imgui")
|
||||
set(BINDINGS_DIR "thirdparty/dear_bindings")
|
||||
@ -42,7 +43,9 @@ add_executable(tibia
|
||||
bitmap.c
|
||||
bitmap.h
|
||||
objects.c
|
||||
objects.h)
|
||||
objects.h
|
||||
network.c
|
||||
network.h)
|
||||
|
||||
target_include_directories(tibia PRIVATE
|
||||
${IMGUI_DIR}
|
||||
@ -50,4 +53,4 @@ target_include_directories(tibia PRIVATE
|
||||
${BINDINGS_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(tibia SDL3::SDL3)
|
||||
target_link_libraries(tibia SDL3::SDL3 SDL3_net::SDL3_net)
|
||||
|
||||
6
app.c
6
app.c
@ -3,6 +3,7 @@
|
||||
#include "render.h"
|
||||
#include "input.h"
|
||||
#include "gui.h"
|
||||
#include "network.h"
|
||||
|
||||
void App_Init(App_t *app) {
|
||||
app->isRunning = false;
|
||||
@ -33,6 +34,10 @@ void App_Init(App_t *app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Network_Init()) {
|
||||
return;
|
||||
}
|
||||
|
||||
app->isRunning = true;
|
||||
}
|
||||
|
||||
@ -44,6 +49,7 @@ void App_Run(App_t *app) {
|
||||
}
|
||||
|
||||
void App_Shutdown(const App_t* app) {
|
||||
Network_Shutdown();
|
||||
Objects_Destroy(&app->graphics);
|
||||
Map_Destroy(&app->map);
|
||||
Bitmap_Destroy(&app->bitmap);
|
||||
|
||||
21
network.c
Normal file
21
network.c
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// Created by rov on 12/27/25.
|
||||
//
|
||||
|
||||
#include "network.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_net/SDL_net.h>
|
||||
|
||||
bool Network_Init() {
|
||||
if (!NET_Init()) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Failed to initialize SDL_net.", NULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Network_Shutdown() {
|
||||
NET_Quit();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user