lots of updates
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
#include "tier0/commandline.h"
|
||||
#include "tier0/mem.h"
|
||||
#include "sv_dll.h"
|
||||
#include "cglm/cglm.h"
|
||||
#include "cl_dll.h"
|
||||
|
||||
IRenderContext *g_pRenderContext;
|
||||
IFileSystem *filesystem;
|
||||
IGameWindowManager *g_pWindowManager;
|
||||
|
||||
CServerGameDLL *g_pServerGame;
|
||||
CClientGameDLL *g_pClientGame;
|
||||
|
||||
extern "C" void FunnyMain( int argc, char **argv )
|
||||
{
|
||||
CommandLine()->CreateCommandLine(argc, argv);
|
||||
@@ -38,81 +41,24 @@ extern "C" void FunnyMain( int argc, char **argv )
|
||||
g_pRenderContext->RegisterGameWindow(pWindow);
|
||||
|
||||
|
||||
ServerGameDLL()->Init();
|
||||
|
||||
IShader *pShader = NULL;
|
||||
IBuffer *pCameraInfoBuffer = NULL;
|
||||
IMaterial *pMaterial = NULL;
|
||||
g_pServerGame = new CServerGameDLL;
|
||||
g_pServerGame->m_pGameWindow = pWindow;
|
||||
g_pServerGame->m_pRenderContext = g_pRenderContext;
|
||||
g_pServerGame->Init();
|
||||
|
||||
IImage *pOutputImage = NULL;
|
||||
IVertexBuffer *pVertices = NULL;
|
||||
|
||||
float vertices[18] = {
|
||||
-0.5, -0.5, 0.5,
|
||||
0.5, -0.5, 0.5,
|
||||
-0.5, 0.5, 0.5,
|
||||
-0.5, 0.5, 0.5,
|
||||
0.5, -0.5, 0.5,
|
||||
0.5, 0.5, 0.5
|
||||
};
|
||||
mat4 mat;
|
||||
glm_mat4_identity(mat);
|
||||
|
||||
pVertices = g_pRenderContext->CreateVertexBuffer(72);
|
||||
|
||||
void *pMapped = pVertices->Map();
|
||||
V_memcpy(pMapped, vertices, 72);
|
||||
pVertices->Unmap();
|
||||
|
||||
pCameraInfoBuffer = g_pRenderContext->CreateConstantBuffer(64);
|
||||
pMapped = pCameraInfoBuffer->Map();
|
||||
V_memcpy(pMapped, mat, 64);
|
||||
pCameraInfoBuffer->Unmap();
|
||||
|
||||
pShader = g_pRenderContext->CreateShader("game/core/shaders/flat.shader_c");
|
||||
pShader->AddLayout(0, 12);
|
||||
pShader->AddAttribute(0, 0, VERTEX_FORMAT_XYZ32_SFLOAT, 0);
|
||||
pShader->AddOutputImage(0, IMAGE_FORMAT_RGBA8_UNORM);
|
||||
pShader->Build();
|
||||
pMaterial = g_pRenderContext->CreateMaterial(pShader);
|
||||
pMaterial->PSSetConstantsBuffer(0, pCameraInfoBuffer);
|
||||
|
||||
pOutputImage = g_pRenderContext->CreateRenderTarget(
|
||||
100,
|
||||
100,
|
||||
IMAGE_FORMAT_RGBA8_UNORM,
|
||||
MULTISAMPLE_TYPE_NONE);
|
||||
g_pClientGame = new CClientGameDLL;
|
||||
g_pClientGame->m_pGameWindow = pWindow;
|
||||
g_pClientGame->m_pRenderContext = g_pRenderContext;
|
||||
g_pClientGame->Init();
|
||||
|
||||
|
||||
for (;;) {
|
||||
g_pWindowManager->Frame(0);
|
||||
if (pWindow->BRenderSizeUpdated())
|
||||
{
|
||||
g_pRenderContext->DestroyImage(pOutputImage);
|
||||
pOutputImage = g_pRenderContext->CreateRenderTarget(
|
||||
pWindow->GetRenderWidth(),
|
||||
pWindow->GetRenderHeight(),
|
||||
IMAGE_FORMAT_RGBA8_UNORM,
|
||||
MULTISAMPLE_TYPE_NONE);
|
||||
}
|
||||
|
||||
IRenderCommandList *pCommandList = g_pRenderContext->CreateCommandList();
|
||||
pCommandList->StartRecording();
|
||||
g_pServerGame->m_pBridge->Frame(0);
|
||||
g_pClientGame->m_pBridge->Frame(0);
|
||||
|
||||
pCommandList->SetRenderResolution(pWindow->GetRenderWidth(), pWindow->GetRenderHeight());
|
||||
pCommandList->SetRenderTarget(0, pOutputImage);
|
||||
pCommandList->SetClearColor(0, 0, 0, 0, 0);
|
||||
|
||||
pCommandList->SetMaterial(pMaterial);
|
||||
pCommandList->SetVertexBuffer(0, pVertices);
|
||||
pCommandList->DrawPrimitives(6, 0, 1, 0);
|
||||
|
||||
pCommandList->EndRecording();
|
||||
pWindow->SetOutputImage(pOutputImage);
|
||||
|
||||
g_pRenderContext->SubmitCommandList(pCommandList);
|
||||
g_pRenderContext->Frame(0);
|
||||
g_pRenderContext->DestroyCommandList(pCommandList);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user