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)
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_CXX_FLAGS "-D_DEBUG")
|
||||
set(CMAKE_CXX_FLAGS "/O2")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-D_DEBUG -Wall")
|
||||
endif()
|
||||
@ -43,7 +43,7 @@ foreach(SHADER_SOURCE ${SHADER_SOURCE_FILES})
|
||||
set(SPIRV "${CMAKE_SOURCE_DIR}/assets/shaders/bin/${FILE_NAME}.spv")
|
||||
add_custom_command(
|
||||
OUTPUT ${SPIRV}
|
||||
COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o ${SPIRV} ${SHADER_SOURCE}
|
||||
COMMAND glslc -o ${SPIRV} ${SHADER_SOURCE}
|
||||
DEPENDS ${SHADER_SOURCE}
|
||||
)
|
||||
list(APPEND SPIRV_BIN_FILES ${SPIRV})
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#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) {
|
||||
/* create layout
|
||||
* 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 {
|
||||
.depthClampEnable = vk::False,
|
||||
.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,
|
||||
.depthBiasEnable = type == eBOX,
|
||||
.depthBiasConstantFactor = 0.01,
|
||||
@ -235,7 +235,7 @@ void GraphicsPipeline::update(uint32_t binding, const Texture& tex) {
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
void GraphicsPipeline::rebuild(bool wireframe) {
|
||||
void GraphicsPipeline::rebuild(bool wireframe, bool culling) {
|
||||
vertex_input_info = vk::PipelineVertexInputStateCreateInfo {
|
||||
.vertexBindingDescriptionCount = static_cast<uint32_t>(vertex_bindings.size()),
|
||||
.pVertexBindingDescriptions = vertex_bindings.data(),
|
||||
@ -243,6 +243,7 @@ void GraphicsPipeline::rebuild(bool wireframe) {
|
||||
.pVertexAttributeDescriptions = vertex_attrs.data(),
|
||||
};
|
||||
|
||||
raster_info.cullMode = culling ? vk::CullModeFlagBits::eBack : vk::CullModeFlagBits::eNone;
|
||||
raster_info.polygonMode = wireframe ? vk::PolygonMode::eLine : vk::PolygonMode::eFill;
|
||||
auto res = dev.createGraphicsPipeline(nullptr, pipeline_info);
|
||||
if (res.result != vk::Result::eSuccess) {
|
||||
|
||||
@ -26,7 +26,7 @@ struct GraphicsPipeline {
|
||||
vk::ArrayProxy<vk::DescriptorSetLayoutBinding> bindings,
|
||||
const vk::VertexInputBindingDescription& vertex_binding,
|
||||
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 */
|
||||
vk::Device dev;
|
||||
@ -76,7 +76,7 @@ struct GraphicsPipeline {
|
||||
void update(uint32_t binding, const Texture& tex);
|
||||
|
||||
|
||||
void rebuild(bool wireframe);
|
||||
void rebuild(bool wireframe, bool culling);
|
||||
|
||||
~GraphicsPipeline();
|
||||
};
|
||||
|
||||
@ -80,6 +80,7 @@ struct Renderer {
|
||||
bool show_bboxes = false;
|
||||
bool should_close = false;
|
||||
bool wireframe_mode = false;
|
||||
bool backface_culling = true;
|
||||
|
||||
size_t n_indices;
|
||||
|
||||
|
||||
@ -24,11 +24,11 @@ static csys::ItemLog& operator<<(csys::ItemLog& log, ImVector<float>& vec) {
|
||||
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)
|
||||
return;
|
||||
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) {
|
||||
@ -124,6 +124,7 @@ UI::UI(Renderer* ren) : ren(ren), dev(ren->dev) {
|
||||
"speed",
|
||||
"max_fps",
|
||||
"wireframe",
|
||||
"backface_culling",
|
||||
};
|
||||
|
||||
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("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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user