brought back functionality from previous builds but now cross-platform

This commit is contained in:
2025-07-07 15:34:34 +03:00
parent 99eafb9443
commit 83bc9b7f16
61 changed files with 1210 additions and 581 deletions

View File

@@ -1,5 +1,6 @@
#include "brush.h"
#include "baseentity.h"
#include "cglm/mat4.h"
#include "physics.h"
#include "rendering.h"
#include "tier0/platform.h"
@@ -7,6 +8,8 @@
#include "tier1/utlvector.h"
#include "math3d.h"
CUtlVector<IVertexBuffer*> g_BrushVertices;
void CBrushEntity::Precache()
{
@@ -66,9 +69,9 @@ void C_BrushEntity::Spawn()
};
CBrushEntity* pBrushEntity = (CBrushEntity*)pEntity;
uint32_t numVertices = 15*pBrushEntity->m_mesh.GetSize();
uint32_t numVertices = pBrushEntity->m_mesh.GetSize();
vertexBuffer = IRenderer::CreateVertexBuffer(numVertices*4);
vertexBuffer = IRenderer::CreateVertexBuffer(numVertices*60);
Vertex_t *pTriangles = (Vertex_t*)vertexBuffer->Map();
uint32_t i = 0;
@@ -100,15 +103,7 @@ void C_BrushEntity::Destroy()
}
void C_BrushEntity::Think( float fDelta )
{
mat4 matrix;
glm_mat4_zero(matrix);
for (int i = 0; i < 9; i++) {
matrix[i/3][i%3] = pEntity->m_matrix[i/3][i%3];
}
matrix[3][3] = 1;
matrix[3][0] = pEntity->m_position[0];
matrix[3][1] = pEntity->m_position[1];
matrix[3][2] = pEntity->m_position[2];
g_BrushVertices.AppendTail(vertexBuffer);
};
IGraphicsPipeline *g_BrushPipeline;
@@ -123,33 +118,47 @@ private:
};
DECLARE_MESH_RENDERING_STAGE(CBrushRendering, brush_rasterizer);
CUtlVector<IVertexBuffer*> g_BrushVertices;
ITexture *bricks;
void CBrushRendering::Init()
{
V_printf("cool\n");
IRenderer::CreateGraphicsPipeline(
{
{"shaders/brush_vert.spv", SHADER_TYPE_VERTEX},
{"shaders/brush_frag.spv", SHADER_TYPE_FRAGMENT},
},
{}, 64,
20,
{{0,0,EVertexFormat::VERTEX_FORMAT_X32Y32Z32}, {12,1,EVertexFormat::VERTEX_FORMAT_X32Y32}},
{EImageFormat::IMAGE_FORMAT_R8G8B8A8}
);
g_BrushPipeline = IRenderer::CreateGraphicsPipeline(
{
{"gfx/mesh_vert.shader", SHADER_TYPE_VERTEX},
{"gfx/mesh_frag.shader", SHADER_TYPE_FRAGMENT},
},
{
{SHADER_INPUT_TYPE_UNIFORM_BUFFER,0},
{SHADER_INPUT_TYPE_TEXTURES,1},
},
80,
20,
{{0,0,EVertexFormat::VERTEX_FORMAT_X32Y32Z32}, {12,1,EVertexFormat::VERTEX_FORMAT_X32Y32}},
{EImageFormat::IMAGE_FORMAT_R8G8B8A8},
true
);
bricks = ITextureManager::LoadTexture("textures/bricks.png");
};
void CBrushRendering::Frame( float fDelta )
{
V_printf("cooll\n");
IRenderer::ResetState();
IRenderer::SetDepthMode(DEPTH_MODE_LESS_EQUAL);
IRenderer::BindPipeline(g_BrushPipeline);
for (auto &vertices: g_BrushVertices)
struct {
mat4 i;
uint32_t a = ITextureManager::GetTextureID(bricks);
uint32_t b = 0;
uint32_t c = 0;
} constants;
glm_mat4_identity(constants.i);
IRenderer::SetConstants(sizeof(constants), &constants);
IRenderer::BindData(0, IRenderer::GetCameraMatrix(), 0);
IRenderer::PushBindings();
for (auto &v: g_BrushVertices)
{
IRenderer::Draw(vertices, 0);
IRenderer::Draw(v, 0);
}
g_BrushVertices = {};
};
void CBrushRendering::Deinit()