Merge branch 'gitlab-ci' into 'master'

Mingw32 support

See merge request STJr/UltimateZoneBuilder!15
This commit is contained in:
sphere 2023-12-09 12:46:21 +00:00
commit 0f874f4da7
13 changed files with 124 additions and 48 deletions

View file

@ -1,9 +1,5 @@
.COMMONENV:
variables:
BUILDTYPE: Release
CFLAGS: -Wall -Wextra -Werror
CXXFLAGS: -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-private-field
CPPFLAGS: -D NO_SSE
variables:
BUILDTYPE: Release
default:
image: mono:slim
@ -174,8 +170,6 @@ stages:
- build
Release:
extends:
- .COMMONENV
image: mono:latest
@ -211,14 +205,12 @@ Release:
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
i386:
extends:
- .COMMONENV
stage: build
variables:
CC: ccache i686-linux-gnu-gcc
CXX: ccache i686-linux-gnu-g++
CPPFLAGS: -msse2
artifacts:
paths:
@ -252,15 +244,11 @@ i386:
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
amd64:
extends:
- .COMMONENV
stage: build
variables:
CC: ccache x86_64-linux-gnu-gcc
CXX: ccache x86_64-linux-gnu-gcc
CPPFLAGS: -U NO_SSE
artifacts:
paths:
@ -294,9 +282,6 @@ amd64:
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
arm64:
extends:
- .COMMONENV
stage: build
variables:
@ -334,12 +319,71 @@ arm64:
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
win32:
stage: build
variables:
CC: ccache i686-w64-mingw32-gcc-posix
CXX: ccache i686-w64-mingw32-g++-posix
artifacts:
paths:
- "Build/BuilderNative.dll"
expose_as: "Windows x86"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG"
script:
- - |
# apt_toolchain
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
- apt-get install g++-mingw-w64-i686
- |
# apt_toolchain
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
- - |
# make
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling Native"
- make --keep-going Build/BuilderNative.dll MINGW=1 || make --keep-going Build/BuilderNative.dll MINGW=1
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
win64:
stage: build
variables:
CC: ccache x86_64-w64-mingw32-gcc-posix
CXX: ccache x86_64-w64-mingw32-g++-posix
artifacts:
paths:
- "Build/BuilderNative.dll"
expose_as: "Windows amd64"
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME_SLUG"
script:
- - |
# apt_toolchain
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
- apt-get install g++-mingw-w64-x86-64
- |
# apt_toolchain
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
- - |
# make
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling Native"
- make --keep-going Build/BuilderNative.dll MINGW=1 || make --keep-going Build/BuilderNative.dll MINGW=1
- |
# make
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
Debug:
extends:
- .COMMONENV
- Release
allow_failure: true
variables:
BUILDTYPE: Debug
BUILDTYPE: Debug

View file

@ -1,6 +1,10 @@
BUILDTYPE ?= Release
ifdef MINGW
TARGET_EXEC := BuilderNative.dll
else
TARGET_EXEC := libBuilderNative.so
endif
BUILD_DIR := ./Build.Native
SRC_DIRS := ./Source/Native
@ -17,13 +21,21 @@ INC_FLAGS := $(addprefix -I,$(INC_DIRS))
CPPFLAGS_ := $(INC_FLAGS) -MMD -MP
CFLAGS_ = -O2 -g3 -fPIC
CFLAGS_ = -O2 -g3 -fPIC -Wall -Wextra -Wno-unused-parameter -Werror
ifdef MINGW
CFLAGS_ += -msse2
endif
CXXFLAGS_ = -std=c++14 $(CFLAGS_)
LDFLAGS_ = --shared -ldl
ifdef MINGW
LDFLAGS_ = -lopengl32 -lgdi32 -shared -Wl,--subsystem,windows
else
LDFLAGS_ = -lX11 -ldl -shared
endif
all: builder Build/libBuilderNative.so
all: builder Build/$(TARGET_EXEC)
$(BUILD_DIR)/%.c.o: %.c
@mkdir -p $(dir $@)
@ -36,7 +48,7 @@ $(BUILD_DIR)/%.cpp.o: %.cpp
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CXX) $(OBJS) $(LDFLAGS_) $(LDFLAGS) -o $@
Build/libBuilderNative.so: $(BUILD_DIR)/$(TARGET_EXEC)
Build/$(TARGET_EXEC): $(BUILD_DIR)/$(TARGET_EXEC)
cp $< $@
.PHONY: clean

View file

@ -35,7 +35,7 @@ void SetError(const char* fmt, ...)
va_list va;
va_start(va, fmt);
mSetErrorBuffer[0] = 0;
#ifdef WIN32
#ifdef _WIN32
_vsnprintf(mSetErrorBuffer, sizeof(mSetErrorBuffer) - 1, fmt, va);
#else
vsnprintf(mSetErrorBuffer, sizeof(mSetErrorBuffer) - 1, fmt, va);

View file

@ -26,6 +26,22 @@
#include <cmath>
#include "fasttrig.h"
#if defined (__GNUC__) && !defined (__i386__) && !defined (__x86_64__)
#define NO_SSE
#endif
#if defined (_MSC_VER) && defined (_M_IX86_FP) && (_M_IX86_FP <= 1)
#define NO_SSE
#endif
#if defined (_MSC_VER) && defined (_M_ARM)
#define NO_SSE
#endif
#if defined (_MSC_VER) && defined (_M_ARM64)
#define NO_SSE
#endif
#ifndef NO_SSE
#include <xmmintrin.h>
#endif

View file

@ -24,6 +24,7 @@
#include "../Backend.h"
#include "OpenGLContext.h"
#include <list>
#include <mutex>
class GLSharedVertexBuffer;
class GLShader;

View file

@ -63,7 +63,6 @@ private:
int mHeight = 0;
PixelFormat mFormat = {};
bool mCubeTexture = false;
bool mPBOTexture = false;
GLuint mTexture = 0;
GLuint mFramebuffer = 0;
GLuint mDepthRenderbuffer = 0;

View file

@ -30,9 +30,9 @@ public:
OpenGLLoadFunctions() { ogl_LoadFunctions(); }
};
#ifdef WIN32
#ifdef _WIN32
#include <CommCtrl.h>
#include <commctrl.h>
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
@ -178,14 +178,14 @@ void OpenGLContext::SwapBuffers()
int OpenGLContext::GetWidth() const
{
RECT box = { 0 };
RECT box = { 0, 0, 0, 0 };
GetClientRect(window, &box);
return box.right - box.left;
}
int OpenGLContext::GetHeight() const
{
RECT box = { 0 };
RECT box = { 0, 0, 0, 0 };
GetClientRect(window, &box);
return box.bottom - box.top;
}
@ -217,15 +217,15 @@ OpenGLContext::CreateFunctions OpenGLContext::GetCreateFunctions(HWND window)
{
wglMakeCurrent(queryDC, queryContext);
functions.wglCreateContextAttribsARB = (ptr_wglCreateContextAttribsARB)wglGetProcAddress("wglCreateContextAttribsARB");
functions.wglGetPixelFormatAttribivEXT = (ptr_wglGetPixelFormatAttribivEXT)wglGetProcAddress("wglGetPixelFormatAttribivEXT");
functions.wglGetPixelFormatAttribfvEXT = (ptr_wglGetPixelFormatAttribfvEXT)wglGetProcAddress("wglGetPixelFormatAttribfvEXT");
functions.wglChoosePixelFormatEXT = (ptr_wglChoosePixelFormatEXT)wglGetProcAddress("wglChoosePixelFormatEXT");
functions.wglCreateContextAttribsARB = (ptr_wglCreateContextAttribsARB)(void*)wglGetProcAddress("wglCreateContextAttribsARB");
functions.wglGetPixelFormatAttribivEXT = (ptr_wglGetPixelFormatAttribivEXT)(void*)wglGetProcAddress("wglGetPixelFormatAttribivEXT");
functions.wglGetPixelFormatAttribfvEXT = (ptr_wglGetPixelFormatAttribfvEXT)(void*)wglGetProcAddress("wglGetPixelFormatAttribfvEXT");
functions.wglChoosePixelFormatEXT = (ptr_wglChoosePixelFormatEXT)(void*)wglGetProcAddress("wglChoosePixelFormatEXT");
HMODULE opengl32 = LoadLibrary("opengl32.dll");
if (opengl32)
{
functions.error = reinterpret_cast<ptr_glError>(GetProcAddress(opengl32, "glGetError"));
functions.error = reinterpret_cast<ptr_glError>((void*)GetProcAddress(opengl32, "glGetError"));
FreeLibrary(opengl32);
}
@ -513,9 +513,6 @@ private:
bool is_glx_extension_supported(const char* ext_name);
int major_version = 3;
int minor_version = 2;
void* opengl_lib_handle = nullptr;
};

View file

@ -69,7 +69,7 @@ static int TestPointer(const PROC pTest)
return 1;
}
static PROC WinGetProcAddress(const char *name)
static void *WinGetProcAddress(const char *name)
{
HMODULE glMod = NULL;
PROC pFunc = wglGetProcAddress((LPCSTR)name);
@ -87,7 +87,6 @@ static PROC WinGetProcAddress(const char *name)
#define IntGetProcAddress(name) AppleGLGetProcAddress(name)
#else
#if defined(__sgi) || defined(__sun) || defined(__unix__)
void* GL_GetProcAddress(const char* proc);
#define IntGetProcAddress(name) GL_GetProcAddress((const char*)name)
//#define IntGetProcAddress(name) PosixGetProcAddress((const GLubyte*)name)
/* END OF MANUAL CHANGES, DO NOT REMOVE! */

View file

@ -4216,6 +4216,8 @@ int ogl_GetMinorVersion(void);
int ogl_GetMajorVersion(void);
int ogl_IsVersionGEQ(int majorVersion, int minorVersion);
void* GL_GetProcAddress(const char* proc);
#ifdef __cplusplus
}
#endif /*__cplusplus*/

View file

@ -30,8 +30,8 @@
#include <memory>
#include <string>
#ifdef WIN32
#include <Windows.h>
#ifdef _WIN32
#include <windows.h>
#undef min
#undef max
#endif

View file

@ -22,7 +22,7 @@
#include "Precomp.h"
#include "RawMouse.h"
#ifdef WIN32
#ifdef _WIN32
#ifndef HID_USAGE_PAGE_GENERIC
#define HID_USAGE_PAGE_GENERIC ((USHORT) 0x01)
@ -105,7 +105,7 @@ LRESULT RawMouse::OnMessage(INT message, WPARAM wparam, LPARAM lparam)
{
std::vector<uint32_t> buf((size + 3) / 4);
result = GetRawInputData(rawinputHandle, RID_INPUT, buf.data(), &size, sizeof(RAWINPUTHEADER));
if (result >= 0)
if (result != (UINT)-1)
{
RAWINPUT* rawinput = (RAWINPUT*)buf.data();
if (rawinput->header.dwType == RIM_TYPEMOUSE)
@ -172,7 +172,7 @@ extern "C"
RawMouse* RawMouse_New(void* hwnd)
{
#ifdef WIN32
#ifdef _WIN32
return new RawMouse(hwnd);
#else
return nullptr;

View file

@ -21,7 +21,7 @@
#pragma once
#ifdef WIN32
#ifdef _WIN32
class RawMouse
{

View file

@ -39,10 +39,16 @@
#define M_PI 3.14159265358979323846
#endif
#ifdef WIN32
#ifndef FORCEINLINE
#if defined (_MSC_VER)
#define FORCEINLINE __forceinline
//#elif defined (__MINGW32__)
//#define FORCEINLINE inline
#elif defined (__GNUC__)
#define FORCEINLINE inline __attribute__((always_inline))
#else
#define FORCEINLINE
#define FORCEINLINE inline
#endif
#endif
// This uses a sine table with linear interpolation