Skip to content

Commit

Permalink
update sokol headers, remove sokol_time.h dependency, simplify build
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Jan 20, 2022
1 parent 7bdeed9 commit cc56af9
Show file tree
Hide file tree
Showing 9 changed files with 1,398 additions and 723 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.0)
project(pacman)
set(CMAKE_C_STANDARD 11)
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif()

# Linux -pthread shenanigans
if (CMAKE_SYSTEM_NAME STREQUAL Linux)
Expand All @@ -17,7 +14,6 @@ set(SOKOL_HEADERS
sokol/sokol_gfx.h
sokol/sokol_app.h
sokol/sokol_audio.h
sokol/sokol_time.h
sokol/sokol_glue.h)
add_library(sokol STATIC sokol/sokol.c ${SOKOL_HEADERS})
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
Expand Down Expand Up @@ -46,6 +42,7 @@ else()
endif()
target_link_libraries(pacman sokol)
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_link_options(pacman PUBLIC --shell-file ../sokol/shell.html)
target_link_options(pacman PUBLIC -sNO_FILESYSTEM=1 -sASSERTIONS=0 -sMALLOC=emmalloc --closure=1)
endif()
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ To run the compilation result in the system web browser:

## IDE Support

On Windows, cmake will automatically create a **Visual Studio** solution file which can be opened with the ```start``` command:
On Windows with Visual Studio cmake will automatically create a **Visual Studio** solution file which can be opened with ```cmake --open .```:
```
cd build
cmake ..
start pacman.sln
cmake --open .
```

On macOS, the cmake **Xcode** generator can be used to create an
Xcode project which can be opened with the ```open``` command:
Xcode project which can be opened with ```cmake --open .```
```
cd build
cmake -GXcode ..
open pacman.xcodeproj
cmake --open .
```

On all platforms with **Visual Studio Code** and the Microsoft C/C++ and
Expand Down
4 changes: 1 addition & 3 deletions pacman.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_audio.h"
#include "sokol_time.h"
#include "sokol_glue.h"
#include <assert.h>
#include <string.h> // memset()
Expand Down Expand Up @@ -713,7 +712,6 @@ sapp_desc sokol_main(int argc, char* argv[]) {
}

static void init(void) {
stm_setup();
gfx_init();
snd_init();

Expand All @@ -728,7 +726,7 @@ static void init(void) {
static void frame(void) {

// run the game at a fixed tick rate regardless of frame rate
uint32_t frame_time_ns = (uint32_t) stm_ns(stm_laptime(&state.timing.laptime_store));
uint32_t frame_time_ns = (uint32_t) (sapp_frame_duration() * 1000000000.0);
// clamp max frame time (so the timing isn't messed up when stopping in the debugger)
if (frame_time_ns > 33333333) {
frame_time_ns = 33333333;
Expand Down
1 change: 0 additions & 1 deletion sokol/sokol.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
#include "sokol_app.h"
#include "sokol_gfx.h"
#include "sokol_audio.h"
#include "sokol_time.h"
#include "sokol_glue.h"
Loading

0 comments on commit cc56af9

Please sign in to comment.