added mesh rendering
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -10,3 +10,6 @@
|
|||||||
[submodule "external/stb"]
|
[submodule "external/stb"]
|
||||||
path = external/stb
|
path = external/stb
|
||||||
url = https://github.com/nothings/stb.git
|
url = https://github.com/nothings/stb.git
|
||||||
|
[submodule "external/SDL"]
|
||||||
|
path = external/SDL
|
||||||
|
url = https://github.com/libsdl-org/SDL.git
|
||||||
|
|||||||
14
build.c
14
build.c
@@ -18,15 +18,15 @@ char* include_dirs[] = {
|
|||||||
#include "fgui/__build.c"
|
#include "fgui/__build.c"
|
||||||
#include "rapier/__build.c"
|
#include "rapier/__build.c"
|
||||||
#include "engine/__build.c"
|
#include "engine/__build.c"
|
||||||
#include "game/__build.c"
|
#include "game/server/__build.c"
|
||||||
|
#include "game/client/__build.c"
|
||||||
|
|
||||||
#include "launcher/__build.c"
|
#include "launcher/__build.c"
|
||||||
#include "funnyassets/__build.c"
|
#include "funnyassets/__build.c"
|
||||||
|
|
||||||
int build(struct build_data b) {
|
|
||||||
if (!step("trace"))
|
|
||||||
trace = 1;
|
|
||||||
|
|
||||||
|
int build(struct build_data b) {
|
||||||
|
trace = 1;
|
||||||
makedir("build/"GAME_NAME"/game/" GAME_NAME);
|
makedir("build/"GAME_NAME"/game/" GAME_NAME);
|
||||||
makedir("build/"GAME_NAME"/game/" GAME_NAME "/bin");
|
makedir("build/"GAME_NAME"/game/" GAME_NAME "/bin");
|
||||||
makedir("build/"GAME_NAME"/game/bin/");
|
makedir("build/"GAME_NAME"/game/bin/");
|
||||||
@@ -38,8 +38,12 @@ int build(struct build_data b) {
|
|||||||
launcher_build(b);
|
launcher_build(b);
|
||||||
|
|
||||||
server_build(b);
|
server_build(b);
|
||||||
|
client_build(b);
|
||||||
|
|
||||||
assets_build(b);
|
if (step("noassets"))
|
||||||
|
{
|
||||||
|
assets_build(b);
|
||||||
|
}
|
||||||
mv("build", "tools");
|
mv("build", "tools");
|
||||||
|
|
||||||
if (step("run")!=STEP_FAILED)
|
if (step("run")!=STEP_FAILED)
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
#include "god/build.h"
|
||||||
#include "god/c.h"
|
#include "god/c.h"
|
||||||
#include "god/ld.h"
|
#include "god/ld.h"
|
||||||
#include "god/utils.h"
|
#include "god/utils.h"
|
||||||
|
|
||||||
|
char *engine_lib;
|
||||||
|
char *engine_implib;
|
||||||
void engine_build(struct build_data b)
|
void engine_build(struct build_data b)
|
||||||
{
|
{
|
||||||
|
char *szVideoFile = "engine/vk_videosdl.cpp";
|
||||||
char* files[] = {
|
char* files[] = {
|
||||||
"engine/console.cpp",
|
"engine/console.cpp",
|
||||||
"engine/filesystem.cpp",
|
"engine/filesystem.cpp",
|
||||||
@@ -11,12 +15,12 @@ void engine_build(struct build_data b)
|
|||||||
"engine/engine.cpp",
|
"engine/engine.cpp",
|
||||||
|
|
||||||
/* rendering */
|
/* rendering */
|
||||||
"engine/vk_videolinux.cpp",
|
|
||||||
"engine/vk_video.cpp",
|
"engine/vk_video.cpp",
|
||||||
"engine/vk_brush.cpp",
|
"engine/vk_brush.cpp",
|
||||||
|
"engine/vk_mesh.cpp",
|
||||||
|
szVideoFile,
|
||||||
|
|
||||||
/* entities */
|
/* entities */
|
||||||
|
|
||||||
"engine/baseentity.cpp",
|
"engine/baseentity.cpp",
|
||||||
"engine/level.cpp",
|
"engine/level.cpp",
|
||||||
"engine/brush.cpp",
|
"engine/brush.cpp",
|
||||||
@@ -30,9 +34,6 @@ void engine_build(struct build_data b)
|
|||||||
"engine/cl_light.cpp",
|
"engine/cl_light.cpp",
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
char *rustFiles[] = {
|
|
||||||
"engine/rust/physics.rs"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct project p = {
|
struct project p = {
|
||||||
@@ -40,7 +41,6 @@ void engine_build(struct build_data b)
|
|||||||
.files = files,
|
.files = files,
|
||||||
.name = "engine",
|
.name = "engine",
|
||||||
};
|
};
|
||||||
|
|
||||||
struct project o = C_compile(p, (struct C_settings){
|
struct project o = C_compile(p, (struct C_settings){
|
||||||
.generation_flags = C_GENERATION_FLAGS_PIC,
|
.generation_flags = C_GENERATION_FLAGS_PIC,
|
||||||
.compile_flags = C_COMPILE_FLAGS_WALL,
|
.compile_flags = C_COMPILE_FLAGS_WALL,
|
||||||
@@ -49,16 +49,28 @@ void engine_build(struct build_data b)
|
|||||||
add_item(&o.files, tier1_lib);
|
add_item(&o.files, tier1_lib);
|
||||||
add_item(&o.files, rapierLib);
|
add_item(&o.files, rapierLib);
|
||||||
|
|
||||||
|
char *szVulkan = (char*)1;
|
||||||
|
char *szws2 = (char*)1;
|
||||||
|
if (b.kernel==BUILD_KERNEL_WINDOWS)
|
||||||
|
{
|
||||||
|
szVulkan="vulkan-1";
|
||||||
|
szws2="ws2_32";
|
||||||
|
}
|
||||||
|
if (b.kernel==BUILD_KERNEL_LINUX)
|
||||||
|
{
|
||||||
|
szVulkan="vulkan";
|
||||||
|
}
|
||||||
|
|
||||||
char* libs[] = {
|
char* libs[] = {
|
||||||
"c",
|
"c",
|
||||||
"vulkan",
|
"SDL3",
|
||||||
"X11",
|
szVulkan,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
char* dll = ld_link_project(o, (struct link_settings){
|
engine_lib = ld_link_project(o, (struct link_settings){
|
||||||
.type = LINK_TYPE_DYNAMIC,
|
.type = LINK_TYPE_DYNAMIC,
|
||||||
.libs = libs,
|
.libs = libs,
|
||||||
});
|
});
|
||||||
mv("build/"GAME_NAME"/game/bin",dll);
|
mv("build/"GAME_NAME"/game/bin",engine_lib);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
|
#include "cglm/mat4.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
CUtlSelfReferencingVector<CBaseEntity*> g_entities;
|
CUtlSelfReferencingVector<CBaseEntity*> g_entities;
|
||||||
CUtlVector<CEntityRegistry*> g_RegisteredEntities;
|
CUtlVector<CEntityRegistry*> g_RegisteredEntities;
|
||||||
|
|
||||||
|
CBaseEntity::CBaseEntity()
|
||||||
|
{
|
||||||
|
glm_mat4_identity(m_matrix);
|
||||||
|
};
|
||||||
|
|
||||||
CEntityRegistry::CEntityRegistry(const char *szName, const char *szClass, EntityRegistryFn pfn) :
|
CEntityRegistry::CEntityRegistry(const char *szName, const char *szClass, EntityRegistryFn pfn) :
|
||||||
m_szName(szName), m_szClass(szClass), m_pfn(pfn), m_pClientfn(0)
|
m_szName(szName), m_szClass(szClass), m_pfn(pfn), m_pClientfn(0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,22 +22,20 @@ void CBrushEntity::Spawn()
|
|||||||
for (auto tri: m_mesh)
|
for (auto tri: m_mesh)
|
||||||
{
|
{
|
||||||
V_memcpy(&triangles[i],tri.location,36);
|
V_memcpy(&triangles[i],tri.location,36);
|
||||||
i+=1;
|
i+=3;
|
||||||
}
|
}
|
||||||
V_printf("indicides %i\n",indicies.GetSize());
|
|
||||||
V_printf("vertices %i\n",triangles.GetSize());
|
|
||||||
|
|
||||||
px_collider_params params = {};
|
px_collider_params params = {};
|
||||||
params.friction = 0;
|
params.friction = 0.6;
|
||||||
m_collider = px_trimesh((Point<float>*)triangles.GetMemory(), triangles.GetSize(), (uint32_t(*)[3])indicies.GetMemory(), indicies.GetSize()/3 ,params);
|
m_collider = px_trimesh((Point<float>*)triangles.GetMemory(), triangles.GetSize(), (uint32_t(*)[3])indicies.GetMemory(), indicies.GetSize()/3 ,params);
|
||||||
|
//m_collider = px_box(4, 10, 1, params);
|
||||||
px_matrix mat = {};
|
px_matrix mat = {};
|
||||||
mat.m[0] = 1;
|
mat.m[0] = 1;
|
||||||
mat.m[4] = 1;
|
mat.m[5] = 1;
|
||||||
mat.m[9] = 1;
|
mat.m[10] = 1;
|
||||||
mat.m[15] = 1;
|
mat.m[15] = 1;
|
||||||
px_rigidbody_params param = {};
|
px_rigidbody_params param = {};
|
||||||
param.gravity_scale = 1;
|
param.gravity_scale = 1;
|
||||||
m_body = px_staticbody(px, m_collider, mat);
|
px_fixedbody(px, m_collider);
|
||||||
};
|
};
|
||||||
|
|
||||||
void CBrushEntity::Destroy()
|
void CBrushEntity::Destroy()
|
||||||
@@ -67,7 +65,7 @@ void C_BrushEntity::Spawn()
|
|||||||
pAlbedo = ITextureManager::LoadTexture("gfx/bricks.png");
|
pAlbedo = ITextureManager::LoadTexture("gfx/bricks.png");
|
||||||
CBrushEntity* pBrushEntity = (CBrushEntity*)pEntity;
|
CBrushEntity* pBrushEntity = (CBrushEntity*)pEntity;
|
||||||
uint32_t numVertices = 15*pBrushEntity->m_mesh.GetSize();
|
uint32_t numVertices = 15*pBrushEntity->m_mesh.GetSize();
|
||||||
vertexBuffer = IBrushRenderer::CreateVertexBuffer(numVertices*4);
|
vertexBuffer = IRenderer::CreateVertexBuffer(numVertices*4);
|
||||||
Vertex_t *pTriangles = (Vertex_t*)vertexBuffer->Map();
|
Vertex_t *pTriangles = (Vertex_t*)vertexBuffer->Map();
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for (auto &triangle: pBrushEntity->m_mesh)
|
for (auto &triangle: pBrushEntity->m_mesh)
|
||||||
@@ -103,7 +101,7 @@ void C_BrushEntity::Destroy()
|
|||||||
void C_BrushEntity::Think( float fDelta )
|
void C_BrushEntity::Think( float fDelta )
|
||||||
{
|
{
|
||||||
material.m.albedo = ITextureManager::GetTexture(pAlbedo);
|
material.m.albedo = ITextureManager::GetTexture(pAlbedo);
|
||||||
IBrushRenderer::SetMaterial(&material);
|
IRenderer::SetMaterial(&material);
|
||||||
mesh->Draw();
|
mesh->Draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
|
#include "rendering.h"
|
||||||
|
|
||||||
class C_Light: public C_BaseEntity
|
class C_Light: public C_BaseEntity
|
||||||
{
|
{
|
||||||
@@ -8,6 +8,8 @@ public:
|
|||||||
virtual void Spawn( void ) override;
|
virtual void Spawn( void ) override;
|
||||||
virtual void Destroy( void ) override;
|
virtual void Destroy( void ) override;
|
||||||
virtual void Think( float fDelta ) override;
|
virtual void Think( float fDelta ) override;
|
||||||
|
IVertexBuffer *vertexBuffer;
|
||||||
|
IMesh *mesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_Light::Precache()
|
void C_Light::Precache()
|
||||||
@@ -17,6 +19,56 @@ void C_Light::Precache()
|
|||||||
|
|
||||||
void C_Light::Spawn()
|
void C_Light::Spawn()
|
||||||
{
|
{
|
||||||
|
float cubeVertices[] = {
|
||||||
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
|
||||||
|
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
|
||||||
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
|
||||||
|
-0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
|
||||||
|
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
|
||||||
|
-0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
|
||||||
|
|
||||||
|
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
||||||
|
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
||||||
|
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
|
||||||
|
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
||||||
|
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
|
||||||
|
-0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
|
||||||
|
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
||||||
|
-0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
||||||
|
-0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
|
||||||
|
};
|
||||||
|
vertexBuffer = IRenderer::CreateVertexBuffer(sizeof(cubeVertices));
|
||||||
|
void *pTriangles = vertexBuffer->Map();
|
||||||
|
V_memcpy(pTriangles, cubeVertices, sizeof(cubeVertices));
|
||||||
|
vertexBuffer->Unmap();
|
||||||
|
|
||||||
|
mesh = IMeshRenderer::CreateMesh();
|
||||||
|
mesh->SetVertexBuffer(vertexBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
void C_Light::Destroy()
|
void C_Light::Destroy()
|
||||||
@@ -25,7 +77,9 @@ void C_Light::Destroy()
|
|||||||
}
|
}
|
||||||
void C_Light::Think( float fDelta )
|
void C_Light::Think( float fDelta )
|
||||||
{
|
{
|
||||||
|
IRenderer::SetMaterial(0);
|
||||||
|
mesh->SetMatrix(pEntity->m_matrix);
|
||||||
|
mesh->Draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
LINK_CLIENT_ENTITY(C_Light, CLight)
|
LINK_CLIENT_ENTITY(C_Light, CLight)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
|
|
||||||
void C_WorldSpawn::Precache()
|
void C_WorldSpawn::Precache()
|
||||||
{
|
{
|
||||||
|
C_BrushEntity::Precache();
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_WorldSpawn::Spawn()
|
void C_WorldSpawn::Spawn()
|
||||||
|
|||||||
1
engine/client.cpp
Normal file
1
engine/client.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include "client.h"
|
||||||
@@ -8,13 +8,12 @@
|
|||||||
#include "baseentity.h"
|
#include "baseentity.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
|
|
||||||
#ifdef __linux
|
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
double fPrev = 0;
|
double fPrev = 0;
|
||||||
double fCurrent = 0;
|
double fCurrent = 0;
|
||||||
|
|
||||||
|
funnyphysics *px;
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Engine entry point
|
// Purpose: Engine entry point
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -49,7 +48,6 @@ void IEngine_Signal(int sig)
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
funnyphysics *px;
|
|
||||||
|
|
||||||
void IEngine::Init()
|
void IEngine::Init()
|
||||||
{
|
{
|
||||||
@@ -83,15 +81,6 @@ void IEngine::Shutdown()
|
|||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
void IIEngine::PrecacheModel( const char *psz )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void IIEngine::PrecacheSound( const char *psz )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CBaseEntity *IIEngine::SpawnEntity( const char *szName )
|
CBaseEntity *IIEngine::SpawnEntity( const char *szName )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ bool IFileSystem::LoadPackFile( const char *szFilename )
|
|||||||
unsigned long long nNumFiles = 0;
|
unsigned long long nNumFiles = 0;
|
||||||
PackDirectory_t *pDirs = NULL;
|
PackDirectory_t *pDirs = NULL;
|
||||||
|
|
||||||
FILE* f = V_fopen(szFilename, "r");
|
FILE* f = V_fopen(szFilename, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Plat_FatalErrorFunc("Failed to open %s",szFilename);
|
Plat_FatalErrorFunc("Failed to open %s",szFilename);
|
||||||
V_fread(&header,1,sizeof(header),f);
|
V_fread(&header,1,sizeof(header),f);
|
||||||
|
|||||||
@@ -5,19 +5,23 @@
|
|||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
|
|
||||||
void *g_serverdll;
|
void *g_serverdll;
|
||||||
|
ConVar g_tickrate("tickrate","64",FCVAR_PROTECTED);
|
||||||
|
float g_fAccumulator = 0;
|
||||||
|
|
||||||
void IServer::LoadGame( const char *psz )
|
void IServer::LoadGame( const char *psz )
|
||||||
{
|
{
|
||||||
|
#ifdef __WIN32__
|
||||||
|
g_serverdll = Plat_LoadLibrary(CUtlString("%s/bin/server.dll", psz));
|
||||||
|
#endif
|
||||||
|
#ifdef __linux__
|
||||||
g_serverdll = Plat_LoadLibrary(CUtlString("%s/bin/libserver.so", psz));
|
g_serverdll = Plat_LoadLibrary(CUtlString("%s/bin/libserver.so", psz));
|
||||||
|
#endif
|
||||||
void (*GameLoadfn)() = (void(*)())Plat_GetProc(g_serverdll, "IGame_Load");
|
void (*GameLoadfn)() = (void(*)())Plat_GetProc(g_serverdll, "IGame_Load");
|
||||||
if (!GameLoadfn)
|
if (!GameLoadfn)
|
||||||
Plat_FatalErrorFunc("IGame_Load not found in libserver.so\n");
|
Plat_FatalErrorFunc("IGame_Load not found in libserver.so\n");
|
||||||
GameLoadfn();
|
GameLoadfn();
|
||||||
};
|
};
|
||||||
|
|
||||||
ConVar g_tickrate("tickrate","64",FCVAR_PROTECTED);
|
|
||||||
float g_fAccumulator = 0;
|
|
||||||
|
|
||||||
void IServer::Think( float fDelta )
|
void IServer::Think( float fDelta )
|
||||||
{
|
{
|
||||||
g_fAccumulator += fDelta;
|
g_fAccumulator += fDelta;
|
||||||
|
|||||||
@@ -23,15 +23,16 @@ void CLight::Precache()
|
|||||||
void CLight::Spawn()
|
void CLight::Spawn()
|
||||||
{
|
{
|
||||||
px_collider_params params = {};
|
px_collider_params params = {};
|
||||||
params.friction = 0;
|
params.friction = 0.7;
|
||||||
col = px_box(1, 1, 1, params);
|
col = px_box(0.5,0.5,0.5, params);
|
||||||
px_matrix mat = {};
|
px_matrix mat = {};
|
||||||
mat.m[0] = 1;
|
mat.m[0] = 1;
|
||||||
mat.m[4] = 1;
|
mat.m[5] = 1;
|
||||||
mat.m[9] = 1;
|
mat.m[10] = 1;
|
||||||
mat.m[15] = 1;
|
mat.m[15] = 1;
|
||||||
mat.m[3]=-10;
|
|
||||||
mat.m[11]=10;
|
mat.m[11]=10;
|
||||||
|
mat.m[7]=-4;
|
||||||
|
mat.m[3]=12;
|
||||||
px_rigidbody_params param = {};
|
px_rigidbody_params param = {};
|
||||||
param.gravity_scale = 1;
|
param.gravity_scale = 1;
|
||||||
m_body=px_rigidbody(px, col, mat, param);
|
m_body=px_rigidbody(px, col, mat, param);
|
||||||
@@ -43,8 +44,9 @@ void CLight::Destroy()
|
|||||||
}
|
}
|
||||||
void CLight::Think( float fDelta )
|
void CLight::Think( float fDelta )
|
||||||
{
|
{
|
||||||
px_vec3 pos = px_getposition(px, m_body);
|
px_matrix pos = px_getmatrix(px, m_body);
|
||||||
V_printf("%p %f %f %f\n",col, pos.m[0], pos.m[1], pos.m[2]);
|
V_memcpy(m_matrix, pos.m, 64);
|
||||||
|
V_printf("%p %f %f %f\n",col, pos.m[12], pos.m[13], pos.m[14]);
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_ENTITY(light, CLight)
|
DECLARE_ENTITY(light, CLight)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ void CWorldSpawn::Precache()
|
|||||||
|
|
||||||
void CWorldSpawn::Spawn()
|
void CWorldSpawn::Spawn()
|
||||||
{
|
{
|
||||||
|
V_printf("Cool\n");
|
||||||
CBrushEntity::Spawn();
|
CBrushEntity::Spawn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,48 +4,27 @@
|
|||||||
#include "vk_helper.h"
|
#include "vk_helper.h"
|
||||||
#include "vulkan/vulkan_core.h"
|
#include "vulkan/vulkan_core.h"
|
||||||
|
|
||||||
extern VkSampler g_invalidTextureSampler;
|
|
||||||
|
vk_tripipeline_t g_brushPipeline = {};
|
||||||
|
|
||||||
|
VkDescriptorPool g_brushDescriptorPool;
|
||||||
|
VkDescriptorSet g_brushDescriptorSet;
|
||||||
|
|
||||||
|
VkSampler g_brushSampler;
|
||||||
|
|
||||||
|
|
||||||
abstract_class CBrush: public IBrush
|
abstract_class CBrush: public IBrush
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetPosition( vec3 position ) override;
|
|
||||||
void SetRotationEuler( vec3 angle ) override;
|
|
||||||
void SetRotationQuat( vec4 quaternion) override;
|
|
||||||
void SetMatrix( mat3 matrix ) override;
|
|
||||||
void SetScale( vec3 scale ) override;
|
|
||||||
|
|
||||||
void SetVertexBuffer( IVertexBuffer *pBuffer ) override;
|
void SetVertexBuffer( IVertexBuffer *pBuffer ) override;
|
||||||
void SetIndexBuffer( IIndexBuffer *pBuffer ) override;
|
void SetIndexBuffer( IIndexBuffer *pBuffer ) override;
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
|
||||||
IMaterial *m_pMaterial = NULL;
|
Material_t m_material;
|
||||||
CVertexBuffer *m_pVertexBuffer = NULL;
|
CVertexBuffer *m_pVertexBuffer = NULL;
|
||||||
CIndexBuffer *m_pIndexBuffer = NULL;
|
CIndexBuffer *m_pIndexBuffer = NULL;
|
||||||
};
|
};
|
||||||
void CBrush::SetPosition( vec3 position )
|
CUtlVector<CBrush> g_drawnBrushes;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrush::SetRotationEuler( vec3 angle )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrush::SetRotationQuat( vec4 quaternion)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrush::SetMatrix( mat3 matrix )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBrush::SetScale( vec3 scale )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CBrush::SetVertexBuffer( IVertexBuffer *pBuffer )
|
void CBrush::SetVertexBuffer( IVertexBuffer *pBuffer )
|
||||||
@@ -58,34 +37,15 @@ void CBrush::SetIndexBuffer( IIndexBuffer *pBuffer )
|
|||||||
m_pIndexBuffer = (CIndexBuffer*)pBuffer;
|
m_pIndexBuffer = (CIndexBuffer*)pBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
CUtlVector<CBrush> g_drawnMeshes;
|
|
||||||
IMaterial *g_pDefaultMaterial;
|
|
||||||
IMaterial *g_pCurrentMaterial;
|
|
||||||
|
|
||||||
void CBrush::Draw()
|
void CBrush::Draw()
|
||||||
{
|
{
|
||||||
g_drawnMeshes.AppendTail(*this);
|
if (!g_pCurrentMaterial)
|
||||||
|
m_material = {};
|
||||||
|
else
|
||||||
|
m_material = g_pCurrentMaterial->m;
|
||||||
|
g_drawnBrushes.AppendTail(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract_class CMaterial: public IMaterial
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CUtlVector<ITexture*> g_textures;
|
|
||||||
|
|
||||||
vk_tripipeline_t g_brushPipeline = {};
|
|
||||||
vk_image2d_t meshdepth;
|
|
||||||
vk_image2d_t meshcolor;
|
|
||||||
extern bool g_bConfigNotify;
|
|
||||||
|
|
||||||
VkDescriptorPool g_brushDescriptorPool;
|
|
||||||
VkDescriptorSet g_brushDescriptorSet;
|
|
||||||
vk_buffer_t g_brushProjection;
|
|
||||||
struct MeshProjection {
|
|
||||||
mat4 projection;
|
|
||||||
} *g_brushProject;
|
|
||||||
|
|
||||||
VkSampler g_brushSampler;
|
|
||||||
|
|
||||||
void IBrushRenderer::Init()
|
void IBrushRenderer::Init()
|
||||||
{
|
{
|
||||||
@@ -111,9 +71,6 @@ void IBrushRenderer::Init()
|
|||||||
shaders[1].Destroy();
|
shaders[1].Destroy();
|
||||||
shaders[0].Destroy();
|
shaders[0].Destroy();
|
||||||
|
|
||||||
meshdepth.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
|
||||||
meshcolor.Create(1280, 720, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
|
|
||||||
|
|
||||||
CUtlVector<VkDescriptorPoolSize> pools;
|
CUtlVector<VkDescriptorPoolSize> pools;
|
||||||
for (auto &binding: bindings)
|
for (auto &binding: bindings)
|
||||||
{
|
{
|
||||||
@@ -137,8 +94,6 @@ void IBrushRenderer::Init()
|
|||||||
allocInfo.pSetLayouts = &g_brushPipeline.m_descriptorSetLayout;
|
allocInfo.pSetLayouts = &g_brushPipeline.m_descriptorSetLayout;
|
||||||
vkAllocateDescriptorSets(g_vkDevice, &allocInfo, &g_brushDescriptorSet);
|
vkAllocateDescriptorSets(g_vkDevice, &allocInfo, &g_brushDescriptorSet);
|
||||||
|
|
||||||
g_brushProjection.Create(64, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
|
||||||
g_brushProject = (MeshProjection*)g_brushProjection.Map(0, 64);
|
|
||||||
|
|
||||||
VkPhysicalDeviceProperties properties{};
|
VkPhysicalDeviceProperties properties{};
|
||||||
vkGetPhysicalDeviceProperties(g_vkPhysicalDevice, &properties);
|
vkGetPhysicalDeviceProperties(g_vkPhysicalDevice, &properties);
|
||||||
@@ -164,17 +119,6 @@ void IBrushRenderer::Init()
|
|||||||
|
|
||||||
void IBrushRenderer::Frame( float fDelta )
|
void IBrushRenderer::Frame( float fDelta )
|
||||||
{
|
{
|
||||||
glm_mat4_identity(g_brushProject->projection);
|
|
||||||
glm_perspective(glm_rad(90),(float)g_nWindowWidth/g_nWindowHeight, 0.01, 100, g_brushProject->projection);
|
|
||||||
glm_rotate(g_brushProject->projection, glm_rad(90), (vec4){1,0,0,0});
|
|
||||||
glm_scale(g_brushProject->projection, (vec4){1,-1,1,1});
|
|
||||||
glm_rotate(g_brushProject->projection, glm_rad(-90), (vec4){0,0,1,0});
|
|
||||||
if (g_bConfigNotify)
|
|
||||||
{
|
|
||||||
meshdepth.Destroy();
|
|
||||||
meshdepth.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CUtlVector<VkWriteDescriptorSet> writes(2);
|
CUtlVector<VkWriteDescriptorSet> writes(2);
|
||||||
for (auto &write: writes)
|
for (auto &write: writes)
|
||||||
@@ -186,9 +130,9 @@ void IBrushRenderer::Frame( float fDelta )
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkDescriptorBufferInfo bufferInfo = {};
|
VkDescriptorBufferInfo bufferInfo = {};
|
||||||
bufferInfo.buffer = g_brushProjection.m_buffer;
|
bufferInfo.buffer = g_cameraProperties.m_buffer;
|
||||||
bufferInfo.offset = 0;
|
bufferInfo.offset = 0;
|
||||||
bufferInfo.range = g_brushProjection.m_nSize;
|
bufferInfo.range = g_cameraProperties.m_nSize;
|
||||||
writes[0].dstBinding = 0;
|
writes[0].dstBinding = 0;
|
||||||
writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
writes[0].descriptorCount = 1;
|
writes[0].descriptorCount = 1;
|
||||||
@@ -237,7 +181,7 @@ void IBrushRenderer::Frame( float fDelta )
|
|||||||
};
|
};
|
||||||
VkRenderingAttachmentInfo depthAttachment = {
|
VkRenderingAttachmentInfo depthAttachment = {
|
||||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||||
.imageView = meshdepth.m_imageView,
|
.imageView = g_meshdepth.m_imageView,
|
||||||
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
|
||||||
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
@@ -317,14 +261,10 @@ void IBrushRenderer::Frame( float fDelta )
|
|||||||
|
|
||||||
vkCmdBindPipeline(g_vkCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_brushPipeline.m_pipeline);
|
vkCmdBindPipeline(g_vkCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_brushPipeline.m_pipeline);
|
||||||
vkCmdBindDescriptorSets(g_vkCommandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS, g_brushPipeline.m_layout, 0, 1, &g_brushDescriptorSet, 0, NULL);
|
vkCmdBindDescriptorSets(g_vkCommandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS, g_brushPipeline.m_layout, 0, 1, &g_brushDescriptorSet, 0, NULL);
|
||||||
for (auto &mesh: g_drawnMeshes)
|
for (auto &mesh: g_drawnBrushes)
|
||||||
{
|
{
|
||||||
VkDeviceSize offset = 0;
|
VkDeviceSize offset = 0;
|
||||||
uint32_t textureID = 0;
|
uint32_t textureID = mesh.m_material.albedo;
|
||||||
if (g_pCurrentMaterial == 0)
|
|
||||||
textureID = 0;
|
|
||||||
else
|
|
||||||
textureID = ((CMaterial*)g_pCurrentMaterial)->m.albedo;
|
|
||||||
vkCmdPushConstants(g_vkCommandBuffer, g_brushPipeline.m_layout, VK_SHADER_STAGE_ALL, 0, 4, &textureID);
|
vkCmdPushConstants(g_vkCommandBuffer, g_brushPipeline.m_layout, VK_SHADER_STAGE_ALL, 0, 4, &textureID);
|
||||||
vkCmdBindVertexBuffers(g_vkCommandBuffer, 0, 1, &mesh.m_pVertexBuffer->m_buffer.m_buffer, &offset);
|
vkCmdBindVertexBuffers(g_vkCommandBuffer, 0, 1, &mesh.m_pVertexBuffer->m_buffer.m_buffer, &offset);
|
||||||
if (mesh.m_pIndexBuffer)
|
if (mesh.m_pIndexBuffer)
|
||||||
@@ -349,7 +289,7 @@ void IBrushRenderer::Frame( float fDelta )
|
|||||||
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
.dstAccessMask = 0,
|
.dstAccessMask = 0,
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.image = g_swapchainImage,
|
.image = g_swapchainImage,
|
||||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
};
|
};
|
||||||
@@ -358,23 +298,10 @@ void IBrushRenderer::Frame( float fDelta )
|
|||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
0, 0, NULL, 0, NULL, 1, &barrier);
|
0, 0, NULL, 0, NULL, 1, &barrier);
|
||||||
g_drawnMeshes = CUtlVector<CBrush>();
|
g_drawnBrushes = CUtlVector<CBrush>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
IVertexBuffer *IBrushRenderer::CreateVertexBuffer( uint32_t uSize )
|
|
||||||
{
|
|
||||||
CVertexBuffer *pBuffer = new CVertexBuffer();
|
|
||||||
pBuffer->m_buffer.Create(uSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
|
|
||||||
return pBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
IIndexBuffer *IBrushRenderer::CreateIndexBuffer( uint32_t uSize )
|
|
||||||
{
|
|
||||||
CIndexBuffer *pBuffer = new CIndexBuffer();
|
|
||||||
pBuffer->m_buffer.Create(uSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
|
|
||||||
return pBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
IBrush *IBrushRenderer::CreateMesh()
|
IBrush *IBrushRenderer::CreateMesh()
|
||||||
{
|
{
|
||||||
@@ -387,21 +314,3 @@ void IBrushRenderer::Destroy( IBrush *pModel )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMaterial *IBrushRenderer::LoadMaterial( const char *szMaterial )
|
|
||||||
{
|
|
||||||
FileHandle_t file = IFileSystem::Open(szMaterial, IFILE_READ);
|
|
||||||
CMaterial *pMaterial = new CMaterial;
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
return g_pDefaultMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
IFileSystem::Close(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IBrushRenderer::SetMaterial( IMaterial *pMaterial )
|
|
||||||
{
|
|
||||||
g_pCurrentMaterial = pMaterial;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,7 @@
|
|||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "tier1/commandline.h"
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
#include "X11/X.h"
|
|
||||||
#include "X11/Xlib.h"
|
|
||||||
#include "vulkan/vulkan.h"
|
#include "vulkan/vulkan.h"
|
||||||
#include "vulkan/vulkan_core.h"
|
|
||||||
#include "vulkan/vulkan_xlib.h"
|
|
||||||
|
|
||||||
#define VULKAN_RENDERING_IMPL
|
#define VULKAN_RENDERING_IMPL
|
||||||
#include "vk_video.h"
|
#include "vk_video.h"
|
||||||
@@ -21,31 +17,6 @@
|
|||||||
#include "cglm/affine.h"
|
#include "cglm/affine.h"
|
||||||
#include "cglm/cglm.h"
|
#include "cglm/cglm.h"
|
||||||
|
|
||||||
extern Display* g_xdisplay;
|
|
||||||
extern int g_xscreen;
|
|
||||||
extern Window g_xroot;
|
|
||||||
extern Window g_xwin;
|
|
||||||
|
|
||||||
extern VkInstance g_vkInstance;
|
|
||||||
extern VkPhysicalDevice g_vkPhysicalDevice;
|
|
||||||
extern VkDevice g_vkDevice;
|
|
||||||
extern uint32_t g_drawfamily;
|
|
||||||
extern VkQueue g_drawQueue;
|
|
||||||
extern uint32_t g_presentfamily;
|
|
||||||
extern VkQueue g_presentQueue;
|
|
||||||
extern VmaAllocator g_allocator;
|
|
||||||
|
|
||||||
extern VkSurfaceKHR g_surface;
|
|
||||||
extern VkSwapchainKHR g_swapchain;
|
|
||||||
|
|
||||||
extern VkCommandPool g_vkCommandPool;
|
|
||||||
extern VkCommandBuffer g_vkCommandBuffer;
|
|
||||||
extern VkImageView g_swapchainImageView;
|
|
||||||
extern VkImage g_swapchainImage;
|
|
||||||
|
|
||||||
extern uint32_t g_nWindowWidth;
|
|
||||||
extern uint32_t g_nWindowHeight;
|
|
||||||
|
|
||||||
class CVertexBuffer: public IVertexBuffer
|
class CVertexBuffer: public IVertexBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -70,3 +41,42 @@ class CTexture: public ITexture
|
|||||||
public:
|
public:
|
||||||
vk_image2d_t image;
|
vk_image2d_t image;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern VkInstance g_vkInstance;
|
||||||
|
extern VkPhysicalDevice g_vkPhysicalDevice;
|
||||||
|
extern VkDevice g_vkDevice;
|
||||||
|
extern uint32_t g_drawfamily;
|
||||||
|
extern VkQueue g_drawQueue;
|
||||||
|
extern uint32_t g_presentfamily;
|
||||||
|
extern VkQueue g_presentQueue;
|
||||||
|
extern VmaAllocator g_allocator;
|
||||||
|
|
||||||
|
extern VkSurfaceKHR g_surface;
|
||||||
|
extern VkSwapchainKHR g_swapchain;
|
||||||
|
|
||||||
|
extern VkCommandPool g_vkCommandPool;
|
||||||
|
extern VkCommandBuffer g_vkCommandBuffer;
|
||||||
|
extern VkImageView g_swapchainImageView;
|
||||||
|
extern VkImage g_swapchainImage;
|
||||||
|
|
||||||
|
extern bool g_bConfigNotify;
|
||||||
|
extern uint32_t g_nWindowWidth;
|
||||||
|
extern uint32_t g_nWindowHeight;
|
||||||
|
|
||||||
|
extern VkSampler g_invalidTextureSampler;
|
||||||
|
extern IMaterial *g_pDefaultMaterial;
|
||||||
|
extern IMaterial *g_pCurrentMaterial;
|
||||||
|
|
||||||
|
extern CUtlVector<ITexture*> g_textures;
|
||||||
|
|
||||||
|
struct CameraProjection {
|
||||||
|
mat4 viewprojection;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern vk_buffer_t g_cameraProperties;
|
||||||
|
extern CameraProjection *g_cameraDataMap;
|
||||||
|
|
||||||
|
extern vk_image2d_t g_meshdepth;
|
||||||
|
extern vk_image2d_t g_meshcolor;
|
||||||
|
|||||||
354
engine/vk_mesh.cpp
Normal file
354
engine/vk_mesh.cpp
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
#include "cglm/mat4.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
#include "rendering.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
#include "vk_helper.h"
|
||||||
|
#include "vulkan/vulkan_core.h"
|
||||||
|
|
||||||
|
|
||||||
|
vk_tripipeline_t g_meshPipeline = {};
|
||||||
|
|
||||||
|
VkDescriptorPool g_meshDescriptorPool;
|
||||||
|
VkDescriptorSet g_meshDescriptorSet;
|
||||||
|
|
||||||
|
VkSampler g_meshSampler;
|
||||||
|
|
||||||
|
|
||||||
|
abstract_class CMesh: public IMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMesh();
|
||||||
|
void SetPosition( vec3 position ) override;
|
||||||
|
void SetRotationEuler( vec3 angle ) override;
|
||||||
|
void SetRotationQuat( vec4 quaternion) override;
|
||||||
|
void SetMatrix( mat4 matrix ) override;
|
||||||
|
void SetScale( vec3 scale ) override;
|
||||||
|
|
||||||
|
void SetVertexBuffer( IVertexBuffer *pBuffer ) override;
|
||||||
|
void SetIndexBuffer( IIndexBuffer *pBuffer ) override;
|
||||||
|
void Draw() override;
|
||||||
|
|
||||||
|
Material_t m_material;
|
||||||
|
CVertexBuffer *m_pVertexBuffer = NULL;
|
||||||
|
CIndexBuffer *m_pIndexBuffer = NULL;
|
||||||
|
mat4 m_matrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMesh::CMesh()
|
||||||
|
{
|
||||||
|
glm_mat4_identity(m_matrix);
|
||||||
|
};
|
||||||
|
|
||||||
|
void CMesh::SetPosition( vec3 position )
|
||||||
|
{
|
||||||
|
m_matrix[0][3] = position[0];
|
||||||
|
m_matrix[1][3] = position[1];
|
||||||
|
m_matrix[2][3] = position[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetRotationEuler( vec3 angle )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetRotationQuat( vec4 quaternion)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetMatrix( mat4 matrix )
|
||||||
|
{
|
||||||
|
memcpy(m_matrix,matrix,64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetScale( vec3 scale )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetVertexBuffer( IVertexBuffer *pBuffer )
|
||||||
|
{
|
||||||
|
m_pVertexBuffer = (CVertexBuffer*)pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMesh::SetIndexBuffer( IIndexBuffer *pBuffer )
|
||||||
|
{
|
||||||
|
m_pIndexBuffer = (CIndexBuffer*)pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CUtlVector<CMesh> g_drawnMeshes;
|
||||||
|
|
||||||
|
void CMesh::Draw()
|
||||||
|
{
|
||||||
|
if (!g_pCurrentMaterial)
|
||||||
|
m_material = {};
|
||||||
|
else
|
||||||
|
m_material = g_pCurrentMaterial->m;
|
||||||
|
g_drawnMeshes.AppendTail(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMeshRenderer::Init()
|
||||||
|
{
|
||||||
|
CUtlVector<vk_shader_t> shaders(2);
|
||||||
|
for (auto &shader: shaders)
|
||||||
|
{
|
||||||
|
shader.m_shaderModule = NULL;
|
||||||
|
}
|
||||||
|
shaders[0].Create("gfx/mesh_vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
|
shaders[1].Create("gfx/mesh_frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
CUtlVector<VkDescriptorSetLayoutBinding> bindings(2);
|
||||||
|
bindings[0] = {};
|
||||||
|
bindings[0].binding = 0;
|
||||||
|
bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
|
bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
|
bindings[0].descriptorCount = 1;
|
||||||
|
bindings[1] = {};
|
||||||
|
bindings[1].binding = 1;
|
||||||
|
bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
bindings[1].descriptorCount = 1024;
|
||||||
|
g_meshPipeline.Create(shaders, bindings, 76);
|
||||||
|
shaders[1].Destroy();
|
||||||
|
shaders[0].Destroy();
|
||||||
|
|
||||||
|
CUtlVector<VkDescriptorPoolSize> pools;
|
||||||
|
for (auto &binding: bindings)
|
||||||
|
{
|
||||||
|
VkDescriptorPoolSize dps = {};
|
||||||
|
dps.type = binding.descriptorType;
|
||||||
|
dps.descriptorCount = binding.descriptorCount;
|
||||||
|
pools.AppendTail(dps);
|
||||||
|
}
|
||||||
|
|
||||||
|
VkDescriptorPoolCreateInfo poolInfo = {};
|
||||||
|
poolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||||
|
poolInfo.poolSizeCount = pools.GetSize();
|
||||||
|
poolInfo.pPoolSizes = pools.GetData();
|
||||||
|
poolInfo.maxSets = 1;
|
||||||
|
vkCreateDescriptorPool(g_vkDevice, &poolInfo, NULL, &g_meshDescriptorPool);
|
||||||
|
|
||||||
|
VkDescriptorSetAllocateInfo allocInfo = {};
|
||||||
|
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||||
|
allocInfo.descriptorPool = g_meshDescriptorPool;
|
||||||
|
allocInfo.descriptorSetCount = 1;
|
||||||
|
allocInfo.pSetLayouts = &g_meshPipeline.m_descriptorSetLayout;
|
||||||
|
vkAllocateDescriptorSets(g_vkDevice, &allocInfo, &g_meshDescriptorSet);
|
||||||
|
|
||||||
|
|
||||||
|
VkPhysicalDeviceProperties properties{};
|
||||||
|
vkGetPhysicalDeviceProperties(g_vkPhysicalDevice, &properties);
|
||||||
|
VkSamplerCreateInfo samplerInfo{};
|
||||||
|
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
|
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||||
|
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
||||||
|
samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
|
samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
|
samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
|
samplerInfo.anisotropyEnable = VK_FALSE;
|
||||||
|
samplerInfo.maxAnisotropy = properties.limits.maxSamplerAnisotropy;
|
||||||
|
samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||||
|
samplerInfo.unnormalizedCoordinates = VK_FALSE;
|
||||||
|
samplerInfo.compareEnable = VK_FALSE;
|
||||||
|
samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS;
|
||||||
|
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
||||||
|
samplerInfo.mipLodBias = 0.0f;
|
||||||
|
samplerInfo.minLod = 0.0f;
|
||||||
|
samplerInfo.maxLod = 0.0f;
|
||||||
|
vkCreateSampler(g_vkDevice, &samplerInfo, nullptr, &g_meshSampler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMeshRenderer::Frame( float fDelta )
|
||||||
|
{
|
||||||
|
CUtlVector<VkWriteDescriptorSet> writes(2);
|
||||||
|
for (auto &write: writes)
|
||||||
|
{
|
||||||
|
write = {};
|
||||||
|
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
|
write.dstSet = g_meshDescriptorSet;
|
||||||
|
write.dstArrayElement = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VkDescriptorBufferInfo bufferInfo = {};
|
||||||
|
bufferInfo.buffer = g_cameraProperties.m_buffer;
|
||||||
|
bufferInfo.offset = 0;
|
||||||
|
bufferInfo.range = g_cameraProperties.m_nSize;
|
||||||
|
writes[0].dstBinding = 0;
|
||||||
|
writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
|
writes[0].descriptorCount = 1;
|
||||||
|
writes[0].pBufferInfo = &bufferInfo;
|
||||||
|
|
||||||
|
CUtlVector<VkDescriptorImageInfo> textures;
|
||||||
|
textures.Reserve(g_textures.GetSize());
|
||||||
|
for (ITexture *t: g_textures)
|
||||||
|
{
|
||||||
|
CTexture *texture = (CTexture*)t;
|
||||||
|
VkDescriptorImageInfo image = {};
|
||||||
|
image.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
|
image.imageView = texture->image.m_imageView;
|
||||||
|
image.sampler = g_meshSampler;
|
||||||
|
textures.AppendTail(image);
|
||||||
|
};
|
||||||
|
textures[0].sampler = g_invalidTextureSampler;
|
||||||
|
writes[1].dstBinding = 1;
|
||||||
|
writes[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
writes[1].descriptorCount = textures.GetSize();
|
||||||
|
writes[1].pImageInfo = textures.GetData();
|
||||||
|
vkUpdateDescriptorSets(g_vkDevice, writes.GetSize(), writes.GetData(), 0, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
VkImageMemoryBarrier barrier = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = 0,
|
||||||
|
.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
.image = g_swapchainImage,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
|
};
|
||||||
|
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
0, 0, NULL, 0, NULL, 1, &barrier);
|
||||||
|
|
||||||
|
VkRenderingAttachmentInfo colorAttachment = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||||
|
.imageView = g_swapchainImageView,
|
||||||
|
.imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
};
|
||||||
|
VkRenderingAttachmentInfo depthAttachment = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||||
|
.imageView = g_meshdepth.m_imageView,
|
||||||
|
.imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL,
|
||||||
|
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
|
||||||
|
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
|
||||||
|
};
|
||||||
|
|
||||||
|
VkRenderingInfo renderInfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
||||||
|
.renderArea = {{0, 0}, {g_nWindowWidth, g_nWindowHeight}},
|
||||||
|
.layerCount = 1,
|
||||||
|
.colorAttachmentCount = 1,
|
||||||
|
.pColorAttachments = &colorAttachment,
|
||||||
|
.pDepthAttachment = &depthAttachment,
|
||||||
|
};
|
||||||
|
vkCmdBeginRendering(g_vkCommandBuffer, &renderInfo);
|
||||||
|
|
||||||
|
vkCmdSetRasterizerDiscardEnable(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
vkCmdSetDepthBiasEnable(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
_vkCmdSetPolygonModeEXT(g_vkCommandBuffer, VK_POLYGON_MODE_FILL);
|
||||||
|
vkCmdSetCullMode(g_vkCommandBuffer, VK_CULL_MODE_BACK_BIT);
|
||||||
|
vkCmdSetFrontFace(g_vkCommandBuffer, VK_FRONT_FACE_COUNTER_CLOCKWISE);
|
||||||
|
|
||||||
|
vkCmdSetDepthTestEnable(g_vkCommandBuffer, VK_TRUE);
|
||||||
|
vkCmdSetDepthWriteEnable(g_vkCommandBuffer, VK_TRUE);
|
||||||
|
vkCmdSetDepthCompareOp(g_vkCommandBuffer, VK_COMPARE_OP_LESS);
|
||||||
|
vkCmdSetStencilTestEnable(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
|
||||||
|
_vkCmdSetRasterizationSamplesEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_1_BIT);
|
||||||
|
VkSampleMask sampleMask = 0xFFFFFFFF;
|
||||||
|
_vkCmdSetSampleMaskEXT(g_vkCommandBuffer, VK_SAMPLE_COUNT_1_BIT, &sampleMask);
|
||||||
|
_vkCmdSetAlphaToCoverageEnableEXT(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
|
||||||
|
VkViewport viewport = {0, 0, (float)g_nWindowWidth, (float)g_nWindowHeight, 0.0f, 1.0f};
|
||||||
|
VkRect2D scissor = {{0, 0}, {g_nWindowWidth, g_nWindowHeight}};
|
||||||
|
vkCmdSetViewportWithCount(g_vkCommandBuffer, 1, &viewport);
|
||||||
|
vkCmdSetScissorWithCount(g_vkCommandBuffer, 1, &scissor);
|
||||||
|
|
||||||
|
vkCmdSetPrimitiveTopology(g_vkCommandBuffer, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST);
|
||||||
|
vkCmdSetPrimitiveRestartEnable(g_vkCommandBuffer, VK_FALSE);
|
||||||
|
|
||||||
|
VkVertexInputBindingDescription2EXT binding = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT,
|
||||||
|
.binding = 0,
|
||||||
|
.stride = 20,
|
||||||
|
.inputRate = VK_VERTEX_INPUT_RATE_VERTEX,
|
||||||
|
.divisor = 1,
|
||||||
|
};
|
||||||
|
VkVertexInputAttributeDescription2EXT attributes[2] = {
|
||||||
|
{
|
||||||
|
VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT,
|
||||||
|
NULL,
|
||||||
|
0, 0,
|
||||||
|
VK_FORMAT_R32G32B32_SFLOAT,
|
||||||
|
0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT,
|
||||||
|
NULL,
|
||||||
|
1, 0,
|
||||||
|
VK_FORMAT_R32G32_SFLOAT,
|
||||||
|
12
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_vkCmdSetVertexInputEXT(g_vkCommandBuffer, 1, &binding, 2, attributes);
|
||||||
|
|
||||||
|
VkBool32 blendEnable = VK_FALSE;
|
||||||
|
VkColorBlendEquationEXT blendEquation = {
|
||||||
|
VK_BLEND_FACTOR_SRC_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, VK_BLEND_OP_ADD,
|
||||||
|
VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ZERO, VK_BLEND_OP_ADD
|
||||||
|
};
|
||||||
|
VkColorComponentFlags writeMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
|
||||||
|
VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
|
||||||
|
|
||||||
|
_vkCmdSetColorBlendEnableEXT(g_vkCommandBuffer, 0, 1, &blendEnable);
|
||||||
|
_vkCmdSetColorBlendEquationEXT(g_vkCommandBuffer, 0, 1, &blendEquation);
|
||||||
|
_vkCmdSetColorWriteMaskEXT(g_vkCommandBuffer, 0, 1, &writeMask);
|
||||||
|
|
||||||
|
vkCmdBindPipeline(g_vkCommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, g_meshPipeline.m_pipeline);
|
||||||
|
vkCmdBindDescriptorSets(g_vkCommandBuffer,VK_PIPELINE_BIND_POINT_GRAPHICS, g_meshPipeline.m_layout, 0, 1, &g_meshDescriptorSet, 0, NULL);
|
||||||
|
for (auto &mesh: g_drawnMeshes)
|
||||||
|
{
|
||||||
|
VkDeviceSize offset = 0;
|
||||||
|
uint32_t textureID = mesh.m_material.albedo;
|
||||||
|
vkCmdPushConstants(g_vkCommandBuffer, g_meshPipeline.m_layout, VK_SHADER_STAGE_ALL, 0, 64, mesh.m_matrix);
|
||||||
|
vkCmdPushConstants(g_vkCommandBuffer, g_meshPipeline.m_layout, VK_SHADER_STAGE_ALL, 64, 4, &textureID);
|
||||||
|
vkCmdBindVertexBuffers(g_vkCommandBuffer, 0, 1, &mesh.m_pVertexBuffer->m_buffer.m_buffer, &offset);
|
||||||
|
if (mesh.m_pIndexBuffer)
|
||||||
|
{
|
||||||
|
vkCmdBindIndexBuffer(
|
||||||
|
g_vkCommandBuffer,
|
||||||
|
mesh.m_pIndexBuffer->m_buffer.m_buffer,
|
||||||
|
0,
|
||||||
|
VK_INDEX_TYPE_UINT32
|
||||||
|
);
|
||||||
|
vkCmdDrawIndexed(g_vkCommandBuffer, mesh.m_pIndexBuffer->m_buffer.m_nSize/4, 1, 0, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vkCmdDraw(g_vkCommandBuffer, mesh.m_pVertexBuffer->m_buffer.m_nSize/12,1,0,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vkCmdEndRendering(g_vkCommandBuffer);
|
||||||
|
|
||||||
|
barrier = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
|
.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
.dstAccessMask = 0,
|
||||||
|
.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
|
||||||
|
.image = g_swapchainImage,
|
||||||
|
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}
|
||||||
|
};
|
||||||
|
|
||||||
|
vkCmdPipelineBarrier(g_vkCommandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||||
|
0, 0, NULL, 0, NULL, 1, &barrier);
|
||||||
|
g_drawnMeshes = CUtlVector<CMesh>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IMesh *IMeshRenderer::CreateMesh()
|
||||||
|
{
|
||||||
|
CMesh *mesh = new CMesh;
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMeshRenderer::Destroy( IBrush *pModel )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
0
engine/vk_postprocessing.cpp
Normal file
0
engine/vk_postprocessing.cpp
Normal file
0
engine/vk_shading.cpp
Normal file
0
engine/vk_shading.cpp
Normal file
@@ -11,6 +11,15 @@
|
|||||||
|
|
||||||
VkSampler g_invalidTextureSampler;
|
VkSampler g_invalidTextureSampler;
|
||||||
|
|
||||||
|
vk_buffer_t g_cameraProperties;
|
||||||
|
CameraProjection *g_cameraDataMap;
|
||||||
|
|
||||||
|
IMaterial *g_pDefaultMaterial;
|
||||||
|
IMaterial *g_pCurrentMaterial;
|
||||||
|
|
||||||
|
vk_image2d_t g_meshdepth;
|
||||||
|
vk_image2d_t g_meshcolor;
|
||||||
|
|
||||||
void IVulkan::Init()
|
void IVulkan::Init()
|
||||||
{
|
{
|
||||||
char invalidTexture[1024] = {};
|
char invalidTexture[1024] = {};
|
||||||
@@ -43,13 +52,33 @@ void IVulkan::Init()
|
|||||||
samplerInfo.minLod = 0.0f;
|
samplerInfo.minLod = 0.0f;
|
||||||
samplerInfo.maxLod = 0.0f;
|
samplerInfo.maxLod = 0.0f;
|
||||||
vkCreateSampler(g_vkDevice, &samplerInfo, nullptr, &g_invalidTextureSampler);
|
vkCreateSampler(g_vkDevice, &samplerInfo, nullptr, &g_invalidTextureSampler);
|
||||||
IBrushRenderer::Init();
|
|
||||||
|
|
||||||
|
g_cameraProperties.Create(sizeof(CameraProjection), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT);
|
||||||
|
g_cameraDataMap = (CameraProjection*)g_cameraProperties.Map(0, 64);
|
||||||
|
|
||||||
|
g_meshdepth.Create(1280, 720, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
||||||
|
g_meshcolor.Create(1280, 720, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
|
||||||
|
|
||||||
|
IBrushRenderer::Init();
|
||||||
|
IMeshRenderer::Init();
|
||||||
};
|
};
|
||||||
|
|
||||||
void IVulkan::Frame()
|
void IVulkan::Frame()
|
||||||
{
|
{
|
||||||
|
glm_mat4_identity(g_cameraDataMap->viewprojection);
|
||||||
|
glm_perspective(glm_rad(90),(float)g_nWindowWidth/g_nWindowHeight, 0.01, 100, g_cameraDataMap->viewprojection);
|
||||||
|
glm_rotate(g_cameraDataMap->viewprojection, glm_rad(90), (vec4){1,0,0,0});
|
||||||
|
glm_scale(g_cameraDataMap->viewprojection, (vec4){1,-1,1,1});
|
||||||
|
glm_rotate(g_cameraDataMap->viewprojection, glm_rad(90), (vec4){0,0,1,0});
|
||||||
|
|
||||||
|
if (g_bConfigNotify)
|
||||||
|
{
|
||||||
|
g_meshdepth.Destroy();
|
||||||
|
g_meshdepth.Create(g_nWindowWidth, g_nWindowHeight, VK_FORMAT_D32_SFLOAT, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
IBrushRenderer::Frame(0);
|
IBrushRenderer::Frame(0);
|
||||||
|
IMeshRenderer::Frame(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
void vk_shader_t::Create( const char *szPath, VkShaderStageFlagBits shaderStage )
|
void vk_shader_t::Create( const char *szPath, VkShaderStageFlagBits shaderStage )
|
||||||
@@ -472,3 +501,35 @@ ITexture *ITextureManager::LoadTexture( const char *szName )
|
|||||||
pTexture->szName = szName;
|
pTexture->szName = szName;
|
||||||
return pTexture;
|
return pTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IMaterial *IRenderer::LoadMaterial( const char *szMaterial )
|
||||||
|
{
|
||||||
|
FileHandle_t file = IFileSystem::Open(szMaterial, IFILE_READ);
|
||||||
|
IMaterial *pMaterial = new IMaterial;
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
return g_pDefaultMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
IFileSystem::Close(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRenderer::SetMaterial( IMaterial *pMaterial )
|
||||||
|
{
|
||||||
|
g_pCurrentMaterial = pMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
IVertexBuffer *IRenderer::CreateVertexBuffer( uint32_t uSize )
|
||||||
|
{
|
||||||
|
CVertexBuffer *pBuffer = new CVertexBuffer();
|
||||||
|
pBuffer->m_buffer.Create(uSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
|
||||||
|
return pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
IIndexBuffer *IRenderer::CreateIndexBuffer( uint32_t uSize )
|
||||||
|
{
|
||||||
|
CIndexBuffer *pBuffer = new CIndexBuffer();
|
||||||
|
pBuffer->m_buffer.Create(uSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT);
|
||||||
|
return pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ ConVar vulkan_gpu("vk_gpu", "0", FCVAR_ARCHIVE);
|
|||||||
|
|
||||||
|
|
||||||
VkCommandPool g_vkCommandPool;
|
VkCommandPool g_vkCommandPool;
|
||||||
|
|
||||||
/* more efficient */
|
/* more efficient */
|
||||||
CUtlVector<VkCommandBuffer> g_commandBuffers;
|
CUtlVector<VkCommandBuffer> g_commandBuffers;
|
||||||
VkCommandBuffer g_vkCommandBuffer;
|
VkCommandBuffer g_vkCommandBuffer;
|
||||||
@@ -49,11 +50,18 @@ VkImage g_swapchainImage;
|
|||||||
|
|
||||||
uint32_t g_nNumSwapchainImages = 0;
|
uint32_t g_nNumSwapchainImages = 0;
|
||||||
|
|
||||||
|
#define VK_DEVICE_FUNCTION(name) PFN_##name _##name
|
||||||
|
#include "vk_external_functions.cpp"
|
||||||
|
#undef VK_DEVICE_FUNCTION
|
||||||
|
|
||||||
|
char g_bConfigNotify = 0;
|
||||||
|
uint32_t g_nWindowWidth = 1280;
|
||||||
|
uint32_t g_nWindowHeight = 720;
|
||||||
|
|
||||||
void IVideo_SwapchainInit()
|
void IVideo_SwapchainInit()
|
||||||
{
|
{
|
||||||
|
|
||||||
/* swapchain */
|
/* swapchain */
|
||||||
|
|
||||||
VkXlibSurfaceCreateInfoKHR surfaceCreateInfo = {};
|
VkXlibSurfaceCreateInfoKHR surfaceCreateInfo = {};
|
||||||
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||||
surfaceCreateInfo.dpy = g_xdisplay;
|
surfaceCreateInfo.dpy = g_xdisplay;
|
||||||
@@ -176,16 +184,13 @@ void IVideo_SwapchainDestroy()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define VK_DEVICE_FUNCTION(name) PFN_##name _##name
|
|
||||||
#include "vk_external_functions.cpp"
|
|
||||||
#undef VK_DEVICE_FUNCTION
|
|
||||||
|
|
||||||
void IVideo::Init()
|
void IVideo::Init()
|
||||||
{
|
{
|
||||||
g_xdisplay = XOpenDisplay(NULL);
|
g_xdisplay = XOpenDisplay(NULL);
|
||||||
g_xscreen = DefaultScreen(g_xdisplay);
|
g_xscreen = DefaultScreen(g_xdisplay);
|
||||||
g_xroot = RootWindow(g_xdisplay, g_xscreen);
|
g_xroot = RootWindow(g_xdisplay, g_xscreen);
|
||||||
g_xwin = XCreateSimpleWindow(g_xdisplay, g_xroot, 0, 0, 1280, 720, 0, 0, 0);
|
g_xwin = XCreateSimpleWindow(g_xdisplay, g_xroot, 0, 0, 1280, 720, 0, 0, 0);
|
||||||
|
|
||||||
XSelectInput(g_xdisplay, g_xwin, StructureNotifyMask);
|
XSelectInput(g_xdisplay, g_xwin, StructureNotifyMask);
|
||||||
|
|
||||||
vulkan_gpu.SetValue(ICommandLine::ParamValue("-gpu"));
|
vulkan_gpu.SetValue(ICommandLine::ParamValue("-gpu"));
|
||||||
@@ -338,7 +343,6 @@ void IVideo::Init()
|
|||||||
#undef VK_DEVICE_FUNCTION
|
#undef VK_DEVICE_FUNCTION
|
||||||
|
|
||||||
IVideo_SwapchainInit();
|
IVideo_SwapchainInit();
|
||||||
|
|
||||||
XMapWindow(g_xdisplay, g_xwin);
|
XMapWindow(g_xdisplay, g_xwin);
|
||||||
XFlush(g_xdisplay);
|
XFlush(g_xdisplay);
|
||||||
|
|
||||||
@@ -346,10 +350,6 @@ void IVideo::Init()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char g_bConfigNotify = 0;
|
|
||||||
uint32_t g_nWindowWidth = 1280;
|
|
||||||
uint32_t g_nWindowHeight = 720;
|
|
||||||
|
|
||||||
void IVideo_HandleX11()
|
void IVideo_HandleX11()
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
|||||||
424
engine/vk_videosdl.cpp
Normal file
424
engine/vk_videosdl.cpp
Normal file
@@ -0,0 +1,424 @@
|
|||||||
|
#include "rendering.h"
|
||||||
|
#include "tier0/platform.h"
|
||||||
|
#include "tier1/utlvector.h"
|
||||||
|
#include "console.h"
|
||||||
|
#include "tier1/commandline.h"
|
||||||
|
|
||||||
|
#include "vulkan/vulkan.h"
|
||||||
|
#include "SDL3/SDL.h"
|
||||||
|
#define SDL_MAIN_HANDLED
|
||||||
|
#include "SDL3/SDL_main.h"
|
||||||
|
#include "SDL3/SDL_vulkan.h"
|
||||||
|
#include "SDL3/SDL_events.h"
|
||||||
|
|
||||||
|
#define VULKAN_RENDERING_IMPL
|
||||||
|
#include "vk_video.h"
|
||||||
|
|
||||||
|
#define VMA_VULKAN_VERSION 1004000
|
||||||
|
#define VMA_IMPLEMENTATION
|
||||||
|
#include "vk_mem_alloc.h"
|
||||||
|
|
||||||
|
SDL_Window *g_window;
|
||||||
|
|
||||||
|
VkInstance g_vkInstance = NULL;
|
||||||
|
VkPhysicalDevice g_vkPhysicalDevice = NULL;
|
||||||
|
VkDevice g_vkDevice = NULL;
|
||||||
|
uint32_t g_drawfamily = 0;
|
||||||
|
VkQueue g_drawQueue;
|
||||||
|
uint32_t g_presentfamily = 0;
|
||||||
|
VkQueue g_presentQueue;
|
||||||
|
VmaAllocator g_allocator = NULL;
|
||||||
|
|
||||||
|
VkSurfaceKHR g_surface;
|
||||||
|
VkSwapchainKHR g_swapchain;
|
||||||
|
|
||||||
|
ConVar vulkan_gpu("vk_gpu", "0", FCVAR_ARCHIVE);
|
||||||
|
|
||||||
|
|
||||||
|
VkCommandPool g_vkCommandPool;
|
||||||
|
|
||||||
|
/* more efficient */
|
||||||
|
CUtlVector<VkCommandBuffer> g_commandBuffers;
|
||||||
|
VkCommandBuffer g_vkCommandBuffer;
|
||||||
|
CUtlVector<vk_framedata_t> g_frameData;
|
||||||
|
CUtlVector<VkImage> g_swapchainImages;
|
||||||
|
CUtlVector<VkImageView> g_swapchainImageViews;
|
||||||
|
VkImageView g_swapchainImageView;
|
||||||
|
VkImage g_swapchainImage;
|
||||||
|
|
||||||
|
uint32_t g_nNumSwapchainImages = 0;
|
||||||
|
|
||||||
|
#define VK_DEVICE_FUNCTION(name) PFN_##name _##name
|
||||||
|
#include "vk_external_functions.cpp"
|
||||||
|
#undef VK_DEVICE_FUNCTION
|
||||||
|
|
||||||
|
char g_bConfigNotify = 0;
|
||||||
|
uint32_t g_nWindowWidth = 1280;
|
||||||
|
uint32_t g_nWindowHeight = 720;
|
||||||
|
|
||||||
|
|
||||||
|
void IVideo_SwapchainInit()
|
||||||
|
{
|
||||||
|
|
||||||
|
/* swapchain */
|
||||||
|
SDL_Vulkan_CreateSurface(g_window, g_vkInstance, NULL, &g_surface);
|
||||||
|
|
||||||
|
VkSurfaceCapabilitiesKHR surfaceCapatibilities = {};
|
||||||
|
|
||||||
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vkPhysicalDevice, g_surface, &surfaceCapatibilities);
|
||||||
|
|
||||||
|
const VkFormat preferedSurfaceFormats[] = {
|
||||||
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32_t numSurfaceFormats = 0;
|
||||||
|
vkGetPhysicalDeviceSurfaceFormatsKHR(g_vkPhysicalDevice, g_surface, &numSurfaceFormats, NULL);
|
||||||
|
CUtlVector<VkSurfaceFormatKHR> surfaceFormats(numSurfaceFormats);
|
||||||
|
vkGetPhysicalDeviceSurfaceFormatsKHR(g_vkPhysicalDevice, g_surface, &numSurfaceFormats, surfaceFormats.GetData());
|
||||||
|
|
||||||
|
VkSurfaceFormatKHR selectedFormat = surfaceFormats[0];
|
||||||
|
for (auto &format: surfaceFormats)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sizeof(preferedSurfaceFormats)/sizeof(VkFormat); i++)
|
||||||
|
{
|
||||||
|
selectedFormat = surfaceFormats[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t numSurfacePresentModes = 0;
|
||||||
|
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, g_surface, &numSurfacePresentModes, NULL);
|
||||||
|
CUtlVector<VkPresentModeKHR> surfacePresentModes(numSurfacePresentModes);
|
||||||
|
vkGetPhysicalDeviceSurfacePresentModesKHR(g_vkPhysicalDevice, g_surface, &numSurfacePresentModes, surfacePresentModes.GetData());
|
||||||
|
|
||||||
|
VkSwapchainCreateInfoKHR swapchainCreateInfo = {};
|
||||||
|
swapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||||
|
swapchainCreateInfo.surface = g_surface;
|
||||||
|
swapchainCreateInfo.imageFormat = selectedFormat.format;
|
||||||
|
swapchainCreateInfo.imageColorSpace = selectedFormat.colorSpace;
|
||||||
|
swapchainCreateInfo.presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
|
||||||
|
swapchainCreateInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
|
swapchainCreateInfo.preTransform = surfaceCapatibilities.currentTransform;
|
||||||
|
swapchainCreateInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||||
|
swapchainCreateInfo.imageArrayLayers = 1;
|
||||||
|
swapchainCreateInfo.imageExtent = surfaceCapatibilities.minImageExtent;
|
||||||
|
swapchainCreateInfo.minImageCount = surfaceCapatibilities.minImageCount;
|
||||||
|
vkCreateSwapchainKHR(g_vkDevice, &swapchainCreateInfo, NULL, &g_swapchain);
|
||||||
|
|
||||||
|
vkGetSwapchainImagesKHR(g_vkDevice, g_swapchain, &g_nNumSwapchainImages, NULL);
|
||||||
|
g_swapchainImages = CUtlVector<VkImage>(g_nNumSwapchainImages);
|
||||||
|
g_swapchainImageViews = CUtlVector<VkImageView>(g_nNumSwapchainImages);
|
||||||
|
g_commandBuffers = CUtlVector<VkCommandBuffer>(g_nNumSwapchainImages);
|
||||||
|
g_frameData = CUtlVector<vk_framedata_t>(g_nNumSwapchainImages);
|
||||||
|
vkGetSwapchainImagesKHR(g_vkDevice, g_swapchain, &g_nNumSwapchainImages, g_swapchainImages.GetData());
|
||||||
|
|
||||||
|
for (int i = 0; i < g_nNumSwapchainImages; i++)
|
||||||
|
{
|
||||||
|
VkImageViewCreateInfo createInfo = {};
|
||||||
|
createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
||||||
|
createInfo.image = g_swapchainImages[i];
|
||||||
|
createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||||
|
createInfo.format = selectedFormat.format;
|
||||||
|
createInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
createInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
createInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
createInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY;
|
||||||
|
createInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||||
|
createInfo.subresourceRange.baseMipLevel = 0;
|
||||||
|
createInfo.subresourceRange.levelCount = 1;
|
||||||
|
createInfo.subresourceRange.baseArrayLayer = 0;
|
||||||
|
createInfo.subresourceRange.layerCount = 1;
|
||||||
|
|
||||||
|
vkCreateImageView(g_vkDevice, &createInfo, NULL, &g_swapchainImageViews[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* command buffers */
|
||||||
|
VkCommandPoolCreateInfo commandPoolCreateInfo = {};
|
||||||
|
commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
|
commandPoolCreateInfo.queueFamilyIndex = g_drawfamily;
|
||||||
|
commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||||
|
vkCreateCommandPool(g_vkDevice, &commandPoolCreateInfo, NULL, &g_vkCommandPool);
|
||||||
|
|
||||||
|
VkCommandBufferAllocateInfo commandBufferAllocInfo = {};
|
||||||
|
commandBufferAllocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||||
|
commandBufferAllocInfo.commandPool = g_vkCommandPool;
|
||||||
|
commandBufferAllocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||||
|
commandBufferAllocInfo.commandBufferCount = g_nNumSwapchainImages;
|
||||||
|
vkAllocateCommandBuffers(g_vkDevice, &commandBufferAllocInfo, g_commandBuffers.GetData());
|
||||||
|
|
||||||
|
/* sync */
|
||||||
|
|
||||||
|
VkFenceCreateInfo fenceCreateInfo = {};
|
||||||
|
fenceCreateInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
||||||
|
fenceCreateInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
|
||||||
|
|
||||||
|
VkSemaphoreCreateInfo semaphoreCreateInfo = {};
|
||||||
|
semaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||||
|
|
||||||
|
for (int i = 0; i < g_nNumSwapchainImages; i++)
|
||||||
|
{
|
||||||
|
vkCreateFence(g_vkDevice,&fenceCreateInfo, NULL, &g_frameData[i].fence);
|
||||||
|
vkCreateSemaphore(g_vkDevice, &semaphoreCreateInfo, NULL, &g_frameData[i].draw);
|
||||||
|
vkCreateSemaphore(g_vkDevice, &semaphoreCreateInfo, NULL, &g_frameData[i].present);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void IVideo_SwapchainDestroy()
|
||||||
|
{
|
||||||
|
vkDestroySwapchainKHR(g_vkDevice, g_swapchain, NULL);
|
||||||
|
vkDestroySurfaceKHR(g_vkInstance, g_surface, NULL);
|
||||||
|
for (int i = 0; i < g_nNumSwapchainImages; i++)
|
||||||
|
{
|
||||||
|
vkDestroyImageView(g_vkDevice, g_swapchainImageViews[i], NULL);
|
||||||
|
vkDestroySemaphore(g_vkDevice, g_frameData[i].draw, NULL);
|
||||||
|
vkDestroySemaphore(g_vkDevice, g_frameData[i].present, NULL);
|
||||||
|
vkDestroyFence(g_vkDevice, g_frameData[i].fence, NULL);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void IVideo::Init()
|
||||||
|
{
|
||||||
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
|
||||||
|
g_window = SDL_CreateWindow("rtt", 1280, 720, SDL_WINDOW_VULKAN);
|
||||||
|
|
||||||
|
unsigned int nExtensionCount = 0;
|
||||||
|
const char* const* szExtensions = SDL_Vulkan_GetInstanceExtensions(&nExtensionCount);
|
||||||
|
|
||||||
|
vulkan_gpu.SetValue(ICommandLine::ParamValue("-gpu"));
|
||||||
|
VkResult r = VK_SUCCESS;
|
||||||
|
uint32_t i = 0;
|
||||||
|
|
||||||
|
/* Instance */
|
||||||
|
VkApplicationInfo applicationInfo = {};
|
||||||
|
applicationInfo.apiVersion = VK_API_VERSION_1_4;
|
||||||
|
|
||||||
|
VkInstanceCreateInfo instanceCreateInfo = {};
|
||||||
|
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
|
instanceCreateInfo.pApplicationInfo = &applicationInfo;
|
||||||
|
|
||||||
|
instanceCreateInfo.enabledExtensionCount = nExtensionCount;
|
||||||
|
instanceCreateInfo.ppEnabledExtensionNames = szExtensions;
|
||||||
|
r = vkCreateInstance(&instanceCreateInfo, NULL, &g_vkInstance);
|
||||||
|
if ( r != VK_SUCCESS )
|
||||||
|
Plat_FatalErrorFunc("Failed to create VkInstance!");
|
||||||
|
|
||||||
|
|
||||||
|
/* Physical Devices */
|
||||||
|
uint32_t nNumPhysicalDevices = 0;
|
||||||
|
vkEnumeratePhysicalDevices(g_vkInstance, &nNumPhysicalDevices, NULL);
|
||||||
|
if ( nNumPhysicalDevices == 0 )
|
||||||
|
Plat_FatalErrorFunc("No GPU drivers available!");
|
||||||
|
CUtlVector<VkPhysicalDevice> PhysicalDevices(nNumPhysicalDevices);
|
||||||
|
|
||||||
|
vkEnumeratePhysicalDevices(g_vkInstance, &nNumPhysicalDevices, PhysicalDevices.GetData());
|
||||||
|
|
||||||
|
/* enumerate them for the user */
|
||||||
|
for (auto &device: PhysicalDevices)
|
||||||
|
{
|
||||||
|
VkPhysicalDeviceProperties Properties = {};
|
||||||
|
vkGetPhysicalDeviceProperties(device, &Properties);
|
||||||
|
V_printf("GPU%i available: %s\n", i, Properties.deviceName);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select one in vk_gpu */
|
||||||
|
g_vkPhysicalDevice = PhysicalDevices[vulkan_gpu.GetInt()];
|
||||||
|
VkPhysicalDeviceProperties Properties = {};
|
||||||
|
vkGetPhysicalDeviceProperties(g_vkPhysicalDevice, &Properties);
|
||||||
|
V_printf("Using %s\n", Properties.deviceName);
|
||||||
|
|
||||||
|
/* queue family */
|
||||||
|
uint32_t nNumQueueFamilies = 0;
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(g_vkPhysicalDevice, &nNumQueueFamilies, NULL);
|
||||||
|
CUtlVector<VkQueueFamilyProperties> queueFamilyProperties(nNumQueueFamilies);
|
||||||
|
vkGetPhysicalDeviceQueueFamilyProperties(g_vkPhysicalDevice, &nNumQueueFamilies, queueFamilyProperties.GetData());
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
for (auto &family: queueFamilyProperties)
|
||||||
|
{
|
||||||
|
if (family.queueFlags & VK_QUEUE_GRAPHICS_BIT)
|
||||||
|
{
|
||||||
|
g_drawfamily = i;
|
||||||
|
g_presentfamily = i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create device */
|
||||||
|
float queuePriority = 1.0f;
|
||||||
|
VkDeviceQueueCreateInfo queueCreateInfo = {};
|
||||||
|
queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||||
|
queueCreateInfo.queueFamilyIndex = g_drawfamily;
|
||||||
|
queueCreateInfo.queueCount = 1;
|
||||||
|
queueCreateInfo.pQueuePriorities = &queuePriority;
|
||||||
|
|
||||||
|
VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT pdvidsfe = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT,
|
||||||
|
.vertexInputDynamicState = VK_TRUE,
|
||||||
|
};
|
||||||
|
|
||||||
|
VkPhysicalDeviceExtendedDynamicState3FeaturesEXT pdeds3fe = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT,
|
||||||
|
.pNext = &pdvidsfe,
|
||||||
|
.extendedDynamicState3DepthClampEnable = VK_TRUE,
|
||||||
|
.extendedDynamicState3PolygonMode = VK_TRUE,
|
||||||
|
.extendedDynamicState3RasterizationSamples = VK_TRUE,
|
||||||
|
.extendedDynamicState3SampleMask = VK_TRUE,
|
||||||
|
.extendedDynamicState3AlphaToCoverageEnable = VK_TRUE,
|
||||||
|
.extendedDynamicState3LogicOpEnable = VK_TRUE,
|
||||||
|
.extendedDynamicState3ColorBlendEnable = VK_TRUE,
|
||||||
|
.extendedDynamicState3ColorBlendEquation = VK_TRUE,
|
||||||
|
.extendedDynamicState3ColorWriteMask = VK_TRUE,
|
||||||
|
};
|
||||||
|
|
||||||
|
VkPhysicalDeviceExtendedDynamicState2FeaturesEXT pdeds2fe = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT,
|
||||||
|
.pNext = &pdeds3fe,
|
||||||
|
.extendedDynamicState2LogicOp = VK_TRUE,
|
||||||
|
.extendedDynamicState2PatchControlPoints = VK_TRUE,
|
||||||
|
};
|
||||||
|
|
||||||
|
VkPhysicalDeviceVulkan13Features pdv13f = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
|
||||||
|
.pNext = &pdeds2fe,
|
||||||
|
.dynamicRendering = VK_TRUE,
|
||||||
|
};
|
||||||
|
VkPhysicalDeviceVulkan12Features pdv12f = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
|
||||||
|
.pNext = &pdv13f,
|
||||||
|
.runtimeDescriptorArray = VK_TRUE,
|
||||||
|
.bufferDeviceAddress = VK_TRUE,
|
||||||
|
};
|
||||||
|
VkPhysicalDeviceVulkan11Features pdv11f = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
|
||||||
|
.pNext = &pdv12f,
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *szEnabledGPUExtensions[] = {
|
||||||
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
|
VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME,
|
||||||
|
VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME,
|
||||||
|
};
|
||||||
|
VkDeviceCreateInfo deviceCreateInfo = {};
|
||||||
|
deviceCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
|
||||||
|
deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo;
|
||||||
|
deviceCreateInfo.queueCreateInfoCount = 1;
|
||||||
|
deviceCreateInfo.enabledExtensionCount = sizeof(szEnabledGPUExtensions)/(sizeof(const char*));
|
||||||
|
deviceCreateInfo.ppEnabledExtensionNames = szEnabledGPUExtensions;
|
||||||
|
deviceCreateInfo.pNext = &pdv11f;
|
||||||
|
|
||||||
|
r = vkCreateDevice(g_vkPhysicalDevice, &deviceCreateInfo, NULL, &g_vkDevice);
|
||||||
|
if ( r != VK_SUCCESS )
|
||||||
|
Plat_FatalErrorFunc("Failed to create VkDevice!");
|
||||||
|
vkGetDeviceQueue(g_vkDevice, g_drawfamily, 0, &g_drawQueue);
|
||||||
|
vkGetDeviceQueue(g_vkDevice, g_presentfamily, 0, &g_presentQueue);
|
||||||
|
|
||||||
|
VmaVulkanFunctions vulkanFunctions = {};
|
||||||
|
vulkanFunctions.vkGetInstanceProcAddr = &vkGetInstanceProcAddr;
|
||||||
|
vulkanFunctions.vkGetDeviceProcAddr = &vkGetDeviceProcAddr;
|
||||||
|
|
||||||
|
VmaAllocatorCreateInfo allocatorCreateInfo = {};
|
||||||
|
allocatorCreateInfo.flags = VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT;
|
||||||
|
allocatorCreateInfo.vulkanApiVersion = VK_API_VERSION_1_4;
|
||||||
|
allocatorCreateInfo.physicalDevice = g_vkPhysicalDevice;
|
||||||
|
allocatorCreateInfo.device = g_vkDevice;
|
||||||
|
allocatorCreateInfo.instance = g_vkInstance;
|
||||||
|
vmaCreateAllocator(&allocatorCreateInfo, &g_allocator);
|
||||||
|
|
||||||
|
#define VK_DEVICE_FUNCTION(name) _##name = (PFN_##name)vkGetDeviceProcAddr(g_vkDevice, #name)
|
||||||
|
#include "vk_external_functions.cpp"
|
||||||
|
#undef VK_DEVICE_FUNCTION
|
||||||
|
|
||||||
|
IVideo_SwapchainInit();
|
||||||
|
|
||||||
|
IVulkan::Init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IVideo_HandleEvents()
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event))
|
||||||
|
{
|
||||||
|
switch (event.type)
|
||||||
|
{
|
||||||
|
case SDL_EVENT_WINDOW_RESIZED:
|
||||||
|
g_nWindowWidth = event.window.data1;
|
||||||
|
g_nWindowHeight = event.window.data2;
|
||||||
|
g_bConfigNotify = 2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void IVideo::Frame( float fDelta )
|
||||||
|
{
|
||||||
|
static uint32_t s_frameID = 0;
|
||||||
|
IVideo_HandleEvents();
|
||||||
|
|
||||||
|
vk_framedata_t frame = g_frameData[s_frameID];
|
||||||
|
vkDeviceWaitIdle(g_vkDevice);
|
||||||
|
|
||||||
|
vkWaitForFences(g_vkDevice, 1, &frame.fence, VK_TRUE, UINT64_MAX);
|
||||||
|
|
||||||
|
uint32_t imageIndex = 0;
|
||||||
|
VkResult r = vkAcquireNextImageKHR(g_vkDevice, g_swapchain, UINT64_MAX, frame.draw, VK_NULL_HANDLE, &imageIndex);
|
||||||
|
if (r == VK_ERROR_OUT_OF_DATE_KHR || r == VK_SUBOPTIMAL_KHR || g_bConfigNotify == 2)
|
||||||
|
{
|
||||||
|
g_bConfigNotify=1;
|
||||||
|
vkDeviceWaitIdle(g_vkDevice);
|
||||||
|
IVideo_SwapchainDestroy();
|
||||||
|
IVideo_SwapchainInit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vk_framedata_t frameindex = g_frameData[imageIndex];
|
||||||
|
|
||||||
|
vkResetFences(g_vkDevice, 1, &frame.fence);
|
||||||
|
|
||||||
|
g_vkCommandBuffer = g_commandBuffers[s_frameID];
|
||||||
|
g_swapchainImageView = g_swapchainImageViews[imageIndex];
|
||||||
|
g_swapchainImage = g_swapchainImages[imageIndex];
|
||||||
|
vkResetCommandBuffer(g_vkCommandBuffer, 0);
|
||||||
|
|
||||||
|
VkCommandBufferBeginInfo beginInfo = {};
|
||||||
|
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||||
|
vkBeginCommandBuffer(g_vkCommandBuffer, &beginInfo);
|
||||||
|
IVulkan::Frame();
|
||||||
|
vkEndCommandBuffer(g_vkCommandBuffer);
|
||||||
|
|
||||||
|
VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT};
|
||||||
|
VkSubmitInfo submitInfo = {};
|
||||||
|
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
|
submitInfo.waitSemaphoreCount = 1;
|
||||||
|
submitInfo.pWaitSemaphores = &frame.draw;
|
||||||
|
submitInfo.pWaitDstStageMask = waitStages;
|
||||||
|
submitInfo.commandBufferCount = 1;
|
||||||
|
submitInfo.pCommandBuffers = &g_vkCommandBuffer;
|
||||||
|
submitInfo.signalSemaphoreCount = 1;
|
||||||
|
submitInfo.pSignalSemaphores = &frameindex.present;
|
||||||
|
|
||||||
|
vkQueueSubmit(g_drawQueue, 1, &submitInfo, frame.fence);
|
||||||
|
|
||||||
|
VkPresentInfoKHR presentInfo = {};
|
||||||
|
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
|
||||||
|
presentInfo.waitSemaphoreCount = 1;
|
||||||
|
presentInfo.pWaitSemaphores = &frameindex.present;
|
||||||
|
presentInfo.swapchainCount = 1;
|
||||||
|
presentInfo.pSwapchains = &g_swapchain;
|
||||||
|
presentInfo.pImageIndices = &imageIndex;
|
||||||
|
|
||||||
|
|
||||||
|
r = vkQueuePresentKHR(g_presentQueue, &presentInfo);
|
||||||
|
if (r == VK_ERROR_OUT_OF_DATE_KHR || r == VK_SUBOPTIMAL_KHR)
|
||||||
|
{
|
||||||
|
vkDeviceWaitIdle(g_vkDevice);
|
||||||
|
IVideo_SwapchainDestroy();
|
||||||
|
IVideo_SwapchainInit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_bConfigNotify = 0;
|
||||||
|
s_frameID=(s_frameID+1)%g_nNumSwapchainImages;
|
||||||
|
};
|
||||||
1
external/SDL
vendored
Submodule
1
external/SDL
vendored
Submodule
Submodule external/SDL added at b51273512b
0
fpc/build.sh
Normal file
0
fpc/build.sh
Normal file
0
fpc/main.cpp
Normal file
0
fpc/main.cpp
Normal file
@@ -1,3 +1,4 @@
|
|||||||
|
#include "god/build.h"
|
||||||
#include "god/slang.h"
|
#include "god/slang.h"
|
||||||
#include "god/utils.h"
|
#include "god/utils.h"
|
||||||
#include "god/common.h"
|
#include "god/common.h"
|
||||||
@@ -13,7 +14,7 @@ void build_shader(char *name, enum slang_stage stage)
|
|||||||
mv(string_clone("funnyassets/_rtt/gfx/%s.spv",name),file);
|
mv(string_clone("funnyassets/_rtt/gfx/%s.spv",name),file);
|
||||||
};
|
};
|
||||||
|
|
||||||
void makepak(char *name)
|
void makepak(struct build_data b, char *name)
|
||||||
{
|
{
|
||||||
struct run_project rp = run_new("python");
|
struct run_project rp = run_new("python");
|
||||||
run_add_arg(&rp, "tools/makepak64.py");
|
run_add_arg(&rp, "tools/makepak64.py");
|
||||||
@@ -28,9 +29,11 @@ void assets_build(struct build_data b)
|
|||||||
makedir("funnyassets/_rtt/gfx");
|
makedir("funnyassets/_rtt/gfx");
|
||||||
build_shader("brush_frag", SLANG_STAGE_FRAGMENT);
|
build_shader("brush_frag", SLANG_STAGE_FRAGMENT);
|
||||||
build_shader("brush_vert", SLANG_STAGE_VERTEX);
|
build_shader("brush_vert", SLANG_STAGE_VERTEX);
|
||||||
|
build_shader("mesh_frag", SLANG_STAGE_FRAGMENT);
|
||||||
|
build_shader("mesh_vert", SLANG_STAGE_VERTEX);
|
||||||
mv("funnyassets/_rtt/","funnyassets/maps");
|
mv("funnyassets/_rtt/","funnyassets/maps");
|
||||||
mv("funnyassets/_rtt/","funnyassets/gfx");
|
mv("funnyassets/_rtt/","funnyassets/gfx");
|
||||||
mv("funnyassets/_rtt/","funnyassets/textures");
|
mv("funnyassets/_rtt/","funnyassets/textures");
|
||||||
mv("funnyassets/_rtt/","funnyassets/materials");
|
mv("funnyassets/_rtt/","funnyassets/materials");
|
||||||
makepak("rtt");
|
makepak(b, "rtt");
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
funnyassets/_rtt/gfx/mesh_frag.spv
Normal file
BIN
funnyassets/_rtt/gfx/mesh_frag.spv
Normal file
Binary file not shown.
BIN
funnyassets/_rtt/gfx/mesh_vert.spv
Normal file
BIN
funnyassets/_rtt/gfx/mesh_vert.spv
Normal file
Binary file not shown.
Binary file not shown.
23
funnyassets/gfx_shaders/mesh_frag.slang
Normal file
23
funnyassets/gfx_shaders/mesh_frag.slang
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "mesh_shared.slang"
|
||||||
|
|
||||||
|
uint32_t hash32(uint32_t x) {
|
||||||
|
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||||
|
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||||
|
x = (x >> 16) ^ x;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[vk::binding(1)]]
|
||||||
|
uniform Sampler2D textures[];
|
||||||
|
|
||||||
|
|
||||||
|
float4 main(
|
||||||
|
VertexOutput input,
|
||||||
|
uint triid: SV_PrimitiveID,
|
||||||
|
uniform PushConstants constants,
|
||||||
|
) : SV_TARGET
|
||||||
|
{
|
||||||
|
return float4(textures[constants.albedoID].Sample(input.uv).xyz, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
15
funnyassets/gfx_shaders/mesh_shared.slang
Normal file
15
funnyassets/gfx_shaders/mesh_shared.slang
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct VertexOutput
|
||||||
|
{
|
||||||
|
float4 position: SV_Position;
|
||||||
|
float2 uv: TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PushConstants
|
||||||
|
{
|
||||||
|
float4x4 modelMatrix;
|
||||||
|
uint albedoID;
|
||||||
|
uint roughnessID;
|
||||||
|
uint metalnessID;
|
||||||
|
};
|
||||||
24
funnyassets/gfx_shaders/mesh_vert.slang
Normal file
24
funnyassets/gfx_shaders/mesh_vert.slang
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "mesh_shared.slang"
|
||||||
|
|
||||||
|
struct VertexInput
|
||||||
|
{
|
||||||
|
float3 position: POSITION;
|
||||||
|
float2 uv: TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
[[vk::binding(0)]]
|
||||||
|
cbuffer CameraInfo
|
||||||
|
{
|
||||||
|
float4x4 projection;
|
||||||
|
};
|
||||||
|
|
||||||
|
VertexOutput main(
|
||||||
|
VertexInput input,
|
||||||
|
uniform PushConstants constants,
|
||||||
|
)
|
||||||
|
{
|
||||||
|
VertexOutput output;
|
||||||
|
output.position = mul(projection, mul(constants.modelMatrix, float4(input.position,1)));
|
||||||
|
output.uv = input.uv;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,99 +1,99 @@
|
|||||||
{
|
{
|
||||||
"classname" "worldspawn"
|
"classname" "worldspawn"
|
||||||
{
|
{
|
||||||
(-10.000000 -5.999999 -2.000000) (-10.000001 -9.999999 -2.000000) (-10.000001 -9.999999 -4.000000) (6.483328 1.451694) (6.483328 0.190320) (7.114015 0.190320) BRICK0
|
(10.000000 2.000001 -2.000000) (9.999999 6.000001 -2.000000) (9.999999 6.000001 -4.000000) (6.483328 1.451694) (6.483328 0.190320) (7.114015 0.190320) BRICK0
|
||||||
(-10.000000 -5.999999 -2.000000) (-10.000001 -9.999999 -4.000000) (-10.000000 -5.999999 -4.000000) (6.483328 1.451694) (7.114015 0.190320) (7.114015 1.451694) BRICK0
|
(10.000000 2.000001 -2.000000) (9.999999 6.000001 -4.000000) (10.000000 2.000001 -4.000000) (6.483328 1.451694) (7.114015 0.190320) (7.114015 1.451694) BRICK0
|
||||||
(-14.000000 -1.999999 -2.000000) (-16.000000 -1.999999 -2.000000) (-16.000000 -2.299999 -2.000000) (0.820848 2.713067) (0.190320 2.713067) (0.190320 2.618464) BRICK0
|
(14.000000 -1.999999 -2.000000) (16.000000 -1.999999 -2.000000) (16.000000 -1.699999 -2.000000) (0.820848 2.713067) (0.190320 2.713067) (0.190320 2.618464) BRICK0
|
||||||
(-14.000000 -1.999999 -2.000000) (-16.000000 -2.299999 -2.000000) (-14.000000 -2.299999 -2.000000) (0.820848 2.713067) (0.190320 2.618464) (0.820848 2.618464) BRICK0
|
(14.000000 -1.999999 -2.000000) (16.000000 -1.699999 -2.000000) (14.000000 -1.699999 -2.000000) (0.820848 2.713067) (0.190320 2.618464) (0.820848 2.618464) BRICK0
|
||||||
(-8.000000 -1.999999 -4.000000) (-8.000000 2.000001 -4.000000) (-12.000000 2.000001 -2.000000) (2.726604 2.713067) (2.726604 3.974441) (1.451375 3.974441) BRICK0
|
(8.000000 -1.999999 -4.000000) (8.000000 -6.000000 -4.000000) (12.000000 -5.999999 -2.000000) (2.726604 2.713067) (2.726604 3.974441) (1.451375 3.974441) BRICK0
|
||||||
(-8.000000 -1.999999 -4.000000) (-12.000000 2.000001 -2.000000) (-12.000000 -1.999999 -2.000000) (2.726604 2.713067) (1.451375 3.974441) (1.451375 2.713067) BRICK0
|
(8.000000 -1.999999 -4.000000) (12.000000 -5.999999 -2.000000) (12.000000 -1.999999 -2.000000) (2.726604 2.713067) (1.451375 3.974441) (1.451375 2.713067) BRICK0
|
||||||
(-8.000000 -1.999999 -4.000000) (-12.000000 -1.999999 -2.000000) (-8.000000 -1.999999 -2.000000) (6.798353 5.902491) (6.167666 7.163865) (6.167666 5.902491) BRICK0
|
(8.000000 -1.999999 -4.000000) (12.000000 -1.999999 -2.000000) (8.000000 -1.999999 -2.000000) (6.798353 5.902491) (6.167666 7.163865) (6.167666 5.902491) BRICK0
|
||||||
(-14.000000 -1.999999 -2.000000) (-14.000000 2.000001 -2.000000) (-16.000000 2.000001 -2.000000) (0.820848 2.713067) (0.820848 3.974441) (0.190320 3.974441) BRICK0
|
(14.000000 -1.999999 -2.000000) (14.000000 -5.999999 -2.000000) (16.000000 -5.999999 -2.000000) (0.820848 2.713067) (0.820848 3.974441) (0.190320 3.974441) BRICK0
|
||||||
(-14.000000 -1.999999 -2.000000) (-16.000000 2.000001 -2.000000) (-16.000000 -1.999999 -2.000000) (0.820848 2.713067) (0.190320 3.974441) (0.190320 2.713067) BRICK0
|
(14.000000 -1.999999 -2.000000) (16.000000 -5.999999 -2.000000) (16.000000 -1.999999 -2.000000) (0.820848 2.713067) (0.190320 3.974441) (0.190320 2.713067) BRICK0
|
||||||
(-14.000000 -2.299999 -2.000000) (-16.000000 -2.299999 -2.000000) (-16.000000 -5.699999 -2.000000) (0.820848 2.618464) (0.190320 2.618464) (0.190320 1.546297) BRICK0
|
(14.000000 -1.699999 -2.000000) (16.000000 -1.699999 -2.000000) (16.000000 1.700001 -2.000000) (0.820848 2.618464) (0.190320 2.618464) (0.190320 1.546297) BRICK0
|
||||||
(-14.000000 -2.299999 -2.000000) (-16.000000 -5.699999 -2.000000) (-14.000000 -5.699999 -2.000000) (0.820848 2.618464) (0.190320 1.546297) (0.820848 1.546297) BRICK0
|
(14.000000 -1.699999 -2.000000) (16.000000 1.700001 -2.000000) (14.000000 1.700001 -2.000000) (0.820848 2.618464) (0.190320 1.546297) (0.820848 1.546297) BRICK0
|
||||||
(-4.000000 -2.000000 -4.000000) (-4.000000 2.000000 -4.000000) (-8.000000 2.000001 -4.000000) (3.987659 2.713067) (3.987659 3.974441) (2.726604 3.974441) BRICK0
|
(4.000000 -2.000000 -4.000000) (4.000000 -6.000000 -4.000000) (8.000000 -6.000000 -4.000000) (3.987659 2.713067) (3.987659 3.974441) (2.726604 3.974441) BRICK0
|
||||||
(-4.000000 -2.000000 -4.000000) (-8.000000 2.000001 -4.000000) (-8.000000 -1.999999 -4.000000) (3.987659 2.713067) (2.726604 3.974441) (2.726604 2.713067) BRICK0
|
(4.000000 -2.000000 -4.000000) (8.000000 -6.000000 -4.000000) (8.000000 -1.999999 -4.000000) (3.987659 2.713067) (2.726604 3.974441) (2.726604 2.713067) BRICK0
|
||||||
(-12.000000 -2.299999 -2.000000) (-12.000000 -5.699999 -2.000000) (-10.300000 -5.699999 -2.000000) (1.451375 2.618464) (1.451375 1.546297) (1.987324 1.546297) BRICK0
|
(12.000000 -1.699999 -2.000000) (12.000000 1.700001 -2.000000) (10.300000 1.700001 -2.000000) (1.451375 2.618464) (1.451375 1.546297) (1.987324 1.546297) BRICK0
|
||||||
(-12.000000 -2.299999 -2.000000) (-10.300000 -5.699999 -2.000000) (-10.300000 -2.299999 -2.000000) (1.451375 2.618464) (1.987324 1.546297) (1.987324 2.618464) BRICK0
|
(12.000000 -1.699999 -2.000000) (10.300000 1.700001 -2.000000) (10.300000 -1.699999 -2.000000) (1.451375 2.618464) (1.987324 1.546297) (1.987324 2.618464) BRICK0
|
||||||
(-8.000000 -6.000000 -4.000000) (-10.000000 -5.999999 -4.000000) (-10.000001 -9.999999 -4.000000) (2.726604 1.451694) (2.096077 1.451694) (2.096077 0.190320) BRICK0
|
(8.000000 2.000001 -4.000000) (10.000000 2.000001 -4.000000) (9.999999 6.000001 -4.000000) (2.726604 1.451694) (2.096077 1.451694) (2.096077 0.190320) BRICK0
|
||||||
(-8.000000 -6.000000 -4.000000) (-10.000001 -9.999999 -4.000000) (-8.000001 -9.999999 -4.000000) (2.726604 1.451694) (2.096077 0.190320) (2.726604 0.190320) BRICK0
|
(8.000000 2.000001 -4.000000) (9.999999 6.000001 -4.000000) (8.000000 6.000000 -4.000000) (2.726604 1.451694) (2.096077 0.190320) (2.726604 0.190320) BRICK0
|
||||||
(-4.000000 -6.000000 -4.000000) (-8.000000 -6.000000 -4.000000) (-8.000001 -9.999999 -4.000000) (3.987659 1.451694) (2.726604 1.451694) (2.726604 0.190320) BRICK0
|
(4.000000 2.000000 -4.000000) (8.000000 2.000001 -4.000000) (8.000000 6.000000 -4.000000) (3.987659 1.451694) (2.726604 1.451694) (2.726604 0.190320) BRICK0
|
||||||
(-4.000000 -6.000000 -4.000000) (-8.000001 -9.999999 -4.000000) (-4.000000 -10.000000 -4.000000) (3.987659 1.451694) (2.726604 0.190320) (3.987659 0.190320) BRICK0
|
(4.000000 2.000000 -4.000000) (8.000000 6.000000 -4.000000) (3.999999 6.000000 -4.000000) (3.987659 1.451694) (2.726604 0.190320) (3.987659 0.190320) BRICK0
|
||||||
(-8.000000 -6.000000 -4.000000) (-8.000000 -6.000000 -2.000000) (-10.000000 -5.999999 -2.000000) (6.325656 2.620692) (6.325656 1.990005) (6.956343 1.990005) BRICK0
|
(8.000000 2.000001 -4.000000) (8.000000 2.000001 -2.000000) (10.000000 2.000001 -2.000000) (6.325656 2.620692) (6.325656 1.990005) (6.956343 1.990005) BRICK0
|
||||||
(-8.000000 -6.000000 -4.000000) (-10.000000 -5.999999 -2.000000) (-10.000000 -5.999999 -4.000000) (6.325656 2.620692) (6.956343 1.990005) (6.956343 2.620692) BRICK0
|
(8.000000 2.000001 -4.000000) (10.000000 2.000001 -2.000000) (10.000000 2.000001 -4.000000) (6.325656 2.620692) (6.956343 1.990005) (6.956343 2.620692) BRICK0
|
||||||
(-8.000000 -1.999999 -4.000000) (-8.000000 -1.999999 -2.000000) (-8.000000 -6.000000 -2.000000) (5.156658 7.258468) (4.525971 7.258468) (4.525971 5.997094) BRICK0
|
(8.000000 -1.999999 -4.000000) (8.000000 -1.999999 -2.000000) (8.000000 2.000001 -2.000000) (5.156658 7.258468) (4.525971 7.258468) (4.525971 5.997094) BRICK0
|
||||||
(-8.000000 -1.999999 -4.000000) (-8.000000 -6.000000 -2.000000) (-8.000000 -6.000000 -4.000000) (5.156658 7.258468) (4.525971 5.997094) (5.156658 5.997094) BRICK0
|
(8.000000 -1.999999 -4.000000) (8.000000 2.000001 -2.000000) (8.000000 2.000001 -4.000000) (5.156658 7.258468) (4.525971 5.997094) (5.156658 5.997094) BRICK0
|
||||||
(-4.000000 -2.000000 -4.000000) (-8.000000 -1.999999 -4.000000) (-8.000000 -6.000000 -4.000000) (3.987659 2.713067) (2.726604 2.713067) (2.726604 1.451694) BRICK0
|
(4.000000 -2.000000 -4.000000) (8.000000 -1.999999 -4.000000) (8.000000 2.000001 -4.000000) (3.987659 2.713067) (2.726604 2.713067) (2.726604 1.451694) BRICK0
|
||||||
(-4.000000 -2.000000 -4.000000) (-8.000000 -6.000000 -4.000000) (-4.000000 -6.000000 -4.000000) (3.987659 2.713067) (2.726604 1.451694) (3.987659 1.451694) BRICK0
|
(4.000000 -2.000000 -4.000000) (8.000000 2.000001 -4.000000) (4.000000 2.000000 -4.000000) (3.987659 2.713067) (2.726604 1.451694) (3.987659 1.451694) BRICK0
|
||||||
(-10.300000 -2.299999 -2.000000) (-10.300000 -5.699999 -2.000000) (-8.300000 -5.699999 -2.000000) (1.987324 2.618464) (1.987324 1.546297) (2.617851 1.546297) BRICK0
|
(10.300000 -1.699999 -2.000000) (10.300000 1.700001 -2.000000) (8.300000 1.700001 -2.000000) (1.987324 2.618464) (1.987324 1.546297) (2.617851 1.546297) BRICK0
|
||||||
(-10.300000 -2.299999 -2.000000) (-8.300000 -5.699999 -2.000000) (-8.300000 -2.299999 -2.000000) (1.987324 2.618464) (2.617851 1.546297) (2.617851 2.618464) BRICK0
|
(10.300000 -1.699999 -2.000000) (8.300000 1.700001 -2.000000) (8.300000 -1.699999 -2.000000) (1.987324 2.618464) (2.617851 1.546297) (2.617851 2.618464) BRICK0
|
||||||
(-10.300000 -5.699999 -2.000000) (-12.000000 -5.699999 -2.000000) (-12.000001 -9.999999 -2.000000) (1.987324 1.546297) (1.451375 1.546297) (1.451375 0.190320) BRICK0
|
(10.300000 1.700001 -2.000000) (12.000000 1.700001 -2.000000) (11.999999 6.000001 -2.000000) (1.987324 1.546297) (1.451375 1.546297) (1.451375 0.190320) BRICK0
|
||||||
(-10.300000 -5.699999 -2.000000) (-12.000001 -9.999999 -2.000000) (-10.300001 -9.999999 -2.000000) (1.987324 1.546297) (1.451375 0.190320) (1.987324 0.190320) BRICK0
|
(10.300000 1.700001 -2.000000) (11.999999 6.000001 -2.000000) (10.299999 6.000001 -2.000000) (1.987324 1.546297) (1.451375 0.190320) (1.987324 0.190320) BRICK0
|
||||||
(-8.000000 2.000001 -4.000000) (-4.000000 2.000000 -4.000000) (-4.000000 4.000000 -4.000000) (2.726604 3.974441) (3.987659 3.974441) (3.987659 4.605128) BRICK0
|
(8.000000 -6.000000 -4.000000) (4.000000 -6.000000 -4.000000) (4.000000 -8.000000 -4.000000) (2.726604 3.974441) (3.987659 3.974441) (3.987659 4.605128) BRICK0
|
||||||
(-8.000000 2.000001 -4.000000) (-4.000000 4.000000 -4.000000) (-8.000000 4.000000 -4.000000) (2.726604 3.974441) (3.987659 4.605128) (2.726604 4.605128) BRICK0
|
(8.000000 -6.000000 -4.000000) (4.000000 -8.000000 -4.000000) (8.000000 -8.000000 -4.000000) (2.726604 3.974441) (3.987659 4.605128) (2.726604 4.605128) BRICK0
|
||||||
(-8.000000 2.000001 -4.000000) (-8.000000 4.000000 -4.000000) (-8.000000 4.000000 -2.000000) (1.451694 6.562484) (0.821007 6.562484) (0.821007 5.931798) BRICK0
|
(8.000000 -6.000000 -4.000000) (8.000000 -8.000000 -4.000000) (8.000000 -8.000000 -2.000000) (1.451694 6.562484) (0.821007 6.562484) (0.821007 5.931798) BRICK0
|
||||||
(-8.000000 2.000001 -4.000000) (-8.000000 4.000000 -2.000000) (-8.000000 2.000001 -2.000000) (1.451694 6.562484) (0.821007 5.931798) (1.451694 5.931798) BRICK0
|
(8.000000 -6.000000 -4.000000) (8.000000 -8.000000 -2.000000) (8.000000 -6.000000 -2.000000) (1.451694 6.562484) (0.821007 5.931798) (1.451694 5.931798) BRICK0
|
||||||
(-8.000000 4.000000 -4.000000) (-4.000000 4.000000 -4.000000) (-4.000000 4.000000 -2.000000) (7.809680 5.902491) (7.809680 7.163865) (7.178993 7.163865) BRICK0
|
(8.000000 -8.000000 -4.000000) (4.000000 -8.000000 -4.000000) (4.000000 -8.000000 -2.000000) (7.809680 5.902491) (7.809680 7.163865) (7.178993 7.163865) BRICK0
|
||||||
(-8.000000 4.000000 -4.000000) (-4.000000 4.000000 -2.000000) (-8.000000 4.000000 -2.000000) (7.809680 5.902491) (7.178993 7.163865) (7.178992 5.902491) BRICK0
|
(8.000000 -8.000000 -4.000000) (4.000000 -8.000000 -2.000000) (8.000000 -8.000000 -2.000000) (7.809680 5.902491) (7.178993 7.163865) (7.178992 5.902491) BRICK0
|
||||||
(-8.000000 2.000001 -4.000000) (-8.000000 2.000001 -2.000000) (-12.000000 2.000001 -2.000000) (5.945016 2.713067) (5.314330 2.713067) (5.314329 1.451694) BRICK0
|
(8.000000 -6.000000 -4.000000) (8.000000 -6.000000 -2.000000) (12.000000 -5.999999 -2.000000) (5.945016 2.713067) (5.314330 2.713067) (5.314329 1.451694) BRICK0
|
||||||
(-12.000000 -5.699999 -2.000000) (-14.000000 -5.699999 -2.000000) (-14.000001 -9.999999 -2.000000) (1.451375 1.546297) (0.820848 1.546297) (0.820848 0.190320) BRICK0
|
(12.000000 1.700001 -2.000000) (14.000000 1.700001 -2.000000) (13.999999 6.000001 -2.000000) (1.451375 1.546297) (0.820848 1.546297) (0.820848 0.190320) BRICK0
|
||||||
(-12.000000 -5.699999 -2.000000) (-14.000001 -9.999999 -2.000000) (-12.000001 -9.999999 -2.000000) (1.451375 1.546297) (0.820848 0.190320) (1.451375 0.190320) BRICK0
|
(12.000000 1.700001 -2.000000) (13.999999 6.000001 -2.000000) (11.999999 6.000001 -2.000000) (1.451375 1.546297) (0.820848 0.190320) (1.451375 0.190320) BRICK0
|
||||||
(-12.000000 -2.299999 -2.000000) (-14.000000 -2.299999 -2.000000) (-14.000000 -5.699999 -2.000000) (1.451375 2.618464) (0.820848 2.618464) (0.820848 1.546297) BRICK0
|
(12.000000 -1.699999 -2.000000) (14.000000 -1.699999 -2.000000) (14.000000 1.700001 -2.000000) (1.451375 2.618464) (0.820848 2.618464) (0.820848 1.546297) BRICK0
|
||||||
(-12.000000 -2.299999 -2.000000) (-14.000000 -5.699999 -2.000000) (-12.000000 -5.699999 -2.000000) (1.451375 2.618464) (0.820848 1.546297) (1.451375 1.546297) BRICK0
|
(12.000000 -1.699999 -2.000000) (14.000000 1.700001 -2.000000) (12.000000 1.700001 -2.000000) (1.451375 2.618464) (0.820848 1.546297) (1.451375 1.546297) BRICK0
|
||||||
(-12.000000 -1.999999 -2.000000) (-12.000000 2.000001 -2.000000) (-14.000000 2.000001 -2.000000) (1.451375 2.713067) (1.451375 3.974441) (0.820848 3.974441) BRICK0
|
(12.000000 -1.999999 -2.000000) (12.000000 -5.999999 -2.000000) (14.000000 -5.999999 -2.000000) (1.451375 2.713067) (1.451375 3.974441) (0.820848 3.974441) BRICK0
|
||||||
(-12.000000 -1.999999 -2.000000) (-14.000000 2.000001 -2.000000) (-14.000000 -1.999999 -2.000000) (1.451375 2.713067) (0.820848 3.974441) (0.820848 2.713067) BRICK0
|
(12.000000 -1.999999 -2.000000) (14.000000 -5.999999 -2.000000) (14.000000 -1.999999 -2.000000) (1.451375 2.713067) (0.820848 3.974441) (0.820848 2.713067) BRICK0
|
||||||
(-12.000000 -1.999999 -2.000000) (-14.000000 -1.999999 -2.000000) (-14.000000 -2.299999 -2.000000) (1.451375 2.713067) (0.820848 2.713067) (0.820848 2.618464) BRICK0
|
(12.000000 -1.999999 -2.000000) (14.000000 -1.999999 -2.000000) (14.000000 -1.699999 -2.000000) (1.451375 2.713067) (0.820848 2.713067) (0.820848 2.618464) BRICK0
|
||||||
(-12.000000 -1.999999 -2.000000) (-14.000000 -2.299999 -2.000000) (-12.000000 -2.299999 -2.000000) (1.451375 2.713067) (0.820848 2.618464) (1.451375 2.618464) BRICK0
|
(12.000000 -1.999999 -2.000000) (14.000000 -1.699999 -2.000000) (12.000000 -1.699999 -2.000000) (1.451375 2.713067) (0.820848 2.618464) (1.451375 2.618464) BRICK0
|
||||||
(-8.000000 2.000001 -2.000000) (-8.000000 4.000000 -2.000000) (-8.000000 4.000000 1.000000) (1.451694 5.931798) (0.821007 5.931798) (0.821007 4.985767) BRICK0
|
(8.000000 -6.000000 -2.000000) (8.000000 -8.000000 -2.000000) (8.000000 -8.000000 1.000000) (1.451694 5.931798) (0.821007 5.931798) (0.821007 4.985767) BRICK0
|
||||||
(-8.000000 2.000001 -2.000000) (-8.000000 4.000000 1.000000) (-8.000000 2.000001 1.000000) (1.451694 5.931798) (0.821007 4.985767) (1.451694 4.985767) BRICK0
|
(8.000000 -6.000000 -2.000000) (8.000000 -8.000000 1.000000) (8.000000 -6.000000 1.000000) (1.451694 5.931798) (0.821007 4.985767) (1.451694 4.985767) BRICK0
|
||||||
(-14.000000 2.000001 -2.000000) (-12.000000 2.000001 -2.000000) (-12.000000 2.000001 1.000000) (5.314329 0.821007) (5.314329 1.451694) (4.368299 1.451694) BRICK0
|
(14.000000 -5.999999 -2.000000) (12.000000 -5.999999 -2.000000) (12.000000 -5.999999 1.000000) (5.314329 0.821007) (5.314329 1.451694) (4.368299 1.451694) BRICK0
|
||||||
(-14.000000 2.000001 -2.000000) (-12.000000 2.000001 1.000000) (-14.000000 2.000001 1.000000) (5.314329 0.821007) (4.368299 1.451694) (4.368299 0.821007) BRICK0
|
(14.000000 -5.999999 -2.000000) (12.000000 -5.999999 1.000000) (14.000000 -5.999999 1.000000) (5.314329 0.821007) (4.368299 1.451694) (4.368299 0.821007) BRICK0
|
||||||
(-12.000000 2.000001 -2.000000) (-8.000000 2.000001 -2.000000) (-8.000000 2.000001 1.000000) (5.314329 1.451694) (5.314330 2.713067) (4.368299 2.713067) BRICK0
|
(12.000000 -5.999999 -2.000000) (8.000000 -6.000000 -2.000000) (8.000000 -6.000000 1.000000) (5.314329 1.451694) (5.314330 2.713067) (4.368299 2.713067) BRICK0
|
||||||
(-12.000000 2.000001 -2.000000) (-8.000000 2.000001 1.000000) (-12.000000 2.000001 1.000000) (5.314329 1.451694) (4.368299 2.713067) (4.368299 1.451694) BRICK0
|
(12.000000 -5.999999 -2.000000) (8.000000 -6.000000 1.000000) (12.000000 -5.999999 1.000000) (5.314329 1.451694) (4.368299 2.713067) (4.368299 1.451694) BRICK0
|
||||||
(-16.000000 -2.299999 -2.000000) (-16.000000 -1.999999 -2.000000) (-16.000000 -1.999999 1.000000) (6.956025 4.165875) (6.956025 4.260478) (6.009995 4.260478) BRICK0
|
(16.000000 -1.699999 -2.000000) (16.000000 -1.999999 -2.000000) (16.000000 -1.999999 1.000000) (6.956025 4.165875) (6.956025 4.260478) (6.009995 4.260478) BRICK0
|
||||||
(-16.000000 -2.299999 -2.000000) (-16.000000 -1.999999 1.000000) (-16.000000 -2.299999 1.000000) (6.956025 4.165875) (6.009995 4.260478) (6.009995 4.165875) BRICK0
|
(16.000000 -1.699999 -2.000000) (16.000000 -1.999999 1.000000) (16.000000 -1.699999 1.000000) (6.956025 4.165875) (6.009995 4.260478) (6.009995 4.165875) BRICK0
|
||||||
(-16.000000 -1.999999 -2.000000) (-16.000000 2.000001 -2.000000) (-16.000000 2.000001 1.000000) (6.956025 4.260478) (6.956025 5.521852) (6.009995 5.521852) BRICK0
|
(16.000000 -1.999999 -2.000000) (16.000000 -5.999999 -2.000000) (16.000000 -5.999999 1.000000) (6.956025 4.260478) (6.956025 5.521852) (6.009995 5.521852) BRICK0
|
||||||
(-16.000000 -1.999999 -2.000000) (-16.000000 2.000001 1.000000) (-16.000000 -1.999999 1.000000) (6.956025 4.260478) (6.009995 5.521852) (6.009995 4.260478) BRICK0
|
(16.000000 -1.999999 -2.000000) (16.000000 -5.999999 1.000000) (16.000000 -1.999999 1.000000) (6.956025 4.260478) (6.009995 5.521852) (6.009995 4.260478) BRICK0
|
||||||
(-16.000000 2.000001 -2.000000) (-14.000000 2.000001 -2.000000) (-14.000000 2.000001 1.000000) (5.314329 0.190320) (5.314329 0.821007) (4.368299 0.821007) BRICK0
|
(16.000000 -5.999999 -2.000000) (14.000000 -5.999999 -2.000000) (14.000000 -5.999999 1.000000) (5.314329 0.190320) (5.314329 0.821007) (4.368299 0.821007) BRICK0
|
||||||
(-16.000000 2.000001 -2.000000) (-14.000000 2.000001 1.000000) (-16.000000 2.000001 1.000000) (5.314329 0.190320) (4.368299 0.821007) (4.368299 0.190320) BRICK0
|
(16.000000 -5.999999 -2.000000) (14.000000 -5.999999 1.000000) (16.000000 -5.999999 1.000000) (5.314329 0.190320) (4.368299 0.821007) (4.368299 0.190320) BRICK0
|
||||||
(-14.000001 -9.999999 -2.000000) (-14.000000 -5.699999 -2.000000) (-14.000000 -5.699999 1.000000) (2.778364 4.985768) (2.778364 6.341744) (1.832334 6.341744) BRICK0
|
(13.999999 6.000001 -2.000000) (14.000000 1.700001 -2.000000) (14.000000 1.700001 1.000000) (2.778364 4.985768) (2.778364 6.341744) (1.832334 6.341744) BRICK0
|
||||||
(-14.000001 -9.999999 -2.000000) (-14.000000 -5.699999 1.000000) (-14.000001 -9.999999 1.000000) (2.778364 4.985768) (1.832334 6.341744) (1.832334 4.985768) BRICK0
|
(13.999999 6.000001 -2.000000) (14.000000 1.700001 1.000000) (13.999999 6.000001 1.000000) (2.778364 4.985768) (1.832334 6.341744) (1.832334 4.985768) BRICK0
|
||||||
(-16.000000 -5.699999 -2.000000) (-16.000000 -2.299999 -2.000000) (-16.000000 -2.299999 1.000000) (6.956025 3.093707) (6.956025 4.165875) (6.009995 4.165875) BRICK0
|
(16.000000 1.700001 -2.000000) (16.000000 -1.699999 -2.000000) (16.000000 -1.699999 1.000000) (6.956025 3.093707) (6.956025 4.165875) (6.009995 4.165875) BRICK0
|
||||||
(-16.000000 -5.699999 -2.000000) (-16.000000 -2.299999 1.000000) (-16.000000 -5.699999 1.000000) (6.956025 3.093707) (6.009995 4.165875) (6.009994 3.093707) BRICK0
|
(16.000000 1.700001 -2.000000) (16.000000 -1.699999 1.000000) (16.000000 1.700001 1.000000) (6.956025 3.093707) (6.009995 4.165875) (6.009994 3.093707) BRICK0
|
||||||
(-14.000000 -5.699999 -2.000000) (-16.000000 -5.699999 -2.000000) (-16.000000 -5.699999 1.000000) (2.463020 7.668415) (1.832333 7.668415) (1.832333 6.722384) BRICK0
|
(14.000000 1.700001 -2.000000) (16.000000 1.700001 -2.000000) (16.000000 1.700001 1.000000) (2.463020 7.668415) (1.832333 7.668415) (1.832333 6.722384) BRICK0
|
||||||
(-14.000000 -5.699999 -2.000000) (-16.000000 -5.699999 1.000000) (-14.000000 -5.699999 1.000000) (2.463020 7.668415) (1.832333 6.722384) (2.463020 6.722384) BRICK0
|
(14.000000 1.700001 -2.000000) (16.000000 1.700001 1.000000) (14.000000 1.700001 1.000000) (2.463020 7.668415) (1.832333 6.722384) (2.463020 6.722384) BRICK0
|
||||||
(-8.000000 4.000000 1.000000) (-8.000000 4.000000 -2.000000) (-8.000000 6.000000 -2.000000) (0.821007 4.985767) (0.821007 5.931798) (0.190320 5.931798) BRICK0
|
(8.000000 -8.000000 1.000000) (8.000000 -8.000000 -2.000000) (8.000001 -9.999999 -2.000000) (0.821007 4.985767) (0.821007 5.931798) (0.190320 5.931798) BRICK0
|
||||||
(-8.000000 4.000000 1.000000) (-8.000000 6.000000 -2.000000) (-8.000000 6.000000 1.000000) (0.821007 4.985767) (0.190320 5.931798) (0.190320 4.985767) BRICK0
|
(8.000000 -8.000000 1.000000) (8.000001 -9.999999 -2.000000) (8.000001 -9.999999 1.000000) (0.821007 4.985767) (0.190320 5.931798) (0.190320 4.985767) BRICK0
|
||||||
(-10.300000 -2.299999 -2.000000) (-8.300000 -2.299999 -2.000000) (-8.300000 -2.299999 -1.500000) (3.854987 5.521851) (3.854987 6.152538) (3.697315 6.152538) BRICK0
|
(10.300000 -1.699999 -2.000000) (8.300000 -1.699999 -2.000000) (8.300000 -1.699999 -1.500000) (3.854987 5.521851) (3.854987 6.152538) (3.697315 6.152538) BRICK0
|
||||||
(-10.300000 -2.299999 -2.000000) (-8.300000 -2.299999 -1.500000) (-10.300000 -2.299999 -1.500000) (3.854987 5.521851) (3.697315 6.152538) (3.697315 5.521851) BRICK0
|
(10.300000 -1.699999 -2.000000) (8.300000 -1.699999 -1.500000) (10.300000 -1.699999 -1.500000) (3.854987 5.521851) (3.697315 6.152538) (3.697315 5.521851) BRICK0
|
||||||
(-10.300000 -5.699999 -2.000000) (-10.300001 -9.999999 -2.000000) (-10.300001 -9.999999 -1.500000) (3.316675 4.985768) (3.316675 6.341744) (3.159004 6.341744) BRICK0
|
(10.300000 1.700001 -2.000000) (10.299999 6.000001 -2.000000) (10.299999 6.000001 -1.500000) (3.316675 4.985768) (3.316675 6.341744) (3.159004 6.341744) BRICK0
|
||||||
(-10.300000 -5.699999 -2.000000) (-10.300001 -9.999999 -1.500000) (-10.300000 -5.699999 -1.500000) (3.316675 4.985768) (3.159004 6.341744) (3.159004 4.985768) BRICK0
|
(10.300000 1.700001 -2.000000) (10.299999 6.000001 -1.500000) (10.300000 1.700001 -1.500000) (3.316675 4.985768) (3.159004 6.341744) (3.159004 4.985768) BRICK0
|
||||||
(-10.000000 -5.999999 -2.000000) (-8.000000 -6.000000 -2.000000) (-8.000000 -6.000000 -1.500000) (6.956343 1.990005) (6.325656 1.990005) (6.325656 1.832333) BRICK0
|
(10.000000 2.000001 -2.000000) (8.000000 2.000001 -2.000000) (8.000000 2.000001 -1.500000) (6.956343 1.990005) (6.325656 1.990005) (6.325656 1.832333) BRICK0
|
||||||
(-10.000000 -5.999999 -2.000000) (-8.000000 -6.000000 -1.500000) (-10.000000 -5.999999 -1.500000) (6.956343 1.990005) (6.325656 1.832333) (6.956343 1.832333) BRICK0
|
(10.000000 2.000001 -2.000000) (8.000000 2.000001 -1.500000) (10.000000 2.000001 -1.500000) (6.956343 1.990005) (6.325656 1.832333) (6.956343 1.832333) BRICK0
|
||||||
(-12.000000 -1.999999 -2.000000) (-12.000000 -2.299999 -2.000000) (-12.000000 -2.299999 -1.500000) (2.938263 6.880056) (2.843660 6.880056) (2.843660 6.722384) BRICK0
|
(12.000000 -1.999999 -2.000000) (12.000000 -1.699999 -2.000000) (12.000000 -1.699999 -1.500000) (2.938263 6.880056) (2.843660 6.880056) (2.843660 6.722384) BRICK0
|
||||||
(-12.000000 -1.999999 -2.000000) (-12.000000 -2.299999 -1.500000) (-12.000000 -1.999999 -1.500000) (2.938263 6.880056) (2.843660 6.722384) (2.938263 6.722384) BRICK0
|
(12.000000 -1.999999 -2.000000) (12.000000 -1.699999 -1.500000) (12.000000 -1.999999 -1.500000) (2.938263 6.880056) (2.843660 6.722384) (2.938263 6.722384) BRICK0
|
||||||
(-8.300000 -2.299999 -2.000000) (-8.300000 -5.699999 -2.000000) (-8.300000 -5.699999 -1.500000) (7.494336 3.093707) (7.494337 4.165875) (7.336665 4.165875) BRICK0
|
(8.300000 -1.699999 -2.000000) (8.300000 1.700001 -2.000000) (8.300000 1.700001 -1.500000) (7.494336 3.093707) (7.494337 4.165875) (7.336665 4.165875) BRICK0
|
||||||
(-8.300000 -2.299999 -2.000000) (-8.300000 -5.699999 -1.500000) (-8.300000 -2.299999 -1.500000) (7.494336 3.093707) (7.336665 4.165875) (7.336665 3.093707) BRICK0
|
(8.300000 -1.699999 -2.000000) (8.300000 1.700001 -1.500000) (8.300000 -1.699999 -1.500000) (7.494336 3.093707) (7.336665 4.165875) (7.336665 3.093707) BRICK0
|
||||||
(-8.000000 -1.999999 -2.000000) (-12.000000 -1.999999 -2.000000) (-12.000000 -1.999999 -1.500000) (6.167666 5.902491) (6.167666 7.163865) (6.009995 7.163865) BRICK0
|
(8.000000 -1.999999 -2.000000) (12.000000 -1.999999 -2.000000) (12.000000 -1.999999 -1.500000) (6.167666 5.902491) (6.167666 7.163865) (6.009995 7.163865) BRICK0
|
||||||
(-8.000000 -1.999999 -2.000000) (-12.000000 -1.999999 -1.500000) (-8.000000 -1.999999 -1.500000) (6.167666 5.902491) (6.009995 7.163865) (6.009995 5.902491) BRICK0
|
(8.000000 -1.999999 -2.000000) (12.000000 -1.999999 -1.500000) (8.000000 -1.999999 -1.500000) (6.167666 5.902491) (6.009995 7.163865) (6.009995 5.902491) BRICK0
|
||||||
(-8.000000 -6.000000 -2.000000) (-8.000000 -1.999999 -2.000000) (-8.000000 -1.999999 -1.500000) (4.525971 5.997094) (4.525971 7.258468) (4.368299 7.258468) BRICK0
|
(8.000000 2.000001 -2.000000) (8.000000 -1.999999 -2.000000) (8.000000 -1.999999 -1.500000) (4.525971 5.997094) (4.525971 7.258468) (4.368299 7.258468) BRICK0
|
||||||
(-8.000000 -6.000000 -2.000000) (-8.000000 -1.999999 -1.500000) (-8.000000 -6.000000 -1.500000) (4.525971 5.997094) (4.368299 7.258468) (4.368299 5.997094) BRICK0
|
(8.000000 2.000001 -2.000000) (8.000000 -1.999999 -1.500000) (8.000000 2.000001 -1.500000) (4.525971 5.997094) (4.368299 7.258468) (4.368299 5.997094) BRICK0
|
||||||
(-8.300000 -5.699999 -2.000000) (-10.300000 -5.699999 -2.000000) (-10.300000 -5.699999 -1.500000) (3.854987 6.533178) (3.854987 7.163865) (3.697315 7.163865) BRICK0
|
(8.300000 1.700001 -2.000000) (10.300000 1.700001 -2.000000) (10.300000 1.700001 -1.500000) (3.854987 6.533178) (3.854987 7.163865) (3.697315 7.163865) BRICK0
|
||||||
(-8.300000 -5.699999 -2.000000) (-10.300000 -5.699999 -1.500000) (-8.300000 -5.699999 -1.500000) (3.854987 6.533178) (3.697315 7.163865) (3.697315 6.533178) BRICK0
|
(8.300000 1.700001 -2.000000) (10.300000 1.700001 -1.500000) (8.300000 1.700001 -1.500000) (3.854987 6.533178) (3.697315 7.163865) (3.697315 6.533178) BRICK0
|
||||||
(-10.000001 -9.999999 -2.000000) (-10.000000 -5.999999 -2.000000) (-10.000000 -5.999999 -1.500000) (6.483328 0.190320) (6.483328 1.451694) (6.325656 1.451694) BRICK0
|
(9.999999 6.000001 -2.000000) (10.000000 2.000001 -2.000000) (10.000000 2.000001 -1.500000) (6.483328 0.190320) (6.483328 1.451694) (6.325656 1.451694) BRICK0
|
||||||
(-10.000001 -9.999999 -2.000000) (-10.000000 -5.999999 -1.500000) (-10.000001 -9.999999 -1.500000) (6.483328 0.190320) (6.325656 1.451694) (6.325656 0.190320) BRICK0
|
(9.999999 6.000001 -2.000000) (10.000000 2.000001 -1.500000) (9.999999 6.000001 -1.500000) (6.483328 0.190320) (6.325656 1.451694) (6.325656 0.190320) BRICK0
|
||||||
(-12.000000 -2.299999 -2.000000) (-10.300000 -2.299999 -2.000000) (-10.300000 -2.299999 -1.500000) (3.854987 4.985767) (3.854987 5.521851) (3.697315 5.521851) BRICK0
|
(12.000000 -1.699999 -2.000000) (10.300000 -1.699999 -2.000000) (10.300000 -1.699999 -1.500000) (3.854987 4.985767) (3.854987 5.521851) (3.697315 5.521851) BRICK0
|
||||||
(-12.000000 -2.299999 -2.000000) (-10.300000 -2.299999 -1.500000) (-12.000000 -2.299999 -1.500000) (3.854987 4.985767) (3.697315 5.521851) (3.697315 4.985767) BRICK0
|
(12.000000 -1.699999 -2.000000) (10.300000 -1.699999 -1.500000) (12.000000 -1.699999 -1.500000) (3.854987 4.985767) (3.697315 5.521851) (3.697315 4.985767) BRICK0
|
||||||
(-10.000000 -5.999999 -1.500000) (-10.300000 -5.699999 -1.500000) (-10.300001 -9.999999 -1.500000) (4.998827 4.355081) (4.904248 4.449684) (4.904248 3.093707) BRICK0
|
(10.000000 2.000001 -1.500000) (10.300000 1.700001 -1.500000) (10.299999 6.000001 -1.500000) (4.998827 4.355081) (4.904248 4.449684) (4.904248 3.093707) BRICK0
|
||||||
(-10.000000 -5.999999 -1.500000) (-10.300001 -9.999999 -1.500000) (-10.000001 -9.999999 -1.500000) (4.998827 4.355081) (4.904248 3.093707) (4.998827 3.093707) BRICK0
|
(10.000000 2.000001 -1.500000) (10.299999 6.000001 -1.500000) (9.999999 6.000001 -1.500000) (4.998827 4.355081) (4.904248 3.093707) (4.998827 3.093707) BRICK0
|
||||||
(-8.000000 -6.000000 -1.500000) (-8.300000 -5.699999 -1.500000) (-10.300000 -5.699999 -1.500000) (5.629354 4.355081) (5.534775 4.449684) (4.904248 4.449684) BRICK0
|
(8.000000 2.000001 -1.500000) (8.300000 1.700001 -1.500000) (10.300000 1.700001 -1.500000) (5.629354 4.355081) (5.534775 4.449684) (4.904248 4.449684) BRICK0
|
||||||
(-8.000000 -6.000000 -1.500000) (-10.300000 -5.699999 -1.500000) (-10.000000 -5.999999 -1.500000) (5.629354 4.355081) (4.904248 4.449684) (4.998827 4.355081) BRICK0
|
(8.000000 2.000001 -1.500000) (10.300000 1.700001 -1.500000) (10.000000 2.000001 -1.500000) (5.629354 4.355081) (4.904248 4.449684) (4.998827 4.355081) BRICK0
|
||||||
(-8.000000 -1.999999 -1.500000) (-8.300000 -2.299999 -1.500000) (-8.300000 -5.699999 -1.500000) (5.629354 5.616455) (5.534775 5.521852) (5.534775 4.449684) BRICK0
|
(8.000000 -1.999999 -1.500000) (8.300000 -1.699999 -1.500000) (8.300000 1.700001 -1.500000) (5.629354 5.616455) (5.534775 5.521852) (5.534775 4.449684) BRICK0
|
||||||
(-8.000000 -1.999999 -1.500000) (-8.300000 -5.699999 -1.500000) (-8.000000 -6.000000 -1.500000) (5.629354 5.616455) (5.534775 4.449684) (5.629354 4.355081) BRICK0
|
(8.000000 -1.999999 -1.500000) (8.300000 1.700001 -1.500000) (8.000000 2.000001 -1.500000) (5.629354 5.616455) (5.534775 4.449684) (5.629354 4.355081) BRICK0
|
||||||
(-10.300000 -2.299999 -1.500000) (-8.300000 -2.299999 -1.500000) (-8.000000 -1.999999 -1.500000) (4.904248 5.521852) (5.534775 5.521852) (5.629354 5.616455) BRICK0
|
(10.300000 -1.699999 -1.500000) (8.300000 -1.699999 -1.500000) (8.000000 -1.999999 -1.500000) (4.904248 5.521852) (5.534775 5.521852) (5.629354 5.616455) BRICK0
|
||||||
(-8.000000 -1.999999 -1.500000) (-12.000000 -1.999999 -1.500000) (-12.000000 -2.299999 -1.500000) (5.629354 5.616455) (4.368299 5.616455) (4.368299 5.521852) BRICK0
|
(8.000000 -1.999999 -1.500000) (12.000000 -1.999999 -1.500000) (12.000000 -1.699999 -1.500000) (5.629354 5.616455) (4.368299 5.616455) (4.368299 5.521852) BRICK0
|
||||||
(-10.300000 -2.299999 -1.500000) (-8.000000 -1.999999 -1.500000) (-12.000000 -2.299999 -1.500000) (4.904248 5.521852) (5.629354 5.616455) (4.368299 5.521852) BRICK0
|
(10.300000 -1.699999 -1.500000) (8.000000 -1.999999 -1.500000) (12.000000 -1.699999 -1.500000) (4.904248 5.521852) (5.629354 5.616455) (4.368299 5.521852) BRICK0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
35
game/client/__build.c
Normal file
35
game/client/__build.c
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "god/build.h"
|
||||||
|
#include "god/c.h"
|
||||||
|
#include "god/ld.h"
|
||||||
|
|
||||||
|
|
||||||
|
char* client_dll = 0;
|
||||||
|
void client_build(struct build_data b)
|
||||||
|
{
|
||||||
|
char* files[] = {
|
||||||
|
"game/client/baseplayer.cpp",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct project p = {
|
||||||
|
.b = &b,
|
||||||
|
.files = files,
|
||||||
|
.name = "client",
|
||||||
|
};
|
||||||
|
|
||||||
|
struct project o = C_compile(p, (struct C_settings){
|
||||||
|
.generation_flags = C_GENERATION_FLAGS_PIC,
|
||||||
|
.compile_flags = C_COMPILE_FLAGS_WALL,
|
||||||
|
.include_dirs = include_dirs,
|
||||||
|
});
|
||||||
|
char* libs[] = {
|
||||||
|
"c",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
client_dll = ld_link_project(o, (struct link_settings){
|
||||||
|
.type = LINK_TYPE_DYNAMIC,
|
||||||
|
.libs = libs,
|
||||||
|
});
|
||||||
|
mv("build/"GAME_NAME"/game/"GAME_NAME"/bin/libclient.so",server_dll);
|
||||||
|
}
|
||||||
32
game/client/baseplayer.cpp
Normal file
32
game/client/baseplayer.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include "baseentity.h"
|
||||||
|
|
||||||
|
class C_BasePlayer: public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Precache ( void ) override;
|
||||||
|
virtual void Spawn( void ) override;
|
||||||
|
virtual void Destroy( void ) override;
|
||||||
|
virtual void Think( float fDelta ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void C_BasePlayer::Precache()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_BasePlayer::Spawn()
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void C_BasePlayer::Destroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
void C_BasePlayer::Think( float fDelta )
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
LINK_CLIENT_ENTITY(C_BasePlayer, CBasePlayer)
|
||||||
@@ -1,20 +1,16 @@
|
|||||||
|
#include "god/build.h"
|
||||||
#include "god/c.h"
|
#include "god/c.h"
|
||||||
#include "god/ld.h"
|
#include "god/ld.h"
|
||||||
|
#include "libgen.h"
|
||||||
|
|
||||||
char* server_dll = 0;
|
char* server_dll = 0;
|
||||||
void server_build(struct build_data b)
|
void server_build(struct build_data b)
|
||||||
{
|
{
|
||||||
char* files[] = {
|
char* files[] = {
|
||||||
"game/game.cpp",
|
"game/server/game.cpp",
|
||||||
"game/baseplayer.cpp",
|
"game/server/baseplayer.cpp",
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
struct C_Macro macros[] = {
|
|
||||||
(struct C_Macro){"TIER0_IMPLEMENTATION","1"},
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct project p = {
|
struct project p = {
|
||||||
.b = &b,
|
.b = &b,
|
||||||
@@ -26,7 +22,6 @@ void server_build(struct build_data b)
|
|||||||
.generation_flags = C_GENERATION_FLAGS_PIC,
|
.generation_flags = C_GENERATION_FLAGS_PIC,
|
||||||
.compile_flags = C_COMPILE_FLAGS_WALL,
|
.compile_flags = C_COMPILE_FLAGS_WALL,
|
||||||
.include_dirs = include_dirs,
|
.include_dirs = include_dirs,
|
||||||
.macros = macros,
|
|
||||||
});
|
});
|
||||||
char* libs[] = {
|
char* libs[] = {
|
||||||
"c",
|
"c",
|
||||||
@@ -2,9 +2,10 @@
|
|||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
|
||||||
PLATFORM_INTERFACE void IGame_Load()
|
DLL_EXPORT void IGame_Load()
|
||||||
{
|
{
|
||||||
ILevel::LoadLevel("maps/test_map");
|
ILevel::LoadLevel("maps/test_map");
|
||||||
return;
|
return;
|
||||||
@@ -10,8 +10,8 @@ static char szLauncherPath[MAX_PATH];
|
|||||||
static char szEnginePath[MAX_PATH];
|
static char szEnginePath[MAX_PATH];
|
||||||
static char szTier0Path[MAX_PATH];
|
static char szTier0Path[MAX_PATH];
|
||||||
|
|
||||||
void *pEngineLib;
|
void *pEngineLib = NULL;
|
||||||
void *pTier0Lib;
|
void *pTier0Lib = NULL;
|
||||||
typedef void (*EngineMainFn)(int argc, char** argv);
|
typedef void (*EngineMainFn)(int argc, char** argv);
|
||||||
EngineMainFn pEngineMain;
|
EngineMainFn pEngineMain;
|
||||||
|
|
||||||
@@ -21,6 +21,8 @@ int main( int argc, char **argv ) {
|
|||||||
|
|
||||||
snprintf(szEnginePath, MAX_PATH, "%s/libengine.so", szLauncherPath);
|
snprintf(szEnginePath, MAX_PATH, "%s/libengine.so", szLauncherPath);
|
||||||
snprintf(szTier0Path, MAX_PATH, "%s/libtier0.so", szLauncherPath);
|
snprintf(szTier0Path, MAX_PATH, "%s/libtier0.so", szLauncherPath);
|
||||||
|
printf("%s\n",szEnginePath);
|
||||||
|
printf("%s\n",szTier0Path);
|
||||||
|
|
||||||
pTier0Lib = dlopen(szTier0Path, RTLD_NOW | RTLD_GLOBAL);
|
pTier0Lib = dlopen(szTier0Path, RTLD_NOW | RTLD_GLOBAL);
|
||||||
if ( !pTier0Lib ) {
|
if ( !pTier0Lib ) {
|
||||||
@@ -32,6 +34,8 @@ int main( int argc, char **argv ) {
|
|||||||
printf("Failed to open libengine.so\n");
|
printf("Failed to open libengine.so\n");
|
||||||
printf("\t%s\n",dlerror());
|
printf("\t%s\n",dlerror());
|
||||||
}
|
}
|
||||||
|
printf("\t%p\n",pTier0Lib);
|
||||||
|
printf("\t%p\n",pEngineLib);
|
||||||
pEngineMain = (EngineMainFn)dlsym(pEngineLib, "FunnyMain");
|
pEngineMain = (EngineMainFn)dlsym(pEngineLib, "FunnyMain");
|
||||||
if ( !pEngineMain ) {
|
if ( !pEngineMain ) {
|
||||||
printf("Symbol not found: FunnyMain\n");
|
printf("Symbol not found: FunnyMain\n");
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#ifndef ENTITY_H
|
#ifndef ENTITY_H
|
||||||
#define ENTITY_H
|
#define ENTITY_H
|
||||||
|
|
||||||
|
#include "engine.h"
|
||||||
#include "tier1/utlvector.h"
|
#include "tier1/utlvector.h"
|
||||||
|
#include "cglm/cglm.h"
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
class C_BaseEntity;
|
class C_BaseEntity;
|
||||||
@@ -19,20 +21,21 @@ struct Triangle_t
|
|||||||
class CBaseEntity
|
class CBaseEntity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
C_BaseEntity *pClientEntity;
|
CBaseEntity();
|
||||||
|
|
||||||
virtual void Precache() = 0;
|
virtual void Precache() = 0;
|
||||||
virtual void Spawn( void ) = 0;
|
virtual void Spawn( void ) = 0;
|
||||||
virtual void Destroy( void ) = 0;
|
virtual void Destroy( void ) = 0;
|
||||||
virtual void Think( float fDelta ) = 0;
|
virtual void Think( float fDelta ) = 0;
|
||||||
|
|
||||||
|
C_BaseEntity *pClientEntity;
|
||||||
|
mat4 m_matrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CUtlSelfReferencingVector<CBaseEntity*> g_entities;
|
|
||||||
|
|
||||||
typedef CBaseEntity*(*EntityRegistryFn)( void );
|
typedef CBaseEntity*(*EntityRegistryFn)( void );
|
||||||
typedef C_BaseEntity*(*ClientEntityRegistryFn)( void );
|
typedef C_BaseEntity*(*ClientEntityRegistryFn)( void );
|
||||||
|
|
||||||
class CEntityRegistry
|
interface CEntityRegistry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CEntityRegistry( const char *szName, const char *szClass, EntityRegistryFn pfn );
|
CEntityRegistry( const char *szName, const char *szClass, EntityRegistryFn pfn );
|
||||||
@@ -43,7 +46,6 @@ public:
|
|||||||
ClientEntityRegistryFn m_pClientfn;
|
ClientEntityRegistryFn m_pClientfn;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CUtlVector<CEntityRegistry*> g_RegisteredEntities;
|
|
||||||
|
|
||||||
|
|
||||||
#define DECLARE_ENTITY(name, class) \
|
#define DECLARE_ENTITY(name, class) \
|
||||||
@@ -66,9 +68,10 @@ public:
|
|||||||
virtual void Destroy( void ) = 0;
|
virtual void Destroy( void ) = 0;
|
||||||
/* happens every frame instead of tick */
|
/* happens every frame instead of tick */
|
||||||
virtual void Think( float fDelta ) = 0;
|
virtual void Think( float fDelta ) = 0;
|
||||||
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class C_EntityRegistry
|
interface C_EntityRegistry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
C_EntityRegistry( const char *pName, ClientEntityRegistryFn pfn );
|
C_EntityRegistry( const char *pName, ClientEntityRegistryFn pfn );
|
||||||
@@ -82,6 +85,8 @@ C_BaseEntity *__c_entity_alloc_##server() \
|
|||||||
C_EntityRegistry __c_entity_##server##_registry(#server, __c_entity_alloc_##server); \
|
C_EntityRegistry __c_entity_##server##_registry(#server, __c_entity_alloc_##server); \
|
||||||
|
|
||||||
|
|
||||||
|
extern CUtlSelfReferencingVector<CBaseEntity*> g_entities;
|
||||||
|
extern CUtlVector<CEntityRegistry*> g_RegisteredEntities;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef CONSOLE_H
|
#ifndef CONSOLE_H
|
||||||
#define CONSOLE_H
|
#define CONSOLE_H
|
||||||
|
|
||||||
#include "tier0/platform.h"
|
#include "engine.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
|
||||||
class ConVar;
|
class ConVar;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef ENGINE_H
|
#ifndef ENGINE_H
|
||||||
#define ENGINE_H
|
#define ENGINE_H
|
||||||
|
|
||||||
|
/* for windows as it sucks */
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
|
|
||||||
class CBaseEntity;
|
class CBaseEntity;
|
||||||
@@ -17,11 +18,9 @@ public:
|
|||||||
interface IIEngine
|
interface IIEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void PrecacheModel( const char *psz );
|
|
||||||
static void PrecacheSound( const char *psz );
|
|
||||||
|
|
||||||
static CBaseEntity *SpawnEntity( const char *szName );
|
static CBaseEntity *SpawnEntity( const char *szName );
|
||||||
static void DestroyEntity( CBaseEntity *pEntity );
|
static void DestroyEntity( CBaseEntity *pEntity );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier1/utlbuffer.h"
|
#include "tier1/utlbuffer.h"
|
||||||
#include "tier1/utlstring.h"
|
#include "tier1/utlstring.h"
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
enum EFileOptions
|
enum EFileOptions
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef LEVEL_H
|
#ifndef LEVEL_H
|
||||||
#define LEVEL_H
|
#define LEVEL_H
|
||||||
|
|
||||||
#include "tier0/platform.h"
|
#include "engine.h"
|
||||||
|
|
||||||
interface ILevel
|
interface ILevel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ struct px_cast_result px_box_cast(struct funnyphysics *px_world,
|
|||||||
struct px_vec3 vel,
|
struct px_vec3 vel,
|
||||||
float time);
|
float time);
|
||||||
|
|
||||||
|
void px_fixedbody(struct funnyphysics *px_world, Collider *collider);
|
||||||
|
|
||||||
void px_frame(struct funnyphysics *px_world, float delta);
|
void px_frame(struct funnyphysics *px_world, float delta);
|
||||||
|
|
||||||
struct px_matrix px_getmatrix(struct funnyphysics *px_world, RigidBodyHandle *body);
|
struct px_matrix px_getmatrix(struct funnyphysics *px_world, RigidBodyHandle *body);
|
||||||
|
|||||||
@@ -29,20 +29,6 @@ public:
|
|||||||
virtual void Unmap() = 0;
|
virtual void Unmap() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
abstract_class IBrush
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void SetPosition( vec3 position ) = 0;
|
|
||||||
virtual void SetRotationEuler( vec3 angle ) = 0;
|
|
||||||
virtual void SetRotationQuat( vec4 quaternion) = 0;
|
|
||||||
virtual void SetMatrix( mat3 matrix ) = 0;
|
|
||||||
virtual void SetScale( vec3 scale ) = 0;
|
|
||||||
|
|
||||||
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
|
||||||
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
|
||||||
virtual void Draw() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum EMaterialType
|
enum EMaterialType
|
||||||
{
|
{
|
||||||
IMATERIAL_ERROR = 0,
|
IMATERIAL_ERROR = 0,
|
||||||
@@ -82,20 +68,64 @@ public:
|
|||||||
Material_t m;
|
Material_t m;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface IRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
static IVertexBuffer *CreateVertexBuffer( uint32_t uSize );
|
||||||
|
static IIndexBuffer *CreateIndexBuffer( uint32_t uSize );
|
||||||
|
|
||||||
|
static IMaterial *LoadMaterial( const char *szName );
|
||||||
|
static void SetMaterial( IMaterial *pMaterial );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
// Brush handler for the rendering
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
abstract_class IBrush
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
||||||
|
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
||||||
|
virtual void Draw() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
interface IBrushRenderer
|
interface IBrushRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Frame( float fDelta );
|
static void Frame( float fDelta );
|
||||||
|
|
||||||
static IVertexBuffer *CreateVertexBuffer( uint32_t uSize );
|
|
||||||
static IIndexBuffer *CreateIndexBuffer( uint32_t uSize );
|
|
||||||
|
|
||||||
static IBrush *CreateMesh();
|
static IBrush *CreateMesh();
|
||||||
static void Destroy( IBrush *pModel );
|
static void Destroy( IBrush *pModel );
|
||||||
|
};
|
||||||
|
|
||||||
static IMaterial *LoadMaterial( const char *szName );
|
//----------------------------------------------------------------------------
|
||||||
static void SetMaterial( IMaterial *pMaterial );
|
// Mesh handler for the rendering
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
abstract_class IMesh
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void SetPosition( vec3 position ) = 0;
|
||||||
|
virtual void SetRotationEuler( vec3 angle ) = 0;
|
||||||
|
virtual void SetRotationQuat( vec4 quaternion) = 0;
|
||||||
|
virtual void SetMatrix( mat4 matrix ) = 0;
|
||||||
|
virtual void SetScale( vec3 scale ) = 0;
|
||||||
|
|
||||||
|
virtual void SetVertexBuffer( IVertexBuffer *pBuffer ) = 0;
|
||||||
|
virtual void SetIndexBuffer( IIndexBuffer *pBuffer ) = 0;
|
||||||
|
virtual void Draw() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IMeshRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Init();
|
||||||
|
static void Frame( float fDelta );
|
||||||
|
|
||||||
|
static IMesh *CreateMesh();
|
||||||
|
static void Destroy( IBrush *pModel );
|
||||||
};
|
};
|
||||||
|
|
||||||
abstract_class ITexture
|
abstract_class ITexture
|
||||||
|
|||||||
@@ -4,6 +4,16 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#define DLL_EXPORT extern "C" __declspec(dllexport)
|
||||||
|
#define DLL_IMPORT extern "C" __declspec(dllimport)
|
||||||
|
|
||||||
|
#define DLL_CLASS_EXPORT __declspec(dllexport)
|
||||||
|
#define DLL_CLASS_IMPORT __declspec(dllimport)
|
||||||
|
|
||||||
|
#define DLL_GLOBAL_EXPORT extern __declspec(dllexport)
|
||||||
|
#define DLL_GLOBAL_IMPORT extern __declspec(dllimport)
|
||||||
|
#else
|
||||||
#define DLL_EXPORT extern "C" __attribute__ ((visibility("default")))
|
#define DLL_EXPORT extern "C" __attribute__ ((visibility("default")))
|
||||||
#define DLL_IMPORT extern "C"
|
#define DLL_IMPORT extern "C"
|
||||||
|
|
||||||
@@ -12,6 +22,7 @@
|
|||||||
|
|
||||||
#define DLL_GLOBAL_EXPORT extern __attribute ((visibility("default")))
|
#define DLL_GLOBAL_EXPORT extern __attribute ((visibility("default")))
|
||||||
#define DLL_GLOBAL_IMPORT extern
|
#define DLL_GLOBAL_IMPORT extern
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TIER0_STATIC
|
#ifdef TIER0_STATIC
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "god/build.h"
|
||||||
#include "god/c.h"
|
#include "god/c.h"
|
||||||
#include "god/ld.h"
|
#include "god/ld.h"
|
||||||
#include "god/utils.h"
|
#include "god/utils.h"
|
||||||
@@ -9,6 +10,12 @@ void rapier_build(struct build_data b)
|
|||||||
cargo_build.wd = "rapier";
|
cargo_build.wd = "rapier";
|
||||||
run_add_arg(&cargo_build, "build");
|
run_add_arg(&cargo_build, "build");
|
||||||
run_add_arg(&cargo_build, "--release");
|
run_add_arg(&cargo_build, "--release");
|
||||||
|
if (b.kernel == BUILD_KERNEL_LINUX)
|
||||||
|
{
|
||||||
|
run_add_arg(&cargo_build, "--target");
|
||||||
|
run_add_arg(&cargo_build, "x86_64-unknown-linux-gnu");
|
||||||
|
rapierLib = "rapier/target/x86_64-unknown-linux-gnu/release/librapier_rtt.a";
|
||||||
|
}
|
||||||
run_run(&cargo_build);
|
run_run(&cargo_build);
|
||||||
struct run_project cbindgen = run_new("cbindgen");
|
struct run_project cbindgen = run_new("cbindgen");
|
||||||
cbindgen.wd = "rapier";
|
cbindgen.wd = "rapier";
|
||||||
@@ -19,5 +26,4 @@ void rapier_build(struct build_data b)
|
|||||||
run_add_arg(&cbindgen, "--output");
|
run_add_arg(&cbindgen, "--output");
|
||||||
run_add_arg(&cbindgen, "../public/physics_gen.h");
|
run_add_arg(&cbindgen, "../public/physics_gen.h");
|
||||||
run_run(&cbindgen);
|
run_run(&cbindgen);
|
||||||
rapierLib = "rapier/target/release/librapier_rtt.a";
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
rapier/px.rs
13
rapier/px.rs
@@ -49,9 +49,9 @@ pub unsafe extern "C" fn px_frame(px_world: *mut funnyphysics, delta:f32) {
|
|||||||
let gravity = vector![0.0, 0.0, -9.81];
|
let gravity = vector![0.0, 0.0, -9.81];
|
||||||
let mut integration_parameters = IntegrationParameters::default();
|
let mut integration_parameters = IntegrationParameters::default();
|
||||||
integration_parameters.dt=delta;
|
integration_parameters.dt=delta;
|
||||||
integration_parameters.min_island_size=1;
|
integration_parameters.min_island_size=256;
|
||||||
integration_parameters.num_solver_iterations=NonZeroUsize::new(4).unwrap();
|
integration_parameters.num_solver_iterations=NonZeroUsize::new(8).unwrap();
|
||||||
integration_parameters.num_internal_stabilization_iterations=2;
|
integration_parameters.num_internal_stabilization_iterations=4;
|
||||||
let physics_hooks = ();
|
let physics_hooks = ();
|
||||||
let event_handler = ();
|
let event_handler = ();
|
||||||
if let Some(px) = px_world.as_mut() {
|
if let Some(px) = px_world.as_mut() {
|
||||||
@@ -107,6 +107,13 @@ pub unsafe extern "C" fn px_staticbody(px_world: *mut funnyphysics, collider: *m
|
|||||||
Box::into_raw(Box::new(body))
|
Box::into_raw(Box::new(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub unsafe extern "C" fn px_fixedbody(px_world: *mut funnyphysics, collider: *mut Collider) {
|
||||||
|
let c = &mut *collider;
|
||||||
|
let px = px_world.as_mut().unwrap();
|
||||||
|
px.collider_set.insert(c.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct px_matrix {
|
pub struct px_matrix {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
|
#include "god/build.h"
|
||||||
#include "god/c.h"
|
#include "god/c.h"
|
||||||
#include "god/ld.h"
|
#include "god/ld.h"
|
||||||
|
|
||||||
char* tier0_dll = 0;
|
char* tier0_lib = 0;
|
||||||
void tier0_build(struct build_data b)
|
void tier0_build(struct build_data b)
|
||||||
{
|
{
|
||||||
char* files[] = {
|
char* files[] = {
|
||||||
@@ -33,9 +34,9 @@ void tier0_build(struct build_data b)
|
|||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
tier0_dll = ld_link_project(o, (struct link_settings){
|
tier0_lib = ld_link_project(o, (struct link_settings){
|
||||||
.type = LINK_TYPE_DYNAMIC,
|
.type = LINK_TYPE_DYNAMIC,
|
||||||
.libs = libs,
|
.libs = libs,
|
||||||
});
|
});
|
||||||
mv("build/"GAME_NAME"/game/bin/libtier0.so",tier0_dll);
|
mv("build/"GAME_NAME"/game/bin/libtier0.so",tier0_lib);
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,16 @@
|
|||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "sys/stat.h"
|
#include "sys/stat.h"
|
||||||
#include "execinfo.h"
|
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "dlfcn.h"
|
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
#ifdef __linux__
|
||||||
|
#include "dlfcn.h"
|
||||||
|
#include "execinfo.h"
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#include "windows.h"
|
||||||
|
#include "dbghelp.h"
|
||||||
|
#endif
|
||||||
PLATFORM_INTERFACE void Plat_FatalErrorFunc(const char* szFormat, ...)
|
PLATFORM_INTERFACE void Plat_FatalErrorFunc(const char* szFormat, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
@@ -76,6 +81,7 @@ PLATFORM_INTERFACE char *Plat_GetExtension( const char *szPath )
|
|||||||
|
|
||||||
PLATFORM_INTERFACE void Plat_Backtrace( void )
|
PLATFORM_INTERFACE void Plat_Backtrace( void )
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
void *buffer[64];
|
void *buffer[64];
|
||||||
int nptrs = backtrace(buffer, 64);
|
int nptrs = backtrace(buffer, 64);
|
||||||
char **symbols = backtrace_symbols(buffer, nptrs);
|
char **symbols = backtrace_symbols(buffer, nptrs);
|
||||||
@@ -90,22 +96,64 @@ PLATFORM_INTERFACE void Plat_Backtrace( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(symbols);
|
free(symbols);
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
void* buffer[64];
|
||||||
|
USHORT nptrs = CaptureStackBackTrace(0, 64, buffer, NULL);
|
||||||
|
|
||||||
|
HANDLE process = GetCurrentProcess();
|
||||||
|
SymInitialize(process, NULL, TRUE);
|
||||||
|
|
||||||
|
SYMBOL_INFO* symbol = (SYMBOL_INFO*)calloc(sizeof(SYMBOL_INFO) + 256, 1);
|
||||||
|
symbol->MaxNameLen = 255;
|
||||||
|
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||||
|
|
||||||
|
if (!symbol) {
|
||||||
|
V_printf("Backtrace failed\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (USHORT i = 0; i < nptrs; i++) {
|
||||||
|
if (SymFromAddr(process, (DWORD64)(buffer[i]), 0, symbol)) {
|
||||||
|
V_printf(" [%d] %s - 0x%0llX\n", i, symbol->Name, symbol->Address);
|
||||||
|
} else {
|
||||||
|
V_printf(" [%d] ??? - 0x%0llX\n", i, (DWORD64)(buffer[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(symbol);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
PLATFORM_INTERFACE void *Plat_LoadLibrary( const char *psz )
|
PLATFORM_INTERFACE void *Plat_LoadLibrary( const char *psz )
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
void *lib = dlopen(psz, RTLD_GLOBAL | RTLD_NOW);
|
void *lib = dlopen(psz, RTLD_GLOBAL | RTLD_NOW);
|
||||||
if (!lib)
|
if (!lib)
|
||||||
V_printf("Failed to open %s\n\t%s\n", psz, dlerror());
|
V_printf("Failed to open %s\n\t%s\n", psz, dlerror());
|
||||||
return lib;
|
return lib;
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
return LoadLibraryA(psz);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
PLATFORM_INTERFACE void *Plat_GetProc( void *lib, const char *psz )
|
PLATFORM_INTERFACE void *Plat_GetProc( void *lib, const char *psz )
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
return dlsym(lib, psz);
|
return dlsym(lib, psz);
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
return (void*)GetProcAddress((HMODULE)lib, psz);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
PLATFORM_INTERFACE void Plat_UnloadLibrary( void *lib )
|
PLATFORM_INTERFACE void Plat_UnloadLibrary( void *lib )
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
dlclose(lib);
|
dlclose(lib);
|
||||||
|
#endif
|
||||||
|
#ifdef __WIN32__
|
||||||
|
FreeLibrary((HMODULE)lib);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
PLATFORM_INTERFACE double Plat_GetTime( void )
|
PLATFORM_INTERFACE double Plat_GetTime( void )
|
||||||
|
|||||||
Reference in New Issue
Block a user