Browse Source

Merge pull request #13 from kolumb/mscv

Add support for MSVC compiler
Alexey Kutepov 5 years ago
parent
commit
1c15a5e422
4 changed files with 40 additions and 3 deletions
  1. 3 0
      .gitignore
  2. 25 0
      README.md
  3. 8 0
      build_msvc.bat
  4. 4 3
      main.c

+ 3 - 0
.gitignore

@@ -1,3 +1,6 @@
 sowon
 *.kra
 *~
+SDL2
+*.obj
+*.exe

+ 25 - 0
README.md

@@ -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

+ 8 - 0
build_msvc.bat

@@ -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

+ 4 - 3
main.c

@@ -1,3 +1,4 @@
+#define _CRT_SECURE_NO_WARNINGS
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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
@@ -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;
             }
         }