Skip to content

Commit

Permalink
Merge pull request #64 from brenocq/ui-redesign
Browse files Browse the repository at this point in the history
UI Refactoring
  • Loading branch information
brenocq authored Jan 19, 2025
2 parents 34f5d3f + d1ead43 commit 0507d6f
Show file tree
Hide file tree
Showing 105 changed files with 1,987 additions and 1,487 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install cmake xorg-dev curl
sudo apt-get install cmake xorg-dev curl
- name: Build
run: ./build.sh --jobs 2 --compiler ${{ matrix.config.compiler }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/updateReadmeButtons.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Update readme buttons

on:
on:
project_card:
types: [created, deleted, moved]
project:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- uses: mymindstorm/setup-emsdk@v13

- name: Checkout atta
uses: actions/checkout@v2

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ tags
imgui.ini

# Debugging/Profile
.cache/
perf.*
.gdb_history
profile/
compile_commands.json
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.14)

project(atta VERSION 0.3.1 LANGUAGES CXX C)
project(atta VERSION 0.3.2 LANGUAGES CXX C)

OPTION(ATTA_BUILD_TESTS
"Set to ON to build also the test executables"
Expand All @@ -11,17 +11,18 @@ OPTION(ATTA_WEB_BUILD_MODULE
OPTION(ATTA_BUILD_DOCS
"Build the documentation"
OFF)
option(ATTA_STATIC_PROJECT_FILE
"Project to be linked statically to atta"
option(ATTA_STATIC_PROJECT_FILE
"Project to be linked statically to atta"
"")
option(ATTA_PROFILE
"Set to ON to enable code profiling"
option(ATTA_PROFILE
"Set to ON to enable code profiling"
ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(ATTA_VERSION_SAFE atta-${CMAKE_PROJECT_VERSION})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/atta/cmakeConfig.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/atta/cmakeConfig.h)

Expand Down Expand Up @@ -123,7 +124,7 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND ATTA_OPTIONS -Wno-unused-parameter)
# Script C linkage
list(APPEND ATTA_OPTIONS -Wno-return-type-c-linkage)
# Math anonymous union
# Math anonymous union
#list(APPEND ATTA_OPTIONS -Wno-nested-anon-types -Wno-gnu-anonymous-struct)
# Glad opengl definitions
#list(APPEND ATTA_OPTIONS -Wno-macro-redefined)
Expand Down Expand Up @@ -218,7 +219,7 @@ if(ATTA_STATIC_PROJECT)
endif()

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/atta/script/scripts.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/src/atta/script/scripts.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/src/atta/script/scripts.h"
)

Expand All @@ -236,7 +237,7 @@ if(NOT (ATTA_SYSTEM_NAME MATCHES "Web") AND NOT ATTA_STATIC_PROJECT_FILE)
########## Install files ##########

# Install atta executable
install(TARGETS atta
install(TARGETS atta
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PRIVATE_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ATTA_VERSION_SAFE}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${ATTA_VERSION_SAFE}
Expand Down
22 changes: 22 additions & 0 deletions src/atta/event/events/meshDestroy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//--------------------------------------------------
// Atta Event Module
// meshDestroy.h
// Date: 2024-01-05
// By Breno Cunha Queiroz
//--------------------------------------------------
#ifndef ATTA_EVENT_EVENTS_MESH_DESTROY_H
#define ATTA_EVENT_EVENTS_MESH_DESTROY_H
#include <atta/event/event.h>

namespace atta::event {

class MeshDestroy : public EventTyped<SID("MeshDestroy")> {
public:
MeshDestroy(StringId sid_) : sid(sid_) {}

const StringId sid;
};

} // namespace atta::event

#endif // ATTA_EVENT_EVENTS_MESH_DESTROY_H
1 change: 1 addition & 0 deletions src/atta/file/project/projectSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <atta/resource/resources/mesh.h>

#include <atta/graphics/interface.h>
#include <atta/ui/interface.h>
#include <atta/utils/config.h>

#include <atta/physics/engines/bulletEngine.h>
Expand Down
23 changes: 12 additions & 11 deletions src/atta/file/project/projectSerializerDeserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ void ProjectSerializer::deserializeComponentModule(Section& section) {

void ProjectSerializer::deserializeGraphicsModule(Section& section) {
if (section.contains("viewports")) {
std::vector<graphics::Viewport> viewports = std::vector<graphics::Viewport>(section["viewports"]);
graphics::clearViewports();
for (auto& viewport : viewports) {
std::shared_ptr<graphics::Viewport> v = std::make_shared<graphics::Viewport>();
*v = viewport;
graphics::addViewport(v);
}
std::vector<ui::Viewport> viewports = std::vector<ui::Viewport>(section["viewports"]);
LOG_WARN("file::ProjectSerializer", "Deserializing viewports was not implemented yet");
// ui::clearViewports();
// for (auto& viewport : viewports) {
// std::shared_ptr<ui::Viewport> v = std::make_shared<ui::Viewport>();
// *v = viewport;
// ui::addViewport(v);
// }
}
if (section.contains("graphicsFPS"))
graphics::setGraphicsFPS(float(section["graphicsFPS"]));
if (section.contains("viewportFPS"))
graphics::setViewportFPS(float(section["viewportFPS"]));
if (section.contains("viewportRendering"))
graphics::setViewportRendering(bool(section["viewportRendering"]));
//if (section.contains("viewportFPS"))
// graphics::setViewportFPS(float(section["viewportFPS"]));
//if (section.contains("viewportRendering"))
// graphics::setViewportRendering(bool(section["viewportRendering"]));
}

void ProjectSerializer::deserializeResourceModule(Section& section) {
Expand Down
15 changes: 8 additions & 7 deletions src/atta/file/project/projectSerializerSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ void ProjectSerializer::serializeComponentModule(Section& section) {
}

void ProjectSerializer::serializeGraphicsModule(Section& section) {
std::vector<std::shared_ptr<graphics::Viewport>> pviewports = graphics::getViewports();
std::vector<graphics::Viewport> viewports;
for (auto pv : pviewports)
viewports.push_back(*pv);
section["viewports"] = viewports;
// std::vector<std::shared_ptr<ui::Viewport>> pviewports = ui::getViewports();
// std::vector<ui::Viewport> viewports;
// for (auto& pv : pviewports)
// viewports.push_back(*pv);
// section["viewports"] = viewports;
LOG_WARN("file::ProjectSerializer", "Serializing viewports was not implemented yet");
section["graphicsFPS"] = graphics::getGraphicsFPS();
section["viewportFPS"] = graphics::getViewportFPS();
section["viewportRendering"] = graphics::getViewportRendering();
// section["viewportFPS"] = graphics::getViewportFPS();
// section["viewportRendering"] = graphics::getViewportRendering();
}

void ProjectSerializer::serializeResourceModule(Section& section) {
Expand Down
8 changes: 4 additions & 4 deletions src/atta/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ set(ATTA_GRAPHICS_MODULE_SOURCE

compute/entityClick.cpp

renderers/renderer.cpp
renderers/common/drawerPipeline.cpp
renderers/common/gridPipeline.cpp
renderers/common/selectedPipeline.cpp
renderers/fastRenderer.cpp
renderers/pbrRenderer.cpp
renderers/phongRenderer.cpp
renderers/common/selectedPipeline.cpp
renderers/common/drawerPipeline.cpp
renderers/renderer.cpp

windows/window.cpp
windows/nullWindow.cpp
Expand All @@ -43,7 +44,6 @@ set(ATTA_GRAPHICS_MODULE_SOURCE
renderQueue.cpp
shader.cpp
vertexBuffer.cpp
viewport.cpp
)

if(ATTA_VULKAN_SUPPORT)
Expand Down
13 changes: 6 additions & 7 deletions src/atta/graphics/apis/openGL/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,15 @@ void Framebuffer::bind(bool clear) {
clearColor[i] = (GLint)std::round(_clearColor[i]);
glClearBufferiv(GL_COLOR, 0, clearColor);
}

if (_depthAttachmentIndex != -1 && _stencilAttachmentIndex != -1) {
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_STENCIL_TEST);
glStencilMask(0x00);
} else if (_depthAttachmentIndex != -1) {
if (_depthAttachmentIndex != -1) {
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
}
if (_stencilAttachmentIndex != -1) {
glClear(GL_STENCIL_BUFFER_BIT);
glStencilMask(0x00);
glEnable(GL_STENCIL_TEST);
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/atta/graphics/apis/vulkan/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace atta::graphics::vk {

Instance::Instance() {
Instance::Instance() : _instance(VK_NULL_HANDLE) {
// Application info
VkApplicationInfo appInfo{};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
Expand Down Expand Up @@ -46,7 +46,8 @@ Instance::Instance() {

// Create instance
VkResult result = vkCreateInstance(&createInfo, nullptr, &_instance);
if (result != VK_SUCCESS)
_wasCreated = result == VK_SUCCESS;
if (!_wasCreated)
LOG_ERROR("gfx::vk::Instance", "Failed to create vulkan instance! Code: $0", common::toString(result));
}

Expand All @@ -55,6 +56,8 @@ Instance::~Instance() {
vkDestroyInstance(_instance, nullptr);
}

bool Instance::wasCreated() const { return _wasCreated; }

VkInstance Instance::getHandle() const { return _instance; }

void Instance::printAvailableExtensions() {
Expand Down
3 changes: 3 additions & 0 deletions src/atta/graphics/apis/vulkan/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Instance {
Instance();
~Instance();

bool wasCreated() const;

VkInstance getHandle() const;

private:
Expand All @@ -29,6 +31,7 @@ class Instance {
std::vector<const char*> getEnabledLayers();

VkInstance _instance;
bool _wasCreated;
VkDebugUtilsMessengerEXT debugMessenger;
};

Expand Down
22 changes: 10 additions & 12 deletions src/atta/graphics/apis/vulkan/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,22 @@ Pipeline::Pipeline(const gfx::Pipeline::CreateInfo& info) : gfx::Pipeline(info),
// Color blend
VkPipelineColorBlendAttachmentState colorBlendAttachment{};
colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
colorBlendAttachment.blendEnable = VK_FALSE; // XXX blend is disabled for now
colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD;
colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
colorBlendAttachment.blendEnable = VK_FALSE;
if (gfx::Image::getNumChannels(_framebuffer->getImage(0)->getFormat()) == 4) {
colorBlendAttachment.blendEnable = VK_TRUE;
colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD;
colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
}

VkPipelineColorBlendStateCreateInfo colorBlending{};
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1;
colorBlending.pAttachments = &colorBlendAttachment;
colorBlending.blendConstants[0] = 0.0f;
colorBlending.blendConstants[1] = 0.0f;
colorBlending.blendConstants[2] = 0.0f;
colorBlending.blendConstants[3] = 0.0f;

// Dynamic state
std::vector<VkDynamicState> dynamicStates = {VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR};
Expand Down
5 changes: 5 additions & 0 deletions src/atta/graphics/apis/vulkan/vulkanAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ void VulkanAPI::generateProcessedTexture(GenerateProcessedTextureInfo gptInfo) {

void* VulkanAPI::getImGuiImage(StringId sid) const { return nullptr; }

bool VulkanAPI::isSupported() {
vk::Instance instance;
return instance.wasCreated();
}

std::shared_ptr<vk::Instance> VulkanAPI::getInstance() const { return _instance; }

std::shared_ptr<vk::PhysicalDevice> VulkanAPI::getPhysicalDevice() const { return _physicalDevice; }
Expand Down
2 changes: 2 additions & 0 deletions src/atta/graphics/apis/vulkan/vulkanAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class VulkanAPI final : public GraphicsAPI {

void* getImGuiImage(StringId sid) const override;

static bool isSupported();

std::shared_ptr<vk::Instance> getInstance() const;
std::shared_ptr<vk::PhysicalDevice> getPhysicalDevice() const;
std::shared_ptr<vk::Device> getDevice() const;
Expand Down
Loading

0 comments on commit 0507d6f

Please sign in to comment.