mouse controls, fixed texture loading
This commit is contained in:
@@ -31,6 +31,11 @@ static void CallKeyEvent( EInputDeviceType eDevice, EInputButton eButton, bool b
|
||||
g_pHumanDeviceManager->SetButtonUnpressed(eButton);
|
||||
}
|
||||
|
||||
static void CallAxisEvent( EInputDeviceType eDevice, EInputAxis eAxis, float fValue )
|
||||
{
|
||||
g_pHumanDeviceManager->AxisEventRelative(eDevice, eAxis, fValue );
|
||||
}
|
||||
|
||||
extern "C" void __cdecl SteamAPIDebug( ESteamNetworkingSocketsDebugOutputType nType, const char *pszMsg )
|
||||
{
|
||||
V_printf("STEAM: %s\n", pszMsg);
|
||||
@@ -88,6 +93,7 @@ extern "C" void FunnyMain( int argc, char **argv )
|
||||
pWindow = g_pWindowManager->CreateWindow();
|
||||
pWindow->Init();
|
||||
pWindow->SetKeyCallback(CallKeyEvent);
|
||||
pWindow->SetAxisCallback(CallAxisEvent);
|
||||
|
||||
g_pRenderContext = (IRenderContext*)pRenderSystemFactory(RENDER_CONTEXT_INTERFACE_VERSION, NULL);
|
||||
g_pRenderContext->SetMainWindowManager(g_pWindowManager);
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
|
||||
virtual void SetButtonPressed( EInputButton eButton ) override;
|
||||
virtual void SetButtonUnpressed( EInputButton eButton ) override;
|
||||
virtual void AxisEventRelative( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) override;
|
||||
|
||||
virtual void WriteUTF8( uint32_t uCode ) override;
|
||||
|
||||
@@ -83,6 +84,13 @@ void CHumanDeviceManager::SetButtonUnpressed( EInputButton eButton )
|
||||
pInput->OnButton(k_EInputDevice_Keyboard, eButton, false);
|
||||
}
|
||||
|
||||
void CHumanDeviceManager::AxisEventRelative( EInputDeviceType eDevice, EInputAxis eAxis, float fValue )
|
||||
{
|
||||
IHumanDeviceInput *pInput = GetCurrentInput();
|
||||
if (pInput)
|
||||
pInput->OnGameAxisDiff(eDevice, eAxis, fValue);
|
||||
}
|
||||
|
||||
void CHumanDeviceManager::WriteUTF8( uint32_t uCode )
|
||||
{
|
||||
|
||||
|
||||
2
external/GameNetworkingSockets
vendored
2
external/GameNetworkingSockets
vendored
Submodule external/GameNetworkingSockets updated: 725e273c74...517fff0cf6
2
external/SDL
vendored
2
external/SDL
vendored
Submodule external/SDL updated: 7c11a8cb9f...1d081314a8
2
external/Vulkan-Headers
vendored
2
external/Vulkan-Headers
vendored
Submodule external/Vulkan-Headers updated: 2e0a6e699e...29184b9898
2
external/Vulkan-Utility-Libraries
vendored
2
external/Vulkan-Utility-Libraries
vendored
Submodule external/Vulkan-Utility-Libraries updated: 4f4c0b6c61...c15a1ac316
2
external/VulkanMemoryAllocator
vendored
2
external/VulkanMemoryAllocator
vendored
Submodule external/VulkanMemoryAllocator updated: f0969e908b...b3cbbb43ea
2
external/cglm
vendored
2
external/cglm
vendored
Submodule external/cglm updated: a886d6e170...83d5b2c973
2
external/funnystdlib
vendored
2
external/funnystdlib
vendored
Submodule external/funnystdlib updated: 4d3914380b...8f8343e250
2
external/slang
vendored
2
external/slang
vendored
Submodule external/slang updated: 5d775e2829...f267cb77a0
2
external/stb
vendored
2
external/stb
vendored
Submodule external/stb updated: 802cd454f2...e6cd9561ea
2
external/volk
vendored
2
external/volk
vendored
Submodule external/volk updated: d64d20b4ea...e91ceff7db
2
external/xtool
vendored
2
external/xtool
vendored
Submodule external/xtool updated: 22655f3e70...f12a84e960
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"Mesh": "game/core/maps/test/test0.fmesh_c",
|
||||
"Material": "game/core/materials/cube.fmat",
|
||||
"Material": "game/core/materials/nerd.fmat",
|
||||
"Physics": "game/core/maps/test/test0.fpx"
|
||||
}
|
||||
|
||||
5
funnyassets/materials/nerd.fmat
Normal file
5
funnyassets/materials/nerd.fmat
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"shader": "funny_basic_pbr",
|
||||
"AlbedoTexture": "game/core/textures/dev/tile64.png",
|
||||
"AlbedoMultiplier": [1,1,1,1]
|
||||
}
|
||||
BIN
funnyassets/textures/dev/tile128.png
Normal file
BIN
funnyassets/textures/dev/tile128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 218 B |
BIN
funnyassets/textures/dev/tile32.png
Normal file
BIN
funnyassets/textures/dev/tile32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 191 B |
BIN
funnyassets/textures/dev/tile64.png
Normal file
BIN
funnyassets/textures/dev/tile64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 194 B |
@@ -223,7 +223,6 @@ void CAssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pOb
|
||||
if ( pValue->GetArray()->GetParameter(3)->GetType()
|
||||
== JSON_PARAMETER_NUMBER )
|
||||
data->w = pValue->GetArray()->GetParameter(3)->GetNumberValue();
|
||||
V_printf("%s %f %f %f %f\n", desc.m_szEditorName, data->x, data->y, data->z, data->w);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -11,7 +11,6 @@ public:
|
||||
virtual void SetUpMesh( MaterialData_t *pData ) override {
|
||||
pData->m_vAlbedoColor = m_vAlbedo;
|
||||
pData->m_uAlbedo = m_tAlbedo;
|
||||
V_printf("SetUpMesh %f\n", pData->m_vAlbedoColor.x);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ void C_MOBAPlayer::Think( float fDelta )
|
||||
vCameraPos.z = 20;
|
||||
vCameraPos.y+=3;
|
||||
g_pWorldRenderer->SetCameraPosition(vCameraPos);
|
||||
Quat vCameraRot;
|
||||
glm_euler_yxz_quat((vec3){m_fPitch, m_fYaw, 0}, *(versor*)&vCameraRot);
|
||||
g_pWorldRenderer->SetCameraRotation(vCameraRot);
|
||||
}
|
||||
BaseClass::Think(fDelta);
|
||||
};
|
||||
@@ -127,3 +130,35 @@ static void IN_LeftUp( int c, char **v ) {
|
||||
((C_MOBAPlayer*)pPlayer)->m_bIsLeft = false;
|
||||
}
|
||||
static ConCommand endleft("-left", IN_LeftUp);
|
||||
|
||||
void Game_OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
static ConVar m_pitch("m_pitch", "0.022", FCVAR_CLIENTDLL);
|
||||
static ConVar m_yaw("m_yaw", "0.022", FCVAR_CLIENTDLL);
|
||||
static ConVar sens("sens", "3", FCVAR_CLIENTDLL);
|
||||
|
||||
void Game_OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue )
|
||||
{
|
||||
C_BaseEntity *pPlayer = UTIL_GetLocalPlayer();
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if (!dynamic_cast<C_MOBAPlayer*>(pPlayer))
|
||||
return;
|
||||
switch(eAxis)
|
||||
{
|
||||
case k_EInputAxis_MouseY:
|
||||
((C_MOBAPlayer*)pPlayer)->m_fPitch -= glm_rad(fValue * m_pitch.GetFloat() * sens.GetFloat());
|
||||
break;
|
||||
case k_EInputAxis_MouseX:
|
||||
((C_MOBAPlayer*)pPlayer)->m_fYaw -= glm_rad(fValue * m_yaw.GetFloat() * sens.GetFloat());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ public:
|
||||
float m_fFBWalkingDirection;
|
||||
float m_fLRWalkingDirection;
|
||||
|
||||
float m_fPitch= 0;
|
||||
float m_fYaw = 0;
|
||||
|
||||
Vector m_vMovementVector;
|
||||
Vector m_vLocalMovementVector;
|
||||
Vector vCameraPos;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "userinput.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "game.h"
|
||||
#include "baseentity.h"
|
||||
|
||||
class CFunnyInput: public IHumanDeviceInput
|
||||
{
|
||||
@@ -48,12 +49,20 @@ void CFunnyInput::OnGameButton( EInputDeviceType eDevice, EInputButton eScancode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Game_OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue );
|
||||
void Game_OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue );
|
||||
|
||||
void CFunnyInput::OnGameAxis( EInputDeviceType eDevice, EInputAxis eAxis, float fValue)
|
||||
{
|
||||
Game_OnGameAxis(eDevice, eAxis, fValue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CFunnyInput::OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fValue )
|
||||
{
|
||||
Game_OnGameAxisDiff(eDevice, eAxis, fValue);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -241,6 +241,7 @@ void CFunnyWorldRenderer::Frame( float fDelta )
|
||||
glm_mat4_identity(matCamera);
|
||||
glm_mat4_identity(matCamera2);
|
||||
glm_translate(matCamera2, m_vPos);
|
||||
glm_quat_rotate(matCamera2, m_vRot, matCamera2);
|
||||
glm_mat4_inv(matCamera2, matCamera2);
|
||||
glm_perspective(glm_rad(75), uWidth/(float)uHeight, 0.01, 10000, matCamera);
|
||||
glm_mul(matCamera, matCamera2, matCamera);
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
|
||||
SDL_WindowID WindowID();
|
||||
|
||||
KeyCallbackFn m_fnKeyCallback;
|
||||
AxisCallbackFn m_fnAxisCallback;
|
||||
KeyCallbackFn m_fnKeyCallback = NULL;
|
||||
AxisCallbackFn m_fnAxisCallback = NULL;
|
||||
|
||||
bool m_bWindowSizeUpdated;
|
||||
uint32_t m_uRenderWidth;
|
||||
@@ -55,6 +55,7 @@ void CSDLGameWindow::Init()
|
||||
Plat_FatalErrorFunc("SDL_CreateWindow: %s\n", SDL_GetError());
|
||||
m_uRenderWidth = 1280;
|
||||
m_uRenderHeight = 720;
|
||||
SDL_SetWindowRelativeMouseMode(m_pWindow, true);
|
||||
}
|
||||
|
||||
void CSDLGameWindow::Shutdown()
|
||||
@@ -231,10 +232,6 @@ void CSDLGameWindowManager::Frame( float fDelta )
|
||||
}
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
for (auto a: m_pWindows)
|
||||
{
|
||||
if (a->WindowID() != event.window.windowID)
|
||||
@@ -242,32 +239,33 @@ void CSDLGameWindowManager::Frame( float fDelta )
|
||||
pWindow = a;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
|
||||
pWindow->m_bWindowSizeUpdated = true;
|
||||
pWindow->m_uRenderWidth = event.window.data1;
|
||||
pWindow->m_uRenderHeight = event.window.data2;
|
||||
break;
|
||||
case SDL_EVENT_KEY_UP:
|
||||
for (auto a: m_pWindows)
|
||||
{
|
||||
if (a->WindowID() != event.window.windowID)
|
||||
break;
|
||||
pWindow = a;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pWindow->m_fnKeyCallback)
|
||||
pWindow->m_fnKeyCallback(k_EInputDevice_Keyboard, GetKeyButton(event.key.key), false);
|
||||
break;
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
for (auto a: m_pWindows)
|
||||
{
|
||||
if (a->WindowID() != event.window.windowID)
|
||||
break;
|
||||
pWindow = a;
|
||||
break;
|
||||
}
|
||||
if (pWindow->m_fnKeyCallback)
|
||||
pWindow->m_fnKeyCallback(k_EInputDevice_Keyboard, GetKeyButton(event.key.key), true);
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
if (pWindow->m_fnAxisCallback)
|
||||
{
|
||||
pWindow->m_fnAxisCallback(k_EInputDevice_Mouse, k_EInputAxis_MouseX, event.motion.xrel);
|
||||
pWindow->m_fnAxisCallback(k_EInputDevice_Mouse, k_EInputAxis_MouseY, event.motion.yrel);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case SDL_EVENT_QUIT:
|
||||
Plat_Exit(0);
|
||||
break;
|
||||
|
||||
@@ -142,6 +142,7 @@ void CVkMaterial::SetShaderResource( uint32_t uRegister, uint32_t uSet, IRenderi
|
||||
writes[1].descriptorCount = 128;
|
||||
writes[1].pImageInfo = stWrites;
|
||||
vkUpdateDescriptorSets(m_pVkShader->m_hDevice, 2, writes, 0, 0);
|
||||
m_pTextureArray = pArray;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,10 @@ void CVkRenderCommandList::SetMaterial( IMaterial *pMaterial )
|
||||
|
||||
CVkSetShaderDataCommand *pSetShaderData = CREATE_COMMAND(m_pCommandBufferManager, SetShaderData);
|
||||
pSetShaderData->pShaderData = pMaterial;
|
||||
{
|
||||
CVkTextureArray *pArray = (CVkTextureArray*)((CVkMaterial*)pMaterial)->m_pTextureArray;
|
||||
|
||||
}
|
||||
m_pCurrentMaterialBuffer->AddCommand(pSetShaderData);
|
||||
|
||||
CVkSetScissorsCommand *pScissorsCommand = CREATE_COMMAND(m_pCommandBufferManager, SetScissors);
|
||||
|
||||
@@ -397,11 +397,11 @@ uint32_t CVkTextureArray::CreateTexture( uint32_t i, const char *szPath )
|
||||
IBuffer *pBuffer = m_pRenderContext->CreateStorageBuffer(uWidth*uHeight*4);
|
||||
pBuffer->Lock();
|
||||
void *pData = pBuffer->Map();
|
||||
V_memcpy(pData, pImg, uWidth*uHeight*uChannels);
|
||||
V_memcpy(pData, pImg, uWidth*uHeight*4);
|
||||
pBuffer->Unmap();
|
||||
pBuffer->Unlock();
|
||||
vkDeviceWaitIdle(s_vkDevice);
|
||||
IImage *pImage = m_pRenderContext->CreateTexture(uWidth, uHeight, IMAGE_FORMAT_RGBA8_UNORM, MULTISAMPLE_TYPE_NONE);
|
||||
IImage *pCompressedImage = m_pRenderContext->CreateTexture(uWidth, uHeight, IMAGE_FORMAT_BC1, MULTISAMPLE_TYPE_NONE);
|
||||
m_pImages[i] = (CVkImage*)pImage;
|
||||
stbi_image_free(pImg);
|
||||
|
||||
|
||||
@@ -338,6 +338,7 @@ private:
|
||||
};
|
||||
CUtlVector<ShaderBinding_t> m_callableShaders = {};
|
||||
};
|
||||
#define MAX_TEXTURES 4096
|
||||
|
||||
class CVkTextureArray: public ITextureArray
|
||||
{
|
||||
@@ -357,7 +358,7 @@ public:
|
||||
IRenderContext *m_pRenderContext;
|
||||
IVkCommandBufferManager *m_pCommandBufferManager;
|
||||
VkSampler m_hSampler;
|
||||
CVkImage *m_pImages[128];
|
||||
CVkImage *m_pImages[MAX_TEXTURES];
|
||||
};
|
||||
|
||||
class CVkMaterial: public IMaterial
|
||||
@@ -377,6 +378,7 @@ public:
|
||||
|
||||
CVkShader *m_pVkShader;
|
||||
CUtlVector<VkDescriptorSet> m_hSets;
|
||||
ITextureArray *m_pTextureArray;
|
||||
private:
|
||||
VkDescriptorPool m_hPool;
|
||||
CUtlVector<VkWriteDescriptorSet> m_writes = {};
|
||||
|
||||
@@ -106,6 +106,7 @@ inline ConVar::ConVar( const char *pName, const char *pDefaultValue, int flags,
|
||||
m_szName = pName;
|
||||
m_flags = flags;
|
||||
SetValue(pDefaultValue);
|
||||
Console()->RegisterVar(this);
|
||||
}
|
||||
|
||||
inline bool ConVar::IsFlagSet( int flag )
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
|
||||
virtual void SetButtonPressed( EInputButton eButton ) = 0;
|
||||
virtual void SetButtonUnpressed( EInputButton eButton ) = 0;
|
||||
virtual void AxisEventRelative( EInputDeviceType eDevice, EInputAxis eAxis, float fValue ) = 0;
|
||||
|
||||
virtual void WriteUTF8( uint32_t uCode ) = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user