Browse Source

several fixes for windows

Kajetan Johannes Hammerle 2 years ago
parent
commit
85050a591b
9 changed files with 31 additions and 35 deletions
  1. 0 2
      .gitignore
  2. 1 1
      images/PNGReader.cpp
  3. 3 3
      math/Matrix.cpp
  4. 3 3
      math/Quaternion.cpp
  5. 4 6
      math/Vector.cpp
  6. 18 9
      meson.build
  7. 1 0
      network/Server.cpp
  8. 0 11
      subprojects/libpng.wrap
  9. 1 0
      wrapper/GL.cpp

+ 0 - 2
.gitignore

@@ -1,2 +0,0 @@
-subprojects/packagecache
-subprojects/libpng-1.6.37

+ 1 - 1
images/PNGReader.cpp

@@ -22,7 +22,7 @@ Error PNGReader::load(const char* path) {
         return error;
     }
     PNGReader::path = path;
-    file = fopen(path, "r");
+    file = fopen(path, "rb");
     if(file == nullptr) {
         Error error = {"file '"};
         error.message.append(path)

+ 3 - 3
math/Matrix.cpp

@@ -86,9 +86,9 @@ Matrix& Matrix::translateTo(const Vector3& v) {
 }
 
 Matrix& Matrix::rotate(float degrees, int a, int b) {
-    float sin;
-    float cos;
-    sincosf(degrees * (M_PI / 180.0f), &sin, &cos);
+    degrees *= (M_PI / 180.0f);
+    float sin = sinf(degrees);
+    float cos = cosf(degrees);
     Vector4 v = data[a];
     data[a] = cos * data[a] - sin * data[b];
     data[b] = sin * v + cos * data[b];

+ 3 - 3
math/Quaternion.cpp

@@ -6,10 +6,10 @@ Quaternion::Quaternion() : w(1.0f) {
 }
 
 Quaternion::Quaternion(const Vector3& axis, float angle) : xyz(axis) {
+    angle *= (M_PI / 360.0f);
     xyz.normalize();
-    float sin;
-    sincosf(angle * (M_PI / 360.0f), &sin, &w);
-    xyz *= sin;
+    w = cosf(angle);
+    xyz *= sinf(angle);
 }
 
 Quaternion Quaternion::lerp(float f, const Quaternion& other) const {

+ 4 - 6
math/Vector.cpp

@@ -7,13 +7,11 @@ Vector<3>& Vector<3>::setAngles(float lengthAngle, float widthAngle) {
     lengthAngle *= (M_PI / 180.0f);
     widthAngle *= (M_PI / 180.0f);
 
-    float sinWidth;
-    float cosWidth;
-    sincosf(widthAngle, &sinWidth, &cosWidth);
+    float sinWidth = sinf(widthAngle);
+    float cosWidth = cosf(widthAngle);
 
-    float sinLength;
-    float cosLength;
-    sincosf(lengthAngle, &sinLength, &cosLength);
+    float sinLength = sinf(lengthAngle);
+    float cosLength = cosf(lengthAngle);
 
     return *this = Vector<3>(cosWidth * cosLength, sinWidth, -sinLength * cosWidth);
 }

+ 18 - 9
meson.build

@@ -61,25 +61,34 @@ src_tests = [
     'tests/VectorTests.cpp',
 ]
 
+compiler = meson.get_compiler('cpp')
+args = compiler.get_supported_arguments(['-Wall', '-Wextra', '-pedantic', '-Werror'])
+
 thread_dep = dependency('threads')
 glew_dep = dependency('glew')
-
-png_proj = subproject('libpng')
-png_dep = png_proj.get_variable('libpng_dep')
-
+zlib_dep = dependency('zlib')
+png_dep = dependency('libpng')
 glfw_dep = dependency('glfw3')
+gl_dep = dependency('GL')
+
+ws2_32_dep = compiler.find_library('ws2_32', required: false)
+winmm_dep = compiler.find_library('winmm', required: false)
 
-args = ['-Wall', '-Wextra', '-pedantic', '-Werror']
+inc = include_directories('.', 
+    glew_dep.get_pkgconfig_variable('includedir'),
+    glfw_dep.get_pkgconfig_variable('includedir'),
+    png_dep.get_pkgconfig_variable('includedir'))
 
-inc = include_directories('.')
 libgamingcore = static_library('gamingcore', 
     sources: src,
     include_directories : inc,
-    dependencies : [thread_dep, glew_dep, glfw_dep, png_dep],
+    dependencies : [thread_dep, glew_dep, glfw_dep, png_dep, zlib_dep, gl_dep, ws2_32_dep, winmm_dep],
     cpp_args: args)
-libgamingcore_dep = declare_dependency(include_directories : inc, link_with : libgamingcore)
+libgamingcore_dep = declare_dependency(
+    include_directories: inc, 
+    link_with: libgamingcore)
 
 executable('tests', 
     sources: src_tests,
     dependencies : libgamingcore_dep,
-    cpp_args: args + ['-DLOG_LEVEL=4'])
+    cpp_args: args + ['-DLOG_LEVEL=4'])

+ 1 - 0
network/Server.cpp

@@ -53,6 +53,7 @@ Error Server::start(Port port, int maxClients) {
         return {"cannot initialize enet"};
     }
     ENetAddress address;
+    memset(&address, 0, sizeof(ENetAddress));
     address.host = ENET_HOST_ANY;
     address.port = port;
 

+ 0 - 11
subprojects/libpng.wrap

@@ -1,11 +0,0 @@
-[wrap-file]
-directory = libpng-1.6.37
-source_url = https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz
-source_filename = libpng-1.6.37.tar.gz
-source_hash = ca74a0dace179a8422187671aee97dd3892b53e168627145271cad5b5ac81307
-patch_url = https://wrapdb.mesonbuild.com/v1/projects/libpng/1.6.37/3/get_zip
-patch_filename = libpng-1.6.37-3-wrap.zip
-patch_hash = 6c9f32fd9150b3a96ab89be52af664e32207e10aa9f5fb9aa015989ee2dd7100
-
-[provide]
-libpng = libpng_dep

+ 1 - 0
wrapper/GL.cpp

@@ -1,4 +1,5 @@
 #include <GL/glew.h>
+#include <GL/glu.h>
 #include <type_traits>
 
 #include "utils/Array.h"