chore: add .clang_format for consistent code formatting
This commit is contained in:
1 parent
67332bbc79
commit
6e6440f0f3
25 files changed
+749
-789
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
# Format Style Options - Created with Clang Power Tools
|
||||||
|
---
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignConsecutiveMacros: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
ColumnLimit: 150
|
||||||
|
EmptyLineBeforeAccessModifier: Never
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentWidth: 4
|
||||||
|
NamespaceIndentation: All
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "4J_Input.h"
|
#include "4J_Input.h"
|
||||||
#include "INP_Main.h"
|
|
||||||
#include "INP_Keyboard.h"
|
#include "INP_Keyboard.h"
|
||||||
|
#include "INP_Main.h"
|
||||||
|
|
||||||
C_4JInput InputManager;
|
C_4JInput InputManager;
|
||||||
CKeyboard InternalKeyboard;
|
CKeyboard InternalKeyboard;
|
||||||
@@ -80,7 +80,7 @@ void C_4JInput::SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs)
|
|||||||
InternalInputManager.SetKeyRepeatRate(fRepeatDelaySecs, fRepeatRateSecs);
|
InternalInputManager.SetKeyRepeatRate(fRepeatDelaySecs, fRepeatRateSecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_4JInput::SetDebugSequence(const char* chSequenceA, int(*Func)(LPVOID), LPVOID lpParam)
|
void C_4JInput::SetDebugSequence(const char *chSequenceA, int (*Func)(LPVOID), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
InternalInputManager.SetDebugSequence(chSequenceA, Func, lpParam);
|
InternalInputManager.SetDebugSequence(chSequenceA, Func, lpParam);
|
||||||
}
|
}
|
||||||
@@ -130,24 +130,24 @@ void C_4JInput::SetMenuDisplayed(int iPad, bool bVal)
|
|||||||
InternalInputManager.SetMenuDisplayed(iPad, bVal);
|
InternalInputManager.SetMenuDisplayed(iPad, bVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
EKeyboardResult C_4JInput::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int(*Func)(LPVOID, const bool), LPVOID lpParam, C_4JInput::EKeyboardMode eMode)
|
EKeyboardResult C_4JInput::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
||||||
|
C_4JInput::EKeyboardMode eMode)
|
||||||
{
|
{
|
||||||
return InternalKeyboard.RequestKeyboard(Title, Text, dwPad, uiMaxChars, Func, lpParam, eMode);
|
return InternalKeyboard.RequestKeyboard(Title, Text, dwPad, uiMaxChars, Func, lpParam, eMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_4JInput::GetText(uint16_t* UTF16String)
|
void C_4JInput::GetText(uint16_t *UTF16String)
|
||||||
{
|
{
|
||||||
InternalKeyboard.GetText(UTF16String);
|
InternalKeyboard.GetText(UTF16String);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool C_4JInput::VerifyStrings(WCHAR **pwStringA, int iStringC, int (*Func)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID lpParam)
|
||||||
bool C_4JInput::VerifyStrings(WCHAR** pwStringA, int iStringC, int(*Func)(LPVOID, STRING_VERIFY_RESPONSE*), LPVOID lpParam)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_4JInput::CancelQueuedVerifyStrings(int(*Func)(LPVOID, STRING_VERIFY_RESPONSE*), LPVOID lpParam) {}
|
void C_4JInput::CancelQueuedVerifyStrings(int (*Func)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID lpParam) {}
|
||||||
|
|
||||||
void C_4JInput::CancelAllVerifyInProgress(void) {}
|
void C_4JInput::CancelAllVerifyInProgress(void) {}
|
||||||
|
|
||||||
//bool C_4JInput::InputDetected(DWORD dwUserIndex,WCHAR *pwchInput) {}
|
// bool C_4JInput::InputDetected(DWORD dwUserIndex,WCHAR *pwchInput) {}
|
||||||
@@ -12,16 +12,13 @@ void CForceFeedback::Initialise(int iInputStateC, unsigned char ucMapC, unsigned
|
|||||||
m_unkBool = 0;
|
m_unkBool = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CForceFeedback::RumbleEnable(int iQuadrant, bool bRumbleEnabled)
|
void CForceFeedback::RumbleEnable(int iQuadrant, bool bRumbleEnabled) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CForceFeedback::CreateEffect(void)
|
void CForceFeedback::CreateEffect(void)
|
||||||
{
|
{
|
||||||
assert(m_EffectC<MAX_EFFECTS);
|
assert(m_EffectC < MAX_EFFECTS);
|
||||||
|
|
||||||
FF_EFFECT* pEffect = &m_Effects[m_EffectC];
|
FF_EFFECT *pEffect = &m_Effects[m_EffectC];
|
||||||
pEffect->m_uiDurationMs = 5;
|
pEffect->m_uiDurationMs = 5;
|
||||||
pEffect->m_uiMagnitude = 500;
|
pEffect->m_uiMagnitude = 500;
|
||||||
pEffect->m_uiEffectType = 0;
|
pEffect->m_uiEffectType = 0;
|
||||||
@@ -33,7 +30,7 @@ void CForceFeedback::CreateEffect(void)
|
|||||||
|
|
||||||
void CForceFeedback::AddEffectInstance(unsigned int uiEffect)
|
void CForceFeedback::AddEffectInstance(unsigned int uiEffect)
|
||||||
{
|
{
|
||||||
FF_EFFECT_INSTANCE* pEffectInst = new FF_EFFECT_INSTANCE();
|
FF_EFFECT_INSTANCE *pEffectInst = new FF_EFFECT_INSTANCE();
|
||||||
pEffectInst->m_Effect = &m_Effects[uiEffect];
|
pEffectInst->m_Effect = &m_Effects[uiEffect];
|
||||||
pEffectInst->m_uiInst = 0;
|
pEffectInst->m_uiInst = 0;
|
||||||
|
|
||||||
@@ -43,8 +40,8 @@ void CForceFeedback::AddEffectInstance(unsigned int uiEffect)
|
|||||||
void CForceFeedback::SetEffectInstanceState(unsigned int uiEffectInstance, unsigned int uiState)
|
void CForceFeedback::SetEffectInstanceState(unsigned int uiEffectInstance, unsigned int uiState)
|
||||||
{
|
{
|
||||||
int iCount = 0;
|
int iCount = 0;
|
||||||
LinkedList::_LL_NODE* pNode;
|
LinkedList::_LL_NODE *pNode;
|
||||||
for (pNode = m_EffectList.m_Head; ; pNode = pNode->m_Next)
|
for (pNode = m_EffectList.m_Head;; pNode = pNode->m_Next)
|
||||||
{
|
{
|
||||||
if ((iCount++) == uiEffectInstance)
|
if ((iCount++) == uiEffectInstance)
|
||||||
break;
|
break;
|
||||||
@@ -52,19 +49,13 @@ void CForceFeedback::SetEffectInstanceState(unsigned int uiEffectInstance, unsig
|
|||||||
pNode->GetDataAs<FF_EFFECT_INSTANCE>()->m_bIsActive = true;
|
pNode->GetDataAs<FF_EFFECT_INSTANCE>()->m_bIsActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CForceFeedback::ProcessEventInstance(FF_EFFECT_INSTANCE* pEffectInst)
|
void CForceFeedback::ProcessEventInstance(FF_EFFECT_INSTANCE *pEffectInst) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void CForceFeedback::PauseEventInstance(FF_EFFECT_INSTANCE *pEffectInst) {}
|
||||||
|
|
||||||
void CForceFeedback::PauseEventInstance(FF_EFFECT_INSTANCE* pEffectInst)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CForceFeedback::AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rightMotorSpeed, float fSeconds)
|
void CForceFeedback::AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rightMotorSpeed, float fSeconds)
|
||||||
{
|
{
|
||||||
RUMBLE_EFFECT* pRumble = new RUMBLE_EFFECT();
|
RUMBLE_EFFECT *pRumble = new RUMBLE_EFFECT();
|
||||||
|
|
||||||
LARGE_INTEGER qwCurrentTime;
|
LARGE_INTEGER qwCurrentTime;
|
||||||
QueryPerformanceCounter(&qwCurrentTime);
|
QueryPerformanceCounter(&qwCurrentTime);
|
||||||
@@ -79,7 +70,7 @@ void CForceFeedback::AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rig
|
|||||||
|
|
||||||
void CForceFeedback::Tick(void)
|
void CForceFeedback::Tick(void)
|
||||||
{
|
{
|
||||||
for (LinkedList::_LL_NODE* pEffectNode = m_EffectList.m_Head; pEffectNode; pEffectNode = pEffectNode->m_Next)
|
for (LinkedList::_LL_NODE *pEffectNode = m_EffectList.m_Head; pEffectNode; pEffectNode = pEffectNode->m_Next)
|
||||||
{
|
{
|
||||||
if (pEffectNode->GetDataAs<FF_EFFECT_INSTANCE>()->m_bIsActive)
|
if (pEffectNode->GetDataAs<FF_EFFECT_INSTANCE>()->m_bIsActive)
|
||||||
{
|
{
|
||||||
@@ -90,12 +81,12 @@ void CForceFeedback::Tick(void)
|
|||||||
LARGE_INTEGER qwCurrentTime;
|
LARGE_INTEGER qwCurrentTime;
|
||||||
QueryPerformanceCounter(&qwCurrentTime);
|
QueryPerformanceCounter(&qwCurrentTime);
|
||||||
|
|
||||||
LinkedList::_LL_NODE* pRumbleNode = m_RumbleList.m_Head;
|
LinkedList::_LL_NODE *pRumbleNode = m_RumbleList.m_Head;
|
||||||
while (pRumbleNode)
|
while (pRumbleNode)
|
||||||
{
|
{
|
||||||
if (pRumbleNode->GetDataAs<RUMBLE_EFFECT>()->m_TimeLeft <= qwCurrentTime.QuadPart)
|
if (pRumbleNode->GetDataAs<RUMBLE_EFFECT>()->m_TimeLeft <= qwCurrentTime.QuadPart)
|
||||||
{
|
{
|
||||||
RUMBLE_EFFECT* pRumble = pRumbleNode->GetDataAs<RUMBLE_EFFECT>();
|
RUMBLE_EFFECT *pRumble = pRumbleNode->GetDataAs<RUMBLE_EFFECT>();
|
||||||
|
|
||||||
pRumble->m_RumbleData.wLeftMotorSpeed = 0;
|
pRumble->m_RumbleData.wLeftMotorSpeed = 0;
|
||||||
pRumble->m_RumbleData.wRightMotorSpeed = 0;
|
pRumble->m_RumbleData.wRightMotorSpeed = 0;
|
||||||
@@ -104,7 +95,7 @@ void CForceFeedback::Tick(void)
|
|||||||
|
|
||||||
m_RumbleList.RemoveNode(pRumbleNode);
|
m_RumbleList.RemoveNode(pRumbleNode);
|
||||||
|
|
||||||
LinkedList::_LL_NODE* pTemp = pRumbleNode;
|
LinkedList::_LL_NODE *pTemp = pRumbleNode;
|
||||||
pRumbleNode = pRumbleNode->m_Next;
|
pRumbleNode = pRumbleNode->m_Next;
|
||||||
|
|
||||||
delete pTemp->m_pvData;
|
delete pTemp->m_pvData;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
class CForceFeedback
|
class CForceFeedback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum FF_PARAMS
|
enum FF_PARAMS
|
||||||
{
|
{
|
||||||
FF_PARAMS_RAMP,
|
FF_PARAMS_RAMP,
|
||||||
@@ -36,7 +35,7 @@ public:
|
|||||||
{
|
{
|
||||||
bool m_bIsActive;
|
bool m_bIsActive;
|
||||||
unsigned int m_uiInst;
|
unsigned int m_uiInst;
|
||||||
CForceFeedback::FF_EFFECT* m_Effect;
|
CForceFeedback::FF_EFFECT *m_Effect;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
|
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
|
||||||
@@ -45,15 +44,15 @@ public:
|
|||||||
void AddEffectInstance(unsigned int uiEffect);
|
void AddEffectInstance(unsigned int uiEffect);
|
||||||
void SetEffectInstanceState(unsigned int uiEffectInstance, unsigned int uiState);
|
void SetEffectInstanceState(unsigned int uiEffectInstance, unsigned int uiState);
|
||||||
|
|
||||||
void ProcessEventInstance(FF_EFFECT_INSTANCE* pEffectInst);
|
void ProcessEventInstance(FF_EFFECT_INSTANCE *pEffectInst);
|
||||||
void PauseEventInstance(FF_EFFECT_INSTANCE* pEffectInst);
|
void PauseEventInstance(FF_EFFECT_INSTANCE *pEffectInst);
|
||||||
|
|
||||||
void AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rightMotorSpeed, float fSeconds);
|
void AddRumble(unsigned int uiPad, WORD leftMotorSpeed, WORD rightMotorSpeed, float fSeconds);
|
||||||
|
|
||||||
void Tick(void);
|
void Tick(void);
|
||||||
|
|
||||||
LinkedList m_EffectList;
|
LinkedList m_EffectList;
|
||||||
FF_EFFECT* m_Effects;
|
FF_EFFECT *m_Effects;
|
||||||
int m_EffectC;
|
int m_EffectC;
|
||||||
LinkedList m_RumbleList;
|
LinkedList m_RumbleList;
|
||||||
float m_TicksPerSecond;
|
float m_TicksPerSecond;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
#include "INP_Keyboard.h"
|
#include "INP_Keyboard.h"
|
||||||
|
|
||||||
void CKeyboard::Tick(void)
|
void CKeyboard::Tick(void) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
||||||
|
C_4JInput::EKeyboardMode eMode)
|
||||||
EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int(*Func)(LPVOID, const bool), LPVOID lpParam, C_4JInput::EKeyboardMode eMode)
|
|
||||||
{
|
{
|
||||||
ClearGlobalText();
|
ClearGlobalText();
|
||||||
SeedEditBox();
|
SeedEditBox();
|
||||||
@@ -14,9 +12,9 @@ EKeyboardResult CKeyboard::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dw
|
|||||||
return EKeyboard_ResultAccept;
|
return EKeyboard_ResultAccept;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeyboard::GetText(uint16_t* UTF16String)
|
void CKeyboard::GetText(uint16_t *UTF16String)
|
||||||
{
|
{
|
||||||
uint16_t* keyString = GetGlobalText();
|
uint16_t *keyString = GetGlobalText();
|
||||||
for (unsigned int index = 0; keyString[index] && index < 0x200; index++)
|
for (unsigned int index = 0; keyString[index] && index < 0x200; index++)
|
||||||
{
|
{
|
||||||
UTF16String[index] = keyString[index];
|
UTF16String[index] = keyString[index];
|
||||||
|
|||||||
@@ -2,28 +2,25 @@
|
|||||||
#include "4J_Input.h"
|
#include "4J_Input.h"
|
||||||
|
|
||||||
void ClearGlobalText();
|
void ClearGlobalText();
|
||||||
uint16_t* GetGlobalText();
|
uint16_t *GetGlobalText();
|
||||||
void SeedEditBox();
|
void SeedEditBox();
|
||||||
|
|
||||||
class CKeyboard
|
class CKeyboard
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum EKeyboardProcessState
|
enum EKeyboardProcessState
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SKeyboardInfo
|
struct SKeyboardInfo
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void Tick(void);
|
void Tick(void);
|
||||||
|
|
||||||
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int(*Func)(LPVOID, const bool), LPVOID lpParam, C_4JInput::EKeyboardMode eMode);
|
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int (*Func)(LPVOID, const bool), LPVOID lpParam,
|
||||||
void GetText(uint16_t* UTF16String);
|
C_4JInput::EKeyboardMode eMode);
|
||||||
|
void GetText(uint16_t *UTF16String);
|
||||||
|
|
||||||
BYTE gap0[0x68];
|
BYTE gap0[0x68];
|
||||||
};
|
};
|
||||||
@@ -22,9 +22,9 @@ CInput::CInput()
|
|||||||
|
|
||||||
void CInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC)
|
void CInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC)
|
||||||
{
|
{
|
||||||
assert(iInputStateC>0);
|
assert(iInputStateC > 0);
|
||||||
assert(ucMapC>0);
|
assert(ucMapC > 0);
|
||||||
assert(ucActionC>0);
|
assert(ucActionC > 0);
|
||||||
|
|
||||||
ZeroMemory(m_Joypads, sizeof(m_Joypads));
|
ZeroMemory(m_Joypads, sizeof(m_Joypads));
|
||||||
|
|
||||||
@@ -50,10 +50,10 @@ void CInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char uc
|
|||||||
m_Joypads[i].m_fSensitivity = 1.0f;
|
m_Joypads[i].m_fSensitivity = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_JoypadMap = (unsigned int**)operator new[](ucMapC * sizeof(int*));
|
m_JoypadMap = (unsigned int **)operator new[](ucMapC * sizeof(int *));
|
||||||
for (int i = 0; i < ucMapC; i++)
|
for (int i = 0; i < ucMapC; i++)
|
||||||
{
|
{
|
||||||
m_JoypadMap[i] = (unsigned int*)operator new[](ucActionC * sizeof(int));
|
m_JoypadMap[i] = (unsigned int *)operator new[](ucActionC * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ucJoypadMapC = ucMapC;
|
m_ucJoypadMapC = ucMapC;
|
||||||
@@ -71,9 +71,9 @@ void CInput::Tick(void)
|
|||||||
m_Keyboard.Tick();
|
m_Keyboard.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInput::SetJoypadValues(JOYPAD* pThisPad)
|
void CInput::SetJoypadValues(JOYPAD *pThisPad)
|
||||||
{
|
{
|
||||||
XINPUT_GAMEPAD* pGamePad = &pThisPad->m_pInputStates[pThisPad->m_ucInputStateIndex].Gamepad;
|
XINPUT_GAMEPAD *pGamePad = &pThisPad->m_pInputStates[pThisPad->m_ucInputStateIndex].Gamepad;
|
||||||
|
|
||||||
if (pGamePad->bLeftTrigger > 0x7Fu)
|
if (pGamePad->bLeftTrigger > 0x7Fu)
|
||||||
{
|
{
|
||||||
@@ -255,16 +255,16 @@ void CInput::SetJoypadSensitivity(int iPad, float fSensitivity)
|
|||||||
|
|
||||||
void CInput::SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal)
|
void CInput::SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal)
|
||||||
{
|
{
|
||||||
assert(ucMap<m_ucJoypadMapC);
|
assert(ucMap < m_ucJoypadMapC);
|
||||||
assert(ucAction<m_ucJoypadMapActionC);
|
assert(ucAction < m_ucJoypadMapActionC);
|
||||||
|
|
||||||
m_JoypadMap[ucMap][ucAction] = uiActionVal;
|
m_JoypadMap[ucMap][ucAction] = uiActionVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CInput::GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction)
|
unsigned int CInput::GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction)
|
||||||
{
|
{
|
||||||
assert(ucMap<m_ucJoypadMapC);
|
assert(ucMap < m_ucJoypadMapC);
|
||||||
assert(ucAction<m_ucJoypadMapActionC);
|
assert(ucAction < m_ucJoypadMapActionC);
|
||||||
|
|
||||||
return m_JoypadMap[ucMap][ucAction];
|
return m_JoypadMap[ucMap][ucAction];
|
||||||
}
|
}
|
||||||
@@ -282,7 +282,7 @@ unsigned char CInput::GetJoypadMapVal(int iPad)
|
|||||||
|
|
||||||
void CInput::SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo)
|
void CInput::SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo)
|
||||||
{
|
{
|
||||||
float* pfTo = nullptr;
|
float *pfTo = nullptr;
|
||||||
|
|
||||||
switch (uiTo)
|
switch (uiTo)
|
||||||
{
|
{
|
||||||
@@ -319,7 +319,7 @@ void CInput::SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int u
|
|||||||
|
|
||||||
void CInput::SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo)
|
void CInput::SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo)
|
||||||
{
|
{
|
||||||
unsigned char* pucTo = nullptr;
|
unsigned char *pucTo = nullptr;
|
||||||
|
|
||||||
switch (uiTo)
|
switch (uiTo)
|
||||||
{
|
{
|
||||||
@@ -402,7 +402,8 @@ unsigned int CInput::GetValue(int iPad, unsigned char ucAction, bool bRepeat)
|
|||||||
|
|
||||||
bool CInput::IsSet(int iPad, unsigned char ucAction)
|
bool CInput::IsSet(int iPad, unsigned char ucAction)
|
||||||
{
|
{
|
||||||
return (!m_bIsMenuDisplayed[iPad] || ucAction <= m_ucMenuActionC) && (m_JoypadMap[m_Joypads[iPad].m_ucMappingValue][ucAction] & m_Joypads[iPad].m_uiButtons) != 0;
|
return (!m_bIsMenuDisplayed[iPad] || ucAction <= m_ucMenuActionC) &&
|
||||||
|
(m_JoypadMap[m_Joypads[iPad].m_ucMappingValue][ucAction] & m_Joypads[iPad].m_uiButtons) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInput::ButtonPressed(int iPad, unsigned char ucAction)
|
bool CInput::ButtonPressed(int iPad, unsigned char ucAction)
|
||||||
@@ -422,7 +423,8 @@ bool CInput::ButtonPressed(int iPad, unsigned char ucAction)
|
|||||||
|
|
||||||
bool CInput::ButtonReleased(int iPad, unsigned char ucAction)
|
bool CInput::ButtonReleased(int iPad, unsigned char ucAction)
|
||||||
{
|
{
|
||||||
return (!m_bIsMenuDisplayed[iPad] || ucAction <= m_ucMenuActionC) && (m_JoypadMap[m_Joypads[iPad].m_ucMappingValue][ucAction] & m_Joypads[iPad].m_uiButtonsReleased) != 0;
|
return (!m_bIsMenuDisplayed[iPad] || ucAction <= m_ucMenuActionC) &&
|
||||||
|
(m_JoypadMap[m_Joypads[iPad].m_ucMappingValue][ucAction] & m_Joypads[iPad].m_uiButtonsReleased) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInput::ButtonDown(int iPad, unsigned char ucAction)
|
bool CInput::ButtonDown(int iPad, unsigned char ucAction)
|
||||||
@@ -541,11 +543,11 @@ void CInput::SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs)
|
|||||||
m_fRepeatRateSecs = fRepeatRateSecs;
|
m_fRepeatRateSecs = fRepeatRateSecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInput::SetDebugSequence(const char* chSequenceA, int(*Func)(LPVOID), LPVOID lpParam)
|
void CInput::SetDebugSequence(const char *chSequenceA, int (*Func)(LPVOID), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
int iLen = strlen(chSequenceA);
|
int iLen = strlen(chSequenceA);
|
||||||
|
|
||||||
m_sDebugSequenceName = (char*)operator new[](iLen);
|
m_sDebugSequenceName = (char *)operator new[](iLen);
|
||||||
strcpy(m_sDebugSequenceName, chSequenceA);
|
strcpy(m_sDebugSequenceName, chSequenceA);
|
||||||
|
|
||||||
m_pDebugSequenceFn = Func;
|
m_pDebugSequenceFn = Func;
|
||||||
@@ -569,7 +571,7 @@ bool CInput::UpdateJoypads()
|
|||||||
|
|
||||||
for (int i = 0; i < MAX_JOYPADS; i++)
|
for (int i = 0; i < MAX_JOYPADS; i++)
|
||||||
{
|
{
|
||||||
JOYPAD* pThisPad = &m_Joypads[i];
|
JOYPAD *pThisPad = &m_Joypads[i];
|
||||||
|
|
||||||
pThisPad->m_uiOldButtons = pThisPad->m_uiButtons;
|
pThisPad->m_uiOldButtons = pThisPad->m_uiButtons;
|
||||||
pThisPad->m_uiButtons = 0;
|
pThisPad->m_uiButtons = 0;
|
||||||
@@ -585,7 +587,7 @@ bool CInput::UpdateJoypads()
|
|||||||
{
|
{
|
||||||
if (!m_Joypads[i].m_bIsDisabled)
|
if (!m_Joypads[i].m_bIsDisabled)
|
||||||
{
|
{
|
||||||
JOYPAD* pThisPad = &m_Joypads[i];
|
JOYPAD *pThisPad = &m_Joypads[i];
|
||||||
|
|
||||||
bool bOldIsConnected = pThisPad->m_bIsConnected;
|
bool bOldIsConnected = pThisPad->m_bIsConnected;
|
||||||
|
|
||||||
@@ -627,8 +629,8 @@ bool CInput::UpdateJoypads()
|
|||||||
ClearJoypadValues(pThisPad);
|
ClearJoypadValues(pThisPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pDebugSequenceFn &&
|
if (m_pDebugSequenceFn && (pThisPad->m_uiButtonsPressed & (_360_JOY_BUTTON_A | _360_JOY_BUTTON_B | _360_JOY_BUTTON_X | _360_JOY_BUTTON_Y |
|
||||||
(pThisPad->m_uiButtonsPressed & (_360_JOY_BUTTON_A | _360_JOY_BUTTON_B | _360_JOY_BUTTON_X | _360_JOY_BUTTON_Y | _360_JOY_BUTTON_RB | _360_JOY_BUTTON_LB)) != 0)
|
_360_JOY_BUTTON_RB | _360_JOY_BUTTON_LB)) != 0)
|
||||||
{
|
{
|
||||||
char chSeq;
|
char chSeq;
|
||||||
|
|
||||||
@@ -676,7 +678,7 @@ bool CInput::UpdateJoypads()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInput::ClearJoypadValues(JOYPAD* pThisPad)
|
void CInput::ClearJoypadValues(JOYPAD *pThisPad)
|
||||||
{
|
{
|
||||||
pThisPad->m_uiButtonsPressed = 0;
|
pThisPad->m_uiButtonsPressed = 0;
|
||||||
pThisPad->m_uiButtonsReleased = 0;
|
pThisPad->m_uiButtonsReleased = 0;
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
class CInput
|
class CInput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
struct JOYPAD
|
struct JOYPAD
|
||||||
{
|
{
|
||||||
bool m_bIsDisabled;
|
bool m_bIsDisabled;
|
||||||
@@ -39,24 +37,23 @@ public:
|
|||||||
unsigned char m_ucLeftTriggerState;
|
unsigned char m_ucLeftTriggerState;
|
||||||
unsigned char m_ucRightTriggerState;
|
unsigned char m_ucRightTriggerState;
|
||||||
|
|
||||||
float* m_pfLeftThumbXAxisMap;
|
float *m_pfLeftThumbXAxisMap;
|
||||||
float* m_pfLeftThumbYAxisMap;
|
float *m_pfLeftThumbYAxisMap;
|
||||||
float* m_pfRightThumbXAxisMap;
|
float *m_pfRightThumbXAxisMap;
|
||||||
float* m_pfRightThumbYAxisMap;
|
float *m_pfRightThumbYAxisMap;
|
||||||
|
|
||||||
float m_fSensitivity;
|
float m_fSensitivity;
|
||||||
|
|
||||||
BYTE* m_pucLeftTriggerAxisMap;
|
BYTE *m_pucLeftTriggerAxisMap;
|
||||||
BYTE* m_pucRightTriggerAxisMap;
|
BYTE *m_pucRightTriggerAxisMap;
|
||||||
|
|
||||||
unsigned char m_ucMappingValue;
|
unsigned char m_ucMappingValue;
|
||||||
unsigned char m_ucInputStateIndex;
|
unsigned char m_ucInputStateIndex;
|
||||||
XINPUT_STATE* m_pInputStates;
|
XINPUT_STATE *m_pInputStates;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct JOYPADS
|
struct JOYPADS
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TimeInfo
|
struct TimeInfo
|
||||||
@@ -73,7 +70,7 @@ public:
|
|||||||
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
|
void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC);
|
||||||
void Tick(void);
|
void Tick(void);
|
||||||
|
|
||||||
void SetJoypadValues(JOYPAD* pThisPad);
|
void SetJoypadValues(JOYPAD *pThisPad);
|
||||||
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax);
|
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax);
|
||||||
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
void SetJoypadSensitivity(int iPad, float fSensitivity);
|
||||||
|
|
||||||
@@ -91,7 +88,7 @@ public:
|
|||||||
bool IsSet(int iPad, unsigned char ucAction);
|
bool IsSet(int iPad, unsigned char ucAction);
|
||||||
|
|
||||||
bool ButtonPressed(int iPad, unsigned char ucAction = 255); // toggled
|
bool ButtonPressed(int iPad, unsigned char ucAction = 255); // toggled
|
||||||
bool ButtonReleased(int iPad, unsigned char ucAction); //toggled
|
bool ButtonReleased(int iPad, unsigned char ucAction); // toggled
|
||||||
bool ButtonDown(int iPad, unsigned char ucAction = 255); // button held down
|
bool ButtonDown(int iPad, unsigned char ucAction = 255); // button held down
|
||||||
|
|
||||||
float GetJoypadStick_Menu_LX(unsigned char ucPad);
|
float GetJoypadStick_Menu_LX(unsigned char ucPad);
|
||||||
@@ -111,11 +108,11 @@ public:
|
|||||||
void SetMenuDisplayed(int iPad, bool bVal);
|
void SetMenuDisplayed(int iPad, bool bVal);
|
||||||
|
|
||||||
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
|
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
|
||||||
void SetDebugSequence(const char* chSequenceA, int(*Func)(LPVOID), LPVOID lpParam);
|
void SetDebugSequence(const char *chSequenceA, int (*Func)(LPVOID), LPVOID lpParam);
|
||||||
FLOAT GetIdleSeconds(int iPad);
|
FLOAT GetIdleSeconds(int iPad);
|
||||||
|
|
||||||
bool UpdateJoypads(void);
|
bool UpdateJoypads(void);
|
||||||
void ClearJoypadValues(JOYPAD* pThisPad);
|
void ClearJoypadValues(JOYPAD *pThisPad);
|
||||||
|
|
||||||
void InitTime(void);
|
void InitTime(void);
|
||||||
void GetStartTime(int iPad, int iKey);
|
void GetStartTime(int iPad, int iKey);
|
||||||
@@ -136,7 +133,7 @@ public:
|
|||||||
unsigned char m_ucJoypadMapActionC;
|
unsigned char m_ucJoypadMapActionC;
|
||||||
unsigned char m_ucMenuActionC;
|
unsigned char m_ucMenuActionC;
|
||||||
|
|
||||||
unsigned int** m_JoypadMap;
|
unsigned int **m_JoypadMap;
|
||||||
|
|
||||||
bool m_bJoypadMapArrayIsSetup;
|
bool m_bJoypadMapArrayIsSetup;
|
||||||
unsigned int m_uiSigninJoypadMask;
|
unsigned int m_uiSigninJoypadMask;
|
||||||
@@ -152,9 +149,9 @@ public:
|
|||||||
TimeInfo m_Timers[MAX_JOYPADS][24];
|
TimeInfo m_Timers[MAX_JOYPADS][24];
|
||||||
LARGE_INTEGER m_LastActivityTime[MAX_JOYPADS];
|
LARGE_INTEGER m_LastActivityTime[MAX_JOYPADS];
|
||||||
|
|
||||||
char* m_sDebugSequenceName;
|
char *m_sDebugSequenceName;
|
||||||
unsigned int m_uiDebugSequenceIndex;
|
unsigned int m_uiDebugSequenceIndex;
|
||||||
int (*m_pDebugSequenceFn)(void*);
|
int (*m_pDebugSequenceFn)(void *);
|
||||||
LPVOID m_pDebugSequenceParam;
|
LPVOID m_pDebugSequenceParam;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ LinkedList::LinkedList()
|
|||||||
this->m_Tail = nullptr;
|
this->m_Tail = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkedList::AddToHead(void* pvData)
|
void LinkedList::AddToHead(void *pvData)
|
||||||
{
|
{
|
||||||
_LL_NODE* pNode = new _LL_NODE();
|
_LL_NODE *pNode = new _LL_NODE();
|
||||||
pNode->m_pvData = pvData;
|
pNode->m_pvData = pvData;
|
||||||
|
|
||||||
if (!m_Tail)
|
if (!m_Tail)
|
||||||
@@ -27,9 +27,9 @@ void LinkedList::AddToHead(void* pvData)
|
|||||||
m_NodeC++;
|
m_NodeC++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkedList::AddToTail(void* pvData)
|
void LinkedList::AddToTail(void *pvData)
|
||||||
{
|
{
|
||||||
_LL_NODE* pNode = new _LL_NODE();
|
_LL_NODE *pNode = new _LL_NODE();
|
||||||
pNode->m_pvData = pvData;
|
pNode->m_pvData = pvData;
|
||||||
|
|
||||||
if (!m_Head)
|
if (!m_Head)
|
||||||
@@ -37,7 +37,8 @@ void LinkedList::AddToTail(void* pvData)
|
|||||||
m_Head = pNode;
|
m_Head = pNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Tail) {
|
if (m_Tail)
|
||||||
|
{
|
||||||
m_Tail->m_Next = pNode;
|
m_Tail->m_Next = pNode;
|
||||||
pNode->m_Prev = m_Tail;
|
pNode->m_Prev = m_Tail;
|
||||||
}
|
}
|
||||||
@@ -49,9 +50,9 @@ void LinkedList::AddToTail(void* pvData)
|
|||||||
m_NodeC++;
|
m_NodeC++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkedList::RemoveNode(_LL_NODE* pNodeToRemove)
|
void LinkedList::RemoveNode(_LL_NODE *pNodeToRemove)
|
||||||
{
|
{
|
||||||
_LL_NODE* pCurrentNode;
|
_LL_NODE *pCurrentNode;
|
||||||
for (pCurrentNode = m_Head; pCurrentNode != pNodeToRemove; pCurrentNode = pCurrentNode->m_Next)
|
for (pCurrentNode = m_Head; pCurrentNode != pNodeToRemove; pCurrentNode = pCurrentNode->m_Next)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
@@ -74,9 +75,9 @@ void LinkedList::RemoveNode(_LL_NODE* pNodeToRemove)
|
|||||||
m_NodeC--;
|
m_NodeC--;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkedList::_LL_NODE* LinkedList::RemoveHeadNode()
|
LinkedList::_LL_NODE *LinkedList::RemoveHeadNode()
|
||||||
{
|
{
|
||||||
_LL_NODE* pHeadNode = m_Head;
|
_LL_NODE *pHeadNode = m_Head;
|
||||||
|
|
||||||
if (m_NodeC > 0)
|
if (m_NodeC > 0)
|
||||||
{
|
{
|
||||||
@@ -91,7 +92,7 @@ void LinkedList::ClearList()
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
_LL_NODE* pHeadNode = RemoveHeadNode();
|
_LL_NODE *pHeadNode = RemoveHeadNode();
|
||||||
if (!pHeadNode)
|
if (!pHeadNode)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -3,29 +3,27 @@
|
|||||||
class LinkedList
|
class LinkedList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
struct _LL_NODE
|
struct _LL_NODE
|
||||||
{
|
{
|
||||||
template<typename T>
|
template <typename T>
|
||||||
T* GetDataAs()
|
T *GetDataAs()
|
||||||
{
|
{
|
||||||
return (T*)m_pvData;
|
return (T *)m_pvData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* m_pvData;
|
void *m_pvData;
|
||||||
_LL_NODE* m_Next;
|
_LL_NODE *m_Next;
|
||||||
_LL_NODE* m_Prev;
|
_LL_NODE *m_Prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
int m_NodeC;
|
int m_NodeC;
|
||||||
_LL_NODE* m_Head;
|
_LL_NODE *m_Head;
|
||||||
_LL_NODE* m_Tail;
|
_LL_NODE *m_Tail;
|
||||||
|
|
||||||
LinkedList();
|
LinkedList();
|
||||||
void AddToHead(void* pvData);
|
void AddToHead(void *pvData);
|
||||||
void AddToTail(void* pvData);
|
void AddToTail(void *pvData);
|
||||||
void RemoveNode(_LL_NODE* pNodeToRemove);
|
void RemoveNode(_LL_NODE *pNodeToRemove);
|
||||||
_LL_NODE* RemoveHeadNode();
|
_LL_NODE *RemoveHeadNode();
|
||||||
void ClearList();
|
void ClearList();
|
||||||
};
|
};
|
||||||
@@ -2,8 +2,11 @@
|
|||||||
#include "4J_Render.h"
|
#include "4J_Render.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
C4JRender RenderManager;
|
||||||
|
|
||||||
void C4JRender::Tick()
|
void C4JRender::Tick()
|
||||||
{
|
{
|
||||||
|
InternalRenderManager.CBuffTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JRender::UpdateGamma(unsigned short usGamma)
|
void C4JRender::UpdateGamma(unsigned short usGamma)
|
||||||
@@ -474,5 +477,3 @@ void C4JRender::Resume()
|
|||||||
{
|
{
|
||||||
InternalRenderManager.Resume();
|
InternalRenderManager.Resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JRender RenderManager;
|
|
||||||
@@ -23,26 +23,28 @@ public:
|
|||||||
void MatrixOrthogonal(float left, float right, float bottom, float top, float zNear, float zFar);
|
void MatrixOrthogonal(float left, float right, float bottom, float top, float zNear, float zFar);
|
||||||
void MatrixPop();
|
void MatrixPop();
|
||||||
void MatrixPush();
|
void MatrixPush();
|
||||||
void MatrixMult(float* mat);
|
void MatrixMult(float *mat);
|
||||||
const float* MatrixGet(int type);
|
const float *MatrixGet(int type);
|
||||||
void Set_matrixDirty();
|
void Set_matrixDirty();
|
||||||
void Initialise(ID3D11Device* pDevice, IDXGISwapChain* pSwapChain);
|
void Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain);
|
||||||
ID3D11DeviceContext* InitialiseContext(bool fromPresent);
|
ID3D11DeviceContext *InitialiseContext(bool fromPresent);
|
||||||
void StartFrame();
|
void StartFrame();
|
||||||
void DoScreenGrabOnNextPresent();
|
void DoScreenGrabOnNextPresent();
|
||||||
void Present();
|
void Present();
|
||||||
void Clear(int flags, D3D11_RECT* pRect);
|
void Clear(int flags, D3D11_RECT *pRect);
|
||||||
void SetClearColour(const float colourRGBA[4]);
|
void SetClearColour(const float colourRGBA[4]);
|
||||||
bool IsWidescreen();
|
bool IsWidescreen();
|
||||||
bool IsHiDef();
|
bool IsHiDef();
|
||||||
void CaptureThumbnail(ImageFileBuffer* pngOut);
|
void CaptureThumbnail(ImageFileBuffer *pngOut);
|
||||||
void CaptureScreen(ImageFileBuffer* jpgOut, XSOCIAL_PREVIEWIMAGE* previewOut);
|
void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut);
|
||||||
void BeginConditionalSurvey(int identifier);
|
void BeginConditionalSurvey(int identifier);
|
||||||
void EndConditionalSurvey();
|
void EndConditionalSurvey();
|
||||||
void BeginConditionalRendering(int identifier);
|
void BeginConditionalRendering(int identifier);
|
||||||
void EndConditionalRendering();
|
void EndConditionalRendering();
|
||||||
void DrawVertices(C4JRender::ePrimitiveType PrimitiveType, int count, void* dataIn, C4JRender::eVertexType vType, C4JRender::ePixelShaderType psType);
|
void DrawVertices(C4JRender::ePrimitiveType PrimitiveType, int count, void *dataIn, C4JRender::eVertexType vType,
|
||||||
void DrawVertexBuffer(C4JRender::ePrimitiveType PrimitiveType, int count, ID3D11Buffer* buffer, C4JRender::eVertexType vType, C4JRender::ePixelShaderType psType);
|
C4JRender::ePixelShaderType psType);
|
||||||
|
void DrawVertexBuffer(C4JRender::ePrimitiveType PrimitiveType, int count, ID3D11Buffer *buffer, C4JRender::eVertexType vType,
|
||||||
|
C4JRender::ePixelShaderType psType);
|
||||||
void CBuffLockStaticCreations();
|
void CBuffLockStaticCreations();
|
||||||
int CBuffCreate(int count);
|
int CBuffCreate(int count);
|
||||||
void CBuffDelete(int first, int count);
|
void CBuffDelete(int first, int count);
|
||||||
@@ -63,14 +65,14 @@ public:
|
|||||||
void TextureSetParam(int param, int value);
|
void TextureSetParam(int param, int value);
|
||||||
void TextureDynamicUpdateStart();
|
void TextureDynamicUpdateStart();
|
||||||
void TextureDynamicUpdateEnd();
|
void TextureDynamicUpdateEnd();
|
||||||
void TextureData(int width, int height, void* data, int level, C4JRender::eTextureFormat format);
|
void TextureData(int width, int height, void *data, int level, C4JRender::eTextureFormat format);
|
||||||
void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void* data, int level);
|
void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level);
|
||||||
HRESULT LoadTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut);
|
HRESULT LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
|
||||||
HRESULT LoadTextureData(BYTE* pbData, DWORD dwBytes, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut);
|
HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
|
||||||
HRESULT SaveTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo, int* ppDataOut);
|
HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut);
|
||||||
HRESULT SaveTextureDataToMemory(void* pOutput, int outputCapacity, int* outputLength, int width, int height, int* ppDataIn);
|
HRESULT SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn);
|
||||||
void TextureGetStats();
|
void TextureGetStats();
|
||||||
ID3D11ShaderResourceView* TextureGetTexture(int idx);
|
ID3D11ShaderResourceView *TextureGetTexture(int idx);
|
||||||
void StateSetColour(float r, float g, float b, float a);
|
void StateSetColour(float r, float g, float b, float a);
|
||||||
void StateSetDepthMask(bool enable);
|
void StateSetDepthMask(bool enable);
|
||||||
void StateSetBlendEnable(bool enable);
|
void StateSetBlendEnable(bool enable);
|
||||||
@@ -108,33 +110,31 @@ public:
|
|||||||
bool Suspended();
|
bool Suspended();
|
||||||
void Resume();
|
void Resume();
|
||||||
void StateUpdate();
|
void StateUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupShaders();
|
void SetupShaders();
|
||||||
void ConvertLinearToPng(ImageFileBuffer* pngOut, unsigned char* linearData, unsigned int width, unsigned int height);
|
void ConvertLinearToPng(ImageFileBuffer *pngOut, unsigned char *linearData, unsigned int width, unsigned int height);
|
||||||
void DrawVertexSetup(C4JRender::eVertexType vType, C4JRender::ePixelShaderType psType, C4JRender::ePrimitiveType primitiveType, int* count, bool* drawIndexed);
|
void DrawVertexSetup(C4JRender::eVertexType vType, C4JRender::ePixelShaderType psType, C4JRender::ePrimitiveType primitiveType, int *count,
|
||||||
|
bool *drawIndexed);
|
||||||
void UpdateTexGenState();
|
void UpdateTexGenState();
|
||||||
void UpdateLightingState();
|
void UpdateLightingState();
|
||||||
void UpdateViewportState();
|
void UpdateViewportState();
|
||||||
void UpdateFogState();
|
void UpdateFogState();
|
||||||
void UpdateTextureState(bool vertexSampler);
|
void UpdateTextureState(bool vertexSampler);
|
||||||
void MultWithStack(DirectX::XMMATRIX matrix);
|
void MultWithStack(DirectX::XMMATRIX matrix);
|
||||||
ID3D11DepthStencilState* GetManagedDepthStencilState();
|
ID3D11DepthStencilState *GetManagedDepthStencilState();
|
||||||
ID3D11BlendState* GetManagedBlendState();
|
ID3D11BlendState *GetManagedBlendState();
|
||||||
ID3D11RasterizerState* GetManagedRasterizerState();
|
ID3D11RasterizerState *GetManagedRasterizerState();
|
||||||
ID3D11SamplerState* GetManagedSamplerState();
|
ID3D11SamplerState *GetManagedSamplerState();
|
||||||
void DeleteInternalBuffer(int index);
|
void DeleteInternalBuffer(int index);
|
||||||
Renderer::Context& getContext();
|
Renderer::Context &getContext();
|
||||||
static D3D11_PRIMITIVE_TOPOLOGY* m_Topologies;
|
static D3D11_PRIMITIVE_TOPOLOGY *m_Topologies;
|
||||||
static DXGI_FORMAT textureFormats[C4JRender::MAX_TEXTURE_FORMATS];
|
static DXGI_FORMAT textureFormats[C4JRender::MAX_TEXTURE_FORMATS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Texture
|
struct Texture
|
||||||
{
|
{
|
||||||
bool allocated;
|
bool allocated;
|
||||||
ID3D11Texture2D* texture;
|
ID3D11Texture2D *texture;
|
||||||
ID3D11ShaderResourceView* view;
|
ID3D11ShaderResourceView *view;
|
||||||
DWORD textureFlags;
|
DWORD textureFlags;
|
||||||
DWORD mipLevels;
|
DWORD mipLevels;
|
||||||
DWORD textureFormat;
|
DWORD textureFormat;
|
||||||
@@ -172,11 +172,11 @@ public:
|
|||||||
CommandBuffer(bool full);
|
CommandBuffer(bool full);
|
||||||
~CommandBuffer();
|
~CommandBuffer();
|
||||||
void StartRecording();
|
void StartRecording();
|
||||||
void EndRecording(ID3D11Device* device);
|
void EndRecording(ID3D11Device *device);
|
||||||
std::uint64_t GetAllocated();
|
std::uint64_t GetAllocated();
|
||||||
bool IsBusy();
|
bool IsBusy();
|
||||||
void AddMatrix(const float* matrix);
|
void AddMatrix(const float *matrix);
|
||||||
void AddVertices(unsigned int stride, unsigned int count, void* dataIn, Renderer::Context& context);
|
void AddVertices(unsigned int stride, unsigned int count, void *dataIn, Renderer::Context &context);
|
||||||
void BindTexture(int idx);
|
void BindTexture(int idx);
|
||||||
void SetColor(float r, float g, float b, float a);
|
void SetColor(float r, float g, float b, float a);
|
||||||
void SetDepthFunc(int func);
|
void SetDepthFunc(int func);
|
||||||
@@ -191,7 +191,7 @@ public:
|
|||||||
void SetBlendFunc(int src, int dst);
|
void SetBlendFunc(int src, int dst);
|
||||||
void SetBlendFactor(unsigned int factor);
|
void SetBlendFactor(unsigned int factor);
|
||||||
void SetFaceCull(bool enable);
|
void SetFaceCull(bool enable);
|
||||||
void Render(C4JRender::eVertexType vertexType, Renderer::Context& context, int primitiveType);
|
void Render(C4JRender::eVertexType vertexType, Renderer::Context &context, int primitiveType);
|
||||||
|
|
||||||
struct Command
|
struct Command
|
||||||
{
|
{
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
float m_matrix[16];
|
float m_matrix[16];
|
||||||
//DirectX::XMMATRIX m_matrix;
|
// DirectX::XMMATRIX m_matrix;
|
||||||
} add_matrix;
|
} add_matrix;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@@ -291,20 +291,18 @@ public:
|
|||||||
} set_face_cull;
|
} set_face_cull;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
ID3D11Buffer* m_vertexBuffer;
|
ID3D11Buffer *m_vertexBuffer;
|
||||||
void* m_vertexData;
|
void *m_vertexData;
|
||||||
std::uint64_t m_vertexDataLength;
|
std::uint64_t m_vertexDataLength;
|
||||||
std::vector<Command> m_commands;
|
std::vector<Command> m_commands;
|
||||||
std::uint64_t m_allocated;
|
std::uint64_t m_allocated;
|
||||||
BYTE isActive;
|
BYTE isActive;
|
||||||
BYTE paddingAfterActive[7];
|
BYTE paddingAfterActive[7];
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeferredCBuff
|
struct DeferredCBuff
|
||||||
{
|
{
|
||||||
Renderer::CommandBuffer* m_command_buf;
|
Renderer::CommandBuffer *m_command_buf;
|
||||||
int m_vertex_index;
|
int m_vertex_index;
|
||||||
int m_vertex_type;
|
int m_vertex_type;
|
||||||
int m_primitive_type;
|
int m_primitive_type;
|
||||||
@@ -313,9 +311,9 @@ public:
|
|||||||
|
|
||||||
struct Context
|
struct Context
|
||||||
{
|
{
|
||||||
Context(ID3D11Device* device, ID3D11DeviceContext* deviceContext);
|
Context(ID3D11Device *device, ID3D11DeviceContext *deviceContext);
|
||||||
ID3D11DeviceContext* m_pDeviceContext;
|
ID3D11DeviceContext *m_pDeviceContext;
|
||||||
ID3DUserDefinedAnnotation* userAnnotation;
|
ID3DUserDefinedAnnotation *userAnnotation;
|
||||||
DWORD contextStateFlags;
|
DWORD contextStateFlags;
|
||||||
BYTE paddingAfterFlags[12];
|
BYTE paddingAfterFlags[12];
|
||||||
DirectX::XMMATRIX matrixStacks[4][16];
|
DirectX::XMMATRIX matrixStacks[4][16];
|
||||||
@@ -345,29 +343,29 @@ public:
|
|||||||
DirectX::XMFLOAT4 lightDirection[2];
|
DirectX::XMFLOAT4 lightDirection[2];
|
||||||
DirectX::XMFLOAT4 lightColour[2];
|
DirectX::XMFLOAT4 lightColour[2];
|
||||||
DirectX::XMFLOAT4 lightAmbientColour;
|
DirectX::XMFLOAT4 lightAmbientColour;
|
||||||
ID3D11Buffer* cbMatrix0;
|
ID3D11Buffer *cbMatrix0;
|
||||||
ID3D11Buffer* cbMatrix1;
|
ID3D11Buffer *cbMatrix1;
|
||||||
ID3D11Buffer* cbMatrix2;
|
ID3D11Buffer *cbMatrix2;
|
||||||
ID3D11Buffer* cbMatrix3;
|
ID3D11Buffer *cbMatrix3;
|
||||||
ID3D11Buffer* cbVertexTexcoord;
|
ID3D11Buffer *cbVertexTexcoord;
|
||||||
ID3D11Buffer* cbFogParams;
|
ID3D11Buffer *cbFogParams;
|
||||||
ID3D11Buffer* cbLighting;
|
ID3D11Buffer *cbLighting;
|
||||||
ID3D11Buffer* cbTexGen;
|
ID3D11Buffer *cbTexGen;
|
||||||
ID3D11Buffer* cbAux0;
|
ID3D11Buffer *cbAux0;
|
||||||
ID3D11Buffer* cbAux1;
|
ID3D11Buffer *cbAux1;
|
||||||
ID3D11Buffer* cbColour;
|
ID3D11Buffer *cbColour;
|
||||||
ID3D11Buffer* cbFogColour;
|
ID3D11Buffer *cbFogColour;
|
||||||
ID3D11Buffer* cbAux2;
|
ID3D11Buffer *cbAux2;
|
||||||
ID3D11Buffer* cbAlphaTest;
|
ID3D11Buffer *cbAlphaTest;
|
||||||
ID3D11Buffer* cbAux3;
|
ID3D11Buffer *cbAux3;
|
||||||
ID3D11Buffer* cbAux4;
|
ID3D11Buffer *cbAux4;
|
||||||
uint64_t dynamicVertexBase;
|
uint64_t dynamicVertexBase;
|
||||||
DWORD dynamicVertexOffset;
|
DWORD dynamicVertexOffset;
|
||||||
BYTE paddingAfterDynamicOffset[4];
|
BYTE paddingAfterDynamicOffset[4];
|
||||||
ID3D11Buffer* dynamicVertexBuffer;
|
ID3D11Buffer *dynamicVertexBuffer;
|
||||||
BYTE paddingBeforeTexGen[8];
|
BYTE paddingBeforeTexGen[8];
|
||||||
DirectX::XMMATRIX texGenMatrices[2];
|
DirectX::XMMATRIX texGenMatrices[2];
|
||||||
Renderer::CommandBuffer* commandBuffer;
|
Renderer::CommandBuffer *commandBuffer;
|
||||||
DWORD recordingBufferIndex;
|
DWORD recordingBufferIndex;
|
||||||
DWORD recordingVertexType;
|
DWORD recordingVertexType;
|
||||||
DWORD recordingPrimitiveType;
|
DWORD recordingPrimitiveType;
|
||||||
@@ -392,25 +390,25 @@ public:
|
|||||||
static _RTL_CRITICAL_SECTION totalAllocCS;
|
static _RTL_CRITICAL_SECTION totalAllocCS;
|
||||||
|
|
||||||
float m_fClearColor[4];
|
float m_fClearColor[4];
|
||||||
ID3D11Device* m_pDevice;
|
ID3D11Device *m_pDevice;
|
||||||
ID3D11DeviceContext* m_pDeviceContext;
|
ID3D11DeviceContext *m_pDeviceContext;
|
||||||
IDXGISwapChain* m_pSwapChain;
|
IDXGISwapChain *m_pSwapChain;
|
||||||
ID3D11RenderTargetView* renderTargetView;
|
ID3D11RenderTargetView *renderTargetView;
|
||||||
ID3D11RenderTargetView* renderTargetViews[4];
|
ID3D11RenderTargetView *renderTargetViews[4];
|
||||||
ID3D11ShaderResourceView* renderTargetShaderResourceView;
|
ID3D11ShaderResourceView *renderTargetShaderResourceView;
|
||||||
ID3D11ShaderResourceView* renderTargetShaderResourceViews[4];
|
ID3D11ShaderResourceView *renderTargetShaderResourceViews[4];
|
||||||
ID3D11Texture2D* renderTargetTextures[4];
|
ID3D11Texture2D *renderTargetTextures[4];
|
||||||
ID3D11DepthStencilView* depthStencilView;
|
ID3D11DepthStencilView *depthStencilView;
|
||||||
ID3D11VertexShader** vertexShaderTable;
|
ID3D11VertexShader **vertexShaderTable;
|
||||||
ID3D11VertexShader* screenSpaceVertexShader;
|
ID3D11VertexShader *screenSpaceVertexShader;
|
||||||
ID3D11VertexShader* screenClearVertexShader;
|
ID3D11VertexShader *screenClearVertexShader;
|
||||||
ID3D11PixelShader** pixelShaderTable;
|
ID3D11PixelShader **pixelShaderTable;
|
||||||
ID3D11PixelShader* screenSpacePixelShader;
|
ID3D11PixelShader *screenSpacePixelShader;
|
||||||
ID3D11PixelShader* screenClearPixelShader;
|
ID3D11PixelShader *screenClearPixelShader;
|
||||||
unsigned int* vertexStrideTable;
|
unsigned int *vertexStrideTable;
|
||||||
ID3D11InputLayout** inputLayoutTable;
|
ID3D11InputLayout **inputLayoutTable;
|
||||||
ID3D11Buffer* quadIndexBuffer;
|
ID3D11Buffer *quadIndexBuffer;
|
||||||
ID3D11Buffer* fanIndexBuffer;
|
ID3D11Buffer *fanIndexBuffer;
|
||||||
DWORD defaultTextureIndex;
|
DWORD defaultTextureIndex;
|
||||||
WORD reservedRendererWord0;
|
WORD reservedRendererWord0;
|
||||||
BYTE paddingAfterRendererWord0[2];
|
BYTE paddingAfterRendererWord0[2];
|
||||||
@@ -429,18 +427,18 @@ public:
|
|||||||
BYTE reservedRendererByte1;
|
BYTE reservedRendererByte1;
|
||||||
BYTE paddingAfterRendererByte1[3];
|
BYTE paddingAfterRendererByte1[3];
|
||||||
DWORD reservedRendererDword1;
|
DWORD reservedRendererDword1;
|
||||||
void* reservedRendererPtr2;
|
void *reservedRendererPtr2;
|
||||||
void* reservedRendererPtr3;
|
void *reservedRendererPtr3;
|
||||||
uint64_t reservedRendererPtr1;
|
uint64_t reservedRendererPtr1;
|
||||||
void* reservedRendererPtr4;
|
void *reservedRendererPtr4;
|
||||||
void* reservedRendererPtr5;
|
void *reservedRendererPtr5;
|
||||||
void* reservedRendererPtr6;
|
void *reservedRendererPtr6;
|
||||||
DWORD reservedRendererDword2;
|
DWORD reservedRendererDword2;
|
||||||
DWORD reservedRendererDword3;
|
DWORD reservedRendererDword3;
|
||||||
std::unordered_map<int, ID3D11BlendState*> managedBlendStates;
|
std::unordered_map<int, ID3D11BlendState *> managedBlendStates;
|
||||||
std::unordered_map<int, ID3D11DepthStencilState*> managedDepthStencilStates;
|
std::unordered_map<int, ID3D11DepthStencilState *> managedDepthStencilStates;
|
||||||
std::unordered_map<int, ID3D11SamplerState*> managedSamplerStates;
|
std::unordered_map<int, ID3D11SamplerState *> managedSamplerStates;
|
||||||
std::unordered_map<int, ID3D11RasterizerState*> managedRasterizerStates;
|
std::unordered_map<int, ID3D11RasterizerState *> managedRasterizerStates;
|
||||||
BYTE shouldScreenGrabNextFrame;
|
BYTE shouldScreenGrabNextFrame;
|
||||||
BYTE suspended;
|
BYTE suspended;
|
||||||
BYTE paddingAfterSuspendState[2];
|
BYTE paddingAfterSuspendState[2];
|
||||||
|
|||||||
@@ -9,12 +9,7 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
Renderer::CommandBuffer::CommandBuffer(bool full)
|
Renderer::CommandBuffer::CommandBuffer(bool full)
|
||||||
: m_vertexBuffer(nullptr)
|
: m_vertexBuffer(nullptr), m_vertexData(nullptr), m_vertexDataLength(0), m_commands(), m_allocated(0x1000), isActive(full ? 1 : 0)
|
||||||
, m_vertexData(nullptr)
|
|
||||||
, m_vertexDataLength(0)
|
|
||||||
, m_commands()
|
|
||||||
, m_allocated(0x1000)
|
|
||||||
, isActive(full ? 1 : 0)
|
|
||||||
{
|
{
|
||||||
std::memset(paddingAfterActive, 0, sizeof(paddingAfterActive));
|
std::memset(paddingAfterActive, 0, sizeof(paddingAfterActive));
|
||||||
m_vertexData = std::malloc(m_allocated);
|
m_vertexData = std::malloc(m_allocated);
|
||||||
@@ -37,11 +32,9 @@ Renderer::CommandBuffer::~CommandBuffer()
|
|||||||
LeaveCriticalSection(&Renderer::totalAllocCS);
|
LeaveCriticalSection(&Renderer::totalAllocCS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CommandBuffer::StartRecording()
|
void Renderer::CommandBuffer::StartRecording() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::CommandBuffer::EndRecording(ID3D11Device* device)
|
void Renderer::CommandBuffer::EndRecording(ID3D11Device *device)
|
||||||
{
|
{
|
||||||
if (m_vertexDataLength != 0)
|
if (m_vertexDataLength != 0)
|
||||||
{
|
{
|
||||||
@@ -69,7 +62,7 @@ bool Renderer::CommandBuffer::IsBusy()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CommandBuffer::AddMatrix(const float* matrix)
|
void Renderer::CommandBuffer::AddMatrix(const float *matrix)
|
||||||
{
|
{
|
||||||
Command command = {};
|
Command command = {};
|
||||||
command.m_command_type = COMMAND_ADD_MATRIX;
|
command.m_command_type = COMMAND_ADD_MATRIX;
|
||||||
@@ -77,7 +70,7 @@ void Renderer::CommandBuffer::AddMatrix(const float* matrix)
|
|||||||
m_commands.push_back(command);
|
m_commands.push_back(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CommandBuffer::AddVertices(unsigned int stride, unsigned int count, void* dataIn, Renderer::Context& context)
|
void Renderer::CommandBuffer::AddVertices(unsigned int stride, unsigned int count, void *dataIn, Renderer::Context &context)
|
||||||
{
|
{
|
||||||
if (context.matrixDirty[3])
|
if (context.matrixDirty[3])
|
||||||
{
|
{
|
||||||
@@ -109,7 +102,7 @@ void Renderer::CommandBuffer::AddVertices(unsigned int stride, unsigned int coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::size_t byteCount = std::size_t(stride) * std::size_t(count);
|
const std::size_t byteCount = std::size_t(stride) * std::size_t(count);
|
||||||
std::memcpy(static_cast<std::uint8_t*>(m_vertexData) + vertexOffset, dataIn, byteCount);
|
std::memcpy(static_cast<std::uint8_t *>(m_vertexData) + vertexOffset, dataIn, byteCount);
|
||||||
m_commands.push_back(command);
|
m_commands.push_back(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,9 +168,9 @@ void Renderer::CommandBuffer::SetLightEnable(int light, bool enable)
|
|||||||
|
|
||||||
void Renderer::CommandBuffer::SetLightDirection(int light, float x, float y, float z)
|
void Renderer::CommandBuffer::SetLightDirection(int light, float x, float y, float z)
|
||||||
{
|
{
|
||||||
Renderer::Context& context = InternalRenderManager.getContext();
|
Renderer::Context &context = InternalRenderManager.getContext();
|
||||||
const std::uint32_t depth = context.matrixStackDepth[3];
|
const std::uint32_t depth = context.matrixStackDepth[3];
|
||||||
const DirectX::XMMATRIX& matrix = context.matrixStacks[3][depth];
|
const DirectX::XMMATRIX &matrix = context.matrixStacks[3][depth];
|
||||||
|
|
||||||
DirectX::XMVECTOR direction = DirectX::XMVectorSet(x, y, z, 0.0f);
|
DirectX::XMVECTOR direction = DirectX::XMVectorSet(x, y, z, 0.0f);
|
||||||
direction = DirectX::XMVector3TransformNormal(direction, matrix);
|
direction = DirectX::XMVector3TransformNormal(direction, matrix);
|
||||||
@@ -249,7 +242,7 @@ void Renderer::CommandBuffer::SetFaceCull(bool enable)
|
|||||||
m_commands.push_back(command);
|
m_commands.push_back(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CommandBuffer::Render(C4JRender::eVertexType vertexType, Renderer::Context& context, int primitiveType)
|
void Renderer::CommandBuffer::Render(C4JRender::eVertexType vertexType, Renderer::Context &context, int primitiveType)
|
||||||
{
|
{
|
||||||
if (!m_vertexBuffer)
|
if (!m_vertexBuffer)
|
||||||
{
|
{
|
||||||
@@ -262,20 +255,15 @@ void Renderer::CommandBuffer::Render(C4JRender::eVertexType vertexType, Renderer
|
|||||||
|
|
||||||
for (std::vector<Command>::const_iterator it = m_commands.begin(); it != m_commands.end(); ++it)
|
for (std::vector<Command>::const_iterator it = m_commands.begin(); it != m_commands.end(); ++it)
|
||||||
{
|
{
|
||||||
const Command& command = *it;
|
const Command &command = *it;
|
||||||
switch (command.m_command_type)
|
switch (command.m_command_type)
|
||||||
{
|
{
|
||||||
case COMMAND_ADD_MATRIX:
|
case COMMAND_ADD_MATRIX:
|
||||||
{
|
{
|
||||||
if (drawVertexType == C4JRender::VERTEX_TYPE_COMPRESSED)
|
if (drawVertexType == C4JRender::VERTEX_TYPE_COMPRESSED)
|
||||||
{
|
{
|
||||||
const float row[4] =
|
const float row[4] = {command.add_matrix.m_matrix[12], command.add_matrix.m_matrix[13], command.add_matrix.m_matrix[14],
|
||||||
{
|
command.add_matrix.m_matrix[15]};
|
||||||
command.add_matrix.m_matrix[12],
|
|
||||||
command.add_matrix.m_matrix[13],
|
|
||||||
command.add_matrix.m_matrix[14],
|
|
||||||
command.add_matrix.m_matrix[15]
|
|
||||||
};
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mappedAux0 = {};
|
D3D11_MAPPED_SUBRESOURCE mappedAux0 = {};
|
||||||
context.m_pDeviceContext->Map(context.cbAux0, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedAux0);
|
context.m_pDeviceContext->Map(context.cbAux0, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedAux0);
|
||||||
std::memcpy(mappedAux0.pData, row, sizeof(row));
|
std::memcpy(mappedAux0.pData, row, sizeof(row));
|
||||||
@@ -332,7 +320,7 @@ void Renderer::CommandBuffer::Render(C4JRender::eVertexType vertexType, Renderer
|
|||||||
drawIndexed = true;
|
drawIndexed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11Buffer* buffer = m_vertexBuffer;
|
ID3D11Buffer *buffer = m_vertexBuffer;
|
||||||
const UINT stride = InternalRenderManager.vertexStrideTable[drawVertexType];
|
const UINT stride = InternalRenderManager.vertexStrideTable[drawVertexType];
|
||||||
const UINT offset = command.add_vertices.m_vertex_index_start;
|
const UINT offset = command.add_vertices.m_vertex_index_start;
|
||||||
context.m_pDeviceContext->IASetVertexBuffers(0, 1, &buffer, &stride, &offset);
|
context.m_pDeviceContext->IASetVertexBuffers(0, 1, &buffer, &stride, &offset);
|
||||||
@@ -350,7 +338,7 @@ void Renderer::CommandBuffer::Render(C4JRender::eVertexType vertexType, Renderer
|
|||||||
case COMMAND_BIND_TEXTURE:
|
case COMMAND_BIND_TEXTURE:
|
||||||
{
|
{
|
||||||
context.boundTextureIndex = command.bind_texture.m_texture_index;
|
context.boundTextureIndex = command.bind_texture.m_texture_index;
|
||||||
ID3D11ShaderResourceView* view = InternalRenderManager.m_textures[context.boundTextureIndex].view;
|
ID3D11ShaderResourceView *view = InternalRenderManager.m_textures[context.boundTextureIndex].view;
|
||||||
context.m_pDeviceContext->PSSetShaderResources(0, 1, &view);
|
context.m_pDeviceContext->PSSetShaderResources(0, 1, &view);
|
||||||
InternalRenderManager.UpdateTextureState(false);
|
InternalRenderManager.UpdateTextureState(false);
|
||||||
break;
|
break;
|
||||||
@@ -482,13 +470,13 @@ bool Renderer::CBuffCall(int index, bool full)
|
|||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
const int internalIndex = externalToInternal[index];
|
const int internalIndex = externalToInternal[index];
|
||||||
if (internalIndex >= 0)
|
if (internalIndex >= 0)
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
const std::uint8_t vertexType = static_cast<std::uint8_t*>(reservedRendererPtr6)[internalIndex];
|
const std::uint8_t vertexType = static_cast<std::uint8_t *>(reservedRendererPtr6)[internalIndex];
|
||||||
const std::uint8_t primitiveType = reinterpret_cast<std::uint8_t*>(reservedRendererPtr1)[internalIndex];
|
const std::uint8_t primitiveType = reinterpret_cast<std::uint8_t *>(reservedRendererPtr1)[internalIndex];
|
||||||
|
|
||||||
if (full)
|
if (full)
|
||||||
{
|
{
|
||||||
@@ -534,7 +522,7 @@ bool Renderer::CBuffCall(int index, bool full)
|
|||||||
int pixelType = 0;
|
int pixelType = 0;
|
||||||
if (static_cast<int>(context.forcedLOD) > -1)
|
if (static_cast<int>(context.forcedLOD) > -1)
|
||||||
{
|
{
|
||||||
const float forcedLod[4] = { static_cast<float>(static_cast<int>(context.forcedLOD)), 0.0f, 0.0f, 0.0f };
|
const float forcedLod[4] = {static_cast<float>(static_cast<int>(context.forcedLOD)), 0.0f, 0.0f, 0.0f};
|
||||||
D3D11_MAPPED_SUBRESOURCE mappedAux4 = {};
|
D3D11_MAPPED_SUBRESOURCE mappedAux4 = {};
|
||||||
context.m_pDeviceContext->Map(context.cbAux4, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedAux4);
|
context.m_pDeviceContext->Map(context.cbAux4, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedAux4);
|
||||||
std::memcpy(mappedAux4.pData, forcedLod, sizeof(forcedLod));
|
std::memcpy(mappedAux4.pData, forcedLod, sizeof(forcedLod));
|
||||||
@@ -550,7 +538,7 @@ bool Renderer::CBuffCall(int index, bool full)
|
|||||||
|
|
||||||
context.m_pDeviceContext->IASetPrimitiveTopology(m_Topologies[primitiveType]);
|
context.m_pDeviceContext->IASetPrimitiveTopology(m_Topologies[primitiveType]);
|
||||||
|
|
||||||
ID3D11Buffer* indexBuffer = nullptr;
|
ID3D11Buffer *indexBuffer = nullptr;
|
||||||
if (primitiveType == C4JRender::PRIMITIVE_TYPE_QUAD_LIST)
|
if (primitiveType == C4JRender::PRIMITIVE_TYPE_QUAD_LIST)
|
||||||
{
|
{
|
||||||
indexBuffer = quadIndexBuffer;
|
indexBuffer = quadIndexBuffer;
|
||||||
@@ -563,12 +551,12 @@ bool Renderer::CBuffCall(int index, bool full)
|
|||||||
context.m_pDeviceContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R16_UINT, 0);
|
context.m_pDeviceContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R16_UINT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::CommandBuffer* commandBuffer = static_cast<Renderer::CommandBuffer**>(reservedRendererPtr3)[internalIndex];
|
Renderer::CommandBuffer *commandBuffer = static_cast<Renderer::CommandBuffer **>(reservedRendererPtr3)[internalIndex];
|
||||||
commandBuffer->Render(static_cast<C4JRender::eVertexType>(vertexType), context, primitiveType);
|
commandBuffer->Render(static_cast<C4JRender::eVertexType>(vertexType), context, primitiveType);
|
||||||
|
|
||||||
if (full)
|
if (full)
|
||||||
{
|
{
|
||||||
this->MultWithStack(static_cast<DirectX::XMMATRIX*>(reservedRendererPtr4)[internalIndex]);
|
this->MultWithStack(static_cast<DirectX::XMMATRIX *>(reservedRendererPtr4)[internalIndex]);
|
||||||
context.matrixStacks[3][0] = DirectX::XMMatrixIdentity();
|
context.matrixStacks[3][0] = DirectX::XMMatrixIdentity();
|
||||||
context.matrixDirty[3] = true;
|
context.matrixDirty[3] = true;
|
||||||
}
|
}
|
||||||
@@ -584,7 +572,7 @@ void Renderer::CBuffClear(int index)
|
|||||||
{
|
{
|
||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
const int internalIndex = externalToInternal[index];
|
const int internalIndex = externalToInternal[index];
|
||||||
if (internalIndex >= 0)
|
if (internalIndex >= 0)
|
||||||
{
|
{
|
||||||
@@ -602,7 +590,7 @@ int Renderer::CBuffCreate(int count)
|
|||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
int first = reservedRendererDword1;
|
int first = reservedRendererDword1;
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
|
|
||||||
if (first < kMaxExternalCBuffers)
|
if (first < kMaxExternalCBuffers)
|
||||||
{
|
{
|
||||||
@@ -656,7 +644,7 @@ int Renderer::CBuffCreate(int count)
|
|||||||
|
|
||||||
void Renderer::CBuffDeferredModeEnd()
|
void Renderer::CBuffDeferredModeEnd()
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
if (!context.deferredModeEnabled)
|
if (!context.deferredModeEnabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -665,16 +653,16 @@ void Renderer::CBuffDeferredModeEnd()
|
|||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
context.deferredModeEnabled = 0;
|
context.deferredModeEnabled = 0;
|
||||||
|
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
int* internalToExternal = static_cast<int*>(reservedRendererPtr5);
|
int *internalToExternal = static_cast<int *>(reservedRendererPtr5);
|
||||||
std::uint8_t* internalVertexTypes = static_cast<std::uint8_t*>(reservedRendererPtr6);
|
std::uint8_t *internalVertexTypes = static_cast<std::uint8_t *>(reservedRendererPtr6);
|
||||||
std::uint8_t* internalPrimitiveTypes = reinterpret_cast<std::uint8_t*>(reservedRendererPtr1);
|
std::uint8_t *internalPrimitiveTypes = reinterpret_cast<std::uint8_t *>(reservedRendererPtr1);
|
||||||
Renderer::CommandBuffer** internalBuffers = static_cast<Renderer::CommandBuffer**>(reservedRendererPtr3);
|
Renderer::CommandBuffer **internalBuffers = static_cast<Renderer::CommandBuffer **>(reservedRendererPtr3);
|
||||||
DirectX::XMMATRIX* internalMatrices = static_cast<DirectX::XMMATRIX*>(reservedRendererPtr4);
|
DirectX::XMMATRIX *internalMatrices = static_cast<DirectX::XMMATRIX *>(reservedRendererPtr4);
|
||||||
|
|
||||||
for (std::vector<Renderer::DeferredCBuff>::const_iterator it = context.deferredBuffers.begin(); it != context.deferredBuffers.end(); ++it)
|
for (std::vector<Renderer::DeferredCBuff>::const_iterator it = context.deferredBuffers.begin(); it != context.deferredBuffers.end(); ++it)
|
||||||
{
|
{
|
||||||
const Renderer::DeferredCBuff& deferred = *it;
|
const Renderer::DeferredCBuff &deferred = *it;
|
||||||
const int existingIndex = externalToInternal[deferred.m_vertex_index];
|
const int existingIndex = externalToInternal[deferred.m_vertex_index];
|
||||||
if (existingIndex >= 0)
|
if (existingIndex >= 0)
|
||||||
{
|
{
|
||||||
@@ -710,7 +698,7 @@ void Renderer::CBuffDelete(int first, int count)
|
|||||||
{
|
{
|
||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
const int end = first + count;
|
const int end = first + count;
|
||||||
for (int i = first; i < end; ++i)
|
for (int i = first; i < end; ++i)
|
||||||
{
|
{
|
||||||
@@ -728,7 +716,7 @@ void Renderer::CBuffDelete(int first, int count)
|
|||||||
|
|
||||||
void Renderer::CBuffEnd()
|
void Renderer::CBuffEnd()
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
if (context.deferredModeEnabled)
|
if (context.deferredModeEnabled)
|
||||||
@@ -743,12 +731,12 @@ void Renderer::CBuffEnd()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
int* internalToExternal = static_cast<int*>(reservedRendererPtr5);
|
int *internalToExternal = static_cast<int *>(reservedRendererPtr5);
|
||||||
std::uint8_t* internalVertexTypes = static_cast<std::uint8_t*>(reservedRendererPtr6);
|
std::uint8_t *internalVertexTypes = static_cast<std::uint8_t *>(reservedRendererPtr6);
|
||||||
std::uint8_t* internalPrimitiveTypes = reinterpret_cast<std::uint8_t*>(reservedRendererPtr1);
|
std::uint8_t *internalPrimitiveTypes = reinterpret_cast<std::uint8_t *>(reservedRendererPtr1);
|
||||||
Renderer::CommandBuffer** internalBuffers = static_cast<Renderer::CommandBuffer**>(reservedRendererPtr3);
|
Renderer::CommandBuffer **internalBuffers = static_cast<Renderer::CommandBuffer **>(reservedRendererPtr3);
|
||||||
DirectX::XMMATRIX* internalMatrices = static_cast<DirectX::XMMATRIX*>(reservedRendererPtr4);
|
DirectX::XMMATRIX *internalMatrices = static_cast<DirectX::XMMATRIX *>(reservedRendererPtr4);
|
||||||
|
|
||||||
const int existingIndex = externalToInternal[context.recordingBufferIndex];
|
const int existingIndex = externalToInternal[context.recordingBufferIndex];
|
||||||
if (existingIndex >= 0)
|
if (existingIndex >= 0)
|
||||||
@@ -793,10 +781,10 @@ int Renderer::CBuffSize(int index)
|
|||||||
|
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
const int internalIndex = static_cast<std::int16_t*>(reservedRendererPtr2)[index];
|
const int internalIndex = static_cast<std::int16_t *>(reservedRendererPtr2)[index];
|
||||||
if (internalIndex >= 0)
|
if (internalIndex >= 0)
|
||||||
{
|
{
|
||||||
size = static_cast<Renderer::CommandBuffer**>(reservedRendererPtr3)[internalIndex]->GetAllocated();
|
size = static_cast<Renderer::CommandBuffer **>(reservedRendererPtr3)[internalIndex]->GetAllocated();
|
||||||
}
|
}
|
||||||
LeaveCriticalSection(&rtl_critical_section100);
|
LeaveCriticalSection(&rtl_critical_section100);
|
||||||
return size;
|
return size;
|
||||||
@@ -804,7 +792,7 @@ int Renderer::CBuffSize(int index)
|
|||||||
|
|
||||||
void Renderer::CBuffStart(int index, bool full)
|
void Renderer::CBuffStart(int index, bool full)
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
context.commandBuffer = new (std::nothrow) Renderer::CommandBuffer(full);
|
context.commandBuffer = new (std::nothrow) Renderer::CommandBuffer(full);
|
||||||
context.recordingBufferIndex = index;
|
context.recordingBufferIndex = index;
|
||||||
context.matrixModeType = 3;
|
context.matrixModeType = 3;
|
||||||
@@ -819,11 +807,11 @@ void Renderer::CBuffTick()
|
|||||||
|
|
||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
Renderer::CommandBuffer** buffers = static_cast<Renderer::CommandBuffer**>(reservedRendererPtr3);
|
Renderer::CommandBuffer **buffers = static_cast<Renderer::CommandBuffer **>(reservedRendererPtr3);
|
||||||
const int firstPending = kMaxInternalCBuffers - static_cast<int>(reservedRendererDword3);
|
const int firstPending = kMaxInternalCBuffers - static_cast<int>(reservedRendererDword3);
|
||||||
for (int i = firstPending; i < kMaxInternalCBuffers; ++i)
|
for (int i = firstPending; i < kMaxInternalCBuffers; ++i)
|
||||||
{
|
{
|
||||||
Renderer::CommandBuffer* buffer = buffers[i];
|
Renderer::CommandBuffer *buffer = buffers[i];
|
||||||
if (buffer)
|
if (buffer)
|
||||||
{
|
{
|
||||||
delete buffer;
|
delete buffer;
|
||||||
@@ -841,12 +829,12 @@ void Renderer::DeleteInternalBuffer(int index)
|
|||||||
|
|
||||||
EnterCriticalSection(&rtl_critical_section100);
|
EnterCriticalSection(&rtl_critical_section100);
|
||||||
|
|
||||||
Renderer::CommandBuffer** internalBuffers = static_cast<Renderer::CommandBuffer**>(reservedRendererPtr3);
|
Renderer::CommandBuffer **internalBuffers = static_cast<Renderer::CommandBuffer **>(reservedRendererPtr3);
|
||||||
DirectX::XMMATRIX* internalMatrices = static_cast<DirectX::XMMATRIX*>(reservedRendererPtr4);
|
DirectX::XMMATRIX *internalMatrices = static_cast<DirectX::XMMATRIX *>(reservedRendererPtr4);
|
||||||
std::uint8_t* internalVertexTypes = static_cast<std::uint8_t*>(reservedRendererPtr6);
|
std::uint8_t *internalVertexTypes = static_cast<std::uint8_t *>(reservedRendererPtr6);
|
||||||
std::uint8_t* internalPrimitiveTypes = reinterpret_cast<std::uint8_t*>(reservedRendererPtr1);
|
std::uint8_t *internalPrimitiveTypes = reinterpret_cast<std::uint8_t *>(reservedRendererPtr1);
|
||||||
std::int16_t* externalToInternal = static_cast<std::int16_t*>(reservedRendererPtr2);
|
std::int16_t *externalToInternal = static_cast<std::int16_t *>(reservedRendererPtr2);
|
||||||
int* internalToExternal = static_cast<int*>(reservedRendererPtr5);
|
int *internalToExternal = static_cast<int *>(reservedRendererPtr5);
|
||||||
|
|
||||||
++reservedRendererDword3;
|
++reservedRendererDword3;
|
||||||
const int recycledSlot = kMaxInternalCBuffers - static_cast<int>(reservedRendererDword3);
|
const int recycledSlot = kMaxInternalCBuffers - static_cast<int>(reservedRendererDword3);
|
||||||
|
|||||||
@@ -9,70 +9,52 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
Renderer InternalRenderManager;
|
||||||
|
|
||||||
|
DWORD Renderer::tlsIdx = TlsAlloc();
|
||||||
|
int Renderer::totalAlloc = 0;
|
||||||
|
_RTL_CRITICAL_SECTION Renderer::totalAllocCS = {0};
|
||||||
|
|
||||||
static const unsigned int kVertexBufferSize = 0x100000u;
|
static const unsigned int kVertexBufferSize = 0x100000u;
|
||||||
static const float kAspectRatio = 1.7777778f;
|
static const float kAspectRatio = 1.7777778f;
|
||||||
static const unsigned int kScreenGrabWidth = 1920u;
|
static const unsigned int kScreenGrabWidth = 1920u;
|
||||||
static const unsigned int kScreenGrabHeight = 1080u;
|
static const unsigned int kScreenGrabHeight = 1080u;
|
||||||
static const unsigned int kThumbnailSize = 64u;
|
static const unsigned int kThumbnailSize = 64u;
|
||||||
|
|
||||||
static const unsigned int g_vertexStrides[C4JRender::VERTEX_TYPE_COUNT] = {
|
static const unsigned int g_vertexStrides[C4JRender::VERTEX_TYPE_COUNT] = {32u, 16u, 32u, 32u};
|
||||||
32u, 16u, 32u, 32u};
|
|
||||||
|
|
||||||
Renderer InternalRenderManager;
|
unsigned int Renderer::s_auiWidths[MAX_MIP_LEVELS + 1] = {1920u, 512u, 256u, 128u, 64u, 0u};
|
||||||
|
|
||||||
|
unsigned int Renderer::s_auiHeights[MAX_MIP_LEVELS + 1] = {1080u, 512u, 256u, 128u, 64u, 0xFFFFFFFFu};
|
||||||
|
|
||||||
DWORD Renderer::tlsIdx = TlsAlloc();
|
|
||||||
unsigned int Renderer::s_auiWidths[MAX_MIP_LEVELS + 1] = {1920u, 512u, 256u,
|
|
||||||
128u, 64u, 0u};
|
|
||||||
unsigned int Renderer::s_auiHeights[MAX_MIP_LEVELS + 1] = {
|
|
||||||
1080u, 512u, 256u, 128u, 64u, 0xFFFFFFFFu};
|
|
||||||
D3D11_INPUT_ELEMENT_DESC Renderer::g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1[5] = {
|
D3D11_INPUT_ELEMENT_DESC Renderer::g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1[5] = {
|
||||||
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,
|
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
D3D11_INPUT_PER_VERTEX_DATA, 0},
|
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12,
|
{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
D3D11_INPUT_PER_VERTEX_DATA, 0},
|
{"NORMAL", 0, DXGI_FORMAT_R8G8B8A8_SNORM, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 20, D3D11_INPUT_PER_VERTEX_DATA,
|
{"TEXCOORD", 1, DXGI_FORMAT_R16G16_SINT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
0},
|
|
||||||
{"NORMAL", 0, DXGI_FORMAT_R8G8B8A8_SNORM, 0, 24,
|
|
||||||
D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
||||||
{"TEXCOORD", 1, DXGI_FORMAT_R16G16_SINT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA,
|
|
||||||
0},
|
|
||||||
};
|
};
|
||||||
D3D11_INPUT_ELEMENT_DESC Renderer::g_vertex_PTN_Elements_Compressed[2] = {
|
|
||||||
{"POSITION", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 0,
|
|
||||||
D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
||||||
{"TEXCOORD", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 8,
|
|
||||||
D3D11_INPUT_PER_VERTEX_DATA, 0},
|
|
||||||
};
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY Renderer::g_topologies[C4JRender::PRIMITIVE_TYPE_COUNT] = {
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST,
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP,
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST,
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST,
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_LINELIST,
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP,
|
|
||||||
};
|
|
||||||
int Renderer::totalAlloc = 0;
|
|
||||||
_RTL_CRITICAL_SECTION Renderer::totalAllocCS = {0};
|
|
||||||
|
|
||||||
Renderer::Context::Context(ID3D11Device *device,
|
D3D11_INPUT_ELEMENT_DESC Renderer::g_vertex_PTN_Elements_Compressed[2] = {
|
||||||
ID3D11DeviceContext *deviceContext)
|
{"POSITION", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
: m_pDeviceContext(deviceContext), userAnnotation(nullptr),
|
{"TEXCOORD", 0, DXGI_FORMAT_R16G16B16A16_SINT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||||
contextStateFlags(0), matrixModeType(0), boundTextureIndex(0),
|
};
|
||||||
faceCullEnabled(1), depthTestEnabled(1), alphaTestEnabled(0),
|
|
||||||
alphaReference(1.0f), depthWriteEnabled(1), fogEnabled(0),
|
D3D11_PRIMITIVE_TOPOLOGY Renderer::g_topologies[C4JRender::PRIMITIVE_TYPE_COUNT] = {
|
||||||
fogNearDistance(0.0f), fogFarDistance(0.0f), fogDensity(0.0f),
|
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST,
|
||||||
fogColourRed(0.0f), fogColourBlue(0.0f), fogColourGreen(0.0f), fogMode(0),
|
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D11_PRIMITIVE_TOPOLOGY_LINELIST, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP,
|
||||||
lightingEnabled(0), lightingDirty(0), forcedLOD(0xFFFFFFFFu),
|
};
|
||||||
cbMatrix0(nullptr), cbMatrix1(nullptr), cbMatrix2(nullptr),
|
|
||||||
cbMatrix3(nullptr), cbVertexTexcoord(nullptr), cbFogParams(nullptr),
|
Renderer::Context::Context(ID3D11Device *device, ID3D11DeviceContext *deviceContext)
|
||||||
cbLighting(nullptr), cbTexGen(nullptr), cbAux0(nullptr), cbAux1(nullptr),
|
: m_pDeviceContext(deviceContext), userAnnotation(nullptr), contextStateFlags(0), matrixModeType(0), boundTextureIndex(0), faceCullEnabled(1),
|
||||||
cbColour(nullptr), cbFogColour(nullptr), cbAux2(nullptr),
|
depthTestEnabled(1), alphaTestEnabled(0), alphaReference(1.0f), depthWriteEnabled(1), fogEnabled(0), fogNearDistance(0.0f),
|
||||||
cbAlphaTest(nullptr), cbAux3(nullptr), cbAux4(nullptr),
|
fogFarDistance(0.0f), fogDensity(0.0f), fogColourRed(0.0f), fogColourBlue(0.0f), fogColourGreen(0.0f), fogMode(0), lightingEnabled(0),
|
||||||
dynamicVertexBase(0), dynamicVertexOffset(0),
|
lightingDirty(0), forcedLOD(0xFFFFFFFFu), cbMatrix0(nullptr), cbMatrix1(nullptr), cbMatrix2(nullptr), cbMatrix3(nullptr),
|
||||||
dynamicVertexBuffer(nullptr), commandBuffer(nullptr),
|
cbVertexTexcoord(nullptr), cbFogParams(nullptr), cbLighting(nullptr), cbTexGen(nullptr), cbAux0(nullptr), cbAux1(nullptr), cbColour(nullptr),
|
||||||
recordingBufferIndex(0), recordingVertexType(0),
|
cbFogColour(nullptr), cbAux2(nullptr), cbAlphaTest(nullptr), cbAux3(nullptr), cbAux4(nullptr), dynamicVertexBase(0), dynamicVertexOffset(0),
|
||||||
recordingPrimitiveType(0), deferredModeEnabled(0), deferredBuffers(),
|
dynamicVertexBuffer(nullptr), commandBuffer(nullptr), recordingBufferIndex(0), recordingVertexType(0), recordingPrimitiveType(0),
|
||||||
reservedContext0(0), reservedContext1(0) {
|
deferredModeEnabled(0), deferredBuffers(), reservedContext0(0), reservedContext1(0)
|
||||||
|
{
|
||||||
deviceContext->QueryInterface(IID_PPV_ARGS(&userAnnotation));
|
deviceContext->QueryInterface(IID_PPV_ARGS(&userAnnotation));
|
||||||
std::memset(matrixStacks, 0, sizeof(matrixStacks));
|
std::memset(matrixStacks, 0, sizeof(matrixStacks));
|
||||||
std::memset(matrixDirty, 0, sizeof(matrixDirty));
|
std::memset(matrixDirty, 0, sizeof(matrixDirty));
|
||||||
@@ -91,7 +73,8 @@ Renderer::Context::Context(ID3D11Device *device,
|
|||||||
blendFactor[3] = 0.0f;
|
blendFactor[3] = 0.0f;
|
||||||
|
|
||||||
const DirectX::XMMATRIX identity = DirectX::XMMatrixIdentity();
|
const DirectX::XMMATRIX identity = DirectX::XMMatrixIdentity();
|
||||||
for (unsigned int i = 0; i < 4; ++i) {
|
for (unsigned int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
matrixStacks[i][0] = identity;
|
matrixStacks[i][0] = identity;
|
||||||
matrixStackDepth[i] = 0;
|
matrixStackDepth[i] = 0;
|
||||||
}
|
}
|
||||||
@@ -105,8 +88,7 @@ Renderer::Context::Context(ID3D11Device *device,
|
|||||||
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||||
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||||
blendDesc.RenderTarget[0].RenderTargetWriteMask =
|
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||||
D3D11_COLOR_WRITE_ENABLE_ALL;
|
|
||||||
|
|
||||||
depthStencilDesc.DepthEnable = TRUE;
|
depthStencilDesc.DepthEnable = TRUE;
|
||||||
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
@@ -161,8 +143,7 @@ Renderer::Context::Context(ID3D11Device *device,
|
|||||||
device->CreateBuffer(&cbDesc, &cbData, &cbVertexTexcoord);
|
device->CreateBuffer(&cbDesc, &cbData, &cbVertexTexcoord);
|
||||||
device->CreateBuffer(&cbDesc, &cbData, &cbFogParams);
|
device->CreateBuffer(&cbDesc, &cbData, &cbFogParams);
|
||||||
|
|
||||||
const UINT lightingBytes =
|
const UINT lightingBytes = sizeof(lightDirection) + sizeof(lightColour) + sizeof(lightAmbientColour);
|
||||||
sizeof(lightDirection) + sizeof(lightColour) + sizeof(lightAmbientColour);
|
|
||||||
cbDesc.ByteWidth = lightingBytes;
|
cbDesc.ByteWidth = lightingBytes;
|
||||||
cbData.pSysMem = lightDirection;
|
cbData.pSysMem = lightDirection;
|
||||||
device->CreateBuffer(&cbDesc, &cbData, &cbLighting);
|
device->CreateBuffer(&cbDesc, &cbData, &cbLighting);
|
||||||
@@ -214,7 +195,8 @@ void Renderer::BeginConditionalSurvey(int) {}
|
|||||||
|
|
||||||
void Renderer::CaptureScreen(ImageFileBuffer *, XSOCIAL_PREVIEWIMAGE *) {}
|
void Renderer::CaptureScreen(ImageFileBuffer *, XSOCIAL_PREVIEWIMAGE *) {}
|
||||||
|
|
||||||
void Renderer::Clear(int flags, D3D11_RECT *) {
|
void Renderer::Clear(int flags, D3D11_RECT *)
|
||||||
|
{
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
|
|
||||||
ID3D11BlendState *blendState = nullptr;
|
ID3D11BlendState *blendState = nullptr;
|
||||||
@@ -231,15 +213,12 @@ void Renderer::Clear(int flags, D3D11_RECT *) {
|
|||||||
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||||
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||||
blendDesc.RenderTarget[0].RenderTargetWriteMask =
|
blendDesc.RenderTarget[0].RenderTargetWriteMask = (flags & CLEAR_COLOUR_FLAG) ? D3D11_COLOR_WRITE_ENABLE_ALL : 0;
|
||||||
(flags & CLEAR_COLOUR_FLAG) ? D3D11_COLOR_WRITE_ENABLE_ALL : 0;
|
|
||||||
m_pDevice->CreateBlendState(&blendDesc, &blendState);
|
m_pDevice->CreateBlendState(&blendDesc, &blendState);
|
||||||
|
|
||||||
D3D11_DEPTH_STENCIL_DESC depthDesc = {};
|
D3D11_DEPTH_STENCIL_DESC depthDesc = {};
|
||||||
depthDesc.DepthEnable = (flags & CLEAR_DEPTH_FLAG) ? TRUE : FALSE;
|
depthDesc.DepthEnable = (flags & CLEAR_DEPTH_FLAG) ? TRUE : FALSE;
|
||||||
depthDesc.DepthWriteMask = depthDesc.DepthEnable
|
depthDesc.DepthWriteMask = depthDesc.DepthEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
? D3D11_DEPTH_WRITE_MASK_ALL
|
|
||||||
: D3D11_DEPTH_WRITE_MASK_ZERO;
|
|
||||||
depthDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
|
depthDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
depthDesc.StencilEnable = FALSE;
|
depthDesc.StencilEnable = FALSE;
|
||||||
depthDesc.StencilReadMask = 0xFFu;
|
depthDesc.StencilReadMask = 0xFFu;
|
||||||
@@ -264,43 +243,40 @@ void Renderer::Clear(int flags, D3D11_RECT *) {
|
|||||||
context.m_pDeviceContext->VSSetShader(screenClearVertexShader, nullptr, 0);
|
context.m_pDeviceContext->VSSetShader(screenClearVertexShader, nullptr, 0);
|
||||||
context.m_pDeviceContext->IASetInputLayout(nullptr);
|
context.m_pDeviceContext->IASetInputLayout(nullptr);
|
||||||
context.m_pDeviceContext->PSSetShader(screenClearPixelShader, nullptr, 0);
|
context.m_pDeviceContext->PSSetShader(screenClearPixelShader, nullptr, 0);
|
||||||
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView,
|
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
|
||||||
depthStencilView);
|
|
||||||
context.m_pDeviceContext->OMSetBlendState(blendState, nullptr, 0xFFFFFFFFu);
|
context.m_pDeviceContext->OMSetBlendState(blendState, nullptr, 0xFFFFFFFFu);
|
||||||
context.m_pDeviceContext->OMSetDepthStencilState(depthState, 0);
|
context.m_pDeviceContext->OMSetDepthStencilState(depthState, 0);
|
||||||
context.m_pDeviceContext->RSSetState(rasterizerState);
|
context.m_pDeviceContext->RSSetState(rasterizerState);
|
||||||
context.m_pDeviceContext->PSSetShaderResources(0, 0, nullptr);
|
context.m_pDeviceContext->PSSetShaderResources(0, 0, nullptr);
|
||||||
context.m_pDeviceContext->IASetPrimitiveTopology(
|
context.m_pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
|
||||||
context.m_pDeviceContext->Draw(4, 0);
|
context.m_pDeviceContext->Draw(4, 0);
|
||||||
|
|
||||||
if (blendState) {
|
if (blendState)
|
||||||
|
{
|
||||||
blendState->Release();
|
blendState->Release();
|
||||||
blendState = nullptr;
|
blendState = nullptr;
|
||||||
}
|
}
|
||||||
if (depthState) {
|
if (depthState)
|
||||||
|
{
|
||||||
depthState->Release();
|
depthState->Release();
|
||||||
depthState = nullptr;
|
depthState = nullptr;
|
||||||
}
|
}
|
||||||
if (rasterizerState) {
|
if (rasterizerState)
|
||||||
|
{
|
||||||
rasterizerState->Release();
|
rasterizerState->Release();
|
||||||
rasterizerState = nullptr;
|
rasterizerState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.m_pDeviceContext->OMSetBlendState(this->GetManagedBlendState(),
|
context.m_pDeviceContext->OMSetBlendState(this->GetManagedBlendState(), context.blendFactor, 0xFFFFFFFFu);
|
||||||
context.blendFactor, 0xFFFFFFFFu);
|
context.m_pDeviceContext->OMSetDepthStencilState(this->GetManagedDepthStencilState(), 0);
|
||||||
context.m_pDeviceContext->OMSetDepthStencilState(
|
|
||||||
this->GetManagedDepthStencilState(), 0);
|
|
||||||
context.m_pDeviceContext->RSSetState(this->GetManagedRasterizerState());
|
context.m_pDeviceContext->RSSetState(this->GetManagedRasterizerState());
|
||||||
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView,
|
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
|
||||||
depthStencilView);
|
|
||||||
activeVertexType = 0xFFFFFFFFu;
|
activeVertexType = 0xFFFFFFFFu;
|
||||||
activePixelType = 0xFFFFFFFFu;
|
activePixelType = 0xFFFFFFFFu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::ConvertLinearToPng(ImageFileBuffer *pngOut,
|
void Renderer::ConvertLinearToPng(ImageFileBuffer *pngOut, unsigned char *linearData, unsigned int width, unsigned int height)
|
||||||
unsigned char *linearData, unsigned int width,
|
{
|
||||||
unsigned int height) {
|
|
||||||
const size_t dataSize = size_t(width) * size_t(height) * 4u;
|
const size_t dataSize = size_t(width) * size_t(height) * 4u;
|
||||||
const size_t outputCapacity = ((dataSize * 24u) / 20u) + 256u;
|
const size_t outputCapacity = ((dataSize * 24u) / 20u) + 256u;
|
||||||
const int outputCapacityInt = int(outputCapacity);
|
const int outputCapacityInt = int(outputCapacity);
|
||||||
@@ -308,45 +284,46 @@ void Renderer::ConvertLinearToPng(ImageFileBuffer *pngOut,
|
|||||||
const int heightInt = int(height);
|
const int heightInt = int(height);
|
||||||
void *outputBuffer = std::malloc(outputCapacity);
|
void *outputBuffer = std::malloc(outputCapacity);
|
||||||
int outputLength = 0;
|
int outputLength = 0;
|
||||||
this->SaveTextureDataToMemory(outputBuffer, outputCapacityInt, &outputLength,
|
this->SaveTextureDataToMemory(outputBuffer, outputCapacityInt, &outputLength, widthInt, heightInt, reinterpret_cast<int *>(linearData));
|
||||||
widthInt, heightInt,
|
|
||||||
reinterpret_cast<int *>(linearData));
|
|
||||||
pngOut->m_type = ImageFileBuffer::e_typePNG;
|
pngOut->m_type = ImageFileBuffer::e_typePNG;
|
||||||
pngOut->m_pBuffer = outputBuffer;
|
pngOut->m_pBuffer = outputBuffer;
|
||||||
pngOut->m_bufferSize = outputLength;
|
pngOut->m_bufferSize = outputLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DoScreenGrabOnNextPresent() { shouldScreenGrabNextFrame = 1; }
|
void Renderer::DoScreenGrabOnNextPresent()
|
||||||
|
{
|
||||||
|
shouldScreenGrabNextFrame = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::EndConditionalRendering() {}
|
void Renderer::EndConditionalRendering() {}
|
||||||
|
|
||||||
void Renderer::EndConditionalSurvey() {}
|
void Renderer::EndConditionalSurvey() {}
|
||||||
|
|
||||||
void Renderer::BeginEvent(LPCWSTR eventName) {
|
void Renderer::BeginEvent(LPCWSTR eventName)
|
||||||
Renderer::Context *context =
|
{
|
||||||
static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
Renderer::Context *context = static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
||||||
if (context &&
|
if (context && context->m_pDeviceContext->GetType() != D3D11_DEVICE_CONTEXT_DEFERRED && context->userAnnotation)
|
||||||
context->m_pDeviceContext->GetType() != D3D11_DEVICE_CONTEXT_DEFERRED &&
|
{
|
||||||
context->userAnnotation) {
|
|
||||||
context->userAnnotation->BeginEvent(eventName);
|
context->userAnnotation->BeginEvent(eventName);
|
||||||
++context->contextStateFlags;
|
++context->contextStateFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::EndEvent() {
|
void Renderer::EndEvent()
|
||||||
Renderer::Context *context =
|
{
|
||||||
static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
Renderer::Context *context = static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
||||||
if (context &&
|
if (context && context->m_pDeviceContext->GetType() != D3D11_DEVICE_CONTEXT_DEFERRED && context->userAnnotation)
|
||||||
context->m_pDeviceContext->GetType() != D3D11_DEVICE_CONTEXT_DEFERRED &&
|
{
|
||||||
context->userAnnotation) {
|
|
||||||
context->userAnnotation->EndEvent();
|
context->userAnnotation->EndEvent();
|
||||||
if (context->contextStateFlags > 0) {
|
if (context->contextStateFlags > 0)
|
||||||
|
{
|
||||||
--context->contextStateFlags;
|
--context->contextStateFlags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain)
|
||||||
|
{
|
||||||
m_pDevice = pDevice;
|
m_pDevice = pDevice;
|
||||||
m_pDeviceContext = this->InitialiseContext(true);
|
m_pDeviceContext = this->InitialiseContext(true);
|
||||||
m_pSwapChain = pSwapChain;
|
m_pSwapChain = pSwapChain;
|
||||||
@@ -382,7 +359,8 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
UINT backBufferSampleQuality = 0;
|
UINT backBufferSampleQuality = 0;
|
||||||
ID3D11Texture2D *backBuffer = nullptr;
|
ID3D11Texture2D *backBuffer = nullptr;
|
||||||
pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
|
pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
|
||||||
if (backBuffer) {
|
if (backBuffer)
|
||||||
|
{
|
||||||
D3D11_TEXTURE2D_DESC backDesc = {};
|
D3D11_TEXTURE2D_DESC backDesc = {};
|
||||||
backBuffer->GetDesc(&backDesc);
|
backBuffer->GetDesc(&backDesc);
|
||||||
backBufferWidth = backDesc.Width;
|
backBufferWidth = backDesc.Width;
|
||||||
@@ -390,18 +368,19 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
backBufferSampleCount = backDesc.SampleDesc.Count;
|
backBufferSampleCount = backDesc.SampleDesc.Count;
|
||||||
backBufferSampleQuality = backDesc.SampleDesc.Quality;
|
backBufferSampleQuality = backDesc.SampleDesc.Quality;
|
||||||
m_pDevice->CreateRenderTargetView(backBuffer, nullptr, &renderTargetView);
|
m_pDevice->CreateRenderTargetView(backBuffer, nullptr, &renderTargetView);
|
||||||
m_pDevice->CreateShaderResourceView(backBuffer, nullptr,
|
m_pDevice->CreateShaderResourceView(backBuffer, nullptr, &renderTargetShaderResourceView);
|
||||||
&renderTargetShaderResourceView);
|
|
||||||
backBuffer->Release();
|
backBuffer->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11RenderTargetView *boundRTV = nullptr;
|
ID3D11RenderTargetView *boundRTV = nullptr;
|
||||||
m_pDeviceContext->OMGetRenderTargets(1, &boundRTV, &depthStencilView);
|
m_pDeviceContext->OMGetRenderTargets(1, &boundRTV, &depthStencilView);
|
||||||
if (boundRTV) {
|
if (boundRTV)
|
||||||
|
{
|
||||||
boundRTV->Release();
|
boundRTV->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!depthStencilView && backBufferWidth != 0 && backBufferHeight != 0) {
|
if (!depthStencilView && backBufferWidth != 0 && backBufferHeight != 0)
|
||||||
|
{
|
||||||
D3D11_TEXTURE2D_DESC depthDesc = {};
|
D3D11_TEXTURE2D_DESC depthDesc = {};
|
||||||
depthDesc.Width = backBufferWidth;
|
depthDesc.Width = backBufferWidth;
|
||||||
depthDesc.Height = backBufferHeight;
|
depthDesc.Height = backBufferHeight;
|
||||||
@@ -414,15 +393,15 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
|
|
||||||
ID3D11Texture2D *depthTexture = nullptr;
|
ID3D11Texture2D *depthTexture = nullptr;
|
||||||
if (SUCCEEDED(
|
if (SUCCEEDED(m_pDevice->CreateTexture2D(&depthDesc, nullptr, &depthTexture)))
|
||||||
m_pDevice->CreateTexture2D(&depthDesc, nullptr, &depthTexture))) {
|
{
|
||||||
m_pDevice->CreateDepthStencilView(depthTexture, nullptr,
|
m_pDevice->CreateDepthStencilView(depthTexture, nullptr, &depthStencilView);
|
||||||
&depthStencilView);
|
|
||||||
depthTexture->Release();
|
depthTexture->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_MIP_LEVELS - 1; ++i) {
|
for (unsigned int i = 0; i < MAX_MIP_LEVELS - 1; ++i)
|
||||||
|
{
|
||||||
D3D11_TEXTURE2D_DESC desc = {};
|
D3D11_TEXTURE2D_DESC desc = {};
|
||||||
desc.Width = s_auiWidths[i + 1];
|
desc.Width = s_auiWidths[i + 1];
|
||||||
desc.Height = s_auiHeights[i + 1];
|
desc.Height = s_auiHeights[i + 1];
|
||||||
@@ -434,10 +413,8 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
|
||||||
m_pDevice->CreateTexture2D(&desc, nullptr, &renderTargetTextures[i]);
|
m_pDevice->CreateTexture2D(&desc, nullptr, &renderTargetTextures[i]);
|
||||||
m_pDevice->CreateRenderTargetView(renderTargetTextures[i], nullptr,
|
m_pDevice->CreateRenderTargetView(renderTargetTextures[i], nullptr, &renderTargetViews[i]);
|
||||||
&renderTargetViews[i]);
|
m_pDevice->CreateShaderResourceView(renderTargetTextures[i], nullptr, &renderTargetShaderResourceViews[i]);
|
||||||
m_pDevice->CreateShaderResourceView(renderTargetTextures[i], nullptr,
|
|
||||||
&renderTargetShaderResourceViews[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memset(m_textures, 0, sizeof(m_textures));
|
std::memset(m_textures, 0, sizeof(m_textures));
|
||||||
@@ -446,8 +423,7 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
|
|
||||||
unsigned char *defaultTextureData = new unsigned char[0x400u];
|
unsigned char *defaultTextureData = new unsigned char[0x400u];
|
||||||
std::memset(defaultTextureData, 0xFF, 0x400u);
|
std::memset(defaultTextureData, 0xFF, 0x400u);
|
||||||
this->TextureData(16, 16, defaultTextureData, 0,
|
this->TextureData(16, 16, defaultTextureData, 0, C4JRender::TEXTURE_FORMAT_RxGyBzAw);
|
||||||
C4JRender::TEXTURE_FORMAT_RxGyBzAw);
|
|
||||||
delete[] defaultTextureData;
|
delete[] defaultTextureData;
|
||||||
|
|
||||||
presentCount = 0;
|
presentCount = 0;
|
||||||
@@ -464,7 +440,8 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
reservedRendererByte0 = 0;
|
reservedRendererByte0 = 0;
|
||||||
|
|
||||||
unsigned short *quadIndices = new unsigned short[0x18000u];
|
unsigned short *quadIndices = new unsigned short[0x18000u];
|
||||||
for (unsigned int i = 0; i < 0x4000u; ++i) {
|
for (unsigned int i = 0; i < 0x4000u; ++i)
|
||||||
|
{
|
||||||
const unsigned short base = (unsigned short)(i * 4u);
|
const unsigned short base = (unsigned short)(i * 4u);
|
||||||
const unsigned int offset = i * 6u;
|
const unsigned int offset = i * 6u;
|
||||||
quadIndices[offset + 0] = base;
|
quadIndices[offset + 0] = base;
|
||||||
@@ -484,7 +461,8 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
delete[] quadIndices;
|
delete[] quadIndices;
|
||||||
|
|
||||||
unsigned short *fanIndices = new unsigned short[0x2FFFAu];
|
unsigned short *fanIndices = new unsigned short[0x2FFFAu];
|
||||||
for (unsigned int i = 0; i < 65534u; ++i) {
|
for (unsigned int i = 0; i < 65534u; ++i)
|
||||||
|
{
|
||||||
const unsigned int offset = i * 3u;
|
const unsigned int offset = i * 3u;
|
||||||
fanIndices[offset + 0] = 0u;
|
fanIndices[offset + 0] = 0u;
|
||||||
fanIndices[offset + 1] = (unsigned short)(i + 1u);
|
fanIndices[offset + 1] = (unsigned short)(i + 1u);
|
||||||
@@ -503,32 +481,44 @@ void Renderer::Initialise(ID3D11Device *pDevice, IDXGISwapChain *pSwapChain) {
|
|||||||
m_Topologies = g_topologies;
|
m_Topologies = g_topologies;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11DeviceContext *Renderer::InitialiseContext(bool fromPresent) {
|
ID3D11DeviceContext *Renderer::InitialiseContext(bool fromPresent)
|
||||||
|
{
|
||||||
ID3D11DeviceContext *deviceContext = nullptr;
|
ID3D11DeviceContext *deviceContext = nullptr;
|
||||||
if (fromPresent) {
|
if (fromPresent)
|
||||||
|
{
|
||||||
m_pDevice->GetImmediateContext(&deviceContext);
|
m_pDevice->GetImmediateContext(&deviceContext);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_pDevice->CreateDeferredContext(0, &deviceContext);
|
m_pDevice->CreateDeferredContext(0, &deviceContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::Context *context =
|
Renderer::Context *context = new (std::nothrow) Renderer::Context(m_pDevice, deviceContext);
|
||||||
new (std::nothrow) Renderer::Context(m_pDevice, deviceContext);
|
|
||||||
TlsSetValue(Renderer::tlsIdx, context);
|
TlsSetValue(Renderer::tlsIdx, context);
|
||||||
return deviceContext;
|
return deviceContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Renderer::IsHiDef() { return true; }
|
bool Renderer::IsHiDef()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Renderer::IsWidescreen() { return true; }
|
bool Renderer::IsWidescreen()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::Present() {
|
void Renderer::Present()
|
||||||
if (shouldScreenGrabNextFrame) {
|
{
|
||||||
|
if (shouldScreenGrabNextFrame)
|
||||||
|
{
|
||||||
int *linearData = new int[kScreenGrabWidth * kScreenGrabHeight];
|
int *linearData = new int[kScreenGrabWidth * kScreenGrabHeight];
|
||||||
ID3D11Texture2D *backBuffer = nullptr;
|
ID3D11Texture2D *backBuffer = nullptr;
|
||||||
ID3D11Texture2D *stagingTexture = nullptr;
|
ID3D11Texture2D *stagingTexture = nullptr;
|
||||||
|
|
||||||
m_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
|
m_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&backBuffer));
|
||||||
if (backBuffer) {
|
if (backBuffer)
|
||||||
|
{
|
||||||
D3D11_TEXTURE2D_DESC desc = {};
|
D3D11_TEXTURE2D_DESC desc = {};
|
||||||
backBuffer->GetDesc(&desc);
|
backBuffer->GetDesc(&desc);
|
||||||
desc.Usage = D3D11_USAGE_STAGING;
|
desc.Usage = D3D11_USAGE_STAGING;
|
||||||
@@ -538,19 +528,21 @@ void Renderer::Present() {
|
|||||||
m_pDevice->CreateTexture2D(&desc, nullptr, &stagingTexture);
|
m_pDevice->CreateTexture2D(&desc, nullptr, &stagingTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stagingTexture && backBuffer) {
|
if (stagingTexture && backBuffer)
|
||||||
|
{
|
||||||
m_pDeviceContext->CopyResource(stagingTexture, backBuffer);
|
m_pDeviceContext->CopyResource(stagingTexture, backBuffer);
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
if (SUCCEEDED(m_pDeviceContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0,
|
if (SUCCEEDED(m_pDeviceContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mapped)))
|
||||||
&mapped))) {
|
{
|
||||||
unsigned char *dst = reinterpret_cast<unsigned char *>(linearData);
|
unsigned char *dst = reinterpret_cast<unsigned char *>(linearData);
|
||||||
const unsigned char *src =
|
const unsigned char *src = reinterpret_cast<const unsigned char *>(mapped.pData);
|
||||||
reinterpret_cast<const unsigned char *>(mapped.pData);
|
for (unsigned int y = 0; y < kScreenGrabHeight; ++y)
|
||||||
for (unsigned int y = 0; y < kScreenGrabHeight; ++y) {
|
{
|
||||||
unsigned char *dstRow = dst + y * (kScreenGrabWidth * 4u);
|
unsigned char *dstRow = dst + y * (kScreenGrabWidth * 4u);
|
||||||
const unsigned char *srcRow = src + y * mapped.RowPitch;
|
const unsigned char *srcRow = src + y * mapped.RowPitch;
|
||||||
std::memcpy(dstRow, srcRow, kScreenGrabWidth * 4u);
|
std::memcpy(dstRow, srcRow, kScreenGrabWidth * 4u);
|
||||||
for (unsigned int x = 0; x < kScreenGrabWidth; ++x) {
|
for (unsigned int x = 0; x < kScreenGrabWidth; ++x)
|
||||||
|
{
|
||||||
dstRow[x * 4u + 3u] = 0xFF;
|
dstRow[x * 4u + 3u] = 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,11 +559,13 @@ void Renderer::Present() {
|
|||||||
this->SaveTextureData(fileName, &info, linearData);
|
this->SaveTextureData(fileName, &info, linearData);
|
||||||
delete[] linearData;
|
delete[] linearData;
|
||||||
|
|
||||||
if (stagingTexture) {
|
if (stagingTexture)
|
||||||
|
{
|
||||||
stagingTexture->Release();
|
stagingTexture->Release();
|
||||||
stagingTexture = nullptr;
|
stagingTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (backBuffer) {
|
if (backBuffer)
|
||||||
|
{
|
||||||
backBuffer->Release();
|
backBuffer->Release();
|
||||||
backBuffer = nullptr;
|
backBuffer = nullptr;
|
||||||
}
|
}
|
||||||
@@ -582,35 +576,41 @@ void Renderer::Present() {
|
|||||||
++presentCount;
|
++presentCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Resume() { suspended = 0; }
|
void Renderer::Resume()
|
||||||
|
{
|
||||||
|
suspended = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::SetClearColour(const float colourRGBA[4]) {
|
void Renderer::SetClearColour(const float colourRGBA[4])
|
||||||
|
{
|
||||||
std::memcpy(m_fClearColor, colourRGBA, sizeof(m_fClearColor));
|
std::memcpy(m_fClearColor, colourRGBA, sizeof(m_fClearColor));
|
||||||
|
|
||||||
Renderer::Context *context =
|
Renderer::Context *context = static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
||||||
static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
if (context)
|
||||||
if (context) {
|
{
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
context->m_pDeviceContext->Map(context->cbAux3, 0, D3D11_MAP_WRITE_DISCARD,
|
context->m_pDeviceContext->Map(context->cbAux3, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
0, &mapped);
|
|
||||||
std::memcpy(mapped.pData, colourRGBA, sizeof(float) * 4);
|
std::memcpy(mapped.pData, colourRGBA, sizeof(float) * 4);
|
||||||
context->m_pDeviceContext->Unmap(context->cbAux3, 0);
|
context->m_pDeviceContext->Unmap(context->cbAux3, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetupShaders() {
|
void Renderer::SetupShaders()
|
||||||
|
{
|
||||||
vertexShaderTable = new ID3D11VertexShader *[C4JRender::VERTEX_TYPE_COUNT];
|
vertexShaderTable = new ID3D11VertexShader *[C4JRender::VERTEX_TYPE_COUNT];
|
||||||
pixelShaderTable = new ID3D11PixelShader *[C4JRender::PIXEL_SHADER_COUNT];
|
pixelShaderTable = new ID3D11PixelShader *[C4JRender::PIXEL_SHADER_COUNT];
|
||||||
vertexStrideTable = new unsigned int[C4JRender::VERTEX_TYPE_COUNT];
|
vertexStrideTable = new unsigned int[C4JRender::VERTEX_TYPE_COUNT];
|
||||||
inputLayoutTable = new ID3D11InputLayout *[C4JRender::VERTEX_TYPE_COUNT];
|
inputLayoutTable = new ID3D11InputLayout *[C4JRender::VERTEX_TYPE_COUNT];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < C4JRender::VERTEX_TYPE_COUNT; ++i) {
|
for (unsigned int i = 0; i < C4JRender::VERTEX_TYPE_COUNT; ++i)
|
||||||
|
{
|
||||||
vertexShaderTable[i] = nullptr;
|
vertexShaderTable[i] = nullptr;
|
||||||
inputLayoutTable[i] = nullptr;
|
inputLayoutTable[i] = nullptr;
|
||||||
vertexStrideTable[i] = g_vertexStrides[i];
|
vertexStrideTable[i] = g_vertexStrides[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < C4JRender::PIXEL_SHADER_COUNT; ++i) {
|
for (unsigned int i = 0; i < C4JRender::PIXEL_SHADER_COUNT; ++i)
|
||||||
|
{
|
||||||
pixelShaderTable[i] = nullptr;
|
pixelShaderTable[i] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,62 +619,35 @@ void Renderer::SetupShaders() {
|
|||||||
screenSpacePixelShader = nullptr;
|
screenSpacePixelShader = nullptr;
|
||||||
screenClearPixelShader = nullptr;
|
screenClearPixelShader = nullptr;
|
||||||
|
|
||||||
m_pDevice->CreateVertexShader(
|
m_pDevice->CreateVertexShader(VS_PF3_TF2_CB4_NB4_XW1_Data, sizeof(VS_PF3_TF2_CB4_NB4_XW1_Data), nullptr,
|
||||||
VS_PF3_TF2_CB4_NB4_XW1_Data, sizeof(VS_PF3_TF2_CB4_NB4_XW1_Data), nullptr,
|
|
||||||
&vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1]);
|
&vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1]);
|
||||||
m_pDevice->CreateVertexShader(
|
m_pDevice->CreateVertexShader(VS_Compressed_Data, sizeof(VS_Compressed_Data), nullptr, &vertexShaderTable[C4JRender::VERTEX_TYPE_COMPRESSED]);
|
||||||
VS_Compressed_Data, sizeof(VS_Compressed_Data), nullptr,
|
m_pDevice->CreateVertexShader(VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data, sizeof(VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data), nullptr,
|
||||||
&vertexShaderTable[C4JRender::VERTEX_TYPE_COMPRESSED]);
|
|
||||||
m_pDevice->CreateVertexShader(
|
|
||||||
VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data,
|
|
||||||
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data), nullptr,
|
|
||||||
&vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT]);
|
&vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT]);
|
||||||
m_pDevice->CreateVertexShader(
|
m_pDevice->CreateVertexShader(VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data, sizeof(VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data), nullptr,
|
||||||
VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data,
|
|
||||||
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data), nullptr,
|
|
||||||
&vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN]);
|
&vertexShaderTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN]);
|
||||||
m_pDevice->CreateVertexShader(VS_ScreenSpace_Data,
|
m_pDevice->CreateVertexShader(VS_ScreenSpace_Data, sizeof(VS_ScreenSpace_Data), nullptr, &screenSpaceVertexShader);
|
||||||
sizeof(VS_ScreenSpace_Data), nullptr,
|
m_pDevice->CreateVertexShader(VS_ScreenClear_Data, sizeof(VS_ScreenClear_Data), nullptr, &screenClearVertexShader);
|
||||||
&screenSpaceVertexShader);
|
|
||||||
m_pDevice->CreateVertexShader(VS_ScreenClear_Data,
|
|
||||||
sizeof(VS_ScreenClear_Data), nullptr,
|
|
||||||
&screenClearVertexShader);
|
|
||||||
|
|
||||||
m_pDevice->CreatePixelShader(
|
m_pDevice->CreatePixelShader(PS_Standard_Data, sizeof(PS_Standard_Data), nullptr, &pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_STANDARD]);
|
||||||
PS_Standard_Data, sizeof(PS_Standard_Data), nullptr,
|
m_pDevice->CreatePixelShader(PS_TextureProjection_Data, sizeof(PS_TextureProjection_Data), nullptr,
|
||||||
&pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_STANDARD]);
|
|
||||||
m_pDevice->CreatePixelShader(
|
|
||||||
PS_TextureProjection_Data, sizeof(PS_TextureProjection_Data), nullptr,
|
|
||||||
&pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_PROJECTION]);
|
&pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_PROJECTION]);
|
||||||
m_pDevice->CreatePixelShader(
|
m_pDevice->CreatePixelShader(PS_ForceLOD_Data, sizeof(PS_ForceLOD_Data), nullptr, &pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_FORCELOD]);
|
||||||
PS_ForceLOD_Data, sizeof(PS_ForceLOD_Data), nullptr,
|
m_pDevice->CreatePixelShader(PS_ScreenSpace_Data, sizeof(PS_ScreenSpace_Data), nullptr, &screenSpacePixelShader);
|
||||||
&pixelShaderTable[C4JRender::PIXEL_SHADER_TYPE_FORCELOD]);
|
m_pDevice->CreatePixelShader(PS_ScreenClear_Data, sizeof(PS_ScreenClear_Data), nullptr, &screenClearPixelShader);
|
||||||
m_pDevice->CreatePixelShader(PS_ScreenSpace_Data, sizeof(PS_ScreenSpace_Data),
|
|
||||||
nullptr, &screenSpacePixelShader);
|
|
||||||
m_pDevice->CreatePixelShader(PS_ScreenClear_Data, sizeof(PS_ScreenClear_Data),
|
|
||||||
nullptr, &screenClearPixelShader);
|
|
||||||
|
|
||||||
m_pDevice->CreateInputLayout(
|
m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, VS_PF3_TF2_CB4_NB4_XW1_Data, sizeof(VS_PF3_TF2_CB4_NB4_XW1_Data),
|
||||||
g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, VS_PF3_TF2_CB4_NB4_XW1_Data,
|
|
||||||
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Data),
|
|
||||||
&inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1]);
|
&inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1]);
|
||||||
m_pDevice->CreateInputLayout(
|
m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_Compressed, 2, VS_Compressed_Data, sizeof(VS_Compressed_Data),
|
||||||
g_vertex_PTN_Elements_Compressed, 2, VS_Compressed_Data,
|
|
||||||
sizeof(VS_Compressed_Data),
|
|
||||||
&inputLayoutTable[C4JRender::VERTEX_TYPE_COMPRESSED]);
|
&inputLayoutTable[C4JRender::VERTEX_TYPE_COMPRESSED]);
|
||||||
m_pDevice->CreateInputLayout(
|
m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data,
|
||||||
g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5,
|
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data), &inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT]);
|
||||||
VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data,
|
m_pDevice->CreateInputLayout(g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5, VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data,
|
||||||
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Lighting_Data),
|
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data), &inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN]);
|
||||||
&inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT]);
|
|
||||||
m_pDevice->CreateInputLayout(
|
|
||||||
g_vertex_PTN_Elements_PF3_TF2_CB4_NB4_XW1, 5,
|
|
||||||
VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data,
|
|
||||||
sizeof(VS_PF3_TF2_CB4_NB4_XW1_Texgen_Data),
|
|
||||||
&inputLayoutTable[C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StartFrame() {
|
void Renderer::StartFrame()
|
||||||
|
{
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
|
|
||||||
activeVertexType = 0xFFFFFFFFu;
|
activeVertexType = 0xFFFFFFFFu;
|
||||||
@@ -706,21 +679,28 @@ void Renderer::StartFrame() {
|
|||||||
viewport.MinDepth = 0.0f;
|
viewport.MinDepth = 0.0f;
|
||||||
viewport.MaxDepth = 1.0f;
|
viewport.MaxDepth = 1.0f;
|
||||||
context.m_pDeviceContext->RSSetViewports(1, &viewport);
|
context.m_pDeviceContext->RSSetViewports(1, &viewport);
|
||||||
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView,
|
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
|
||||||
depthStencilView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Suspend() { suspended = 1; }
|
void Renderer::Suspend()
|
||||||
|
{
|
||||||
|
suspended = 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool Renderer::Suspended() { return suspended != 0; }
|
bool Renderer::Suspended()
|
||||||
|
{
|
||||||
|
return suspended != 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::UpdateGamma(unsigned short) {}
|
void Renderer::UpdateGamma(unsigned short) {}
|
||||||
|
|
||||||
Renderer::Context &Renderer::getContext() {
|
Renderer::Context &Renderer::getContext()
|
||||||
|
{
|
||||||
return *static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
return *static_cast<Renderer::Context *>(TlsGetValue(Renderer::tlsIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut)
|
||||||
|
{
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
|
|
||||||
float left;
|
float left;
|
||||||
@@ -731,7 +711,8 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
bottom = 0.0f;
|
bottom = 0.0f;
|
||||||
right = 1.0f;
|
right = 1.0f;
|
||||||
top = 1.0f;
|
top = 1.0f;
|
||||||
switch (m_ViewportType) {
|
switch (m_ViewportType)
|
||||||
|
{
|
||||||
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
||||||
bottom = 0.5f;
|
bottom = 0.5f;
|
||||||
break;
|
break;
|
||||||
@@ -769,11 +750,14 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
const float viewportHeight = top - bottom;
|
const float viewportHeight = top - bottom;
|
||||||
const float viewportScaledWidth = rightScaled - leftScaled;
|
const float viewportScaledWidth = rightScaled - leftScaled;
|
||||||
|
|
||||||
if (viewportHeight <= viewportScaledWidth) {
|
if (viewportHeight <= viewportScaledWidth)
|
||||||
|
{
|
||||||
const float pad = (viewportScaledWidth - viewportHeight) * 0.5f;
|
const float pad = (viewportScaledWidth - viewportHeight) * 0.5f;
|
||||||
leftScaled += pad;
|
leftScaled += pad;
|
||||||
rightScaled -= pad;
|
rightScaled -= pad;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const float pad = (viewportHeight - viewportScaledWidth) * 0.5f;
|
const float pad = (viewportHeight - viewportScaledWidth) * 0.5f;
|
||||||
bottom += pad;
|
bottom += pad;
|
||||||
top -= pad;
|
top -= pad;
|
||||||
@@ -797,8 +781,7 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||||
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||||
blendDesc.RenderTarget[0].RenderTargetWriteMask =
|
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||||
D3D11_COLOR_WRITE_ENABLE_ALL;
|
|
||||||
m_pDevice->CreateBlendState(&blendDesc, &blendState);
|
m_pDevice->CreateBlendState(&blendDesc, &blendState);
|
||||||
|
|
||||||
D3D11_DEPTH_STENCIL_DESC depthDesc = {};
|
D3D11_DEPTH_STENCIL_DESC depthDesc = {};
|
||||||
@@ -843,7 +826,8 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
context.m_pDeviceContext->OMSetDepthStencilState(depthState, 0);
|
context.m_pDeviceContext->OMSetDepthStencilState(depthState, 0);
|
||||||
context.m_pDeviceContext->RSSetState(rasterizerState);
|
context.m_pDeviceContext->RSSetState(rasterizerState);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < MAX_MIP_LEVELS - 1; ++i) {
|
for (unsigned int i = 0; i < MAX_MIP_LEVELS - 1; ++i)
|
||||||
|
{
|
||||||
D3D11_VIEWPORT viewport = {};
|
D3D11_VIEWPORT viewport = {};
|
||||||
viewport.TopLeftX = 0.0f;
|
viewport.TopLeftX = 0.0f;
|
||||||
viewport.TopLeftY = 0.0f;
|
viewport.TopLeftY = 0.0f;
|
||||||
@@ -852,28 +836,26 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
viewport.MinDepth = 0.0f;
|
viewport.MinDepth = 0.0f;
|
||||||
viewport.MaxDepth = 1.0f;
|
viewport.MaxDepth = 1.0f;
|
||||||
|
|
||||||
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetViews[i],
|
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetViews[i], nullptr);
|
||||||
nullptr);
|
|
||||||
context.m_pDeviceContext->RSSetViewports(1, &viewport);
|
context.m_pDeviceContext->RSSetViewports(1, &viewport);
|
||||||
|
|
||||||
ID3D11ShaderResourceView *inputTexture =
|
ID3D11ShaderResourceView *inputTexture = (i == 0) ? renderTargetShaderResourceView : renderTargetShaderResourceViews[i - 1];
|
||||||
(i == 0) ? renderTargetShaderResourceView
|
|
||||||
: renderTargetShaderResourceViews[i - 1];
|
|
||||||
context.m_pDeviceContext->PSSetShaderResources(0, 1, &inputTexture);
|
context.m_pDeviceContext->PSSetShaderResources(0, 1, &inputTexture);
|
||||||
context.m_pDeviceContext->PSSetSamplers(0, 1, &samplerState);
|
context.m_pDeviceContext->PSSetSamplers(0, 1, &samplerState);
|
||||||
context.m_pDeviceContext->IASetPrimitiveTopology(
|
context.m_pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||||
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
|
||||||
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
context.m_pDeviceContext->Map(context.cbAux1, 0, D3D11_MAP_WRITE_DISCARD, 0,
|
context.m_pDeviceContext->Map(context.cbAux1, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
&mapped);
|
|
||||||
float *constants = static_cast<float *>(mapped.pData);
|
float *constants = static_cast<float *>(mapped.pData);
|
||||||
if (i == 0) {
|
if (i == 0)
|
||||||
|
{
|
||||||
constants[0] = sampleLeft;
|
constants[0] = sampleLeft;
|
||||||
constants[1] = bottom;
|
constants[1] = bottom;
|
||||||
constants[2] = sampleWidth;
|
constants[2] = sampleWidth;
|
||||||
constants[3] = sampleHeight;
|
constants[3] = sampleHeight;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
constants[0] = 0.0f;
|
constants[0] = 0.0f;
|
||||||
constants[1] = 0.0f;
|
constants[1] = 0.0f;
|
||||||
constants[2] = 1.0f;
|
constants[2] = 1.0f;
|
||||||
@@ -891,20 +873,20 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
desc.MiscFlags = 0;
|
desc.MiscFlags = 0;
|
||||||
m_pDevice->CreateTexture2D(&desc, nullptr, &stagingTexture);
|
m_pDevice->CreateTexture2D(&desc, nullptr, &stagingTexture);
|
||||||
|
|
||||||
unsigned char *linearData =
|
unsigned char *linearData = new unsigned char[kThumbnailSize * kThumbnailSize * 4u];
|
||||||
new unsigned char[kThumbnailSize * kThumbnailSize * 4u];
|
if (stagingTexture)
|
||||||
if (stagingTexture) {
|
{
|
||||||
context.m_pDeviceContext->CopyResource(
|
context.m_pDeviceContext->CopyResource(stagingTexture, renderTargetTextures[MAX_MIP_LEVELS - 2]);
|
||||||
stagingTexture, renderTargetTextures[MAX_MIP_LEVELS - 2]);
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
if (SUCCEEDED(context.m_pDeviceContext->Map(stagingTexture, 0,
|
if (SUCCEEDED(context.m_pDeviceContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mapped)))
|
||||||
D3D11_MAP_READ, 0, &mapped))) {
|
{
|
||||||
const unsigned char *src =
|
const unsigned char *src = static_cast<const unsigned char *>(mapped.pData);
|
||||||
static_cast<const unsigned char *>(mapped.pData);
|
|
||||||
unsigned char *dst = linearData;
|
unsigned char *dst = linearData;
|
||||||
for (unsigned int y = 0; y < kThumbnailSize; ++y) {
|
for (unsigned int y = 0; y < kThumbnailSize; ++y)
|
||||||
|
{
|
||||||
std::memcpy(dst, src, kThumbnailSize * 4u);
|
std::memcpy(dst, src, kThumbnailSize * 4u);
|
||||||
for (unsigned int x = 0; x < kThumbnailSize; ++x) {
|
for (unsigned int x = 0; x < kThumbnailSize; ++x)
|
||||||
|
{
|
||||||
dst[x * 4u + 3u] = 0xFF;
|
dst[x * 4u + 3u] = 0xFF;
|
||||||
}
|
}
|
||||||
src += mapped.RowPitch;
|
src += mapped.RowPitch;
|
||||||
@@ -917,31 +899,34 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
this->ConvertLinearToPng(pngOut, linearData, kThumbnailSize, kThumbnailSize);
|
this->ConvertLinearToPng(pngOut, linearData, kThumbnailSize, kThumbnailSize);
|
||||||
delete[] linearData;
|
delete[] linearData;
|
||||||
|
|
||||||
if (stagingTexture) {
|
if (stagingTexture)
|
||||||
|
{
|
||||||
stagingTexture->Release();
|
stagingTexture->Release();
|
||||||
stagingTexture = nullptr;
|
stagingTexture = nullptr;
|
||||||
}
|
}
|
||||||
if (samplerState) {
|
if (samplerState)
|
||||||
|
{
|
||||||
samplerState->Release();
|
samplerState->Release();
|
||||||
samplerState = nullptr;
|
samplerState = nullptr;
|
||||||
}
|
}
|
||||||
if (rasterizerState) {
|
if (rasterizerState)
|
||||||
|
{
|
||||||
rasterizerState->Release();
|
rasterizerState->Release();
|
||||||
rasterizerState = nullptr;
|
rasterizerState = nullptr;
|
||||||
}
|
}
|
||||||
if (depthState) {
|
if (depthState)
|
||||||
|
{
|
||||||
depthState->Release();
|
depthState->Release();
|
||||||
depthState = nullptr;
|
depthState = nullptr;
|
||||||
}
|
}
|
||||||
if (blendState) {
|
if (blendState)
|
||||||
|
{
|
||||||
blendState->Release();
|
blendState->Release();
|
||||||
blendState = nullptr;
|
blendState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.m_pDeviceContext->OMSetBlendState(this->GetManagedBlendState(),
|
context.m_pDeviceContext->OMSetBlendState(this->GetManagedBlendState(), context.blendFactor, 0xFFFFFFFFu);
|
||||||
context.blendFactor, 0xFFFFFFFFu);
|
context.m_pDeviceContext->OMSetDepthStencilState(this->GetManagedDepthStencilState(), 0);
|
||||||
context.m_pDeviceContext->OMSetDepthStencilState(
|
|
||||||
this->GetManagedDepthStencilState(), 0);
|
|
||||||
context.m_pDeviceContext->RSSetState(this->GetManagedRasterizerState());
|
context.m_pDeviceContext->RSSetState(this->GetManagedRasterizerState());
|
||||||
|
|
||||||
D3D11_VIEWPORT viewport = {};
|
D3D11_VIEWPORT viewport = {};
|
||||||
@@ -952,8 +937,7 @@ void Renderer::CaptureThumbnail(ImageFileBuffer *pngOut) {
|
|||||||
viewport.MinDepth = 0.0f;
|
viewport.MinDepth = 0.0f;
|
||||||
viewport.MaxDepth = 1.0f;
|
viewport.MaxDepth = 1.0f;
|
||||||
context.m_pDeviceContext->RSSetViewports(1, &viewport);
|
context.m_pDeviceContext->RSSetViewports(1, &viewport);
|
||||||
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView,
|
context.m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
|
||||||
depthStencilView);
|
|
||||||
activeVertexType = 0xFFFFFFFFu;
|
activeVertexType = 0xFFFFFFFFu;
|
||||||
activePixelType = 0xFFFFFFFFu;
|
activePixelType = 0xFFFFFFFFu;
|
||||||
}
|
}
|
||||||
@@ -3,20 +3,20 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
const float* Renderer::MatrixGet(int type)
|
const float *Renderer::MatrixGet(int type)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const int depth = context.matrixStackDepth[type];
|
const int depth = context.matrixStackDepth[type];
|
||||||
return reinterpret_cast<const float*>(&context.matrixStacks[type][depth]);
|
return reinterpret_cast<const float *>(&context.matrixStacks[type][depth]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::MatrixMode(int type)
|
void Renderer::MatrixMode(int type)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.matrixModeType = type;
|
context.matrixModeType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::MatrixMult(float* mat)
|
void Renderer::MatrixMult(float *mat)
|
||||||
{
|
{
|
||||||
DirectX::XMMATRIX matrix;
|
DirectX::XMMATRIX matrix;
|
||||||
std::memcpy(&matrix, mat, sizeof(matrix));
|
std::memcpy(&matrix, mat, sizeof(matrix));
|
||||||
@@ -38,7 +38,7 @@ void Renderer::MatrixPerspective(float fovy, float aspect, float zNear, float zF
|
|||||||
|
|
||||||
void Renderer::MatrixPop()
|
void Renderer::MatrixPop()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const int mode = context.matrixModeType;
|
const int mode = context.matrixModeType;
|
||||||
--context.matrixStackDepth[mode];
|
--context.matrixStackDepth[mode];
|
||||||
context.matrixDirty[mode] = true;
|
context.matrixDirty[mode] = true;
|
||||||
@@ -46,7 +46,7 @@ void Renderer::MatrixPop()
|
|||||||
|
|
||||||
void Renderer::MatrixPush()
|
void Renderer::MatrixPush()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const int mode = context.matrixModeType;
|
const int mode = context.matrixModeType;
|
||||||
const int depth = context.matrixStackDepth[mode];
|
const int depth = context.matrixStackDepth[mode];
|
||||||
context.matrixStacks[mode][depth + 1] = context.matrixStacks[mode][depth];
|
context.matrixStacks[mode][depth + 1] = context.matrixStacks[mode][depth];
|
||||||
@@ -68,7 +68,7 @@ void Renderer::MatrixScale(float x, float y, float z)
|
|||||||
|
|
||||||
void Renderer::MatrixSetIdentity()
|
void Renderer::MatrixSetIdentity()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const int mode = context.matrixModeType;
|
const int mode = context.matrixModeType;
|
||||||
const int depth = context.matrixStackDepth[mode];
|
const int depth = context.matrixStackDepth[mode];
|
||||||
context.matrixStacks[mode][depth] = DirectX::XMMatrixIdentity();
|
context.matrixStacks[mode][depth] = DirectX::XMMatrixIdentity();
|
||||||
@@ -83,17 +83,17 @@ void Renderer::MatrixTranslate(float x, float y, float z)
|
|||||||
|
|
||||||
void Renderer::MultWithStack(DirectX::XMMATRIX matrix)
|
void Renderer::MultWithStack(DirectX::XMMATRIX matrix)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const int mode = context.matrixModeType;
|
const int mode = context.matrixModeType;
|
||||||
const int depth = context.matrixStackDepth[mode];
|
const int depth = context.matrixStackDepth[mode];
|
||||||
DirectX::XMMATRIX& current = context.matrixStacks[mode][depth];
|
DirectX::XMMATRIX ¤t = context.matrixStacks[mode][depth];
|
||||||
current = DirectX::XMMatrixMultiply(matrix, current);
|
current = DirectX::XMMatrixMultiply(matrix, current);
|
||||||
context.matrixDirty[mode] = true;
|
context.matrixDirty[mode] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Set_matrixDirty()
|
void Renderer::Set_matrixDirty()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const DirectX::XMMATRIX identity = DirectX::XMMatrixIdentity();
|
const DirectX::XMMATRIX identity = DirectX::XMMatrixIdentity();
|
||||||
|
|
||||||
context.matrixStacks[0][0] = identity;
|
context.matrixStacks[0][0] = identity;
|
||||||
|
|||||||
@@ -5,16 +5,13 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
ID3D11BlendState* Renderer::GetManagedBlendState()
|
ID3D11BlendState *Renderer::GetManagedBlendState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const D3D11_RENDER_TARGET_BLEND_DESC& rtBlend = context.blendDesc.RenderTarget[0];
|
const D3D11_RENDER_TARGET_BLEND_DESC &rtBlend = context.blendDesc.RenderTarget[0];
|
||||||
|
|
||||||
const int key =
|
const int key = (rtBlend.BlendEnable ? 1 : 0) | ((static_cast<int>(rtBlend.SrcBlend) & 0x1F) << 1) |
|
||||||
(rtBlend.BlendEnable ? 1 : 0) |
|
((static_cast<int>(rtBlend.DestBlend) & 0x1F) << 6) | ((static_cast<int>(rtBlend.RenderTargetWriteMask) & 0x0F) << 11);
|
||||||
((static_cast<int>(rtBlend.SrcBlend) & 0x1F) << 1) |
|
|
||||||
((static_cast<int>(rtBlend.DestBlend) & 0x1F) << 6) |
|
|
||||||
((static_cast<int>(rtBlend.RenderTargetWriteMask) & 0x0F) << 11);
|
|
||||||
|
|
||||||
auto it = managedBlendStates.find(key);
|
auto it = managedBlendStates.find(key);
|
||||||
if (it != managedBlendStates.end())
|
if (it != managedBlendStates.end())
|
||||||
@@ -22,19 +19,17 @@ ID3D11BlendState* Renderer::GetManagedBlendState()
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11BlendState* state = nullptr;
|
ID3D11BlendState *state = nullptr;
|
||||||
m_pDevice->CreateBlendState(&context.blendDesc, &state);
|
m_pDevice->CreateBlendState(&context.blendDesc, &state);
|
||||||
managedBlendStates.emplace(key, state);
|
managedBlendStates.emplace(key, state);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11DepthStencilState* Renderer::GetManagedDepthStencilState()
|
ID3D11DepthStencilState *Renderer::GetManagedDepthStencilState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
const int key =
|
const int key = (context.depthStencilDesc.DepthEnable ? 2 : 0) | ((static_cast<int>(context.depthStencilDesc.DepthFunc) & 0x0F) << 2) |
|
||||||
(context.depthStencilDesc.DepthEnable ? 2 : 0) |
|
|
||||||
((static_cast<int>(context.depthStencilDesc.DepthFunc) & 0x0F) << 2) |
|
|
||||||
(context.depthStencilDesc.DepthWriteMask == D3D11_DEPTH_WRITE_MASK_ALL ? 1 : 0);
|
(context.depthStencilDesc.DepthWriteMask == D3D11_DEPTH_WRITE_MASK_ALL ? 1 : 0);
|
||||||
|
|
||||||
auto it = managedDepthStencilStates.find(key);
|
auto it = managedDepthStencilStates.find(key);
|
||||||
@@ -43,18 +38,17 @@ ID3D11DepthStencilState* Renderer::GetManagedDepthStencilState()
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11DepthStencilState* state = nullptr;
|
ID3D11DepthStencilState *state = nullptr;
|
||||||
m_pDevice->CreateDepthStencilState(&context.depthStencilDesc, &state);
|
m_pDevice->CreateDepthStencilState(&context.depthStencilDesc, &state);
|
||||||
managedDepthStencilStates.emplace(key, state);
|
managedDepthStencilStates.emplace(key, state);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11RasterizerState* Renderer::GetManagedRasterizerState()
|
ID3D11RasterizerState *Renderer::GetManagedRasterizerState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
const int key =
|
const int key = (static_cast<std::uint8_t>(context.rasterizerDesc.DepthBias)) |
|
||||||
(static_cast<std::uint8_t>(context.rasterizerDesc.DepthBias)) |
|
|
||||||
(static_cast<std::uint8_t>(static_cast<int>(context.rasterizerDesc.SlopeScaledDepthBias)) << 8) |
|
(static_cast<std::uint8_t>(static_cast<int>(context.rasterizerDesc.SlopeScaledDepthBias)) << 8) |
|
||||||
((static_cast<int>(context.rasterizerDesc.CullMode) & 0x03) << 16);
|
((static_cast<int>(context.rasterizerDesc.CullMode) & 0x03) << 16);
|
||||||
|
|
||||||
@@ -64,15 +58,15 @@ ID3D11RasterizerState* Renderer::GetManagedRasterizerState()
|
|||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11RasterizerState* state = nullptr;
|
ID3D11RasterizerState *state = nullptr;
|
||||||
m_pDevice->CreateRasterizerState(&context.rasterizerDesc, &state);
|
m_pDevice->CreateRasterizerState(&context.rasterizerDesc, &state);
|
||||||
managedRasterizerStates.emplace(key, state);
|
managedRasterizerStates.emplace(key, state);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11SamplerState* Renderer::GetManagedSamplerState()
|
ID3D11SamplerState *Renderer::GetManagedSamplerState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const int key = m_textures[context.boundTextureIndex].samplerParams;
|
const int key = m_textures[context.boundTextureIndex].samplerParams;
|
||||||
|
|
||||||
auto it = managedSamplerStates.find(key);
|
auto it = managedSamplerStates.find(key);
|
||||||
@@ -102,7 +96,7 @@ ID3D11SamplerState* Renderer::GetManagedSamplerState()
|
|||||||
desc.MinLOD = -(std::numeric_limits<float>::max)();
|
desc.MinLOD = -(std::numeric_limits<float>::max)();
|
||||||
desc.MaxLOD = (std::numeric_limits<float>::max)();
|
desc.MaxLOD = (std::numeric_limits<float>::max)();
|
||||||
|
|
||||||
ID3D11SamplerState* state = nullptr;
|
ID3D11SamplerState *state = nullptr;
|
||||||
m_pDevice->CreateSamplerState(&desc, &state);
|
m_pDevice->CreateSamplerState(&desc, &state);
|
||||||
managedSamplerStates.emplace(key, state);
|
managedSamplerStates.emplace(key, state);
|
||||||
return state;
|
return state;
|
||||||
@@ -110,49 +104,47 @@ ID3D11SamplerState* Renderer::GetManagedSamplerState()
|
|||||||
|
|
||||||
void Renderer::StateSetFogEnable(bool enable)
|
void Renderer::StateSetFogEnable(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.fogEnabled = enable ? 1 : 0;
|
context.fogEnabled = enable ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetFogMode(int mode)
|
void Renderer::StateSetFogMode(int mode)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.fogMode = mode;
|
context.fogMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetFogNearDistance(float dist)
|
void Renderer::StateSetFogNearDistance(float dist)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.fogNearDistance = dist;
|
context.fogNearDistance = dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetFogFarDistance(float dist)
|
void Renderer::StateSetFogFarDistance(float dist)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.fogFarDistance = dist;
|
context.fogFarDistance = dist;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetFogDensity(float density)
|
void Renderer::StateSetFogDensity(float density)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.fogDensity = density;
|
context.fogDensity = density;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetFogColour(float red, float green, float blue)
|
void Renderer::StateSetFogColour(float red, float green, float blue)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.fogColourRed = red;
|
context.fogColourRed = red;
|
||||||
context.fogColourBlue = blue;
|
context.fogColourBlue = blue;
|
||||||
context.fogColourGreen = green;
|
context.fogColourGreen = green;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::UpdateViewportState()
|
void Renderer::UpdateViewportState() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::StateSetLightingEnable(bool enable)
|
void Renderer::StateSetLightingEnable(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetLightingEnable(enable);
|
context.commandBuffer->SetLightingEnable(enable);
|
||||||
@@ -169,7 +161,7 @@ void Renderer::StateSetLightColour(int light, float red, float green, float blue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetLightColour(light, red, green, blue);
|
context.commandBuffer->SetLightColour(light, red, green, blue);
|
||||||
@@ -185,7 +177,7 @@ void Renderer::StateSetLightColour(int light, float red, float green, float blue
|
|||||||
|
|
||||||
void Renderer::StateSetLightAmbientColour(float red, float green, float blue)
|
void Renderer::StateSetLightAmbientColour(float red, float green, float blue)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetLightAmbientColour(red, green, blue);
|
context.commandBuffer->SetLightAmbientColour(red, green, blue);
|
||||||
@@ -206,7 +198,7 @@ void Renderer::StateSetLightEnable(int light, bool enable)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetLightEnable(light, enable);
|
context.commandBuffer->SetLightEnable(light, enable);
|
||||||
@@ -219,15 +211,15 @@ void Renderer::StateSetLightEnable(int light, bool enable)
|
|||||||
|
|
||||||
void Renderer::StateSetColour(float r, float g, float b, float a)
|
void Renderer::StateSetColour(float r, float g, float b, float a)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetColor(r, g, b, a);
|
context.commandBuffer->SetColor(r, g, b, a);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11DeviceContext* d3d11 = context.m_pDeviceContext;
|
ID3D11DeviceContext *d3d11 = context.m_pDeviceContext;
|
||||||
const float colour[4] = { r, g, b, a };
|
const float colour[4] = {r, g, b, a};
|
||||||
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
d3d11->Map(context.cbColour, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
d3d11->Map(context.cbColour, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
@@ -237,7 +229,7 @@ void Renderer::StateSetColour(float r, float g, float b, float a)
|
|||||||
|
|
||||||
void Renderer::StateSetDepthMask(bool enable)
|
void Renderer::StateSetDepthMask(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetDepthMask(enable);
|
context.commandBuffer->SetDepthMask(enable);
|
||||||
@@ -251,7 +243,7 @@ void Renderer::StateSetDepthMask(bool enable)
|
|||||||
|
|
||||||
void Renderer::StateSetBlendEnable(bool enable)
|
void Renderer::StateSetBlendEnable(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetBlendEnable(enable);
|
context.commandBuffer->SetBlendEnable(enable);
|
||||||
@@ -264,7 +256,7 @@ void Renderer::StateSetBlendEnable(bool enable)
|
|||||||
|
|
||||||
void Renderer::StateSetBlendFunc(int src, int dst)
|
void Renderer::StateSetBlendFunc(int src, int dst)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetBlendFunc(src, dst);
|
context.commandBuffer->SetBlendFunc(src, dst);
|
||||||
@@ -278,7 +270,7 @@ void Renderer::StateSetBlendFunc(int src, int dst)
|
|||||||
|
|
||||||
void Renderer::StateSetBlendFactor(unsigned int colour)
|
void Renderer::StateSetBlendFactor(unsigned int colour)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetBlendFactor(colour);
|
context.commandBuffer->SetBlendFactor(colour);
|
||||||
@@ -295,10 +287,10 @@ void Renderer::StateSetBlendFactor(unsigned int colour)
|
|||||||
|
|
||||||
void Renderer::StateSetAlphaFunc(int, float param)
|
void Renderer::StateSetAlphaFunc(int, float param)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.alphaReference = param;
|
context.alphaReference = param;
|
||||||
|
|
||||||
const float alpha[4] = { 0.0f, 0.0f, 0.0f, context.alphaTestEnabled ? context.alphaReference : 0.0f };
|
const float alpha[4] = {0.0f, 0.0f, 0.0f, context.alphaTestEnabled ? context.alphaReference : 0.0f};
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
context.m_pDeviceContext->Map(context.cbAlphaTest, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
context.m_pDeviceContext->Map(context.cbAlphaTest, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
std::memcpy(mapped.pData, alpha, sizeof(alpha));
|
std::memcpy(mapped.pData, alpha, sizeof(alpha));
|
||||||
@@ -307,7 +299,7 @@ void Renderer::StateSetAlphaFunc(int, float param)
|
|||||||
|
|
||||||
void Renderer::StateSetDepthFunc(int func)
|
void Renderer::StateSetDepthFunc(int func)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetDepthFunc(func);
|
context.commandBuffer->SetDepthFunc(func);
|
||||||
@@ -320,7 +312,7 @@ void Renderer::StateSetDepthFunc(int func)
|
|||||||
|
|
||||||
void Renderer::StateSetFaceCull(bool enable)
|
void Renderer::StateSetFaceCull(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetFaceCull(enable);
|
context.commandBuffer->SetFaceCull(enable);
|
||||||
@@ -334,7 +326,7 @@ void Renderer::StateSetFaceCull(bool enable)
|
|||||||
|
|
||||||
void Renderer::StateSetFaceCullCW(bool enable)
|
void Renderer::StateSetFaceCullCW(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.faceCullEnabled)
|
if (context.faceCullEnabled)
|
||||||
{
|
{
|
||||||
context.rasterizerDesc.CullMode = enable ? D3D11_CULL_BACK : D3D11_CULL_FRONT;
|
context.rasterizerDesc.CullMode = enable ? D3D11_CULL_BACK : D3D11_CULL_FRONT;
|
||||||
@@ -347,13 +339,11 @@ void Renderer::StateSetFaceCullCW(bool enable)
|
|||||||
context.m_pDeviceContext->RSSetState(this->GetManagedRasterizerState());
|
context.m_pDeviceContext->RSSetState(this->GetManagedRasterizerState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetLineWidth(float)
|
void Renderer::StateSetLineWidth(float) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::StateSetWriteEnable(bool red, bool green, bool blue, bool alpha)
|
void Renderer::StateSetWriteEnable(bool red, bool green, bool blue, bool alpha)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
std::uint8_t mask = 0;
|
std::uint8_t mask = 0;
|
||||||
mask |= red ? 0x1 : 0;
|
mask |= red ? 0x1 : 0;
|
||||||
@@ -367,7 +357,7 @@ void Renderer::StateSetWriteEnable(bool red, bool green, bool blue, bool alpha)
|
|||||||
|
|
||||||
void Renderer::StateSetDepthTestEnable(bool enable)
|
void Renderer::StateSetDepthTestEnable(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetDepthTestEnable(enable);
|
context.commandBuffer->SetDepthTestEnable(enable);
|
||||||
@@ -381,10 +371,10 @@ void Renderer::StateSetDepthTestEnable(bool enable)
|
|||||||
|
|
||||||
void Renderer::StateSetAlphaTestEnable(bool enable)
|
void Renderer::StateSetAlphaTestEnable(bool enable)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.alphaTestEnabled = enable ? 1 : 0;
|
context.alphaTestEnabled = enable ? 1 : 0;
|
||||||
|
|
||||||
const float alpha[4] = { 0.0f, 0.0f, 0.0f, enable ? context.alphaReference : 0.0f };
|
const float alpha[4] = {0.0f, 0.0f, 0.0f, enable ? context.alphaReference : 0.0f};
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
context.m_pDeviceContext->Map(context.cbAlphaTest, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
context.m_pDeviceContext->Map(context.cbAlphaTest, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
std::memcpy(mapped.pData, alpha, sizeof(alpha));
|
std::memcpy(mapped.pData, alpha, sizeof(alpha));
|
||||||
@@ -393,7 +383,7 @@ void Renderer::StateSetAlphaTestEnable(bool enable)
|
|||||||
|
|
||||||
void Renderer::StateSetDepthSlopeAndBias(float slope, float bias)
|
void Renderer::StateSetDepthSlopeAndBias(float slope, float bias)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
const float scale = 65536.0f;
|
const float scale = 65536.0f;
|
||||||
context.rasterizerDesc.DepthBias = static_cast<int>(bias * scale);
|
context.rasterizerDesc.DepthBias = static_cast<int>(bias * scale);
|
||||||
@@ -403,8 +393,8 @@ void Renderer::StateSetDepthSlopeAndBias(float slope, float bias)
|
|||||||
|
|
||||||
void Renderer::UpdateFogState()
|
void Renderer::UpdateFogState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
ID3D11DeviceContext* d3d11 = context.m_pDeviceContext;
|
ID3D11DeviceContext *d3d11 = context.m_pDeviceContext;
|
||||||
|
|
||||||
float fogParams[4] = {};
|
float fogParams[4] = {};
|
||||||
if (context.fogEnabled)
|
if (context.fogEnabled)
|
||||||
@@ -422,13 +412,7 @@ void Renderer::UpdateFogState()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const float fogColour[4] =
|
const float fogColour[4] = {context.fogColourRed, context.fogColourGreen, context.fogColourBlue, 1.0f};
|
||||||
{
|
|
||||||
context.fogColourRed,
|
|
||||||
context.fogColourGreen,
|
|
||||||
context.fogColourBlue,
|
|
||||||
1.0f
|
|
||||||
};
|
|
||||||
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
d3d11->Map(context.cbFogParams, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
d3d11->Map(context.cbFogParams, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
@@ -442,8 +426,8 @@ void Renderer::UpdateFogState()
|
|||||||
|
|
||||||
void Renderer::StateSetVertexTextureUV(float u, float v)
|
void Renderer::StateSetVertexTextureUV(float u, float v)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
const float texgen[4] = { u - 1.0f, v - 1.0f, 0.0f, 0.0f };
|
const float texgen[4] = {u - 1.0f, v - 1.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
context.m_pDeviceContext->Map(context.cbVertexTexcoord, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
context.m_pDeviceContext->Map(context.cbVertexTexcoord, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
@@ -453,7 +437,7 @@ void Renderer::StateSetVertexTextureUV(float u, float v)
|
|||||||
|
|
||||||
void Renderer::UpdateTexGenState()
|
void Renderer::UpdateTexGenState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
context.m_pDeviceContext->Map(context.cbTexGen, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
context.m_pDeviceContext->Map(context.cbTexGen, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
|
||||||
@@ -463,7 +447,7 @@ void Renderer::UpdateTexGenState()
|
|||||||
|
|
||||||
void Renderer::UpdateLightingState()
|
void Renderer::UpdateLightingState()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (!context.lightingDirty || !context.lightingEnabled)
|
if (!context.lightingDirty || !context.lightingEnabled)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -497,7 +481,7 @@ void Renderer::StateSetLightDirection(int light, float x, float y, float z)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
if (context.commandBuffer != nullptr && context.commandBuffer->isActive != 0)
|
||||||
{
|
{
|
||||||
context.commandBuffer->SetLightDirection(light, x, y, z);
|
context.commandBuffer->SetLightDirection(light, x, y, z);
|
||||||
@@ -505,7 +489,7 @@ void Renderer::StateSetLightDirection(int light, float x, float y, float z)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::uint32_t stackIndex = context.matrixStackDepth[0];
|
const std::uint32_t stackIndex = context.matrixStackDepth[0];
|
||||||
const DirectX::XMMATRIX& modelView = context.matrixStacks[0][stackIndex];
|
const DirectX::XMMATRIX &modelView = context.matrixStacks[0][stackIndex];
|
||||||
const DirectX::XMVECTOR direction = DirectX::XMVectorSet(x, y, z, 0.0f);
|
const DirectX::XMVECTOR direction = DirectX::XMVectorSet(x, y, z, 0.0f);
|
||||||
const DirectX::XMVECTOR transformed = DirectX::XMVector3TransformNormal(direction, modelView);
|
const DirectX::XMVECTOR transformed = DirectX::XMVector3TransformNormal(direction, modelView);
|
||||||
const DirectX::XMVECTOR normalized = DirectX::XMVector3Normalize(transformed);
|
const DirectX::XMVECTOR normalized = DirectX::XMVector3Normalize(transformed);
|
||||||
@@ -581,13 +565,11 @@ void Renderer::StateSetViewport(C4JRender::eViewportType viewportType)
|
|||||||
m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
|
m_pDeviceContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateSetEnableViewportClipPlanes(bool)
|
void Renderer::StateSetEnableViewportClipPlanes(bool) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace)
|
void Renderer::StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
DirectX::XMVECTOR plane = DirectX::XMVectorSet(x, y, z, w);
|
DirectX::XMVECTOR plane = DirectX::XMVectorSet(x, y, z, w);
|
||||||
if (eyeSpace)
|
if (eyeSpace)
|
||||||
@@ -607,13 +589,13 @@ void Renderer::StateSetTexGenCol(int col, float x, float y, float z, float w, bo
|
|||||||
const int activeSet = eyeSpace ? 0 : 1;
|
const int activeSet = eyeSpace ? 0 : 1;
|
||||||
const int inactiveSet = eyeSpace ? 1 : 0;
|
const int inactiveSet = eyeSpace ? 1 : 0;
|
||||||
|
|
||||||
float* active = reinterpret_cast<float*>(&context.texGenMatrices[activeSet]);
|
float *active = reinterpret_cast<float *>(&context.texGenMatrices[activeSet]);
|
||||||
active[col + 0] = transformed.x;
|
active[col + 0] = transformed.x;
|
||||||
active[col + 4] = transformed.y;
|
active[col + 4] = transformed.y;
|
||||||
active[col + 8] = transformed.z;
|
active[col + 8] = transformed.z;
|
||||||
active[col + 12] = transformed.w;
|
active[col + 12] = transformed.w;
|
||||||
|
|
||||||
float* inactive = reinterpret_cast<float*>(&context.texGenMatrices[inactiveSet]);
|
float *inactive = reinterpret_cast<float *>(&context.texGenMatrices[inactiveSet]);
|
||||||
inactive[col + 0] = 0.0f;
|
inactive[col + 0] = 0.0f;
|
||||||
inactive[col + 4] = 0.0f;
|
inactive[col + 4] = 0.0f;
|
||||||
inactive[col + 8] = 0.0f;
|
inactive[col + 8] = 0.0f;
|
||||||
@@ -622,7 +604,7 @@ void Renderer::StateSetTexGenCol(int col, float x, float y, float z, float w, bo
|
|||||||
|
|
||||||
void Renderer::StateSetStencil(D3D11_COMPARISON_FUNC function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask)
|
void Renderer::StateSetStencil(D3D11_COMPARISON_FUNC function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
|
|
||||||
D3D11_DEPTH_STENCIL_DESC desc = context.depthStencilDesc;
|
D3D11_DEPTH_STENCIL_DESC desc = context.depthStencilDesc;
|
||||||
desc.StencilEnable = TRUE;
|
desc.StencilEnable = TRUE;
|
||||||
@@ -631,7 +613,7 @@ void Renderer::StateSetStencil(D3D11_COMPARISON_FUNC function, uint8_t stencil_r
|
|||||||
desc.FrontFace.StencilFunc = function;
|
desc.FrontFace.StencilFunc = function;
|
||||||
desc.BackFace.StencilFunc = function;
|
desc.BackFace.StencilFunc = function;
|
||||||
|
|
||||||
ID3D11DepthStencilState* state = nullptr;
|
ID3D11DepthStencilState *state = nullptr;
|
||||||
m_pDevice->CreateDepthStencilState(&desc, &state);
|
m_pDevice->CreateDepthStencilState(&desc, &state);
|
||||||
m_pDeviceContext->OMSetDepthStencilState(state, stencil_ref);
|
m_pDeviceContext->OMSetDepthStencilState(state, stencil_ref);
|
||||||
if (state != nullptr)
|
if (state != nullptr)
|
||||||
@@ -642,13 +624,13 @@ void Renderer::StateSetStencil(D3D11_COMPARISON_FUNC function, uint8_t stencil_r
|
|||||||
|
|
||||||
void Renderer::StateSetForceLOD(int LOD)
|
void Renderer::StateSetForceLOD(int LOD)
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
context.forcedLOD = LOD;
|
context.forcedLOD = LOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::StateUpdate()
|
void Renderer::StateUpdate()
|
||||||
{
|
{
|
||||||
Context& context = this->getContext();
|
Context &context = this->getContext();
|
||||||
this->StateSetFaceCull(context.faceCullEnabled != 0);
|
this->StateSetFaceCull(context.faceCullEnabled != 0);
|
||||||
this->StateSetDepthMask(context.depthWriteEnabled != 0);
|
this->StateSetDepthMask(context.depthWriteEnabled != 0);
|
||||||
this->StateSetDepthTestEnable(context.depthTestEnabled != 0);
|
this->StateSetDepthTestEnable(context.depthTestEnabled != 0);
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ DXGI_FORMAT Renderer::textureFormats[C4JRender::MAX_TEXTURE_FORMATS] = {
|
|||||||
DXGI_FORMAT_B8G8R8A8_UNORM,
|
DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||||
};
|
};
|
||||||
|
|
||||||
int Renderer::TextureCreate() {
|
int Renderer::TextureCreate()
|
||||||
for (int i = 0; i < 512; ++i) {
|
{
|
||||||
|
for (int i = 0; i < 512; ++i)
|
||||||
|
{
|
||||||
Texture &texture = m_textures[i];
|
Texture &texture = m_textures[i];
|
||||||
if (!texture.allocated) {
|
if (!texture.allocated)
|
||||||
|
{
|
||||||
texture.texture = nullptr;
|
texture.texture = nullptr;
|
||||||
texture.allocated = true;
|
texture.allocated = true;
|
||||||
texture.mipLevels = 1;
|
texture.mipLevels = 1;
|
||||||
@@ -26,42 +29,50 @@ int Renderer::TextureCreate() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::TextureSetTextureLevels(int levels) {
|
void Renderer::TextureSetTextureLevels(int levels)
|
||||||
|
{
|
||||||
const int boundTextureIndex = this->getContext().boundTextureIndex;
|
const int boundTextureIndex = this->getContext().boundTextureIndex;
|
||||||
m_textures[boundTextureIndex].mipLevels = levels;
|
m_textures[boundTextureIndex].mipLevels = levels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Renderer::TextureGetTextureLevels() {
|
int Renderer::TextureGetTextureLevels()
|
||||||
|
{
|
||||||
const int boundTextureIndex = this->getContext().boundTextureIndex;
|
const int boundTextureIndex = this->getContext().boundTextureIndex;
|
||||||
return m_textures[boundTextureIndex].mipLevels;
|
return m_textures[boundTextureIndex].mipLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::TextureSetParam(int param, int value) {
|
void Renderer::TextureSetParam(int param, int value)
|
||||||
|
{
|
||||||
Texture &texture = m_textures[this->getContext().boundTextureIndex];
|
Texture &texture = m_textures[this->getContext().boundTextureIndex];
|
||||||
|
|
||||||
switch (param) {
|
switch (param)
|
||||||
|
{
|
||||||
case GL_TEXTURE_MIN_FILTER:
|
case GL_TEXTURE_MIN_FILTER:
|
||||||
texture.samplerParams &= ~4u;
|
texture.samplerParams &= ~4u;
|
||||||
if (value == 1) {
|
if (value == 1)
|
||||||
|
{
|
||||||
texture.samplerParams |= 4u;
|
texture.samplerParams |= 4u;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_MAG_FILTER:
|
case GL_TEXTURE_MAG_FILTER:
|
||||||
texture.samplerParams &= ~8u;
|
texture.samplerParams &= ~8u;
|
||||||
if (value == 1) {
|
if (value == 1)
|
||||||
|
{
|
||||||
texture.samplerParams |= 8u;
|
texture.samplerParams |= 8u;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_WRAP_S:
|
case GL_TEXTURE_WRAP_S:
|
||||||
texture.samplerParams &= ~1u;
|
texture.samplerParams &= ~1u;
|
||||||
if (value == 0) {
|
if (value == 0)
|
||||||
|
{
|
||||||
texture.samplerParams |= 1u;
|
texture.samplerParams |= 1u;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_WRAP_T:
|
case GL_TEXTURE_WRAP_T:
|
||||||
case 5:
|
case 5:
|
||||||
texture.samplerParams &= ~2u;
|
texture.samplerParams &= ~2u;
|
||||||
if (value == 0) {
|
if (value == 0)
|
||||||
|
{
|
||||||
texture.samplerParams |= 2u;
|
texture.samplerParams |= 2u;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -74,13 +85,14 @@ void Renderer::TextureDynamicUpdateStart() {}
|
|||||||
|
|
||||||
void Renderer::TextureDynamicUpdateEnd() {}
|
void Renderer::TextureDynamicUpdateEnd() {}
|
||||||
|
|
||||||
void Renderer::TextureData(int width, int height, void *data, int level,
|
void Renderer::TextureData(int width, int height, void *data, int level, C4JRender::eTextureFormat format)
|
||||||
C4JRender::eTextureFormat format) {
|
{
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
Texture &texture = m_textures[context.boundTextureIndex];
|
Texture &texture = m_textures[context.boundTextureIndex];
|
||||||
texture.textureFormat = format;
|
texture.textureFormat = format;
|
||||||
|
|
||||||
if (level == 0) {
|
if (level == 0)
|
||||||
|
{
|
||||||
D3D11_TEXTURE2D_DESC desc = {};
|
D3D11_TEXTURE2D_DESC desc = {};
|
||||||
desc.Width = width;
|
desc.Width = width;
|
||||||
desc.Height = height;
|
desc.Height = height;
|
||||||
@@ -91,18 +103,16 @@ void Renderer::TextureData(int width, int height, void *data, int level,
|
|||||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
m_pDevice->CreateTexture2D(&desc, nullptr, &texture.texture);
|
m_pDevice->CreateTexture2D(&desc, nullptr, &texture.texture);
|
||||||
m_pDevice->CreateShaderResourceView(texture.texture, nullptr,
|
m_pDevice->CreateShaderResourceView(texture.texture, nullptr, &texture.view);
|
||||||
&texture.view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const UINT rowPitch = width * 4u;
|
const UINT rowPitch = width * 4u;
|
||||||
const UINT depthPitch = width * height * 4u;
|
const UINT depthPitch = width * height * 4u;
|
||||||
context.m_pDeviceContext->UpdateSubresource(texture.texture, level, nullptr,
|
context.m_pDeviceContext->UpdateSubresource(texture.texture, level, nullptr, data, rowPitch, depthPitch);
|
||||||
data, rowPitch, depthPitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::TextureDataUpdate(int xoffset, int yoffset, int width,
|
void Renderer::TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level)
|
||||||
int height, void *data, int level) {
|
{
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
Texture &texture = m_textures[context.boundTextureIndex];
|
Texture &texture = m_textures[context.boundTextureIndex];
|
||||||
|
|
||||||
@@ -119,11 +129,11 @@ void Renderer::TextureDataUpdate(int xoffset, int yoffset, int width,
|
|||||||
|
|
||||||
const UINT rowPitch = width * 4u;
|
const UINT rowPitch = width * 4u;
|
||||||
const UINT depthPitch = width * height * 4u;
|
const UINT depthPitch = width * height * 4u;
|
||||||
context.m_pDeviceContext->UpdateSubresource(texture.texture, level, &box,
|
context.m_pDeviceContext->UpdateSubresource(texture.texture, level, &box, data, rowPitch, depthPitch);
|
||||||
data, rowPitch, depthPitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::TextureFree(int idx) {
|
void Renderer::TextureFree(int idx)
|
||||||
|
{
|
||||||
Texture &texture = m_textures[idx];
|
Texture &texture = m_textures[idx];
|
||||||
texture.texture->Release();
|
texture.texture->Release();
|
||||||
texture.view->Release();
|
texture.view->Release();
|
||||||
@@ -134,28 +144,34 @@ void Renderer::TextureFree(int idx) {
|
|||||||
|
|
||||||
void Renderer::TextureGetStats() {}
|
void Renderer::TextureGetStats() {}
|
||||||
|
|
||||||
ID3D11ShaderResourceView *Renderer::TextureGetTexture(int idx) {
|
ID3D11ShaderResourceView *Renderer::TextureGetTexture(int idx)
|
||||||
if (idx < 0 || idx > 0x1FF) {
|
{
|
||||||
|
if (idx < 0 || idx > 0x1FF)
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Texture &texture = m_textures[idx];
|
const Texture &texture = m_textures[idx];
|
||||||
if (!texture.allocated) {
|
if (!texture.allocated)
|
||||||
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return texture.view;
|
return texture.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::TextureBind(int idx) {
|
void Renderer::TextureBind(int idx)
|
||||||
|
{
|
||||||
int textureIndex = idx;
|
int textureIndex = idx;
|
||||||
if (textureIndex == -1) {
|
if (textureIndex == -1)
|
||||||
|
{
|
||||||
textureIndex = defaultTextureIndex;
|
textureIndex = defaultTextureIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
|
|
||||||
if (context.commandBuffer && context.commandBuffer->isActive) {
|
if (context.commandBuffer && context.commandBuffer->isActive)
|
||||||
|
{
|
||||||
context.commandBuffer->BindTexture(textureIndex);
|
context.commandBuffer->BindTexture(textureIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,9 +181,11 @@ void Renderer::TextureBind(int idx) {
|
|||||||
this->UpdateTextureState(false);
|
this->UpdateTextureState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::TextureBindVertex(int idx) {
|
void Renderer::TextureBindVertex(int idx)
|
||||||
|
{
|
||||||
int textureIndex = idx;
|
int textureIndex = idx;
|
||||||
if (textureIndex == -1) {
|
if (textureIndex == -1)
|
||||||
|
{
|
||||||
textureIndex = defaultTextureIndex;
|
textureIndex = defaultTextureIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,20 +197,25 @@ void Renderer::TextureBindVertex(int idx) {
|
|||||||
this->UpdateTextureState(true);
|
this->UpdateTextureState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::UpdateTextureState(bool vertexSampler) {
|
void Renderer::UpdateTextureState(bool vertexSampler)
|
||||||
|
{
|
||||||
Renderer::Context &context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
ID3D11SamplerState *sampler = this->GetManagedSamplerState();
|
ID3D11SamplerState *sampler = this->GetManagedSamplerState();
|
||||||
|
|
||||||
if (vertexSampler) {
|
if (vertexSampler)
|
||||||
|
{
|
||||||
context.m_pDeviceContext->VSSetSamplers(0, 1, &sampler);
|
context.m_pDeviceContext->VSSetSamplers(0, 1, &sampler);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
context.m_pDeviceContext->PSSetSamplers(0, 1, &sampler);
|
context.m_pDeviceContext->PSSetSamplers(0, 1, &sampler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Renderer::LoadTextureData(const char *szFilename,
|
HRESULT Renderer::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
|
||||||
D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) {
|
{
|
||||||
if (!szFilename || !pSrcInfo || !ppDataOut) {
|
if (!szFilename || !pSrcInfo || !ppDataOut)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,32 +224,35 @@ HRESULT Renderer::LoadTextureData(const char *szFilename,
|
|||||||
png_image image;
|
png_image image;
|
||||||
std::memset(&image, 0, sizeof(image));
|
std::memset(&image, 0, sizeof(image));
|
||||||
image.version = PNG_IMAGE_VERSION;
|
image.version = PNG_IMAGE_VERSION;
|
||||||
if (!png_image_begin_read_from_file(&image, szFilename)) {
|
if (!png_image_begin_read_from_file(&image, szFilename))
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image.width == 0 || image.height == 0) {
|
if (image.width == 0 || image.height == 0)
|
||||||
|
{
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.format = PNG_FORMAT_RGBA;
|
image.format = PNG_FORMAT_RGBA;
|
||||||
const png_alloc_size_t pixelCount =
|
const png_alloc_size_t pixelCount = png_alloc_size_t(image.width) * png_alloc_size_t(image.height);
|
||||||
png_alloc_size_t(image.width) * png_alloc_size_t(image.height);
|
if (pixelCount == 0 || pixelCount > (std::numeric_limits<size_t>::max)() / sizeof(int))
|
||||||
if (pixelCount == 0 ||
|
{
|
||||||
pixelCount > (std::numeric_limits<size_t>::max)() / sizeof(int)) {
|
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *output = new (std::nothrow) int[size_t(pixelCount)];
|
int *output = new (std::nothrow) int[size_t(pixelCount)];
|
||||||
|
|
||||||
if (!output) {
|
if (!output)
|
||||||
|
{
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!png_image_finish_read(&image, nullptr, output, 0, nullptr)) {
|
if (!png_image_finish_read(&image, nullptr, output, 0, nullptr))
|
||||||
|
{
|
||||||
delete[] output;
|
delete[] output;
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -239,9 +265,10 @@ HRESULT Renderer::LoadTextureData(const char *szFilename,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Renderer::LoadTextureData(BYTE *pbData, DWORD dwBytes,
|
HRESULT Renderer::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
|
||||||
D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) {
|
{
|
||||||
if (!pbData || dwBytes == 0 || !pSrcInfo || !ppDataOut) {
|
if (!pbData || dwBytes == 0 || !pSrcInfo || !ppDataOut)
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,32 +277,35 @@ HRESULT Renderer::LoadTextureData(BYTE *pbData, DWORD dwBytes,
|
|||||||
png_image image;
|
png_image image;
|
||||||
std::memset(&image, 0, sizeof(image));
|
std::memset(&image, 0, sizeof(image));
|
||||||
image.version = PNG_IMAGE_VERSION;
|
image.version = PNG_IMAGE_VERSION;
|
||||||
if (!png_image_begin_read_from_memory(&image, pbData, dwBytes)) {
|
if (!png_image_begin_read_from_memory(&image, pbData, dwBytes))
|
||||||
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image.width == 0 || image.height == 0) {
|
if (image.width == 0 || image.height == 0)
|
||||||
|
{
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.format = PNG_FORMAT_RGBA;
|
image.format = PNG_FORMAT_RGBA;
|
||||||
const png_alloc_size_t pixelCount =
|
const png_alloc_size_t pixelCount = png_alloc_size_t(image.width) * png_alloc_size_t(image.height);
|
||||||
png_alloc_size_t(image.width) * png_alloc_size_t(image.height);
|
if (pixelCount == 0 || pixelCount > (std::numeric_limits<size_t>::max)() / sizeof(int))
|
||||||
if (pixelCount == 0 ||
|
{
|
||||||
pixelCount > (std::numeric_limits<size_t>::max)() / sizeof(int)) {
|
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *output = new (std::nothrow) int[size_t(pixelCount)];
|
int *output = new (std::nothrow) int[size_t(pixelCount)];
|
||||||
|
|
||||||
if (!output) {
|
if (!output)
|
||||||
|
{
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!png_image_finish_read(&image, nullptr, output, 0, nullptr)) {
|
if (!png_image_finish_read(&image, nullptr, output, 0, nullptr))
|
||||||
|
{
|
||||||
delete[] output;
|
delete[] output;
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -288,8 +318,8 @@ HRESULT Renderer::LoadTextureData(BYTE *pbData, DWORD dwBytes,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Renderer::SaveTextureData(const char *szFilename,
|
HRESULT Renderer::SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut)
|
||||||
D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut) {
|
{
|
||||||
png_image image = {};
|
png_image image = {};
|
||||||
image.version = PNG_IMAGE_VERSION;
|
image.version = PNG_IMAGE_VERSION;
|
||||||
image.width = pSrcInfo->Width;
|
image.width = pSrcInfo->Width;
|
||||||
@@ -300,11 +330,10 @@ HRESULT Renderer::SaveTextureData(const char *szFilename,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Renderer::SaveTextureDataToMemory(void *pOutput, int outputCapacity,
|
HRESULT Renderer::SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn)
|
||||||
int *outputLength, int width,
|
{
|
||||||
int height, int *ppDataIn) {
|
if (!pOutput || outputCapacity <= 0 || !outputLength || width <= 0 || height <= 0 || !ppDataIn)
|
||||||
if (!pOutput || outputCapacity <= 0 || !outputLength || width <= 0 ||
|
{
|
||||||
height <= 0 || !ppDataIn) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,8 +345,8 @@ HRESULT Renderer::SaveTextureDataToMemory(void *pOutput, int outputCapacity,
|
|||||||
image.format = PNG_FORMAT_RGBA;
|
image.format = PNG_FORMAT_RGBA;
|
||||||
|
|
||||||
png_alloc_size_t memoryBytes = static_cast<png_alloc_size_t>(outputCapacity);
|
png_alloc_size_t memoryBytes = static_cast<png_alloc_size_t>(outputCapacity);
|
||||||
if (!png_image_write_to_memory(&image, pOutput, &memoryBytes, 0, ppDataIn, 0,
|
if (!png_image_write_to_memory(&image, pOutput, &memoryBytes, 0, ppDataIn, 0, nullptr))
|
||||||
nullptr)) {
|
{
|
||||||
*outputLength = 0;
|
*outputLength = 0;
|
||||||
png_image_free(&image);
|
png_image_free(&image);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -5,17 +5,13 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
D3D11_PRIMITIVE_TOPOLOGY* Renderer::m_Topologies = nullptr;
|
D3D11_PRIMITIVE_TOPOLOGY *Renderer::m_Topologies = nullptr;
|
||||||
|
|
||||||
void Renderer::DrawVertexBuffer(
|
void Renderer::DrawVertexBuffer(C4JRender::ePrimitiveType PrimitiveType, int count, ID3D11Buffer *buffer, C4JRender::eVertexType vType,
|
||||||
C4JRender::ePrimitiveType PrimitiveType,
|
|
||||||
int count,
|
|
||||||
ID3D11Buffer* buffer,
|
|
||||||
C4JRender::eVertexType vType,
|
|
||||||
C4JRender::ePixelShaderType psType)
|
C4JRender::ePixelShaderType psType)
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
ID3D11DeviceContext* d3d11 = context.m_pDeviceContext;
|
ID3D11DeviceContext *d3d11 = context.m_pDeviceContext;
|
||||||
|
|
||||||
int drawCount = count;
|
int drawCount = count;
|
||||||
bool indexed = false;
|
bool indexed = false;
|
||||||
@@ -36,15 +32,11 @@ void Renderer::DrawVertexBuffer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DrawVertexSetup(
|
void Renderer::DrawVertexSetup(C4JRender::eVertexType vType, C4JRender::ePixelShaderType psType, C4JRender::ePrimitiveType PrimitiveType, int *count,
|
||||||
C4JRender::eVertexType vType,
|
bool *indexed)
|
||||||
C4JRender::ePixelShaderType psType,
|
|
||||||
C4JRender::ePrimitiveType PrimitiveType,
|
|
||||||
int* count,
|
|
||||||
bool* indexed)
|
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
ID3D11DeviceContext* d3d11 = context.m_pDeviceContext;
|
ID3D11DeviceContext *d3d11 = context.m_pDeviceContext;
|
||||||
|
|
||||||
C4JRender::eVertexType effectiveVertexType = vType;
|
C4JRender::eVertexType effectiveVertexType = vType;
|
||||||
if (effectiveVertexType == C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 && context.lightingEnabled)
|
if (effectiveVertexType == C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 && context.lightingEnabled)
|
||||||
@@ -118,16 +110,12 @@ void Renderer::DrawVertexSetup(
|
|||||||
*indexed = false;
|
*indexed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DrawVertices(
|
void Renderer::DrawVertices(C4JRender::ePrimitiveType PrimitiveType, int count, void *vertices, C4JRender::eVertexType vType,
|
||||||
C4JRender::ePrimitiveType PrimitiveType,
|
|
||||||
int count,
|
|
||||||
void* vertices,
|
|
||||||
C4JRender::eVertexType vType,
|
|
||||||
C4JRender::ePixelShaderType psType)
|
C4JRender::ePixelShaderType psType)
|
||||||
{
|
{
|
||||||
Renderer::Context& context = this->getContext();
|
Renderer::Context &context = this->getContext();
|
||||||
ID3D11DeviceContext* d3d11 = context.m_pDeviceContext;
|
ID3D11DeviceContext *d3d11 = context.m_pDeviceContext;
|
||||||
Renderer::CommandBuffer* commandBuffer = context.commandBuffer;
|
Renderer::CommandBuffer *commandBuffer = context.commandBuffer;
|
||||||
|
|
||||||
if (commandBuffer != nullptr)
|
if (commandBuffer != nullptr)
|
||||||
{
|
{
|
||||||
@@ -163,12 +151,12 @@ void Renderer::DrawVertices(
|
|||||||
std::printf("ERROR: 0x%x\n", static_cast<unsigned int>(hr));
|
std::printf("ERROR: 0x%x\n", static_cast<unsigned int>(hr));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::memcpy(static_cast<std::uint8_t*>(mapped.pData) + context.dynamicVertexOffset, vertices, copySize);
|
std::memcpy(static_cast<std::uint8_t *>(mapped.pData) + context.dynamicVertexOffset, vertices, copySize);
|
||||||
d3d11->Unmap(context.dynamicVertexBuffer, 0);
|
d3d11->Unmap(context.dynamicVertexBuffer, 0);
|
||||||
|
|
||||||
this->StateUpdate();
|
this->StateUpdate();
|
||||||
|
|
||||||
ID3D11Buffer* dynamicBuffer = context.dynamicVertexBuffer;
|
ID3D11Buffer *dynamicBuffer = context.dynamicVertexBuffer;
|
||||||
const UINT vertexOffset = context.dynamicVertexOffset;
|
const UINT vertexOffset = context.dynamicVertexOffset;
|
||||||
d3d11->IASetVertexBuffers(0, 1, &dynamicBuffer, &stride, &vertexOffset);
|
d3d11->IASetVertexBuffers(0, 1, &dynamicBuffer, &stride, &vertexOffset);
|
||||||
|
|
||||||
|
|||||||
@@ -5,18 +5,16 @@
|
|||||||
C4JStorage StorageManager;
|
C4JStorage StorageManager;
|
||||||
XMARKETPLACE_CONTENTOFFER_INFO InternalContentOfferInfo;
|
XMARKETPLACE_CONTENTOFFER_INFO InternalContentOfferInfo;
|
||||||
|
|
||||||
C4JStorage::C4JStorage()
|
C4JStorage::C4JStorage() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void C4JStorage::Tick(void)
|
void C4JStorage::Tick(void)
|
||||||
{
|
{
|
||||||
InternalStorageManager.Tick();
|
InternalStorageManager.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(UINT uiTitle, UINT uiText, UINT* uiOptionA, UINT uiOptionC, DWORD dwPad,
|
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA, UINT uiOptionC, DWORD dwPad,
|
||||||
int(*Func)(LPVOID, int, const C4JStorage::EMessageResult), LPVOID lpParam, C4JStringTable* pStringTable, WCHAR* pwchFormatString, DWORD dwFocusButton)
|
int (*Func)(LPVOID, int, const C4JStorage::EMessageResult), LPVOID lpParam,
|
||||||
|
C4JStringTable *pStringTable, WCHAR *pwchFormatString, DWORD dwFocusButton)
|
||||||
{
|
{
|
||||||
return EMessage_Undefined;
|
return EMessage_Undefined;
|
||||||
}
|
}
|
||||||
@@ -26,12 +24,13 @@ C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult()
|
|||||||
return EMessage_Undefined;
|
return EMessage_Undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4JStorage::SetSaveDevice(int(*Func)(LPVOID, const bool), LPVOID lpParam, bool bForceResetOfSaveDevice)
|
bool C4JStorage::SetSaveDevice(int (*Func)(LPVOID, const bool), LPVOID lpParam, bool bForceResetOfSaveDevice)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char* pszSavePackName, int iMinimumSaveSize, int(*Func)(LPVOID, const ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID)
|
void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char *pszSavePackName, int iMinimumSaveSize,
|
||||||
|
int (*Func)(LPVOID, const ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID)
|
||||||
{
|
{
|
||||||
InternalStorageManager.Init(Func, lpParam, szGroupID);
|
InternalStorageManager.Init(Func, lpParam, szGroupID);
|
||||||
}
|
}
|
||||||
@@ -51,22 +50,22 @@ void C4JStorage::SetSaveTitle(LPCWSTR pwchDefaultSaveName)
|
|||||||
InternalStorageManager.m_SaveGame.SetSaveTitle(pwchDefaultSaveName);
|
InternalStorageManager.m_SaveGame.SetSaveTitle(pwchDefaultSaveName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4JStorage::GetSaveUniqueNumber(INT* piVal)
|
bool C4JStorage::GetSaveUniqueNumber(INT *piVal)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.GetSaveUniqueNumber(piVal);
|
return InternalStorageManager.m_SaveGame.GetSaveUniqueNumber(piVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4JStorage::GetSaveUniqueFilename(char* pszName)
|
bool C4JStorage::GetSaveUniqueFilename(char *pszName)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.GetSaveUniqueFilename(pszName);
|
return InternalStorageManager.m_SaveGame.GetSaveUniqueFilename(pszName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::SetSaveUniqueFilename(char* szFilename)
|
void C4JStorage::SetSaveUniqueFilename(char *szFilename)
|
||||||
{
|
{
|
||||||
InternalStorageManager.m_SaveGame.SetSaveUniqueFilename(szFilename);
|
InternalStorageManager.m_SaveGame.SetSaveUniqueFilename(szFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::SetState(ESaveGameControlState eControlState, int(*Func)(LPVOID, const bool), LPVOID lpParam)
|
void C4JStorage::SetState(ESaveGameControlState eControlState, int (*Func)(LPVOID, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -86,7 +85,7 @@ unsigned int C4JStorage::GetSaveSize()
|
|||||||
return InternalStorageManager.m_SaveGame.GetSaveSize();
|
return InternalStorageManager.m_SaveGame.GetSaveSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::GetSaveData(void* pvData, unsigned int* puiBytes)
|
void C4JStorage::GetSaveData(void *pvData, unsigned int *puiBytes)
|
||||||
{
|
{
|
||||||
InternalStorageManager.m_SaveGame.GetSaveData(pvData, puiBytes);
|
InternalStorageManager.m_SaveGame.GetSaveData(pvData, puiBytes);
|
||||||
}
|
}
|
||||||
@@ -101,12 +100,12 @@ void C4JStorage::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE
|
|||||||
InternalStorageManager.m_SaveGame.SetSaveImages(pbThumbnail, dwThumbnailBytes, pbImage, dwImageBytes, pbTextData, dwTextDataBytes);
|
InternalStorageManager.m_SaveGame.SetSaveImages(pbThumbnail, dwThumbnailBytes, pbImage, dwImageBytes, pbTextData, dwTextDataBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int(*Func)(LPVOID, const bool), LPVOID lpParam)
|
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int (*Func)(LPVOID, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.SaveSaveData(Func, lpParam);
|
return InternalStorageManager.m_SaveGame.SaveSaveData(Func, lpParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR* wchNewName, int (*Func)(LPVOID lpParam, bool), LPVOID lpParam)
|
void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int (*Func)(LPVOID lpParam, bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -121,7 +120,7 @@ bool C4JStorage::GetSaveDeviceSelected(unsigned int iPad)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool* pbExists)
|
C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool *pbExists)
|
||||||
{
|
{
|
||||||
*pbExists = true;
|
*pbExists = true;
|
||||||
return ESaveGame_Idle;
|
return ESaveGame_Idle;
|
||||||
@@ -137,7 +136,8 @@ void C4JStorage::SetSaveMessageVPosition(float fY)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS* pSaveDetails, const bool), LPVOID lpParam, char* pszSavePackName)
|
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, const bool), LPVOID lpParam,
|
||||||
|
char *pszSavePackName)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.GetSavesInfo(iPad, Func, lpParam, pszSavePackName);
|
return InternalStorageManager.m_SaveGame.GetSavesInfo(iPad, Func, lpParam, pszSavePackName);
|
||||||
}
|
}
|
||||||
@@ -152,42 +152,43 @@ void C4JStorage::ClearSavesInfo()
|
|||||||
InternalStorageManager.m_SaveGame.ClearSavesInfo();
|
InternalStorageManager.m_SaveGame.ClearSavesInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam)
|
C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,
|
||||||
|
int (*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.LoadSaveDataThumbnail(pSaveInfo, Func, lpParam);
|
return InternalStorageManager.m_SaveGame.LoadSaveDataThumbnail(pSaveInfo, Func, lpParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA& xContentData)
|
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA &xContentData)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE* ppbImageData, DWORD* pdwImageBytes)
|
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam)
|
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.LoadSaveData(pSaveInfo, Func, lpParam);
|
return InternalStorageManager.m_SaveGame.LoadSaveData(pSaveInfo, Func, lpParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool), LPVOID lpParam)
|
C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_SaveGame.DeleteSaveData(pSaveInfo, Func, lpParam);
|
return InternalStorageManager.m_SaveGame.DeleteSaveData(pSaveInfo, Func, lpParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::RegisterMarketplaceCountsCallback(int (*Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS*, int), LPVOID lpParam)
|
void C4JStorage::RegisterMarketplaceCountsCallback(int (*Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS *, int), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::SetDLCPackageRoot(char* pszDLCRoot)
|
void C4JStorage::SetDLCPackageRoot(char *pszDLCRoot)
|
||||||
{
|
{
|
||||||
InternalStorageManager.m_DLC.SetPackageRoot(pszDLCRoot);
|
InternalStorageManager.m_DLC.SetPackageRoot(pszDLCRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int(*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask)
|
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int (*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask)
|
||||||
{
|
{
|
||||||
return EDLC_Idle;
|
return EDLC_Idle;
|
||||||
}
|
}
|
||||||
@@ -202,7 +203,7 @@ void C4JStorage::ClearDLCOffers()
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(DWORD dw)
|
XMARKETPLACE_CONTENTOFFER_INFO &C4JStorage::GetOffer(DWORD dw)
|
||||||
{
|
{
|
||||||
return InternalContentOfferInfo;
|
return InternalContentOfferInfo;
|
||||||
}
|
}
|
||||||
@@ -212,7 +213,7 @@ int C4JStorage::GetOfferCount()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64* ullOfferIDA, int(*Func)(LPVOID, int, int), LPVOID lpParam, bool bTrial)
|
DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA, int (*Func)(LPVOID, int, int), LPVOID lpParam, bool bTrial)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -222,17 +223,17 @@ DWORD C4JStorage::GetAvailableDLCCount(int iPad)
|
|||||||
return InternalStorageManager.m_DLC.GetAvailableDLCCount(iPad);
|
return InternalStorageManager.m_DLC.GetAvailableDLCCount(iPad);
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, int), LPVOID lpParam)
|
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, int), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_DLC.GetInstalledDLC(iPad, Func, lpParam);
|
return InternalStorageManager.m_DLC.GetInstalledDLC(iPad, Func, lpParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
XCONTENT_DATA& C4JStorage::GetDLC(DWORD dw)
|
XCONTENT_DATA &C4JStorage::GetDLC(DWORD dw)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_DLC.GetDLC(dw);
|
return InternalStorageManager.m_DLC.GetDLC(dw);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD C4JStorage::MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive)
|
DWORD C4JStorage::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive)
|
||||||
{
|
{
|
||||||
return InternalStorageManager.m_DLC.MountInstalledDLC(iPad, dwDLC, Func, lpParam, szMountDrive);
|
return InternalStorageManager.m_DLC.MountInstalledDLC(iPad, dwDLC, Func, lpParam, szMountDrive);
|
||||||
}
|
}
|
||||||
@@ -242,7 +243,7 @@ DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive)
|
|||||||
return InternalStorageManager.m_DLC.UnmountInstalledDLC(szMountDrive);
|
return InternalStorageManager.m_DLC.UnmountInstalledDLC(szMountDrive);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList)
|
void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector<std::string> &fileList)
|
||||||
{
|
{
|
||||||
InternalStorageManager.m_DLC.GetMountedDLCFileList(szMountDrive, fileList);
|
InternalStorageManager.m_DLC.GetMountedDLCFileList(szMountDrive, fileList);
|
||||||
}
|
}
|
||||||
@@ -253,32 +254,35 @@ std::string C4JStorage::GetMountedPath(std::string szMount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType,
|
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType,
|
||||||
WCHAR* pwchFilename, BYTE** ppBuffer, DWORD* pdwBufferSize, int(*Func)(LPVOID, WCHAR*, int, bool, int), LPVOID lpParam, int iAction)
|
WCHAR *pwchFilename, BYTE **ppBuffer, DWORD *pdwBufferSize,
|
||||||
|
int (*Func)(LPVOID, WCHAR *, int, bool, int), LPVOID lpParam, int iAction)
|
||||||
{
|
{
|
||||||
return ETMSStatus_Idle;
|
return ETMSStatus_Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR* pwchFilename, BYTE* pBuffer, DWORD dwBufferSize)
|
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename, BYTE *pBuffer, DWORD dwBufferSize)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR* pwchFilename)
|
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void C4JStorage::StoreTMSPathName(WCHAR* pwchName)
|
void C4JStorage::StoreTMSPathName(WCHAR *pwchName)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(LPVOID, int, int, PTMSPP_FILEDATA, LPCSTR), LPVOID lpParam, int iUserData)
|
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,
|
||||||
|
LPCSTR szFilename, int (*Func)(LPVOID, int, int, PTMSPP_FILEDATA, LPCSTR), LPVOID lpParam,
|
||||||
|
int iUserData)
|
||||||
{
|
{
|
||||||
return ETMSStatus_Idle;
|
return ETMSStatus_Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int C4JStorage::CRC(unsigned char* buf, int len)
|
unsigned int C4JStorage::CRC(unsigned char *buf, int len)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include "STO_DLC.h"
|
#include "STO_DLC.h"
|
||||||
#include "STO_Main.h"
|
#include "STO_Main.h"
|
||||||
|
|
||||||
XCONTENT_DATA& CDLC::GetDLC(DWORD dw)
|
XCONTENT_DATA &CDLC::GetDLC(DWORD dw)
|
||||||
{
|
{
|
||||||
return m_vInstalledDLCs[dw];
|
return m_vInstalledDLCs[dw];
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ CDLC::CDLC(void) : m_vInstalledDLCs(), m_szMountPath(), m_vDLCDriveMappings()
|
|||||||
ZeroMemory(m_szProductUpgradeKey, sizeof(m_szProductUpgradeKey));
|
ZeroMemory(m_szProductUpgradeKey, sizeof(m_szProductUpgradeKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::EDLCStatus CDLC::GetOffers(int iPad, int(*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask)
|
C4JStorage::EDLCStatus CDLC::GetOffers(int iPad, int (*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask)
|
||||||
{
|
{
|
||||||
return C4JStorage::EDLC_NoOffers;
|
return C4JStorage::EDLC_NoOffers;
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ void CDLC::ClearOffers()
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, int), LPVOID lpParam)
|
C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, int), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
if (m_iHasNewInstalledDLCs)
|
if (m_iHasNewInstalledDLCs)
|
||||||
{
|
{
|
||||||
@@ -100,7 +100,7 @@ C4JStorage::EDLCStatus CDLC::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, i
|
|||||||
return C4JStorage::EDLC_Idle;
|
return C4JStorage::EDLC_Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive)
|
DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive)
|
||||||
{
|
{
|
||||||
this->m_pMountedDLCFunc = Func;
|
this->m_pMountedDLCFunc = Func;
|
||||||
this->m_pMountedDLCParam = lpParam;
|
this->m_pMountedDLCParam = lpParam;
|
||||||
@@ -116,7 +116,7 @@ DWORD CDLC::MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWO
|
|||||||
|
|
||||||
this->m_uiCurrentMappedDLC = dwDLC;
|
this->m_uiCurrentMappedDLC = dwDLC;
|
||||||
|
|
||||||
char* dlcdirPath = m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName;
|
char *dlcdirPath = m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName;
|
||||||
m_vDLCDriveMappings.push_back(DriveMapping(dlcdirPath, m_szMountPath));
|
m_vDLCDriveMappings.push_back(DriveMapping(dlcdirPath, m_szMountPath));
|
||||||
|
|
||||||
m_iHasNewMountedDLCs = true;
|
m_iHasNewMountedDLCs = true;
|
||||||
@@ -149,9 +149,9 @@ DWORD CDLC::UnmountInstalledDLC(LPCSTR szMountDrive)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDLC::GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList)
|
void CDLC::GetMountedDLCFileList(const char *szMountDrive, std::vector<std::string> &fileList)
|
||||||
{
|
{
|
||||||
char* dlcdirPath = new char[256];
|
char *dlcdirPath = new char[256];
|
||||||
sprintf(dlcdirPath, "%s/*", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName);
|
sprintf(dlcdirPath, "%s/*", m_vInstalledDLCs[m_uiCurrentMappedDLC].szFileName);
|
||||||
|
|
||||||
_WIN32_FIND_DATAA atts;
|
_WIN32_FIND_DATAA atts;
|
||||||
@@ -203,13 +203,12 @@ std::string CDLC::GetMountedPath(std::string szMount)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDLC::SetDLCProductCode(const char *szProductCode)
|
||||||
void CDLC::SetDLCProductCode(const char* szProductCode)
|
|
||||||
{
|
{
|
||||||
strcpy(m_szDLCProductCode, szProductCode);
|
strcpy(m_szDLCProductCode, szProductCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDLC::SetProductUpgradeKey(const char* szProductCode)
|
void CDLC::SetProductUpgradeKey(const char *szProductCode)
|
||||||
{
|
{
|
||||||
strcpy(m_szProductUpgradeKey, szProductCode);
|
strcpy(m_szProductUpgradeKey, szProductCode);
|
||||||
}
|
}
|
||||||
@@ -219,7 +218,7 @@ int CDLC::GetAvailableDLCCount(int iPad)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDLC::SetPackageRoot(char* pszDLCRoot)
|
void CDLC::SetPackageRoot(char *pszDLCRoot)
|
||||||
{
|
{
|
||||||
strcpy(this->m_szPackageRoot, pszDLCRoot);
|
strcpy(this->m_szPackageRoot, pszDLCRoot);
|
||||||
}
|
}
|
||||||
@@ -238,7 +237,7 @@ void CDLC::Tick(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDLC::AddInstalled(XCONTENT_DATA* data)
|
void CDLC::AddInstalled(XCONTENT_DATA *data)
|
||||||
{
|
{
|
||||||
m_vInstalledDLCs.push_back(*data);
|
m_vInstalledDLCs.push_back(*data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
class CDLC
|
class CDLC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct DriveMapping
|
struct DriveMapping
|
||||||
{
|
{
|
||||||
DriveMapping(std::string szDirectoryPath, std::string szMountPath) : m_szDirectoryPath(szDirectoryPath), m_szMountPath(szMountPath)
|
DriveMapping(std::string szDirectoryPath, std::string szMountPath) : m_szDirectoryPath(szDirectoryPath), m_szMountPath(szMountPath)
|
||||||
@@ -16,24 +15,25 @@ public:
|
|||||||
std::string m_szMountPath;
|
std::string m_szMountPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
XCONTENT_DATA& GetDLC(DWORD dw);
|
XCONTENT_DATA &GetDLC(DWORD dw);
|
||||||
CDLC(void);
|
CDLC(void);
|
||||||
|
|
||||||
C4JStorage::EDLCStatus GetOffers(int iPad, int(*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask = XMARKETPLACE_OFFERING_TYPE_CONTENT);
|
C4JStorage::EDLCStatus GetOffers(int iPad, int (*Func)(LPVOID, int, DWORD, int), LPVOID lpParam,
|
||||||
|
DWORD dwOfferTypesBitmask = XMARKETPLACE_OFFERING_TYPE_CONTENT);
|
||||||
void ClearOffers();
|
void ClearOffers();
|
||||||
C4JStorage::EDLCStatus GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, int), LPVOID lpParam);
|
C4JStorage::EDLCStatus GetInstalledDLC(int iPad, int (*Func)(LPVOID, int, int), LPVOID lpParam);
|
||||||
DWORD MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive = NULL);
|
DWORD MountInstalledDLC(int iPad, DWORD dwDLC, int (*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive = NULL);
|
||||||
DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL);
|
DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL);
|
||||||
void GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList);
|
void GetMountedDLCFileList(const char *szMountDrive, std::vector<std::string> &fileList);
|
||||||
std::string GetMountedPath(std::string szMount);
|
std::string GetMountedPath(std::string szMount);
|
||||||
|
|
||||||
void SetDLCProductCode(const char* szProductCode);
|
void SetDLCProductCode(const char *szProductCode);
|
||||||
void SetProductUpgradeKey(const char* szProductCode);
|
void SetProductUpgradeKey(const char *szProductCode);
|
||||||
int GetAvailableDLCCount(int iPad);
|
int GetAvailableDLCCount(int iPad);
|
||||||
void SetPackageRoot(char* pszDLCRoot);
|
void SetPackageRoot(char *pszDLCRoot);
|
||||||
|
|
||||||
void Tick(void);
|
void Tick(void);
|
||||||
void AddInstalled(XCONTENT_DATA* data);
|
void AddInstalled(XCONTENT_DATA *data);
|
||||||
DWORD CancelOffers(void);
|
DWORD CancelOffers(void);
|
||||||
|
|
||||||
DWORD dword0;
|
DWORD dword0;
|
||||||
|
|||||||
@@ -10,17 +10,14 @@ CStorage::CStorage(void)
|
|||||||
m_DLC = CDLC();
|
m_DLC = CDLC();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStorage::Init(int(*Func)(LPVOID, const C4JStorage::ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID)
|
void CStorage::Init(int (*Func)(LPVOID, const C4JStorage::ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStorage::Tick(void)
|
void CStorage::Tick(void)
|
||||||
{
|
{
|
||||||
m_DLC.Tick();
|
m_DLC.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStorage::CRC(unsigned char* buf, int len)
|
unsigned int CStorage::CRC(unsigned char *buf, int len)
|
||||||
{
|
{
|
||||||
return ~UpdateCRC(0xFFFFFFFF, buf, len);
|
return ~UpdateCRC(0xFFFFFFFF, buf, len);
|
||||||
}
|
}
|
||||||
@@ -46,7 +43,7 @@ void CStorage::MakeCRCTable(void)
|
|||||||
m_bHasCRCTable = true;
|
m_bHasCRCTable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CStorage::UpdateCRC(unsigned int crc, unsigned __int8* buf, int len)
|
unsigned int CStorage::UpdateCRC(unsigned int crc, unsigned __int8 *buf, int len)
|
||||||
{
|
{
|
||||||
if (!m_bHasCRCTable)
|
if (!m_bHasCRCTable)
|
||||||
{
|
{
|
||||||
@@ -61,7 +58,7 @@ unsigned int CStorage::UpdateCRC(unsigned int crc, unsigned __int8* buf, int len
|
|||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStorage::DebugPrintf(const char* szFormat, ...)
|
void CStorage::DebugPrintf(const char *szFormat, ...)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "STO_SaveGame.h"
|
|
||||||
#include "STO_DLC.h"
|
#include "STO_DLC.h"
|
||||||
|
#include "STO_SaveGame.h"
|
||||||
|
|
||||||
class CStorage
|
class CStorage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CStorage(void);
|
CStorage(void);
|
||||||
|
|
||||||
void Init(int(*Func)(LPVOID, const C4JStorage::ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID);
|
void Init(int (*Func)(LPVOID, const C4JStorage::ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID);
|
||||||
void Tick(void);
|
void Tick(void);
|
||||||
unsigned int CRC(unsigned char* buf, int len);
|
unsigned int CRC(unsigned char *buf, int len);
|
||||||
void MakeCRCTable(void);
|
void MakeCRCTable(void);
|
||||||
unsigned int UpdateCRC(unsigned int crc, unsigned __int8* buf, int len);
|
unsigned int UpdateCRC(unsigned int crc, unsigned __int8 *buf, int len);
|
||||||
void DebugPrintf(const char* szFormat, ...);
|
void DebugPrintf(const char *szFormat, ...);
|
||||||
|
|
||||||
BYTE gap0[8];
|
BYTE gap0[8];
|
||||||
CSaveGame m_SaveGame;
|
CSaveGame m_SaveGame;
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ void CSaveGame::ResetSaveData()
|
|||||||
m_uiSaveSize = 0;
|
m_uiSaveSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState CSaveGame::GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS* pSaveDetails, const bool), LPVOID lpParam, char* pszSavePackName)
|
C4JStorage::ESaveGameState CSaveGame::GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, const bool), LPVOID lpParam,
|
||||||
|
char *pszSavePackName)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATAA findFileData;
|
WIN32_FIND_DATAA findFileData;
|
||||||
WIN32_FILE_ATTRIBUTE_DATA fileInfoBuffer;
|
WIN32_FILE_ATTRIBUTE_DATA fileInfoBuffer;
|
||||||
@@ -90,9 +91,8 @@ C4JStorage::ESaveGameState CSaveGame::GetSavesInfo(int iPad, int (*Func)(LPVOID
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0
|
if ((findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 && strcmp(findFileData.cFileName, ".") &&
|
||||||
&& strcmp(findFileData.cFileName, ".")
|
strcmp(findFileData.cFileName, ".."))
|
||||||
&& strcmp(findFileData.cFileName, ".."))
|
|
||||||
{
|
{
|
||||||
strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveFilename, findFileData.cFileName);
|
strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveFilename, findFileData.cFileName);
|
||||||
strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveTitle, findFileData.cFileName);
|
strcpy_s(m_pSaveDetails->SaveInfoA[i].UTF8SaveTitle, findFileData.cFileName);
|
||||||
@@ -142,13 +142,14 @@ void CSaveGame::ClearSavesInfo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState CSaveGame::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam)
|
C4JStorage::ESaveGameState CSaveGame::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,
|
||||||
|
int (*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
Func(lpParam, pSaveInfo->thumbnailData, pSaveInfo->metaData.thumbnailSize);
|
Func(lpParam, pSaveInfo->thumbnailData, pSaveInfo->metaData.thumbnailSize);
|
||||||
return C4JStorage::ESaveGame_GetSaveThumbnail;
|
return C4JStorage::ESaveGame_GetSaveThumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState CSaveGame::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam)
|
C4JStorage::ESaveGameState CSaveGame::LoadSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
SetSaveUniqueFilename(pSaveInfo->UTF8SaveFilename);
|
SetSaveUniqueFilename(pSaveInfo->UTF8SaveFilename);
|
||||||
|
|
||||||
@@ -193,7 +194,7 @@ unsigned int CSaveGame::GetSaveSize()
|
|||||||
return m_uiSaveSize;
|
return m_uiSaveSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSaveGame::GetSaveData(void* pvData, unsigned int* puiBytes)
|
void CSaveGame::GetSaveData(void *pvData, unsigned int *puiBytes)
|
||||||
{
|
{
|
||||||
if (pvData)
|
if (pvData)
|
||||||
{
|
{
|
||||||
@@ -206,12 +207,12 @@ void CSaveGame::GetSaveData(void* pvData, unsigned int* puiBytes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSaveGame::GetSaveUniqueNumber(INT* piVal)
|
bool CSaveGame::GetSaveUniqueNumber(INT *piVal)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSaveGame::GetSaveUniqueFilename(char* pszName)
|
bool CSaveGame::GetSaveUniqueFilename(char *pszName)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -240,7 +241,7 @@ void CSaveGame::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE p
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState CSaveGame::SaveSaveData(int(*Func)(LPVOID, const bool), LPVOID lpParam)
|
C4JStorage::ESaveGameState CSaveGame::SaveSaveData(int (*Func)(LPVOID, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
char dirName[256];
|
char dirName[256];
|
||||||
char curDir[256];
|
char curDir[256];
|
||||||
@@ -263,28 +264,21 @@ C4JStorage::ESaveGameState CSaveGame::SaveSaveData(int(*Func)(LPVOID, const bool
|
|||||||
return C4JStorage::ESaveGame_Idle;
|
return C4JStorage::ESaveGame_Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
C4JStorage::ESaveGameState CSaveGame::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool), LPVOID lpParam)
|
C4JStorage::ESaveGameState CSaveGame::DeleteSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam)
|
||||||
{
|
{
|
||||||
return C4JStorage::ESaveGame_Idle;
|
return C4JStorage::ESaveGame_Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSaveGame::SetSaveUniqueFilename(char* szFilename)
|
void CSaveGame::SetSaveUniqueFilename(char *szFilename)
|
||||||
{
|
{
|
||||||
strcpy_s(m_szSaveUniqueName, szFilename);
|
strcpy_s(m_szSaveUniqueName, szFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSaveGame::CreateSaveUniqueName(void)
|
void CSaveGame::CreateSaveUniqueName(void)
|
||||||
{
|
{
|
||||||
_SYSTEMTIME UTCSysTime;
|
_SYSTEMTIME UTCSysTime;
|
||||||
GetSystemTime(&UTCSysTime);
|
GetSystemTime(&UTCSysTime);
|
||||||
|
|
||||||
sprintf_s(m_szSaveUniqueName, sizeof(m_szSaveUniqueName),
|
sprintf_s(m_szSaveUniqueName, sizeof(m_szSaveUniqueName), "%4d%02d%02d%02d%02d%02d", UTCSysTime.wYear, UTCSysTime.wMonth, UTCSysTime.wDay,
|
||||||
"%4d%02d%02d%02d%02d%02d",
|
UTCSysTime.wHour, UTCSysTime.wMinute, UTCSysTime.wSecond);
|
||||||
UTCSysTime.wYear,
|
|
||||||
UTCSysTime.wMonth,
|
|
||||||
UTCSysTime.wDay,
|
|
||||||
UTCSysTime.wHour,
|
|
||||||
UTCSysTime.wMinute,
|
|
||||||
UTCSysTime.wSecond);
|
|
||||||
}
|
}
|
||||||
@@ -4,35 +4,36 @@
|
|||||||
class CSaveGame
|
class CSaveGame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CSaveGame();
|
CSaveGame();
|
||||||
void SetSaveDisabled(bool bDisable);
|
void SetSaveDisabled(bool bDisable);
|
||||||
bool GetSaveDisabled(void);
|
bool GetSaveDisabled(void);
|
||||||
|
|
||||||
void ResetSaveData();
|
void ResetSaveData();
|
||||||
C4JStorage::ESaveGameState GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS* pSaveDetails, const bool), LPVOID lpParam, char* pszSavePackName);
|
C4JStorage::ESaveGameState GetSavesInfo(int iPad, int (*Func)(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, const bool), LPVOID lpParam,
|
||||||
|
char *pszSavePackName);
|
||||||
PSAVE_DETAILS ReturnSavesInfo();
|
PSAVE_DETAILS ReturnSavesInfo();
|
||||||
void ClearSavesInfo();
|
void ClearSavesInfo();
|
||||||
C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam);
|
C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes),
|
||||||
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam);
|
LPVOID lpParam);
|
||||||
|
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam);
|
||||||
unsigned int GetSaveSize();
|
unsigned int GetSaveSize();
|
||||||
void GetSaveData(void* pvData, unsigned int* puiBytes);
|
void GetSaveData(void *pvData, unsigned int *puiBytes);
|
||||||
bool GetSaveUniqueNumber(INT* piVal);
|
bool GetSaveUniqueNumber(INT *piVal);
|
||||||
bool GetSaveUniqueFilename(char* pszName);
|
bool GetSaveUniqueFilename(char *pszName);
|
||||||
void SetSaveTitle(LPCWSTR pwchDefaultSaveName);
|
void SetSaveTitle(LPCWSTR pwchDefaultSaveName);
|
||||||
PVOID AllocateSaveData(unsigned int uiBytes);
|
PVOID AllocateSaveData(unsigned int uiBytes);
|
||||||
void SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes);
|
void SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes);
|
||||||
C4JStorage::ESaveGameState SaveSaveData(int(*Func)(LPVOID, const bool), LPVOID lpParam);
|
C4JStorage::ESaveGameState SaveSaveData(int (*Func)(LPVOID, const bool), LPVOID lpParam);
|
||||||
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool), LPVOID lpParam);
|
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo, int (*Func)(LPVOID lpParam, const bool), LPVOID lpParam);
|
||||||
void SetSaveUniqueFilename(char* szFilename);
|
void SetSaveUniqueFilename(char *szFilename);
|
||||||
|
|
||||||
void CreateSaveUniqueName(void);
|
void CreateSaveUniqueName(void);
|
||||||
|
|
||||||
void* m_pSaveData;
|
void *m_pSaveData;
|
||||||
unsigned int m_uiSaveSize;
|
unsigned int m_uiSaveSize;
|
||||||
char m_szSaveUniqueName[32];
|
char m_szSaveUniqueName[32];
|
||||||
char m_szSaveTitle[256];
|
char m_szSaveTitle[256];
|
||||||
bool m_bIsSafeDisabled;
|
bool m_bIsSafeDisabled;
|
||||||
bool m_bHasSaveDetails;
|
bool m_bHasSaveDetails;
|
||||||
SAVE_DETAILS* m_pSaveDetails;
|
SAVE_DETAILS *m_pSaveDetails;
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user