Skip to content

Commit

Permalink
Change group name to CrossVL + win32 build fixes (#48)
Browse files Browse the repository at this point in the history
* Change group name to CrossVL

* Update the project name to CrossVL

* Fix vector type for shaders

* Tabify files

* Fix hello triangle VS input
  • Loading branch information
ArnavMehta3000 authored Aug 24, 2024
1 parent 88a4e28 commit 21b73ad
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
22 changes: 11 additions & 11 deletions Core/Graphics/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
SetVertexShader_OPENGL(shader);
#elif defined (CGL_RHI_METAL)
SetVertexShader_METAL(shader);
SetVertexShader_METAL(shader);
#endif
}

Expand All @@ -116,7 +116,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
SetPixelShader_OPENGL(shader);
#elif defined (CGL_RHI_METAL)
SetPixelShader_METAL(shader);
SetPixelShader_METAL(shader);
#endif
}

Expand All @@ -135,7 +135,7 @@ namespace CGL::Graphics
#if defined(CGL_RHI_OPENGL)
glUseProgram(material.m_id);
#elif defined (CGL_RHI_METAL)
SetRenderPipeline_METAL();
SetRenderPipeline_METAL();
#endif
}

Expand All @@ -147,7 +147,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
SetVertexBuffer_OPENGL(buffer);
#elif defined (CGL_RHI_METAL)
SetVertexBuffer_METAL(buffer);
SetVertexBuffer_METAL(buffer);
#endif
}

Expand All @@ -158,7 +158,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
SetIndexBuffer_OPENGL(buffer);
#elif defined (CGL_RHI_METAL)
SetIndexBuffer_METAL(buffer);
SetIndexBuffer_METAL(buffer);
#endif
}

Expand All @@ -171,7 +171,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
ShaderCompileResult result = CompileVertexShader_OPENGL(source, outShader);
#elif defined (CGL_RHI_METAL)
ShaderCompileResult result = CompileVertexShader_METAL(source, outShader);
ShaderCompileResult result = CompileVertexShader_METAL(source, outShader);
#endif
ShaderCompiler::ReportResult(result, source.Name.data());
return result.Status == ShaderCompileStatus::Success || result.Status == ShaderCompileStatus::HasWarnings;
Expand All @@ -186,7 +186,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
ShaderCompileResult result = CompilePixelShader_OPENGL(source, outShader);
#elif defined (CGL_RHI_METAL)
ShaderCompileResult result = CompilePixelShader_METAL(source, outShader);
ShaderCompileResult result = CompilePixelShader_METAL(source, outShader);
#endif
ShaderCompiler::ReportResult(result, source.Name.data());
return result.Status == ShaderCompileStatus::Success || result.Status == ShaderCompileStatus::HasWarnings;
Expand All @@ -199,7 +199,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
return CreateVertexBuffer_OPENGL(source);
#elif defined (CGL_RHI_METAL)
return CreateVertexBuffer_METAL(source);
return CreateVertexBuffer_METAL(source);
#endif
}

Expand All @@ -210,7 +210,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
return CreateIndexBuffer_OPENGL(source);
#elif defined (CGL_RHI_METAL)
return CreateIndexBuffer_METAL(source);
return CreateIndexBuffer_METAL(source);
#endif
}

Expand Down Expand Up @@ -249,7 +249,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
Draw_OPENGL(vertexCount, startVertex);
#elif defined (CGL_RHI_METAL)
Draw_METAL(vertexCount, startVertex);
Draw_METAL(vertexCount, startVertex);
#endif
}

Expand All @@ -260,7 +260,7 @@ namespace CGL::Graphics
#elif defined(CGL_RHI_OPENGL)
DrawIndexed_OPENGL(indexCount, startIndex, baseVertex);
#elif defined (CGL_RHI_METAL)
DrawIndexed_METAL(indexCount, startIndex, baseVertex);
DrawIndexed_METAL(indexCount, startIndex, baseVertex);
#endif
}
}
24 changes: 12 additions & 12 deletions Core/Graphics/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ namespace CGL::Graphics
void BeginFrame_METAL();
void EndFrame_METAL();
void Resize_METAL(u32 width, u32 height);
void SetRenderPipeline_METAL();
void SetPrimitiveTopology_METAL(PrimitiveType topology);
void SetVertexShader_METAL(const VertexShader& shader);
void SetPixelShader_METAL(const PixelShader& shader);
void SetVertexBuffer_METAL(const VertexBuffer& buffer);
void SetIndexBuffer_METAL(const IndexBuffer& buffer);
ShaderCompileResult CompileVertexShader_METAL(const ShaderSource& source, VertexShader* outShader);
ShaderCompileResult CompilePixelShader_METAL(const ShaderSource& source, PixelShader* outShader);
VertexBuffer CreateVertexBuffer_METAL(const BufferSource& source);
IndexBuffer CreateIndexBuffer_METAL(const BufferSource& source);
void Draw_METAL(u32 vertexCount, u32 startVertex = 0);
void DrawIndexed_METAL(u32 indexCount, u32 startIndex = 0, u32 baseVertex = 0);
void SetRenderPipeline_METAL();
void SetPrimitiveTopology_METAL(PrimitiveType topology);
void SetVertexShader_METAL(const VertexShader& shader);
void SetPixelShader_METAL(const PixelShader& shader);
void SetVertexBuffer_METAL(const VertexBuffer& buffer);
void SetIndexBuffer_METAL(const IndexBuffer& buffer);
ShaderCompileResult CompileVertexShader_METAL(const ShaderSource& source, VertexShader* outShader);
ShaderCompileResult CompilePixelShader_METAL(const ShaderSource& source, PixelShader* outShader);
VertexBuffer CreateVertexBuffer_METAL(const BufferSource& source);
IndexBuffer CreateIndexBuffer_METAL(const BufferSource& source);
void Draw_METAL(u32 vertexCount, u32 startVertex = 0);
void DrawIndexed_METAL(u32 indexCount, u32 startIndex = 0, u32 baseVertex = 0);
METALRendererImpl* GetImpl() const;
#endif

Expand Down
2 changes: 1 addition & 1 deletion Core/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ target("VisualizerCore")

set_default(false)
set_kind("static")
set_group("CrossGL")
set_group("CrossVL")

add_packages("libsdl", "directxmath")
set_options("rhi")
Expand Down
2 changes: 1 addition & 1 deletion Samples/HelloTriangle/Assets/DirectX/HelloTriangleVS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct VS_OUTPUT
VS_OUTPUT main(VS_INPUT input)
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Position = float4(input.Position, 1.0);
output.Position = input.Position;
output.Color = input.Color;
return output;
}
4 changes: 2 additions & 2 deletions Samples/SpinningCube/Assets/DirectX/SpinningCubeVS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cbuffer FrameData : register(b0)

struct VS_INPUT
{
float3 Position : POSITION;
float4 Position : POSITION;
float3 Color : COLOR0;
};

Expand All @@ -21,7 +21,7 @@ VS_OUTPUT main(VS_INPUT input)
{
VS_OUTPUT output = (VS_OUTPUT)0;

output.Position = float4(input.Position, 1.0);
output.Position = input.Position;
output.Position = mul(output.Position, WorldMatrix);
output.Position = mul(output.Position, ViewMatrix);
output.Position = mul(output.Position, ProjMatrix);
Expand Down
16 changes: 8 additions & 8 deletions Samples/SpinningCube/SpinningCube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,42 +70,42 @@ namespace CGL
{
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(-1.0f, 1.0f, -1.0f),
.Position = SM::Vector4(-1.0f, 1.0f, -1.0f, 1.0f),
.Color = SM::Vector4(1.0f, 0.0f, 0.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(1.0f, 1.0f, -1.0f),
.Position = SM::Vector4(1.0f, 1.0f, -1.0f, 1.0f),
.Color = SM::Vector4(0.0f, 1.0f, 0.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(1.0f, 1.0f, 1.0f),
.Position = SM::Vector4(1.0f, 1.0f, 1.0f, 1.0f),
.Color = SM::Vector4(0.0f, 0.0f, 1.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(-1.0f, 1.0f, 1.0f),
.Position = SM::Vector4(-1.0f, 1.0f, 1.0f, 1.0f),
.Color = SM::Vector4(1.0f, 1.0f, 0.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(-1.0f, -1.0f, -1.0f),
.Position = SM::Vector4(-1.0f, -1.0f, -1.0f, 1.0f),
.Color = SM::Vector4(1.0f, 0.0f, 1.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(1.0f, -1.0f, -1.0f),
.Position = SM::Vector4(1.0f, -1.0f, -1.0f, 1.0f),
.Color = SM::Vector4(0.0f, 1.0f, 1.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(1.0f, -1.0f, 1.0f),
.Position = SM::Vector4(1.0f, -1.0f, 1.0f, 1.0f),
.Color = SM::Vector4(1.0f, 0.5f, 0.0f, 1.0f),
},
Graphics::VertexTypes::PositionColor
{
.Position = SM::Vector3(-1.0f, -1.0f, 1.0f),
.Position = SM::Vector4(-1.0f, -1.0f, 1.0f, 1.0f),
.Color = SM::Vector4(0.5f, 0.0f, 0.5f, 1.0f),
},
};
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set_languages("c17", "cxx23")
set_defaultmode("debug")

-- Project name and version
set_project("CrossGLVisualizer")
set_project("CrossVL")
set_version("0.0.1")

-- Enable all warnings and handle them as compilation errors
Expand Down

0 comments on commit 21b73ad

Please sign in to comment.