66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#include "tier2/ifilesystem.h"
|
|
#include "materialsystem/imaterialsystem.h"
|
|
#include "enginebridge.h"
|
|
#include "worldrender.h"
|
|
#include "entitysystem.h"
|
|
#include "baseentity.h"
|
|
#include "game.h"
|
|
#include "cglm/mat4.h"
|
|
#include "cglm/cglm.h"
|
|
|
|
IFileSystem *filesystem;
|
|
IRenderContext *g_pRenderContext;
|
|
IGameWindow *g_pMainWindow;
|
|
static CEngineVars s_vars;
|
|
CEngineVars *g_pEngineVars = &s_vars;
|
|
|
|
class CFunnyGameBridge: public IEngineBridge
|
|
{
|
|
virtual void Init() override;
|
|
virtual void Tick( float fDelta ) override;
|
|
virtual void Frame( float fDelta ) override;
|
|
virtual void Shutdown() override;
|
|
virtual void ConnectInterface( const char *psz, void *pInterface ) override;
|
|
};
|
|
|
|
IEngineBridge *EngineBridge()
|
|
{
|
|
static CFunnyGameBridge s_bridge;
|
|
return &s_bridge;
|
|
}
|
|
|
|
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
|
|
|
void CFunnyGameBridge::Init()
|
|
{
|
|
g_pWorldRenderer->Init();
|
|
C_BaseEntity *pEntity = EntitySystem()->CreateByClassname("player");
|
|
pEntity->Spawn();
|
|
}
|
|
|
|
void CFunnyGameBridge::Tick( float fDelta )
|
|
{
|
|
}
|
|
|
|
void CFunnyGameBridge::Frame( float fDelta )
|
|
{
|
|
g_pEngineVars->m_fTime += fDelta;
|
|
g_pEngineVars->m_fDeltaTime = fDelta;
|
|
EntitySystem()->Think();
|
|
g_pWorldRenderer->Frame(fDelta);
|
|
}
|
|
|
|
void CFunnyGameBridge::Shutdown()
|
|
{
|
|
|
|
}
|
|
|
|
#define CONNECT_INTERFACE(szName, pGlobal) if (!V_strcmp(psz, szName)) { pGlobal = (typeof(pGlobal))pInterface; return; }
|
|
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
|
{
|
|
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
|
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
|
CONNECT_INTERFACE("MainWindow", g_pMainWindow);
|
|
}
|
|
|