made it work with new fpc
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include "c.h"
|
||||
#include "ld.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/commandline.h"
|
||||
|
||||
CUtlVector<CUtlString> engine_CompiledFiles = {
|
||||
"engine/engine.cpp",
|
||||
@@ -27,10 +26,11 @@ DECLARE_BUILD_STAGE(engine)
|
||||
|
||||
compileProject.m_szName = "engine";
|
||||
compileProject.files = engine_CompiledFiles;
|
||||
compileProject.includeDirectories = all_IncludeDirectories;
|
||||
compileProject.includeDirectories = {"public"};
|
||||
compileProject.bFPIC = true;
|
||||
ldProject = ccompiler->Compile(&compileProject);
|
||||
|
||||
/*
|
||||
if (bStaticBuild)
|
||||
ldProject.linkType = ELINK_STATIC_LIBRARY;
|
||||
else
|
||||
@@ -41,20 +41,25 @@ DECLARE_BUILD_STAGE(engine)
|
||||
ldProject.objects.AppendTail((Object_t){material_lib});
|
||||
if (bSteam)
|
||||
ldProject.objects.AppendTail((Object_t){steam_lib});
|
||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||
}
|
||||
*/
|
||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||
|
||||
|
||||
ldProject.libraries = engine_Libraries;
|
||||
CUtlString outputProject = linker->Link(&ldProject);
|
||||
CUtlString szOutputDir = linker->Link(&ldProject);
|
||||
|
||||
/*
|
||||
if (!bStaticBuild)
|
||||
{
|
||||
*/
|
||||
filesystem2->MakeDirectory(CUtlString("%s/bin",szOutputDir.GetString()));
|
||||
filesystem2->CopyFile(CUtlString("%s/bin", szOutputDir.GetString()), outputProject);
|
||||
filesystem2->CopyFile(CUtlString("%s/bin", szOutputDir.GetString()), szOutputDir);
|
||||
/*
|
||||
} else {
|
||||
engine_lib = outputProject;
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -2,15 +2,20 @@
|
||||
#include "c.h"
|
||||
#include "ld.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "tier1/commandline.h"
|
||||
|
||||
ADD_DEPENDENCY_BUILD_FILE(MaterialSystem, "../materialsystem/")
|
||||
ADD_DEPENDENCY_BUILD_FILE(tier0, "../tier0/");
|
||||
ADD_DEPENDENCY_BUILD_FILE(tier1, "../tier1/");
|
||||
ADD_DEPENDENCY_BUILD_FILE(tier2, "../tier2/");
|
||||
#define FUNNYSTDLIB "../external/funnystdlib/"
|
||||
ADD_DEPENDENCY_BUILD_FILE(MaterialSystem, "../materialsystem/build.cpp")
|
||||
ADD_DEPENDENCY_BUILD_FILE(tier0, FUNNYSTDLIB"tier0/build.cpp");
|
||||
ADD_DEPENDENCY_BUILD_FILE(tier1, FUNNYSTDLIB"tier1/build.cpp");
|
||||
ADD_DEPENDENCY_BUILD_FILE(tier2, FUNNYSTDLIB"tier2/build.cpp");
|
||||
|
||||
DECLARE_BUILD_STAGE(engine)
|
||||
{
|
||||
bool bUsesSDL = true;
|
||||
if (Target_t::DefaultTarget().cpu == TARGET_CPU_WASM32)
|
||||
{
|
||||
bUsesSDL = false;
|
||||
}
|
||||
CProject_t compileProject = {};
|
||||
LinkProject_t ldProject = {};
|
||||
|
||||
@@ -19,14 +24,16 @@ DECLARE_BUILD_STAGE(engine)
|
||||
"engine.cpp",
|
||||
"cvar.cpp",
|
||||
|
||||
"gamewindow_sdl.cpp",
|
||||
|
||||
"sv_dll.cpp",
|
||||
"cl_dll.cpp",
|
||||
};
|
||||
if (bUsesSDL)
|
||||
compileProject.files.AppendTail("gamewindow_sdl.cpp");
|
||||
|
||||
compileProject.includeDirectories = {
|
||||
"../public",
|
||||
"../external/SDL/include",
|
||||
FUNNYSTDLIB"public",
|
||||
};
|
||||
compileProject.bFPIC = true;
|
||||
ldProject = ccompiler->Compile(&compileProject);
|
||||
@@ -34,12 +41,29 @@ DECLARE_BUILD_STAGE(engine)
|
||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||
|
||||
ldProject.libraryObjects = {
|
||||
GET_PROJECT_LIBRARY("tier1", "tier1"),
|
||||
GET_PROJECT_LIBRARY("tier2", "tier2"),
|
||||
GET_PROJECT_LIBRARY(tier0, "tier0"),
|
||||
};
|
||||
ldProject.libraries = {
|
||||
"SDL3"
|
||||
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
|
||||
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier2, "tier2")});
|
||||
|
||||
if (bUsesSDL)
|
||||
ldProject.libraries.AppendTail("SDL3");
|
||||
if (ldProject.m_target.kernel & TARGET_KERNEL_WINDOWS_DEVICES)
|
||||
{
|
||||
ldProject.libraryDirectories = {"../external/windows"};
|
||||
ldProject.libraries.AppendTail("winpthread-1");
|
||||
ldProject.libraries.AppendTail("winmm");
|
||||
ldProject.libraries.AppendTail("ole32");
|
||||
ldProject.libraries.AppendTail("gdi32");
|
||||
ldProject.libraries.AppendTail("oleaut32");
|
||||
ldProject.libraries.AppendTail("setupapi");
|
||||
ldProject.libraries.AppendTail("imm32");
|
||||
ldProject.libraries.AppendTail("version");
|
||||
ldProject.libraries.AppendTail("shell32");
|
||||
ldProject.libraries.AppendTail("uuid");
|
||||
|
||||
};
|
||||
|
||||
CUtlString outputProject = linker->Link(&ldProject);
|
||||
|
||||
ADD_OUTPUT_OBJECT("engine", outputProject)
|
||||
|
||||
@@ -3,22 +3,26 @@
|
||||
#include "igamewindow.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "tier1/interface.h"
|
||||
#include "tier1/commandline.h"
|
||||
#include "tier0/commandline.h"
|
||||
#include "tier0/mem.h"
|
||||
#include "sv_dll.h"
|
||||
|
||||
IRenderContext *g_pRenderContext;
|
||||
IFileSystem *filesystem;
|
||||
|
||||
extern "C" void FunnyMain( int argc, char **argv )
|
||||
{
|
||||
CommandLine()->CreateCommandLine(argc, argv);
|
||||
|
||||
void *pFilesystem = Plat_LoadLibrary("libfilesystem.so");
|
||||
CreateInterfaceFn pFilesystemFactory = Sys_GetFactory(pFilesystem);
|
||||
CreateInterfaceFn pFilesystemFactory = Sys_GetFactory("filesystem_std");
|
||||
|
||||
filesystem = (IFileSystem*)pFilesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
|
||||
filesystem->Init();
|
||||
|
||||
gamewindow->Init();
|
||||
g_pMaterialSystem->Init();
|
||||
CreateInterfaceFn pMaterialSystemFactory = Sys_GetFactory("MaterialSystem");
|
||||
CreateInterfaceFn pRenderSystemFactory = Sys_GetFactory("RenderSystemVulkan");
|
||||
g_pRenderContext = (IRenderContext*)pRenderSystemFactory(RENDER_CONTEXT_INTERFACE_VERSION, NULL);
|
||||
g_pRenderContext->Init();
|
||||
|
||||
ServerGameDLL()->Init();
|
||||
|
||||
@@ -43,26 +47,25 @@ extern "C" void FunnyMain( int argc, char **argv )
|
||||
|
||||
pCameraInfoBuffer = g_pRenderContext->CreateConstantBuffer(64);
|
||||
|
||||
/*
|
||||
pShader = g_pRenderContext->CreateShader("funnygame/core/shaders/flat.shader_c");
|
||||
pMaterial = g_pRenderContext->CreateMaterial(pShader);
|
||||
pMaterial->PSSetConstantsBuffer(0, pCameraInfoBuffer);
|
||||
*/
|
||||
|
||||
pOutputImage = g_pRenderContext->CreateRenderTarget(
|
||||
g_pRenderContext->GetNewOutputImageWidth(),
|
||||
g_pRenderContext->GetNewOutputImageHeight(),
|
||||
1280,
|
||||
720,
|
||||
IMAGE_FORMAT_RGBA8_UNORM,
|
||||
MULTISAMPLE_TYPE_NONE);
|
||||
|
||||
IRenderCommandList *pCommandList = g_pRenderContext->CreateCommandList();
|
||||
pCommandList->StartRecording();
|
||||
pCommandList->SetRenderTarget(0, pOutputImage);
|
||||
pCommandList->SetMaterial(pMaterial);
|
||||
pCommandList->SetVertexBuffer(0, pVertices);
|
||||
pCommandList->DrawPrimitives(3, 0, 1, 0);
|
||||
pCommandList->SetClearColor(0, 1,0,0,0);
|
||||
pCommandList->EndRecording();
|
||||
|
||||
for (;;) {
|
||||
gamewindow->UpdateWindow();
|
||||
/*
|
||||
if (g_pRenderContext->BIsOutputImageOutdated())
|
||||
{
|
||||
@@ -77,11 +80,7 @@ extern "C" void FunnyMain( int argc, char **argv )
|
||||
*/
|
||||
|
||||
g_pRenderContext->SubmitCommandList(pCommandList);
|
||||
|
||||
g_pRenderContext->SetOutputImage(pOutputImage);
|
||||
|
||||
gamewindow->UpdateWindow();
|
||||
Materials()->Frame(0);
|
||||
g_pRenderContext->Frame(0);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -36,9 +36,9 @@ void CGameManager::Init()
|
||||
CUtlString sz;
|
||||
|
||||
pFile = filesystem->Open("game.ini", FILEMODE_READ);
|
||||
szData = CUtlBuffer<char>(pFile->Size());
|
||||
pFile->Read(szData.GetMemory(), szData.GetSize());
|
||||
pFile->Close();
|
||||
szData = CUtlBuffer<char>(filesystem->Size(pFile));
|
||||
filesystem->Read(pFile, szData.GetMemory(), szData.GetSize());
|
||||
filesystem->Close(pFile);
|
||||
|
||||
g_pGameParameters= INIManager()->ReadString(szData);
|
||||
pMainGame = g_pGameParameters->GetSection("MainGame");
|
||||
|
||||
@@ -17,48 +17,22 @@ class CSDLGameWindow: public IGameWindow
|
||||
public:
|
||||
virtual void Init() override;
|
||||
virtual void Shutdown() override;
|
||||
virtual void UpdateWindow() override;
|
||||
virtual void Tick( float fDelta ) override;
|
||||
virtual void Frame( float fDelta ) override;
|
||||
virtual uint32_t GetRenderWidth() override;
|
||||
virtual uint32_t GetRenderHeight() override;
|
||||
|
||||
// Rendering info
|
||||
virtual void SetRenderImage( IImage *pImage ) override;
|
||||
virtual bool BIsRenderResolutionUpdated() override;
|
||||
virtual void GetRenderWidth() override;
|
||||
virtual void GetRenderHeight() override;
|
||||
|
||||
// Vulkan stuff
|
||||
virtual int GetVulkanInstanceExtensionCount() override;
|
||||
virtual const char **GetVulkanInstanceExtensions() override;
|
||||
|
||||
virtual void CreateVulkanSurface( void *pInstance, void *pDevice ) override;
|
||||
virtual void DestroyVulkanSurface( void *pInstance, void *pDevice ) override;
|
||||
|
||||
virtual void *GetVulkanSurface() override;
|
||||
virtual void *GetVulkanFence( int iFrame ) override;
|
||||
virtual void *GetVulkanDrawSemaphore( int iFrame ) override;
|
||||
virtual void *GetVulkanPresentSemaphore( int iFrame ) override;
|
||||
virtual IImage *GetVulkanSwapchainImage( int iFrame ) override;
|
||||
virtual void *CreateVulkanSurface( void *pInstance ) override;
|
||||
virtual void DestroyVulkanSurface( void *pInstance ) override;
|
||||
private:
|
||||
|
||||
VkSurfaceKHR m_hSurface;
|
||||
SDL_Window *m_pWindow;
|
||||
EGraphicsAPI m_ePreferredGraphicsAPI;
|
||||
|
||||
uint32_t m_uRenderWidth;
|
||||
uint32_t m_uRenderHeight;
|
||||
bool m_bIsRenderResolutionUpdated;
|
||||
|
||||
void *m_pVulkanSurface;
|
||||
CUtlVector<IImage*> m_vulkanImages;
|
||||
void *m_pVulkanFences[VULKAN_FRAMES_IN_FLIGHT];
|
||||
void *m_pVulkanPresentSemaphores[VULKAN_FRAMES_IN_FLIGHT];
|
||||
};
|
||||
|
||||
CSDLGameWindow g_sdlGameWindow;
|
||||
IGameWindow *gamewindow = &g_sdlGameWindow;
|
||||
|
||||
|
||||
void CSDLGameWindow::Init()
|
||||
{
|
||||
m_ePreferredGraphicsAPI = GRAPHICS_API_VULKAN;
|
||||
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD))
|
||||
Plat_FatalErrorFunc("SDL_Init: %s\n", SDL_GetError());
|
||||
|
||||
@@ -72,18 +46,14 @@ void CSDLGameWindow::Shutdown()
|
||||
|
||||
}
|
||||
|
||||
void CSDLGameWindow::UpdateWindow()
|
||||
void CSDLGameWindow::Frame( float fDelta )
|
||||
{
|
||||
SDL_Event event;
|
||||
m_bIsRenderResolutionUpdated = false;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
m_bIsRenderResolutionUpdated = true;
|
||||
m_uRenderWidth = event.window.data1;
|
||||
m_uRenderWidth = event.window.data2;
|
||||
break;
|
||||
case SDL_EVENT_QUIT:
|
||||
SDL_Quit();
|
||||
@@ -94,46 +64,92 @@ void CSDLGameWindow::UpdateWindow()
|
||||
}
|
||||
}
|
||||
}
|
||||
EGraphicsAPI CSDLGameWindow::GetGraphicsAPI()
|
||||
void CSDLGameWindow::Tick( float fDelta )
|
||||
{
|
||||
return GRAPHICS_API_VULKAN;
|
||||
|
||||
};
|
||||
|
||||
uint32_t CSDLGameWindow::GetRenderWidth()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CSDLGameWindow::GetVulkanInstanceExtensionCount()
|
||||
uint32_t CSDLGameWindow::GetRenderHeight()
|
||||
{
|
||||
if ( m_ePreferredGraphicsAPI != GRAPHICS_API_VULKAN )
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void *CSDLGameWindow::CreateVulkanSurface( void *pInstance )
|
||||
{
|
||||
SDL_Vulkan_CreateSurface(m_pWindow, (VkInstance)pInstance, NULL, (VkSurfaceKHR*)&m_hSurface);
|
||||
return (void*)m_hSurface;
|
||||
}
|
||||
|
||||
void CSDLGameWindow::DestroyVulkanSurface( void *pInstance )
|
||||
{
|
||||
SDL_Vulkan_DestroySurface((VkInstance)pInstance, (VkSurfaceKHR)m_hSurface, NULL);
|
||||
}
|
||||
|
||||
class CSDLGameWindowManager: public IGameWindowManager
|
||||
{
|
||||
|
||||
virtual void Init() override;
|
||||
virtual void Tick( float fDelta ) override;
|
||||
virtual void Frame( float fDelta ) override;
|
||||
virtual void Shutdown() override;
|
||||
|
||||
virtual IGameWindow *CreateWindow() override;
|
||||
virtual void DestroyWindow( IGameWindow* pWindow ) override;
|
||||
|
||||
virtual int GetVulkanInstanceExtensionCount() override;
|
||||
virtual const char **GetVulkanInstanceExtensions() override;
|
||||
};
|
||||
|
||||
void CSDLGameWindowManager::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSDLGameWindowManager::Tick( float fDelta )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSDLGameWindowManager::Frame( float fDelta )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSDLGameWindowManager::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
IGameWindow *CSDLGameWindowManager::CreateWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSDLGameWindowManager::DestroyWindow( IGameWindow* pWindow )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
int CSDLGameWindowManager::GetVulkanInstanceExtensionCount()
|
||||
{
|
||||
uint32_t nCount;
|
||||
SDL_Vulkan_GetInstanceExtensions(&nCount);
|
||||
|
||||
return nCount;
|
||||
}
|
||||
|
||||
const char **CSDLGameWindow::GetVulkanInstanceExtensions()
|
||||
const char **CSDLGameWindowManager::GetVulkanInstanceExtensions()
|
||||
{
|
||||
if ( m_ePreferredGraphicsAPI != GRAPHICS_API_VULKAN )
|
||||
return 0;
|
||||
|
||||
uint32_t nCount;
|
||||
return (const char **)SDL_Vulkan_GetInstanceExtensions(&nCount);
|
||||
}
|
||||
|
||||
void CSDLGameWindow::CreateVulkanSurface( void *pInstance )
|
||||
{
|
||||
if ( m_ePreferredGraphicsAPI != GRAPHICS_API_VULKAN )
|
||||
return;
|
||||
|
||||
SDL_Vulkan_CreateSurface(m_pWindow, (VkInstance)pInstance, NULL, (VkSurfaceKHR*)&m_pVulkanSurface);
|
||||
}
|
||||
|
||||
void CSDLGameWindow::DestroyVulkanSurface( void *pInstance )
|
||||
{
|
||||
SDL_Vulkan_DestroySurface((VkInstance)pInstance, (VkSurfaceKHR)m_pVulkanSurface, NULL);
|
||||
}
|
||||
|
||||
void *CSDLGameWindow::GetVulkanSurface()
|
||||
{
|
||||
return m_pVulkanSurface;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user