sdl update

This commit is contained in:
Timerix22 2024-02-22 02:40:28 +06:00
parent 713c80a93d
commit 14c677a0f5
7 changed files with 37 additions and 19 deletions

View File

@ -5,7 +5,7 @@
default: build_exec_dbg
# creates executable using profile info generated by profile
build_exec: rebuild_all # profile
build_exec: # profile
@cbuild/call_task.sh build_exec 2>&1 | tee -a make_raw.log
# creates executable with debug info and no optimizations

View File

@ -8,17 +8,23 @@ GUI is based on [Dear ImGui](https://github.com/ocornut/imgui) and [SDL](https:/
```shell
git clone --recurse-submodules https://github.com/Timerix22/GraphC
```
2. Install **SDL2** from package manager or compile it from source
```shell
cd SDL2
./configute
make -j [number of cpu cores]
make install
# on windows
mkdir ../libs
cp ./build/.libs/*.dll ../libs/
```
If it didn't work, read [SDL docs](SDL2/docs/README.md) and [INSTALL.txt](SDL2/INSTALL.txt)).
2. Install **SDL2** from package manager or compile it from source.
**If you are using msys, switch to mingw64 shell.**
```shell
cd dependencies/SDL2
./configure
make -j [number of cpu threads]
```
Then you can install it systemwide:
```shell
make install
```
or copy to ./libs:
```shell
mkdir -p ../../libs
cp ./build/.libs/SDL2.dll ../../libs/
```
If it didn't work, read [SDL docs](dependencies/SDL2/docs/README.md) and [INSTALL.txt](dependencies/SDL2/INSTALL.txt).
3. Compile the program
```shell

View File

@ -40,12 +40,12 @@ case "$OS" in
WINDOWS)
EXEC_FILE="$PROJECT.exe"
INCLUDE="-I./dependencies/imgui -I./dependencies/SDL2/include"
LINKER_LIBS="-L./$OBJDIR/libs/ -lSDL2 -lopengl32 -lpthread -lws2_32"
LINKER_LIBS="-L./libs/ -l:SDL2.dll -lopengl32 -lpthread -lws2_32"
;;
LINUX)
EXEC_FILE="$PROJECT"
INCLUDE="-I./dependencies/imgui -I./dependencies/SDL2/include"
LINKER_LIBS="-L./$OBJDIR/libs/ -lSDL2 -lGL"
LINKER_LIBS="-L./libs/ -lSDL2 -lGL"
;;
*)
error "operating system $OS has no configuration variants"
@ -71,7 +71,7 @@ case "$TASK" in
# -flto applies more optimizations across object files
# -flto=auto is needed to multithreaded copilation
# -fuse-linker-plugin is required to use static libs with lto, it strips away all
C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -static"
#-fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"

2
dependencies/SDL2 vendored

@ -1 +1 @@
Subproject commit c2ee45f5ffbba6ff6962eb24fd117586a38cce5e
Subproject commit 903d888cc31d283ccaaaa7e5b5a324c50a103e87

@ -1 +1 @@
Subproject commit 83af9066dbf8dceef44009ef21ac1d6d042db2a3
Subproject commit 63f942fae90ab787d50fe4c13c7504be7852aa1d

View File

@ -21,6 +21,9 @@ f32 getMainWindowDPI(){
Maybe main_window_open(const char* window_title){
SDL_TRY_ZERO(SDL_Init(SDL_INIT_VIDEO));
SDL_version v;
SDL_GetVersion(&v);
kprintf("SDL version: %u.%u.%u\n", v.major, v.minor, v.patch);
// GL 3.0 + GLSL 130
const char* glsl_version = "#version 130";
SDL_TRY_ZERO( SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0));

View File

@ -7,5 +7,14 @@ if [ ! -f libs/fonts_embedded.a ]; then
fi
fi
# copy all precompiled libs
cp libs/* $OBJDIR/libs/
set -x
# copy precompiled static libs to objects
cp libs/*.a "$OBJDIR/libs/"
# copy precompiled shared libs to outdir
if [ $OS == 'WINDOWS' ]; then
cp libs/*.dll "$OUTDIR"
else
cp libs/*.so "$OUTDIR"
fi
set +x