Fix compilation with MinGW

This commit is contained in:
Cameron Cawley 2019-01-10 16:11:39 +00:00
parent 6b36390bdc
commit da28d103c9
5 changed files with 33 additions and 6 deletions

View File

@ -93,6 +93,11 @@ workspace "librw"
filter "action:vs*" filter "action:vs*"
buildoptions { "/wd4996", "/wd4244" } buildoptions { "/wd4996", "/wd4244" }
filter { "platforms:win*gl3", "action:not vs*" }
if _OPTIONS["gfxlib"] == "sdl2" then
includedirs { "/mingw/include/SDL2" } -- TODO: Detect this properly
end
filter {} filter {}
Libdir = "lib/%{cfg.platform}/%{cfg.buildcfg}" Libdir = "lib/%{cfg.platform}/%{cfg.buildcfg}"
@ -122,8 +127,11 @@ function findlibs()
else else
links { "SDL2" } links { "SDL2" }
end end
filter { "platforms:win*gl3" } filter { "platforms:win*gl3", "action:vs*" }
defines { "GLEW_STATIC" } defines { "GLEW_STATIC" }
links { "glew32s" }
filter { "platforms:win*gl3", "action:not vs*" }
links { "glew32" }
filter { "platforms:win-amd64-gl3" } filter { "platforms:win-amd64-gl3" }
libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/x64") } libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/x64") }
libdirs { path.join(_OPTIONS["glfwdir"], "lib-vc2015") } libdirs { path.join(_OPTIONS["glfwdir"], "lib-vc2015") }
@ -132,14 +140,16 @@ function findlibs()
libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") } libdirs { path.join(_OPTIONS["glewdir"], "lib/Release/Win32") }
libdirs { path.join(_OPTIONS["sdl2dir"], "lib/x86") } libdirs { path.join(_OPTIONS["sdl2dir"], "lib/x86") }
filter { "platforms:win*gl3" } filter { "platforms:win*gl3" }
links { "glew32s", "opengl32" } links { "opengl32" }
if _OPTIONS["gfxlib"] == "glfw" then if _OPTIONS["gfxlib"] == "glfw" then
links { "glfw3" } links { "glfw3" }
else else
links { "SDL2" } links { "SDL2" }
end end
filter { "platforms:*d3d9" } filter { "platforms:*d3d9" }
links { "d3d9", "Xinput9_1_0" } links { "gdi32", "d3d9" }
filter { "platforms:*d3d9", "action:vs*" }
links { "Xinput9_1_0" }
filter {} filter {}
end end

1
rw.h
View File

@ -1,4 +1,5 @@
#include <cstdio> #include <cstdio>
#include <cstdlib>
#include <cmath> #include <cmath>
#include "src/rwbase.h" #include "src/rwbase.h"

View File

@ -8,6 +8,10 @@ using namespace rw;
#ifdef RW_D3D9 #ifdef RW_D3D9
#ifndef VK_OEM_NEC_EQUAL
#define VK_OEM_NEC_EQUAL 0x92
#endif
static int keymap[256]; static int keymap[256];
static void static void
initkeymap(void) initkeymap(void)
@ -65,6 +69,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
static int resizing = 0; static int resizing = 0;
static int buttons = 0; static int buttons = 0;
POINTS p;
MouseState ms; MouseState ms;
switch(msg){ switch(msg){
@ -108,7 +113,7 @@ WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
POINTS p = MAKEPOINTS(lParam); p = MAKEPOINTS(lParam);
ms.posx = p.x; ms.posx = p.x;
ms.posy = p.y; ms.posy = p.y;
EventHandler(MOUSEMOVE, &ms); EventHandler(MOUSEMOVE, &ms);
@ -231,8 +236,14 @@ WinMain(HINSTANCE instance, HINSTANCE,
if(!QueryPerformanceCounter((LARGE_INTEGER*)&ticks)) if(!QueryPerformanceCounter((LARGE_INTEGER*)&ticks))
return 0; return 0;
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
args.argc = _argc;
args.argv = _argv;
#else
args.argc = __argc; args.argc = __argc;
args.argv = __argv; args.argv = __argv;
#endif
if(EventHandler(INITIALIZE, nil) == EVENTERROR) if(EventHandler(INITIALIZE, nil) == EVENTERROR)
return 0; return 0;
@ -294,7 +305,11 @@ WinMain(HINSTANCE instance, HINSTANCE,
freopen("CONOUT$", "w", stderr); freopen("CONOUT$", "w", stderr);
*/ */
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
return main(_argc, _argv);
#else
return main(__argc, __argv); return main(__argc, __argv);
#endif
} }
#endif #endif
#endif #endif

View File

@ -17,7 +17,7 @@
namespace rw { namespace rw {
namespace gl3 { namespace gl3 {
static uint32 im2DVbo, im2DIbo; uint32 im2DVbo, im2DIbo;
static int32 u_xform; static int32 u_xform;
#define STARTINDICES 10000 #define STARTINDICES 10000

View File

@ -6,6 +6,8 @@ extern bool dosoftras;
using namespace rw; using namespace rw;
using namespace RWDEVICE; using namespace RWDEVICE;
void rastest_renderTriangles(RWDEVICE::Im2DVertex *scrverts, int32 verts, uint16 *indices, int32 numTris);
// //
// This is a test to implement T&L in software and render with Im2D // This is a test to implement T&L in software and render with Im2D
// //
@ -494,7 +496,6 @@ clipTriangles(MeshState *mstate, CamSpace3DVertex *camverts, Im2DVertex *scrvert
static void static void
submitTriangles(RWDEVICE::Im2DVertex *scrverts, int32 numVerts, uint16 *indices, int32 numTris) submitTriangles(RWDEVICE::Im2DVertex *scrverts, int32 numVerts, uint16 *indices, int32 numTris)
{ {
void rastest_renderTriangles(RWDEVICE::Im2DVertex *scrverts, int32 verts, uint16 *indices, int32 numTris);
rw::SetRenderStatePtr(rw::TEXTURERASTER, nil); rw::SetRenderStatePtr(rw::TEXTURERASTER, nil);
if(dosoftras) if(dosoftras)
rastest_renderTriangles(scrverts, numVerts, indices, numTris); rastest_renderTriangles(scrverts, numVerts, indices, numTris);