Skip to content

Commit

Permalink
Merge pull request tsoding#13 from kolumb/mscv
Browse files Browse the repository at this point in the history
Add support for MSVC compiler
  • Loading branch information
rexim authored Oct 19, 2020
2 parents 4260a00 + c018844 commit 1c15a5e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
sowon
*.kra
*~
SDL2
*.obj
*.exe
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,35 @@

Dependencies: [SDL2](https://www.libsdl.org/download-2.0.php)

### Debian
```console
$ sudo apt-get install libsdl2-dev
$ make
```

### MacOS

```console
$ brew install sdl2 pkg-config
$ make
```

### Windows

#### Visual Studio

- Enter the Visual Studio Command Line Development Environment https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line
- Basically just find `vcvarsall.bat` and run `vcvarsall.bat x64` inside of cmd
- Download [SDL2 VC Development Libraries](https://libsdl.org/release/SDL2-devel-2.0.12-VC.zip) and copy it to `path\to\sowon`

```console
> cd path\to\sowon
> tar -xf SDL2-devel-2.0.12-VC.zip
> move SDL2-2.0.12 SDL2
> del SDL2-devel-2.0.12-VC.zip
> build_msvc
```

## Usage

### Modes
Expand Down
8 changes: 8 additions & 0 deletions build_msvc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off
rem launch this from msvs-enabled console

set CXXFLAGS=/std:c++17 /O2 /FC /W4 /WX /nologo
set INCLUDES=/I SDL2\include
set LIBS=SDL2\lib\x64\SDL2.lib SDL2\lib\x64\SDL2main.lib Shell32.lib

cl.exe %CXXFLAGS% %INCLUDES% /Fesowon main.c /link %LIBS% -SUBSYSTEM:windows
7 changes: 4 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -18,7 +19,7 @@
#define TEXT_WIDTH (CHAR_WIDTH * CHARS_COUNT)
#define TEXT_HEIGHT (CHAR_HEIGHT)
#define WIGGLE_COUNT 3
#define WIGGLE_DURATION (0.40 / WIGGLE_COUNT)
#define WIGGLE_DURATION (0.40f / WIGGLE_COUNT)
#define COLON_INDEX 10
#define MAIN_COLOR_R 220
#define MAIN_COLOR_G 220
Expand Down Expand Up @@ -303,8 +304,8 @@ int main(int argc, char **argv)
time_t t = time(NULL);
struct tm *tm = localtime(&t);
displayed_time = tm->tm_sec
+ tm->tm_min * 60
+ tm->tm_hour * 60 * 60;
+ tm->tm_min * 60.0f
+ tm->tm_hour * 60.0f * 60.0f;
} break;
}
}
Expand Down

0 comments on commit 1c15a5e

Please sign in to comment.