Merge pull request #492 from erorcun/erorcun

Initial GLFW support
This commit is contained in:
aap 2020-04-26 12:49:31 +02:00 committed by GitHub
commit 7052b0b64c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 1983 additions and 83 deletions

View File

@ -1,7 +1,7 @@
Librw = os.getenv("LIBRW") or "librw" Librw = os.getenv("LIBRW") or "librw"
workspace "re3" workspace "re3"
configurations { "Debug", "Release", "ReleaseFH", "DebugRW", "ReleaseRW" } configurations { "Debug", "Release", "ReleaseFH", "DebugRW", "ReleaseRW", "ReleaseGLFW" }
location "build" location "build"
files { "src/*.*" } files { "src/*.*" }
@ -19,6 +19,7 @@ workspace "re3"
files { "src/save/*.*" } files { "src/save/*.*" }
files { "src/skel/*.*" } files { "src/skel/*.*" }
files { "src/skel/win/*.*" } files { "src/skel/win/*.*" }
files { "src/skel/glfw/*.*" }
files { "src/text/*.*" } files { "src/text/*.*" }
files { "src/vehicles/*.*" } files { "src/vehicles/*.*" }
files { "src/weapons/*.*" } files { "src/weapons/*.*" }
@ -40,6 +41,7 @@ workspace "re3"
includedirs { "src/save/" } includedirs { "src/save/" }
includedirs { "src/skel/" } includedirs { "src/skel/" }
includedirs { "src/skel/win" } includedirs { "src/skel/win" }
includedirs { "src/skel/glfw" }
includedirs { "src/text" } includedirs { "src/text" }
includedirs { "src/vehicles" } includedirs { "src/vehicles" }
includedirs { "src/weapons" } includedirs { "src/weapons" }
@ -67,6 +69,21 @@ workspace "re3"
links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse" } links { "rwcore", "rpworld", "rpmatfx", "rpskin", "rphanim", "rtbmp", "rtquat", "rtcharse" }
filter {} filter {}
filter "configurations:ReleaseGLFW"
defines { "GLEW_STATIC", "GLFW_DLL" }
files { "src/fakerw/*.*" }
includedirs { "src/fakerw" }
includedirs { Librw }
includedirs { "glfw-3.3.2.bin.WIN32/include" }
includedirs { "glew-2.1.0/include" }
libdirs { path.join(Librw, "lib/win-x86-gl3/Release") }
libdirs { "glew-2.1.0/lib/Release/Win32" }
libdirs { "glfw-3.3.2.bin.WIN32/lib-vc2015" }
links { "opengl32" }
links { "glew32s" }
links { "glfw3dll" }
links { "rw" }
filter {}
pbcommands = { pbcommands = {
"setlocal EnableDelayedExpansion", "setlocal EnableDelayedExpansion",
@ -107,14 +124,18 @@ project "re3"
symbols "Full" symbols "Full"
staticruntime "off" staticruntime "off"
filter "configurations:not *RW" filter "configurations:Debug or Release or ReleaseFH"
-- prebuildcommands { "cd \"../librw\" && premake5 " .. _ACTION .. " && msbuild \"build/librw.sln\" /property:Configuration=%{cfg.longname} /property:Platform=\"win-x86-d3d9\"" } prebuildcommands { "cd \"../librw\" && premake5 " .. _ACTION .. " && msbuild \"build/librw.sln\" /property:Configuration=%{cfg.longname} /property:Platform=\"win-x86-d3d9\"" }
defines { "LIBRW", "RW_D3D9" } defines { "LIBRW", "RW_D3D9" }
filter "configurations:*RW" filter "configurations:*RW"
defines { "RWLIBS" } defines { "RWLIBS" }
staticruntime "on" staticruntime "on"
linkoptions "/SECTION:_rwcseg,ER!W /MERGE:_rwcseg=.text" linkoptions "/SECTION:_rwcseg,ER!W /MERGE:_rwcseg=.text"
filter "configurations:*GLFW"
prebuildcommands { "cd \"../librw\" && premake5 " .. _ACTION .. " && msbuild \"build/librw.sln\" /property:Configuration=Release /property:Platform=\"win-x86-gl3\"" }
defines { "LIBRW", "RW_GL3" }
filter "configurations:Debug*" filter "configurations:Debug*"
defines { "DEBUG" } defines { "DEBUG" }

View File

@ -1,7 +1,10 @@
#if defined RW_D3D9 || defined RWLIBS
#define DIRECTINPUT_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800
#include <dinput.h> #include <dinput.h>
#include "common.h" #endif
#include "common.h"
#include "crossplatform.h"
#include "ControllerConfig.h" #include "ControllerConfig.h"
#include "Pad.h" #include "Pad.h"
#include "FileMgr.h" #include "FileMgr.h"
@ -15,7 +18,6 @@
#include "World.h" #include "World.h"
#include "ModelIndices.h" #include "ModelIndices.h"
#include "Camera.h" #include "Camera.h"
#include "win.h"
#include "GenericGameStorage.h" #include "GenericGameStorage.h"
CControllerConfigManager ControlsManager; CControllerConfigManager ControlsManager;
@ -41,14 +43,72 @@ void CControllerConfigManager::MakeControllerActionsBlank()
} }
} }
#ifdef RW_GL3
int MapIdToButtonId(int mapId) {
switch (mapId) {
case GLFW_GAMEPAD_BUTTON_A: // Cross
return 2;
case GLFW_GAMEPAD_BUTTON_B: // Circle
return 1;
case GLFW_GAMEPAD_BUTTON_X: // Square
return 3;
case GLFW_GAMEPAD_BUTTON_Y: // Triangle
return 4;
case GLFW_GAMEPAD_BUTTON_LEFT_BUMPER:
return 7;
case GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER:
return 8;
case GLFW_GAMEPAD_BUTTON_BACK:
return 9;
case GLFW_GAMEPAD_BUTTON_START:
return 12;
case GLFW_GAMEPAD_BUTTON_LEFT_THUMB:
return 10;
case GLFW_GAMEPAD_BUTTON_RIGHT_THUMB:
return 11;
case GLFW_GAMEPAD_BUTTON_DPAD_UP:
return 13;
case GLFW_GAMEPAD_BUTTON_DPAD_RIGHT:
return 14;
case GLFW_GAMEPAD_BUTTON_DPAD_DOWN:
return 15;
case GLFW_GAMEPAD_BUTTON_DPAD_LEFT:
return 16;
// GLFW sends those as axes, so I added them here manually.
case 15: // Left trigger
return 5;
case 16: // Right trigger
return 6;
default:
return 0;
}
}
#endif
int32 CControllerConfigManager::GetJoyButtonJustDown() int32 CControllerConfigManager::GetJoyButtonJustDown()
{ {
#ifdef __DINPUT_INCLUDED__ #ifdef __DINPUT_INCLUDED__
#ifdef FIX_BUGS
for (int32 i = 0; i < MAX_BUTTONS; i++)
#else
for (int32 i = 0; i < JOY_BUTTONS; i++) for (int32 i = 0; i < JOY_BUTTONS; i++)
#endif
{ {
if (m_NewState.rgbButtons[i] & 0x80 && !(m_OldState.rgbButtons[i] & 0x80)) if (m_NewState.rgbButtons[i] & 0x80 && !(m_OldState.rgbButtons[i] & 0x80))
return i + 1; return i + 1;
} }
#elif defined RW_GL3
if (m_NewState.isGamepad) {
for (int32 i = 0; i < MAX_BUTTONS; i++) {
if (m_NewState.mappedButtons[i] && !(m_OldState.mappedButtons[i]))
return MapIdToButtonId(i);
}
} else {
for (int32 i = 0; i < Min(m_NewState.numButtons, MAX_BUTTONS); i++) {
if (m_NewState.buttons[i] && !(m_OldState.buttons[i]))
return i + 1;
}
}
#endif #endif
return 0; return 0;
} }
@ -249,8 +309,13 @@ void CControllerConfigManager::InitDefaultControlConfigJoyPad(uint32 buttons)
if (buttons > 16) if (buttons > 16)
btn = 16; btn = 16;
// Now we use SDL Game Controller DB
#if defined RW_D3D9 || defined RWLIBS
if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427
&& AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190) && AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190)
#else
if (0)
#endif
{ {
//GIC USB Joystick, PS2 Gamepad ? //GIC USB Joystick, PS2 Gamepad ?
@ -445,8 +510,13 @@ void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonDown(int32 button, i
break; break;
} }
if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 // Now we use SDL Game Controller DB
#if defined RW_D3D9 || defined RWLIBS
if (AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427
&& AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190) && AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190)
#else
if (0)
#endif
{ {
//GIC USB Joystick, PS2 Gamepad ? //GIC USB Joystick, PS2 Gamepad ?
@ -872,8 +942,13 @@ void CControllerConfigManager::UpdateJoyInConfigMenus_ButtonUp(int32 button, int
break; break;
} }
if ( AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427 // Now we use SDL Game Controller DB
#if defined RW_D3D9 || defined RWLIBS
if (AllValidWinJoys.m_aJoys[JOYSTICK1].m_nVendorID == 0x3427
&& AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190) && AllValidWinJoys.m_aJoys[JOYSTICK1].m_nProductID == 0x1190)
#else
if (0)
#endif
{ {
//GIC USB Joystick, PS2 Gamepad ? //GIC USB Joystick, PS2 Gamepad ?
@ -1809,7 +1884,7 @@ wchar *CControllerConfigManager::GetControllerSettingTextKeyBoard(e_ControllerAc
static wchar ActionText[50]; static wchar ActionText[50];
static wchar NewStringWithNumber[30]; static wchar NewStringWithNumber[30];
for (int32 i = 0; i < ARRAYSIZE(ActionText); i++) for (int32 i = 0; i < ARRAY_SIZE(ActionText); i++)
ActionText[i] = '\0'; ActionText[i] = '\0';
if (GetControllerKeyAssociatedWithAction(action, type) != rsNULL) if (GetControllerKeyAssociatedWithAction(action, type) != rsNULL)
@ -2266,6 +2341,19 @@ void CControllerConfigManager::UpdateJoyButtonState(int32 padnumber)
else else
m_aButtonStates[i] = false; m_aButtonStates[i] = false;
} }
#elif defined RW_GL3
if (m_NewState.isGamepad) {
for (int32 i = 0; i < MAX_BUTTONS; i++) {
if (i == GLFW_GAMEPAD_BUTTON_GUIDE)
continue;
m_aButtonStates[MapIdToButtonId(i)-1] = m_NewState.mappedButtons[i];
}
} else {
for (int32 i = 0; i < Min(m_NewState.numButtons, MAX_BUTTONS); i++) {
m_aButtonStates[i] = m_NewState.buttons[i];
}
}
#endif #endif
} }

View File

@ -96,6 +96,16 @@ class CControllerState;
#define ACTIONNAME_LENGTH 40 #define ACTIONNAME_LENGTH 40
#ifdef RW_GL3
struct GlfwJoyState {
int8 id;
bool isGamepad;
uint8 numButtons;
uint8* buttons;
bool mappedButtons[17];
};
#endif
class CControllerConfigManager class CControllerConfigManager
{ {
public: public:
@ -115,8 +125,9 @@ public:
#ifdef __DINPUT_INCLUDED__ #ifdef __DINPUT_INCLUDED__
DIJOYSTATE2 m_OldState; DIJOYSTATE2 m_OldState;
DIJOYSTATE2 m_NewState; DIJOYSTATE2 m_NewState;
#else #elif defined RW_GL3
uint32 ___padd[0x110 / 4 * 2]; GlfwJoyState m_OldState;
GlfwJoyState m_NewState;
#endif #endif
wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH]; wchar m_aActionNames[MAX_CONTROLLERACTIONS][ACTIONNAME_LENGTH];
bool m_aButtonStates[MAX_BUTTONS]; bool m_aButtonStates[MAX_BUTTONS];
@ -193,6 +204,6 @@ public:
void ResetSettingOrder (e_ControllerAction action); void ResetSettingOrder (e_ControllerAction action);
}; };
VALIDATE_SIZE(CControllerConfigManager, 0x143C); //VALIDATE_SIZE(CControllerConfigManager, 0x143C);
extern CControllerConfigManager ControlsManager; extern CControllerConfigManager ControlsManager;

View File

@ -1,8 +1,11 @@
#if defined RW_D3D9 || defined RWLIBS
#define DIRECTINPUT_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800
#include <dinput.h> #include <dinput.h>
#include "common.h" #endif
#include "win.h" #define WITHWINDOWS
#include "common.h"
#include "crossplatform.h"
#include "Frontend.h" #include "Frontend.h"
#include "Font.h" #include "Font.h"
#include "Pad.h" #include "Pad.h"
@ -430,13 +433,16 @@ CMenuManager::BuildStatLine(char *text, void *stat, bool itsFloat, void *stat2)
void void
CMenuManager::CentreMousePointer() CMenuManager::CentreMousePointer()
{ {
tagPOINT Point;
if (SCREEN_WIDTH * 0.5f != 0.0f && 0.0f != SCREEN_HEIGHT * 0.5f) { if (SCREEN_WIDTH * 0.5f != 0.0f && 0.0f != SCREEN_HEIGHT * 0.5f) {
#if defined RW_D3D9 || defined RWLIBS
tagPOINT Point;
Point.x = SCREEN_WIDTH / 2; Point.x = SCREEN_WIDTH / 2;
Point.y = SCREEN_HEIGHT / 2; Point.y = SCREEN_HEIGHT / 2;
ClientToScreen(PSGLOBAL(window), &Point); ClientToScreen(PSGLOBAL(window), &Point);
SetCursorPos(Point.x, Point.y); SetCursorPos(Point.x, Point.y);
#elif defined RW_GL3
glfwSetCursorPos(PSGLOBAL(window), SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);
#endif
PSGLOBAL(lastMousePos.x) = SCREEN_WIDTH / 2; PSGLOBAL(lastMousePos.x) = SCREEN_WIDTH / 2;
PSGLOBAL(lastMousePos.y) = SCREEN_HEIGHT / 2; PSGLOBAL(lastMousePos.y) = SCREEN_HEIGHT / 2;
@ -4474,12 +4480,20 @@ CMenuManager::ProcessButtonPresses(void)
ControlsManager.MakeControllerActionsBlank(); ControlsManager.MakeControllerActionsBlank();
ControlsManager.InitDefaultControlConfiguration(); ControlsManager.InitDefaultControlConfiguration();
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp()); ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
if (AllValidWinJoys.m_aJoys[0].m_bInitialised) { #if !defined RW_GL3
if (AllValidWinJoys.m_aJoys[JOYSTICK1].m_bInitialised) {
DIDEVCAPS devCaps; DIDEVCAPS devCaps;
devCaps.dwSize = sizeof(DIDEVCAPS); devCaps.dwSize = sizeof(DIDEVCAPS);
PSGLOBAL(joy1)->GetCapabilities(&devCaps); PSGLOBAL(joy1)->GetCapabilities(&devCaps);
ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons); ControlsManager.InitDefaultControlConfigJoyPad(devCaps.dwButtons);
} }
#else
if (PSGLOBAL(joy1id) != -1 && glfwJoystickPresent(PSGLOBAL(joy1id))) {
int count;
glfwGetJoystickButtons(PSGLOBAL(joy1id), &count);
ControlsManager.InitDefaultControlConfigJoyPad(count);
}
#endif
m_ControlMethod = CONTROL_STANDARD; m_ControlMethod = CONTROL_STANDARD;
MousePointerStateHelper.bInvertVertically = false; MousePointerStateHelper.bInvertVertically = false;
TheCamera.m_fMouseAccelHorzntl = 0.0025f; TheCamera.m_fMouseAccelHorzntl = 0.0025f;

View File

@ -2,7 +2,7 @@
#pragma warning( disable : 4005) #pragma warning( disable : 4005)
#pragma warning( pop ) #pragma warning( pop )
#include "common.h" #include "common.h"
#include "win.h" #include "crossplatform.h"
#include "Game.h" #include "Game.h"
#include "main.h" #include "main.h"

View File

@ -1,10 +1,13 @@
#pragma warning( push ) #pragma warning( push )
#pragma warning( disable : 4005) #pragma warning( disable : 4005)
#if defined RW_D3D9 || defined RWLIBS
#define DIRECTINPUT_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800
#include <dinput.h> #include <dinput.h>
#endif
#pragma warning( pop ) #pragma warning( pop )
#include "common.h" #include "common.h"
#include "crossplatform.h"
#ifdef XINPUT #ifdef XINPUT
#include <xinput.h> #include <xinput.h>
#pragma comment( lib, "Xinput9_1_0.lib" ) #pragma comment( lib, "Xinput9_1_0.lib" )
@ -29,7 +32,6 @@
#include "Record.h" #include "Record.h"
#include "Replay.h" #include "Replay.h"
#include "Weather.h" #include "Weather.h"
#include "win.h"
#include "Streaming.h" #include "Streaming.h"
#include "PathFind.h" #include "PathFind.h"
#include "Wanted.h" #include "Wanted.h"
@ -423,6 +425,7 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
{ {
CMouseControllerState state; CMouseControllerState state;
#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil ) if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse(); _InputInitialiseMouse();
@ -432,7 +435,6 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
devCaps.dwSize = sizeof(DIDEVCAPS); devCaps.dwSize = sizeof(DIDEVCAPS);
PSGLOBAL(mouse)->GetCapabilities(&devCaps); PSGLOBAL(mouse)->GetCapabilities(&devCaps);
switch ( devCaps.dwButtons ) switch ( devCaps.dwButtons )
{ {
case 3: case 3:
@ -456,6 +458,19 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
state.WHEELUP = true; state.WHEELUP = true;
} }
} }
#else
// It seems there is no way to get number of buttons on mouse, so assign all buttons if we have mouse.
double xpos = 1.0f, ypos;
glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos);
if (xpos != NULL) {
state.MMB = true;
state.RMB = true;
state.LMB = true;
state.WHEELDN = true;
state.WHEELUP = true;
}
#endif
return state; return state;
} }
@ -464,6 +479,7 @@ void CPad::UpdateMouse()
{ {
if ( IsForegroundApp() ) if ( IsForegroundApp() )
{ {
#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil ) if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse(); _InputInitialiseMouse();
@ -500,6 +516,44 @@ void CPad::UpdateMouse()
OldMouseControllerState = NewMouseControllerState; OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState; NewMouseControllerState = PCTempMouseControllerState;
} }
#else
double xpos = 1.0f, ypos;
glfwGetCursorPos(PSGLOBAL(window), &xpos, &ypos);
if (xpos == NULL)
return;
int32 signX = 1;
int32 signy = 1;
if (!FrontEndMenuManager.m_bMenuActive)
{
if (MousePointerStateHelper.bInvertVertically)
signy = -1;
if (MousePointerStateHelper.bInvertHorizontally)
signX = -1;
}
PCTempMouseControllerState.Clear();
PCTempMouseControllerState.x = (float)(signX * (xpos - PSGLOBAL(lastMousePos.x)));
PCTempMouseControllerState.y = (float)(signy * (ypos - PSGLOBAL(lastMousePos.y)));
PCTempMouseControllerState.LMB = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_LEFT);
PCTempMouseControllerState.RMB = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_RIGHT);
PCTempMouseControllerState.MMB = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_MIDDLE);
PCTempMouseControllerState.MXB1 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_4);
PCTempMouseControllerState.MXB2 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_5);
PSGLOBAL(lastMousePos.x) = xpos;
PSGLOBAL(lastMousePos.y) = ypos;
if (PSGLOBAL(mouseWheel) > 0)
PCTempMouseControllerState.WHEELUP = 1;
else if (PSGLOBAL(mouseWheel) < 0)
PCTempMouseControllerState.WHEELDN = 1;
OldMouseControllerState = NewMouseControllerState;
NewMouseControllerState = PCTempMouseControllerState;
#endif
} }
} }

View File

@ -11,11 +11,11 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#ifdef WITHWINDOWS #if defined _WIN32 && defined WITHWINDOWS
#include <windows.h> #include <windows.h>
#endif #endif
#ifdef WITHD3D #if defined _WIN32 && defined WITHD3D
#include <windows.h> #include <windows.h>
#include <d3d8types.h> #include <d3d8types.h>
#endif #endif

View File

@ -200,7 +200,7 @@ enum Config {
//#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2 //#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2
// Pad // Pad
#define XINPUT // #define XINPUT
#define KANGAROO_CHEAT #define KANGAROO_CHEAT
#define REGISTER_START_BUTTON #define REGISTER_START_BUTTON

View File

@ -1,11 +1,10 @@
#define WITHWINDOWS
#include "common.h" #include "common.h"
#include "patcher.h" #include "patcher.h"
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <windows.h>
StaticPatcher *StaticPatcher::ms_head; StaticPatcher *StaticPatcher::ms_head;
StaticPatcher::StaticPatcher(Patcher func) StaticPatcher::StaticPatcher(Patcher func)

View File

@ -460,13 +460,17 @@ RwBool RwRenderStateSet(RwRenderState state, void *value)
} }
} }
static EngineOpenParams openParams;
// WARNING: unused parameters // WARNING: unused parameters
RwBool RwEngineInit(RwMemoryFunctions *memFuncs, RwUInt32 initFlags, RwUInt32 resArenaSize) { Engine::init(); return true; } RwBool RwEngineInit(RwMemoryFunctions *memFuncs, RwUInt32 initFlags, RwUInt32 resArenaSize) { Engine::init(); return true; }
// TODO: this is platform dependent // TODO: this is platform dependent
RwBool RwEngineOpen(RwEngineOpenParams *initParams) { RwBool RwEngineOpen(RwEngineOpenParams *initParams) {
#if defined RW_D3D9 || defined RWLIBS
static EngineOpenParams openParams;
openParams.window = (HWND)initParams->displayID; openParams.window = (HWND)initParams->displayID;
#else
extern EngineOpenParams openParams;
openParams.window = (GLFWwindow**)initParams->displayID;
#endif
return Engine::open(&openParams); return Engine::open(&openParams);
} }
RwBool RwEngineStart(void) { RwBool RwEngineStart(void) {

View File

@ -1,4 +1,6 @@
#if defined RW_D3D9 || defined RWLIBS
#define WITHD3D #define WITHD3D
#endif
#include "common.h" #include "common.h"
#include "Timecycle.h" #include "Timecycle.h"

View File

@ -2,7 +2,7 @@
#pragma warning( disable : 4005) #pragma warning( disable : 4005)
#pragma warning( pop ) #pragma warning( pop )
#include "common.h" #include "common.h"
#include "win.h" #include "crossplatform.h"
#include "Timer.h" #include "Timer.h"
#ifdef GTA_PC #ifdef GTA_PC

View File

@ -127,6 +127,38 @@ CTxdStore::RemoveRefWithoutDelete(int slot)
GetSlot(slot)->refCount--; GetSlot(slot)->refCount--;
} }
#ifdef RW_GL3
rw::Raster*
convertTexRaster(rw::Raster* ras)
{
rw::Image* img = ras->toImage();
// ras->destroy();
img->unindex();
ras = rw::Raster::createFromImage(img);
img->destroy();
return ras;
}
void
convertTxd(rw::TexDictionary* txd)
{
rw::Texture* tex;
FORLIST(lnk, txd->textures) {
tex = rw::Texture::fromDict(lnk);
rw::Raster* ras = tex->raster;
if (ras && ras->platform != rw::platform) {
if (!(ras->platform == rw::PLATFORM_D3D8 && rw::platform == rw::PLATFORM_D3D9 ||
ras->platform == rw::PLATFORM_D3D9 && rw::platform == rw::PLATFORM_D3D8)) {
tex->raster = convertTexRaster(ras);
ras->destroy();
}
}
tex->setFilter(rw::Texture::LINEAR);
}
}
#endif
bool bool
CTxdStore::LoadTxd(int slot, RwStream *stream) CTxdStore::LoadTxd(int slot, RwStream *stream)
{ {
@ -134,6 +166,9 @@ CTxdStore::LoadTxd(int slot, RwStream *stream)
if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){ if(RwStreamFindChunk(stream, rwID_TEXDICTIONARY, nil, nil)){
def->texDict = RwTexDictionaryGtaStreamRead(stream); def->texDict = RwTexDictionaryGtaStreamRead(stream);
#ifdef RW_GL3
convertTxd(def->texDict);
#endif
return def->texDict != nil; return def->texDict != nil;
} }
printf("Failed to load TXD\n"); printf("Failed to load TXD\n");

View File

@ -1,5 +1,61 @@
#include <time.h> #include <time.h>
// This is the common include for platform/renderer specific skeletons(glfw, win etc.) and cross platform things (like Windows directories wrapper, platform specific global arrays etc.)
// This only has <windef.h> as Win header.
#ifdef _WIN32
#include "win.h"
#endif
#ifdef RW_GL3
typedef struct
{
GLFWwindow* window;
RwBool fullScreen;
RwV2d lastMousePos;
double mouseWheel; // glfw doesn't cache it
int8 joy1id;
int8 joy2id;
}
psGlobalType;
#define PSGLOBAL(var) (((psGlobalType *)(RsGlobal.ps))->var)
void CapturePad(RwInt32 padID);
void joysChangeCB(int jid, int event);
#endif
enum eGameState
{
GS_START_UP = 0,
GS_INIT_LOGO_MPEG,
GS_LOGO_MPEG,
GS_INIT_INTRO_MPEG,
GS_INTRO_MPEG,
GS_INIT_ONCE,
GS_INIT_FRONTEND,
GS_FRONTEND,
GS_INIT_PLAYING_GAME,
GS_PLAYING_GAME,
#ifndef MASTER
GS_ANIMVIEWER,
#endif
};
extern RwUInt32 gGameState;
RwBool IsForegroundApp();
void InitialiseLanguage();
RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode);
RwChar** _psGetVideoModeList();
RwInt32 _psGetNumVideModes();
void _psSelectScreenVM(RwInt32 videoMode);
void HandleExit();
void _InputTranslateShiftKeyUpDown(RsKeyCodes* rs);
// Mostly wrappers around Windows functions
#ifndef MAX_PATH #ifndef MAX_PATH
#if !defined _WIN32 || defined __MINGW32__ #if !defined _WIN32 || defined __MINGW32__
#define MAX_PATH PATH_MAX #define MAX_PATH PATH_MAX
@ -8,8 +64,6 @@
#endif #endif
#endif #endif
// Mostly wrappers around Windows functions
// TODO: Remove USEALTERNATIVEWINFUNCS and don't use it anywhere when re3 becomes fully cross-platform, this is for testing // TODO: Remove USEALTERNATIVEWINFUNCS and don't use it anywhere when re3 becomes fully cross-platform, this is for testing
// Codes compatible with Windows and Linux // Codes compatible with Windows and Linux
#if defined USEALTERNATIVEWINFUNCS || !defined _WIN32 || defined __MINGW32__ #if defined USEALTERNATIVEWINFUNCS || !defined _WIN32 || defined __MINGW32__
@ -27,18 +81,13 @@ struct SYSTEMTIME {
uint16 wMilliseconds; uint16 wMilliseconds;
}; };
#define GetLocalTime GetLocalTime_CP
#else
#include <Windows.h>
#endif
void GetLocalTime_CP(SYSTEMTIME* out); void GetLocalTime_CP(SYSTEMTIME* out);
#define GetLocalTime GetLocalTime_CP
#define OutputDebugString(s) re3_debug("[DBG-2]: " s "\n")
#endif
// Only runs on GNU/POSIX/etc. // Only runs on GNU/POSIX/etc.
#if !defined _WIN32 || defined __MINGW32__ #if !defined _WIN32 || defined __MINGW32__
#define OutputDebugString(s) re3_debug("[DBG-2]: " s "\n")
#include <iostream> #include <iostream>
#include <dirent.h> #include <dirent.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -1,13 +1,14 @@
#include "rwcore.h"
#include "skeleton.h"
#include "events.h"
#include "common.h" #include "common.h"
#include "Pad.h" #include "Pad.h"
#include "ControllerConfig.h" #include "ControllerConfig.h"
#include "Frontend.h" #include "Frontend.h"
#include "Camera.h" #include "Camera.h"
#include "rwcore.h"
#include "skeleton.h"
#include "events.h"
/* /*
***************************************************************************** *****************************************************************************
*/ */

1651
src/skel/glfw/glfw.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -293,7 +293,7 @@ RwBool
RsRwInitialise(void *displayID) RsRwInitialise(void *displayID)
{ {
RwEngineOpenParams openParams; RwEngineOpenParams openParams;
/* /*
* Start RenderWare... * Start RenderWare...
*/ */

View File

@ -1,3 +1,5 @@
#if defined RW_D3D9 || defined RWLIBS
#define _WIN32_WINDOWS 0x0500 #define _WIN32_WINDOWS 0x0500
#define WINVER 0x0500 #define WINVER 0x0500
#define DIRECTINPUT_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800
@ -40,7 +42,7 @@
#include "resource.h" #include "resource.h"
#include "skeleton.h" #include "skeleton.h"
#include "platform.h" #include "platform.h"
#include "win.h" #include "crossplatform.h"
#define MAX_SUBSYSTEMS (16) #define MAX_SUBSYSTEMS (16)
@ -3033,3 +3035,4 @@ int strcasecmp(const char *str1, const char *str2)
return _strcmpi(str1, str2); return _strcmpi(str1, str2);
} }
#endif #endif
#endif

View File

@ -1,3 +1,6 @@
// DON'T include directly. crossplatform.h includes this if you're on Windows.
#if (!defined(_PLATFORM_WIN_H)) #if (!defined(_PLATFORM_WIN_H))
#define _PLATFORM_WIN_H #define _PLATFORM_WIN_H
@ -10,23 +13,6 @@
#include <windef.h> #include <windef.h>
#endif #endif
enum eGameState
{
GS_START_UP = 0,
GS_INIT_LOGO_MPEG,
GS_LOGO_MPEG,
GS_INIT_INTRO_MPEG,
GS_INTRO_MPEG,
GS_INIT_ONCE,
GS_INIT_FRONTEND,
GS_FRONTEND,
GS_INIT_PLAYING_GAME,
GS_PLAYING_GAME,
#ifndef MASTER
GS_ANIMVIEWER,
#endif
};
enum eWinVersion enum eWinVersion
{ {
OS_WIN95 = 0, OS_WIN95 = 0,
@ -38,8 +24,6 @@ enum eWinVersion
extern DWORD _dwOperatingSystemVersion; extern DWORD _dwOperatingSystemVersion;
extern RwUInt32 gGameState;
#ifdef __DINPUT_INCLUDED__ #ifdef __DINPUT_INCLUDED__
/* platform specfic global data */ /* platform specfic global data */
typedef struct typedef struct
@ -101,12 +85,10 @@ extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef __DINPUT_INCLUDED__
extern LRESULT CALLBACK extern LRESULT CALLBACK
MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam); MainWndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam);
RwBool IsForegroundApp();
#ifdef __DINPUT_INCLUDED__
HRESULT _InputInitialise(); HRESULT _InputInitialise();
HRESULT _InputInitialiseMouse(); HRESULT _InputInitialiseMouse();
HRESULT CapturePad(RwInt32 padID); HRESULT CapturePad(RwInt32 padID);
@ -117,26 +99,15 @@ HRESULT _InputGetMouseState(DIMOUSESTATE2 *state);
void _InputShutdown(); void _InputShutdown();
BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ); BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext );
BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key); BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key);
void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);;
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown); BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown);
BOOL _InputIsExtended(INT flag); BOOL _InputIsExtended(INT flag);
#endif #endif
void InitialiseLanguage();
RwBool _psSetVideoMode(RwInt32 subSystem, RwInt32 videoMode);
void CenterVideo(void); void CenterVideo(void);
void CloseClip(void); void CloseClip(void);
RwChar **_psGetVideoModeList();
RwInt32 _psGetNumVideModes();
void _psSelectScreenVM(RwInt32 videoMode);
void HandleExit();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
extern DWORD _dwOperatingSystemVersion;
#endif /* (!defined(_PLATFORM_WIN_H)) */ #endif /* (!defined(_PLATFORM_WIN_H)) */

View File

@ -1,6 +1,3 @@
#define DIRECTINPUT_VERSION 0x0800
#include "dinput.h"
#include "common.h" #include "common.h"
#include "Messages.h" #include "Messages.h"

View File

@ -707,13 +707,13 @@ CBoat::Render()
((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->SetVehicleColour(m_currentColour1, m_currentColour2); ((CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->SetVehicleColour(m_currentColour1, m_currentColour2);
if (!CVehicle::bWheelsOnlyCheat) if (!CVehicle::bWheelsOnlyCheat)
CEntity::Render(); CEntity::Render();
KeepWaterOutVertices[0].color = -1; KeepWaterOutVertices[0].setColor(255, 255, 255, 255);
KeepWaterOutIndices[0] = 0; KeepWaterOutIndices[0] = 0;
KeepWaterOutVertices[1].color = -1; KeepWaterOutVertices[1].setColor(255, 255, 255, 255);
KeepWaterOutIndices[1] = 2; KeepWaterOutIndices[1] = 2;
KeepWaterOutVertices[2].color = -1; KeepWaterOutVertices[2].setColor(255, 255, 255, 255);
KeepWaterOutIndices[2] = 1; KeepWaterOutIndices[2] = 1;
KeepWaterOutVertices[3].color = -1; KeepWaterOutVertices[3].setColor(255, 255, 255, 255);
KeepWaterOutIndices[3] = 1; KeepWaterOutIndices[3] = 1;
KeepWaterOutIndices[4] = 2; KeepWaterOutIndices[4] = 2;
KeepWaterOutIndices[5] = 3; KeepWaterOutIndices[5] = 3;