Merge branch 'master' of github.com:aap/librw

This commit is contained in:
aap 2019-08-04 23:52:10 +02:00
commit 0c8398c7e4
9 changed files with 41 additions and 13 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/bin /bin
/build
/obj /obj
/lib /lib
/output /output

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

@ -1,5 +1,5 @@
#ifdef RW_D3D9 #ifdef RW_D3D9
#define NOMINMAX #define NOMINMAX 1
#include <d3d9.h> #include <d3d9.h>
#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

@ -465,11 +465,11 @@ texfunc(Color t, Color f)
a = srTexUseAlpha ? t.a : f.a; a = srTexUseAlpha ? t.a : f.a;
break; break;
} }
r = clamp(r); Color v;
g = clamp(g); v.r = clamp(r);
b = clamp(b); v.g = clamp(g);
a = clamp(a); v.b = clamp(b);
Color v = { r, g, b, a }; v.a = clamp(a);
return v; return v;
} }

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);

View File

@ -74,7 +74,7 @@ Draw(float timeDelta)
static bool show_another_window = false; static bool show_another_window = false;
static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
rw::RGBA clearcol = { clear_color.x*255, clear_color.y*255, clear_color.z*255, clear_color.w*255 }; rw::RGBA clearcol = rw::makeRGBA(clear_color.x*255, clear_color.y*255, clear_color.z*255, clear_color.w*255);
Scene.camera->clear(&clearcol, rw::Camera::CLEARIMAGE|rw::Camera::CLEARZ); Scene.camera->clear(&clearcol, rw::Camera::CLEARIMAGE|rw::Camera::CLEARZ);
Scene.camera->beginUpdate(); Scene.camera->beginUpdate();