1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 17:30:00 +00:00

sync with upstream

This commit is contained in:
Nikolay Korolev 2020-04-27 00:55:22 +03:00
commit a38a867cc5
22 changed files with 2000 additions and 107 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,8 +124,8 @@ 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"
@ -116,6 +133,10 @@ project "re3"
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

@ -1,5 +1,9 @@
#pragma once #pragma once
#if defined RW_D3D9 || defined RWLIBS
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#endif
// based on x-gtasa // based on x-gtasa
@ -96,6 +100,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:
@ -112,11 +126,12 @@ public:
}; };
bool m_bFirstCapture; bool m_bFirstCapture;
#ifdef __DINPUT_INCLUDED__ #if defined RW_GL3
GlfwJoyState m_OldState;
GlfwJoyState m_NewState;
#else
DIJOYSTATE2 m_OldState; DIJOYSTATE2 m_OldState;
DIJOYSTATE2 m_NewState; DIJOYSTATE2 m_NewState;
#else
uint32 ___padd[0x110 / 4 * 2];
#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 +208,8 @@ public:
void ResetSettingOrder (e_ControllerAction action); void ResetSettingOrder (e_ControllerAction action);
}; };
#ifndef RW_GL3
VALIDATE_SIZE(CControllerConfigManager, 0x143C); VALIDATE_SIZE(CControllerConfigManager, 0x143C);
#endif
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;
@ -4495,12 +4501,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"
@ -455,6 +457,7 @@ CMouseControllerState CMousePointerStateHelper::GetMouseSetUp()
{ {
CMouseControllerState state; CMouseControllerState state;
#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil ) if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse(); _InputInitialiseMouse();
@ -464,7 +467,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:
@ -488,6 +490,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;
} }
@ -496,6 +511,7 @@ void CPad::UpdateMouse()
{ {
if ( IsForegroundApp() ) if ( IsForegroundApp() )
{ {
#if defined RW_D3D9 || defined RWLIBS
if ( PSGLOBAL(mouse) == nil ) if ( PSGLOBAL(mouse) == nil )
_InputInitialiseMouse(); _InputInitialiseMouse();
@ -532,6 +548,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
@ -31,6 +31,7 @@
#define HIERNODEID(hier, i) ((hier)->nodeInfo[i].id) #define HIERNODEID(hier, i) ((hier)->nodeInfo[i].id)
#define HANIMFRAMES(anim) ((anim)->keyframes) #define HANIMFRAMES(anim) ((anim)->keyframes)
#else #else
#define RWHALFPIXEL // always d3d
#define STREAMPOS(str) ((str)->Type.memory.position) #define STREAMPOS(str) ((str)->Type.memory.position)
#define STREAMFILE(str) ((str)->Type.file.fpFile) #define STREAMFILE(str) ((str)->Type.file.fpFile)
#define HIERNODEINFO(hier) ((hier)->pNodeInfo) #define HIERNODEINFO(hier) ((hier)->pNodeInfo)
@ -38,6 +39,12 @@
#define HANIMFRAMES(anim) ((anim)->pFrames) #define HANIMFRAMES(anim) ((anim)->pFrames)
#endif #endif
#ifdef RWHALFPIXEL
#define HALFPX (0.5f)
#else
#define HALFPX (0.0f)
#endif
#define rwVENDORID_ROCKSTAR 0x0253F2 #define rwVENDORID_ROCKSTAR 0x0253F2
// Get rid of bullshit windows definitions, we're not running on an 8086 // Get rid of bullshit windows definitions, we're not running on an 8086
@ -88,13 +95,6 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
return w>>p & (1<<s)-1; return w>>p & (1<<s)-1;
} }
#ifndef RWLIBS
// little hack
extern void **rwengine;
#define RwEngineInstance (*rwengine)
#endif
#include "skeleton.h" #include "skeleton.h"
#include "Draw.h" #include "Draw.h"

View file

@ -200,7 +200,9 @@ enum Config {
//#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2 //#define PS2_ALTERNATIVE_CARSPLASH // unused on PS2
// Pad // Pad
#ifndef RW_GL3
#define XINPUT #define XINPUT
#endif
#define KANGAROO_CHEAT #define KANGAROO_CHEAT
#define ALLCARSHELI_CHEAT #define ALLCARSHELI_CHEAT
#define ALT_DODO_CHEAT #define ALT_DODO_CHEAT

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

@ -1068,13 +1068,13 @@ drawArrow(RwRect r, int direction, int style)
int top = r.y; int top = r.y;
int bottom = r.y+r.h; int bottom = r.y+r.h;
float umin = 0.5f / width; float umin = HALFPX / width;
float vmin = 0.5f / height; float vmin = HALFPX / height;
float umax = (width + 0.5f) / width; float umax = (width + HALFPX) / width;
float vmax = (height + 0.5f) / height; float vmax = (height + HALFPX) / height;
if(direction < 0){ if(direction < 0){
vmin = (height - 0.5f) / height; vmin = (height - HALFPX) / height;
vmax = -0.5f / height; vmax = -HALFPX / height;
} }
if(style){ if(style){
@ -1167,10 +1167,10 @@ drawMouse(void)
float h = RwRasterGetHeight(cursor); float h = RwRasterGetHeight(cursor);
float recipz = 1.0f/RwCameraGetNearClipPlane(cam); float recipz = 1.0f/RwCameraGetNearClipPlane(cam);
float umin = 0.5f / w; float umin = HALFPX / w;
float vmin = 0.5f / h; float vmin = HALFPX / h;
float umax = (w + 0.5f) / w; float umax = (w + HALFPX) / w;
float vmax = (h + 0.5f) / h; float vmax = (h + HALFPX) / h;
vert = vertices; vert = vertices;
RwIm2DVertexSetScreenX(vert, x); RwIm2DVertexSetScreenX(vert, x);

View file

@ -290,9 +290,29 @@ RwTextureAddressMode RwTextureGetAddressingV(const RwTexture *texture);
// TODO // TODO
void _rwD3D8TexDictionaryEnableRasterFormatConversion(bool enable) { } void _rwD3D8TexDictionaryEnableRasterFormatConversion(bool enable) { }
static rw::Raster*
ConvertTexRaster(rw::Raster *ras)
{
using namespace rw;
Image *img = ras->toImage();
ras->destroy();
img->unindex();
ras = Raster::createFromImage(img);
img->destroy();
return ras;
}
// hack for reading native textures // hack for reading native textures
RwBool rwNativeTextureHackRead(RwStream *stream, RwTexture **tex, RwInt32 size) RwBool rwNativeTextureHackRead(RwStream *stream, RwTexture **tex, RwInt32 size)
{ *tex = Texture::streamReadNative(stream); return *tex != nil; } {
*tex = Texture::streamReadNative(stream);
#ifdef RW_GL3
if(strcmp((*tex)->name, "copnu") == 0)
tex = tex;
(*tex)->raster = ConvertTexRaster((*tex)->raster);
#endif
return *tex != nil;
}
@ -460,13 +480,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

@ -58,13 +58,13 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect)
float zero, xmax, ymax; float zero, xmax, ymax;
if(RwRasterGetDepth(RwCameraGetRaster(cam)) == 16){ if(RwRasterGetDepth(RwCameraGetRaster(cam)) == 16){
zero = 0.5f; zero = HALFPX;
xmax = rect->w + 0.5f; xmax = rect->w + HALFPX;
ymax = rect->h + 0.5f; ymax = rect->h + HALFPX;
}else{ }else{
zero = -0.5f; zero = -HALFPX;
xmax = rect->w - 0.5f; xmax = rect->w - HALFPX;
ymax = rect->h - 0.5f; ymax = rect->h - HALFPX;
} }
RwIm2DVertexSetScreenX(&Vertex[0], zero); RwIm2DVertexSetScreenX(&Vertex[0], zero);

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

@ -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"
/* /*
***************************************************************************** *****************************************************************************
*/ */

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

File diff suppressed because it is too large Load diff

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)
@ -3038,3 +3040,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
@ -79,7 +63,6 @@ struct tJoy
bool m_bInitialised; bool m_bInitialised;
bool m_bHasAxisZ; bool m_bHasAxisZ;
bool m_bHasAxisR; bool m_bHasAxisR;
char _pad0;
int m_nVendorID; int m_nVendorID;
int m_nProductID; int m_nProductID;
}; };
@ -101,12 +84,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 +98,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; RwIm3DVertexSetRGBA(&KeepWaterOutVertices[0], 255, 255, 255, 255);
KeepWaterOutIndices[0] = 0; KeepWaterOutIndices[0] = 0;
KeepWaterOutVertices[1].color = -1; RwIm3DVertexSetRGBA(&KeepWaterOutVertices[1], 255, 255, 255, 255);
KeepWaterOutIndices[1] = 2; KeepWaterOutIndices[1] = 2;
KeepWaterOutVertices[2].color = -1; RwIm3DVertexSetRGBA(&KeepWaterOutVertices[2], 255, 255, 255, 255);
KeepWaterOutIndices[2] = 1; KeepWaterOutIndices[2] = 1;
KeepWaterOutVertices[3].color = -1; RwIm3DVertexSetRGBA(&KeepWaterOutVertices[3], 255, 255, 255, 255);
KeepWaterOutIndices[3] = 1; KeepWaterOutIndices[3] = 1;
KeepWaterOutIndices[4] = 2; KeepWaterOutIndices[4] = 2;
KeepWaterOutIndices[5] = 3; KeepWaterOutIndices[5] = 3;