Made some more engine variables accessible to the console
This commit is contained in:
parent
4433d34e32
commit
05927da1d4
@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD 20)
|
|||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "-D_DEBUG")
|
set(CMAKE_CXX_FLAGS "/O2")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "-D_DEBUG -Wall")
|
set(CMAKE_CXX_FLAGS "-D_DEBUG -Wall")
|
||||||
endif()
|
endif()
|
||||||
@ -43,7 +43,7 @@ foreach(SHADER_SOURCE ${SHADER_SOURCE_FILES})
|
|||||||
set(SPIRV "${CMAKE_SOURCE_DIR}/assets/shaders/bin/${FILE_NAME}.spv")
|
set(SPIRV "${CMAKE_SOURCE_DIR}/assets/shaders/bin/${FILE_NAME}.spv")
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${SPIRV}
|
OUTPUT ${SPIRV}
|
||||||
COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o ${SPIRV} ${SHADER_SOURCE}
|
COMMAND glslc -o ${SPIRV} ${SHADER_SOURCE}
|
||||||
DEPENDS ${SHADER_SOURCE}
|
DEPENDS ${SHADER_SOURCE}
|
||||||
)
|
)
|
||||||
list(APPEND SPIRV_BIN_FILES ${SPIRV})
|
list(APPEND SPIRV_BIN_FILES ${SPIRV})
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
#include <util/log.hpp>
|
#include <util/log.hpp>
|
||||||
|
|
||||||
|
|
||||||
GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& shaders, const vk::Extent2D& extent, const RenderPass& render_pass, vk::ArrayProxy<vk::DescriptorSetLayoutBinding> bindings, const vk::VertexInputBindingDescription& vertex_binding, const std::vector<vk::VertexInputAttributeDescription>& vertex_attrs, enum Type type, bool wireframe)
|
GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& shaders, const vk::Extent2D& extent, const RenderPass& render_pass, vk::ArrayProxy<vk::DescriptorSetLayoutBinding> bindings, const vk::VertexInputBindingDescription& vertex_binding, const std::vector<vk::VertexInputAttributeDescription>& vertex_attrs, enum Type type, bool wireframe, bool culling)
|
||||||
: dev(dev), shaders(shaders), extent(extent), render_pass(render_pass), bindings(bindings), vertex_binding(vertex_binding), vertex_attrs(vertex_attrs), type(type) {
|
: dev(dev), shaders(shaders), extent(extent), render_pass(render_pass), bindings(bindings), vertex_binding(vertex_binding), vertex_attrs(vertex_attrs), type(type) {
|
||||||
/* create layout
|
/* create layout
|
||||||
* Eventually add a graphicspipline constructor that allows specification of layouts etc
|
* Eventually add a graphicspipline constructor that allows specification of layouts etc
|
||||||
@ -106,7 +106,7 @@ GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& sh
|
|||||||
raster_info = vk::PipelineRasterizationStateCreateInfo {
|
raster_info = vk::PipelineRasterizationStateCreateInfo {
|
||||||
.depthClampEnable = vk::False,
|
.depthClampEnable = vk::False,
|
||||||
.polygonMode = (type == eBOX || wireframe) ? vk::PolygonMode::eLine : vk::PolygonMode::eFill,
|
.polygonMode = (type == eBOX || wireframe) ? vk::PolygonMode::eLine : vk::PolygonMode::eFill,
|
||||||
.cullMode = type == eBOX ? vk::CullModeFlagBits::eNone : vk::CullModeFlagBits::eNone,
|
.cullMode = (type == eBOX || !culling) ? vk::CullModeFlagBits::eNone : vk::CullModeFlagBits::eBack,
|
||||||
.frontFace = vk::FrontFace::eCounterClockwise,
|
.frontFace = vk::FrontFace::eCounterClockwise,
|
||||||
.depthBiasEnable = type == eBOX,
|
.depthBiasEnable = type == eBOX,
|
||||||
.depthBiasConstantFactor = 0.01,
|
.depthBiasConstantFactor = 0.01,
|
||||||
@ -235,7 +235,7 @@ void GraphicsPipeline::update(uint32_t binding, const Texture& tex) {
|
|||||||
}, nullptr);
|
}, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsPipeline::rebuild(bool wireframe) {
|
void GraphicsPipeline::rebuild(bool wireframe, bool culling) {
|
||||||
vertex_input_info = vk::PipelineVertexInputStateCreateInfo {
|
vertex_input_info = vk::PipelineVertexInputStateCreateInfo {
|
||||||
.vertexBindingDescriptionCount = static_cast<uint32_t>(vertex_bindings.size()),
|
.vertexBindingDescriptionCount = static_cast<uint32_t>(vertex_bindings.size()),
|
||||||
.pVertexBindingDescriptions = vertex_bindings.data(),
|
.pVertexBindingDescriptions = vertex_bindings.data(),
|
||||||
@ -243,6 +243,7 @@ void GraphicsPipeline::rebuild(bool wireframe) {
|
|||||||
.pVertexAttributeDescriptions = vertex_attrs.data(),
|
.pVertexAttributeDescriptions = vertex_attrs.data(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
raster_info.cullMode = culling ? vk::CullModeFlagBits::eBack : vk::CullModeFlagBits::eNone;
|
||||||
raster_info.polygonMode = wireframe ? vk::PolygonMode::eLine : vk::PolygonMode::eFill;
|
raster_info.polygonMode = wireframe ? vk::PolygonMode::eLine : vk::PolygonMode::eFill;
|
||||||
auto res = dev.createGraphicsPipeline(nullptr, pipeline_info);
|
auto res = dev.createGraphicsPipeline(nullptr, pipeline_info);
|
||||||
if (res.result != vk::Result::eSuccess) {
|
if (res.result != vk::Result::eSuccess) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ struct GraphicsPipeline {
|
|||||||
vk::ArrayProxy<vk::DescriptorSetLayoutBinding> bindings,
|
vk::ArrayProxy<vk::DescriptorSetLayoutBinding> bindings,
|
||||||
const vk::VertexInputBindingDescription& vertex_binding,
|
const vk::VertexInputBindingDescription& vertex_binding,
|
||||||
const std::vector<vk::VertexInputAttributeDescription>& vertex_attrs,
|
const std::vector<vk::VertexInputAttributeDescription>& vertex_attrs,
|
||||||
enum Type type = Type::eVERTEX, bool wireframe = false);
|
enum Type type = Type::eVERTEX, bool wireframe = false, bool culling = true);
|
||||||
|
|
||||||
/* everything needed for recreation */
|
/* everything needed for recreation */
|
||||||
vk::Device dev;
|
vk::Device dev;
|
||||||
@ -76,7 +76,7 @@ struct GraphicsPipeline {
|
|||||||
void update(uint32_t binding, const Texture& tex);
|
void update(uint32_t binding, const Texture& tex);
|
||||||
|
|
||||||
|
|
||||||
void rebuild(bool wireframe);
|
void rebuild(bool wireframe, bool culling);
|
||||||
|
|
||||||
~GraphicsPipeline();
|
~GraphicsPipeline();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -80,6 +80,7 @@ struct Renderer {
|
|||||||
bool show_bboxes = false;
|
bool show_bboxes = false;
|
||||||
bool should_close = false;
|
bool should_close = false;
|
||||||
bool wireframe_mode = false;
|
bool wireframe_mode = false;
|
||||||
|
bool backface_culling = true;
|
||||||
|
|
||||||
size_t n_indices;
|
size_t n_indices;
|
||||||
|
|
||||||
|
|||||||
@ -24,11 +24,11 @@ static csys::ItemLog& operator<<(csys::ItemLog& log, ImVector<float>& vec) {
|
|||||||
return log << vec[vec.size() - 1] << " }";
|
return log << vec[vec.size() - 1] << " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wireframe_setter(bool& v, bool in) {
|
static void pipeline_setter(bool& v, bool in) {
|
||||||
if(v == in)
|
if(v == in)
|
||||||
return;
|
return;
|
||||||
v = in;
|
v = in;
|
||||||
__ren->bsp->pipeline->rebuild(in);
|
__ren->bsp->pipeline->rebuild(__ren->wireframe_mode, __ren->backface_culling);
|
||||||
}
|
}
|
||||||
|
|
||||||
UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
||||||
@ -124,6 +124,7 @@ UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
|||||||
"speed",
|
"speed",
|
||||||
"max_fps",
|
"max_fps",
|
||||||
"wireframe",
|
"wireframe",
|
||||||
|
"backface_culling",
|
||||||
};
|
};
|
||||||
|
|
||||||
for(const auto& name : names)
|
for(const auto& name : names)
|
||||||
@ -136,7 +137,8 @@ UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
|||||||
console->System().RegisterVariable("speed", ren->speed, csys::Arg<float>("value"));
|
console->System().RegisterVariable("speed", ren->speed, csys::Arg<float>("value"));
|
||||||
console->System().RegisterVariable("max_fps", ren->max_fps, csys::Arg<float>("value"));
|
console->System().RegisterVariable("max_fps", ren->max_fps, csys::Arg<float>("value"));
|
||||||
|
|
||||||
console->System().RegisterVariable("wireframe", ren->wireframe_mode, wireframe_setter);
|
console->System().RegisterVariable("wireframe", ren->wireframe_mode, pipeline_setter);
|
||||||
|
console->System().RegisterVariable("backface_culling", ren->backface_culling, pipeline_setter);
|
||||||
|
|
||||||
console->System().Log(csys::ItemType::eINFO) << "Welcome to Pleascach!" << csys::endl;
|
console->System().Log(csys::ItemType::eINFO) << "Welcome to Pleascach!" << csys::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user