Fix compilation with MSVC

This commit is contained in:
mrkubax10 2024-05-15 10:55:10 +02:00
parent f182c84c93
commit b68415be42
16 changed files with 77 additions and 23 deletions

View File

@ -199,7 +199,7 @@ if(BUILD_CLIENT)
endif()
if(WINDOW_WIN32)
list(APPEND CLIENT_SOURCES
src/game/window/win32_window.cpp
src/game/window/win32/win32_window.cpp
)
if(RENDERER_GL OR RENDERER_LEGACY_GL)
list(APPEND CLIENT_SOURCES

View File

@ -28,6 +28,7 @@ SOFTWARE.
#if defined(__unix__) || defined(__HAIKU__)
#include <netinet/in.h>
#elif defined(_WIN32)
#define NOMINMAX
#include <winsock2.h>
#endif

View File

@ -28,6 +28,12 @@ SOFTWARE.
#include "common/logger.hpp"
#if defined(_MSC_VER)
// Visual Studio doesn't define ssize_t by default
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
using namespace polygun::network;
static const time_t NETWORK_MANAGER_PACKET_RETRY_INTERVAL = 4;

View File

@ -39,6 +39,12 @@ using namespace polygun::network;
#include <netinet/in.h>
#endif
#if defined(_MSC_VER)
// Visual Studio doesn't define ssize_t by default
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
#if defined(__unix__) || defined(__HAIKU__)
#define INVALID_SOCK 1
#elif defined(_WIN32)

View File

@ -36,6 +36,12 @@ SOFTWARE.
#include "game/gui/style.hpp"
#include "game/renderer/texture.hpp"
#if defined(_MSC_VER)
// Visual Studio doesn't define ssize_t by default
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
using namespace polygun::gui;
Chat::Chat(engine::Engine* engine, Constraint* x, Constraint* y, Constraint* width, Constraint* height, const std::string& id) :

View File

@ -33,6 +33,12 @@ SOFTWARE.
#include "game/gui/layout.hpp"
#include "game/window/event.hpp"
#if defined(_MSC_VER)
// Visual Studio doesn't define ssize_t by default
#include <basetsd.h>
typedef SSIZE_T ssize_t;
#endif
using namespace polygun::gui;
GUIMaster::GUIMaster(engine::Engine* engine) :

View File

@ -32,6 +32,14 @@ SOFTWARE.
#include "common/math/vector.hpp"
#if defined(_MSC_VER)
/*
WinApi defines MessageBox macro which collides with PolyGun MessageBox class, so
undefine it here.
*/
#undef MessageBox
#endif
namespace polygun::renderer {
class Texture;
}

View File

@ -25,14 +25,13 @@ SOFTWARE.
#include "game/renderer/gl/gl_context.hpp"
#if defined(RENDERER_GL)
#include <GL/gl.h>
#if defined(_MSC_VER)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "game/window/win32/winapi.hpp"
#include "game/renderer/gl/msvc_glext.hpp"
#else
#include <GL/glext.h>
#endif
#include <GL/gl.h>
#endif
using namespace polygun::renderer;

View File

@ -17,13 +17,6 @@ extern "C" {
** Modified by mrkubax10 <mrkubax10@onet.pl> for usage in PolyGun
*/
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif

View File

@ -33,7 +33,7 @@ SOFTWARE.
#else
#if defined(_MSC_VER)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "game/window/win32/winapi.hpp"
#include "game/renderer/gl/msvc_glext.hpp"
#endif
#include <GL/gl.h>

View File

@ -25,7 +25,7 @@ SOFTWARE.
#include "game/renderer/gl/win32_gl_context.hpp"
#include "common/logger.hpp"
#include "game/window/win32_window.hpp"
#include "game/window/win32/win32_window.hpp"
#include "game/renderer/gl/opengl.hpp"
using namespace polygun::renderer;

View File

@ -27,12 +27,10 @@ SOFTWARE.
#include "game/renderer/gl/gl_context.hpp"
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#include <windows.h>
#undef UNICODE
//#include <GL/gl.h>
#include "game/window/win32/winapi.hpp"
namespace polygun::window {
class Win32Window;
}

View File

@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "game/window/win32_window.hpp"
#include "game/window/win32/win32_window.hpp"
#include <array>
#include <locale>

View File

@ -25,14 +25,12 @@ SOFTWARE.
#include "game/window/window.hpp"
#include <string>
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#include <windows.h>
#undef UNICODE
#include <thread>
#include <atomic>
#include <memory>
#include "game/window/win32/winapi.hpp"
#if defined(RENDERER_GL) || defined(RENDERER_LEGACY_GL)
#include "game/renderer/gl/win32_gl_context.hpp"
#endif

View File

@ -0,0 +1,33 @@
/*
PolyGun
Copyright (c) 2024 mrkubax10 <mrkubax10@onet.pl>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
#undef UNICODE
#undef WIN32_LEAN_AND_MEAN

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include <config.hpp>
#if defined(WINDOW_WIN32)
#include "game/window/win32_window.hpp"
#include "game/window/win32/win32_window.hpp"
#endif
#if defined(WINDOW_X11)
#include "game/window/x11/x11_window.hpp"