made rendering work
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
|
||||
#include "tier2/ifilesystem.h"
|
||||
#include "igamewindow.h"
|
||||
#include "materialsystem/igamewindow.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "tier1/interface.h"
|
||||
#include "tier0/commandline.h"
|
||||
@@ -9,21 +9,34 @@
|
||||
|
||||
IRenderContext *g_pRenderContext;
|
||||
IFileSystem *filesystem;
|
||||
IGameWindowManager *g_pWindowManager;
|
||||
|
||||
extern "C" void FunnyMain( int argc, char **argv )
|
||||
{
|
||||
CommandLine()->CreateCommandLine(argc, argv);
|
||||
|
||||
CreateInterfaceFn pFilesystemFactory = Sys_GetFactory("filesystem_std");
|
||||
CreateInterfaceFn pMaterialSystemFactory = Sys_GetFactory("MaterialSystem");
|
||||
CreateInterfaceFn pRenderSystemFactory = Sys_GetFactory("RenderSystemVulkan");
|
||||
|
||||
filesystem = (IFileSystem*)pFilesystemFactory(FILESYSTEM_INTERFACE_VERSION, NULL);
|
||||
filesystem->Init();
|
||||
|
||||
CreateInterfaceFn pMaterialSystemFactory = Sys_GetFactory("MaterialSystem");
|
||||
CreateInterfaceFn pRenderSystemFactory = Sys_GetFactory("RenderSystemVulkan");
|
||||
g_pWindowManager = (IGameWindowManager*)pRenderSystemFactory(GAME_WINDOW_MANAGER_INTERFACE_VERSION, NULL);
|
||||
V_printf("%s\n", GAME_WINDOW_MANAGER_INTERFACE_VERSION);
|
||||
g_pWindowManager->Init();
|
||||
|
||||
IGameWindow *pWindow = g_pWindowManager->CreateWindow();
|
||||
pWindow->Init();
|
||||
|
||||
|
||||
g_pRenderContext = (IRenderContext*)pRenderSystemFactory(RENDER_CONTEXT_INTERFACE_VERSION, NULL);
|
||||
g_pRenderContext->SetMainWindowManager(g_pWindowManager);
|
||||
g_pRenderContext->Init();
|
||||
|
||||
g_pRenderContext->RegisterGameWindow(pWindow);
|
||||
|
||||
|
||||
ServerGameDLL()->Init();
|
||||
|
||||
IShader *pShader = NULL;
|
||||
@@ -33,54 +46,68 @@ extern "C" void FunnyMain( int argc, char **argv )
|
||||
IImage *pOutputImage = NULL;
|
||||
IVertexBuffer *pVertices = NULL;
|
||||
|
||||
float vertices[9] = {
|
||||
0,-0.5, 0.5,
|
||||
0.5,0.5, 0.5,
|
||||
-0.5,0.5, 0.5,
|
||||
float vertices[18] = {
|
||||
-0.5, -0.5, 0,
|
||||
0.5, -0.5, 0,
|
||||
-0.5, 0.5, 0,
|
||||
-0.5, 0.5, 0,
|
||||
0.5, -0.5, 0,
|
||||
0.5, 0.5, 0
|
||||
|
||||
};
|
||||
|
||||
pVertices = g_pRenderContext->CreateVertexBuffer(36);
|
||||
pVertices = g_pRenderContext->CreateVertexBuffer(72);
|
||||
|
||||
void *pMapped = pVertices->Map();
|
||||
V_memcpy(pMapped, vertices, 36);
|
||||
V_memcpy(pMapped, vertices, 72);
|
||||
pVertices->Unmap();
|
||||
|
||||
pCameraInfoBuffer = g_pRenderContext->CreateConstantBuffer(64);
|
||||
|
||||
/*
|
||||
pShader = g_pRenderContext->CreateShader("funnygame/core/shaders/flat.shader_c");
|
||||
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(
|
||||
1280,
|
||||
720,
|
||||
100,
|
||||
100,
|
||||
IMAGE_FORMAT_RGBA8_UNORM,
|
||||
MULTISAMPLE_TYPE_NONE);
|
||||
|
||||
IRenderCommandList *pCommandList = g_pRenderContext->CreateCommandList();
|
||||
pCommandList->StartRecording();
|
||||
pCommandList->SetRenderTarget(0, pOutputImage);
|
||||
pCommandList->SetClearColor(0, 1,0,0,0);
|
||||
pCommandList->EndRecording();
|
||||
|
||||
for (;;) {
|
||||
/*
|
||||
if (g_pRenderContext->BIsOutputImageOutdated())
|
||||
g_pWindowManager->Frame(0);
|
||||
if (pWindow->BRenderSizeUpdated())
|
||||
{
|
||||
uint32_t nWidth;
|
||||
uint32_t nHeight;
|
||||
g_pRenderContext->DestroyImage(pOutputImage);
|
||||
pOutputImage = g_pRenderContext->CreateRenderTarget(
|
||||
g_pRenderContext->GetNewOutputImageWidth(),
|
||||
g_pRenderContext->GetNewOutputImageHeight(),
|
||||
pWindow->GetRenderWidth(),
|
||||
pWindow->GetRenderHeight(),
|
||||
IMAGE_FORMAT_RGBA8_UNORM,
|
||||
MULTISAMPLE_TYPE_NONE);
|
||||
}
|
||||
*/
|
||||
|
||||
IRenderCommandList *pCommandList = g_pRenderContext->CreateCommandList();
|
||||
pCommandList->StartRecording();
|
||||
|
||||
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