Skip to content

Commit

Permalink
Fix: Implot not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
brenocq committed Aug 14, 2022
1 parent b95b217 commit f883d6a
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 35 deletions.
12 changes: 7 additions & 5 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
SOURCE_PATH="$SCRIPT_PATH/.."
BUILD_PATH="$SOURCE_PATH/build"
CMAKE_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Release"
BUILD_PATH_TYPE=""
BUILD_PATH_SUFIX="release"
BUILD_NAME_PREFIX=""
BUILD_NAME="release"
BUILD_NAME_SUFIX=""
CMAKE_ATTA_STATIC=""
BUILD_TYPE="default"
RUN_AFTER="false"
Expand Down Expand Up @@ -139,7 +140,7 @@ while [[ $# -gt 0 ]]; do
;;
-d|--debug)
CMAKE_BUILD_TYPE="-DCMAKE_BUILD_TYPE=Debug"
BUILD_PATH_SUFIX="debug"
BUILD_NAME="debug"
shift # past argument
;;
-g|--gdb)
Expand All @@ -163,13 +164,14 @@ while [[ $# -gt 0 ]]; do
-t|--type)
BUILD_TYPE="$2"
if [[ "$BUILD_TYPE" != "default" ]]; then
BUILD_PATH_TYPE="$BUILD_TYPE-"
BUILD_NAME_PREFIX="$BUILD_TYPE-"
fi
shift # past argument
shift # past value
;;
-s|--static)
CMAKE_ATTA_STATIC="-DATTA_STATIC_PROJECT_FILE=$2"
BUILD_NAME_SUFIX="-static"
shift # past argument
shift # past value
;;
Expand All @@ -182,7 +184,7 @@ done


# Change to build directory
BUILD_PATH="$BUILD_PATH/$BUILD_PATH_TYPE$BUILD_PATH_SUFIX"
BUILD_PATH="$BUILD_PATH/$BUILD_NAME_PREFIX$BUILD_NAME$BUILD_NAME_SUFIX"
mkdir -p $BUILD_PATH && cd $BUILD_PATH

# Build
Expand Down
8 changes: 8 additions & 0 deletions src/atta/component/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ void Factory::runScripts(float dt) {
//}
}

EntityId Factory::getPrototypeId() const { return _prototypeId; }
EntityId Factory::getFirstCloneId() const { return _firstCloneEid; }
Entity Factory::getFirstClone() const { return Entity{_firstCloneEid}; }
Entity Factory::getLastClone() const { return Entity{_firstCloneEid + static_cast<EntityId>(_maxClones) - 1}; }
uint64_t Factory::getMaxClones() const { return _maxClones; }
uint64_t Factory::getNumClones() const { return _maxClones; }
std::vector<std::pair<ComponentId, uint8_t*>>& Factory::getComponentMemories() { return _componentMemories; }

std::vector<ComponentId> Factory::getComponentsIds() const {
std::vector<ComponentId> components;

Expand Down
12 changes: 7 additions & 5 deletions src/atta/component/factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ class Factory {
T* getComponent(uint64_t cloneId = 0);
void runScripts(float dt);

EntityId getPrototypeId() const { return _prototypeId; }
EntityId getFirstCloneId() const { return _firstCloneEid; }
EntityId getPrototypeId() const;
EntityId getFirstCloneId() const;
std::vector<Entity> getClones() const;
std::vector<EntityId> getCloneIds() const;
uint64_t getMaxClones() const { return _maxClones; }
uint64_t getNumClones() const { return _maxClones; }
std::vector<std::pair<ComponentId, uint8_t*>>& getComponentMemories() { return _componentMemories; }
Entity getFirstClone() const;
Entity getLastClone() const;
uint64_t getMaxClones() const;
uint64_t getNumClones() const;
std::vector<std::pair<ComponentId, uint8_t*>>& getComponentMemories();
std::vector<ComponentId> getComponentsIds() const;
std::vector<uint8_t*> getMemories() const;

Expand Down
6 changes: 2 additions & 4 deletions src/atta/component/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ void Manager::registerComponentImpl(ComponentRegistry* componentRegistry) {
}

if (oldIndex == -1) {
LOG_DEBUG("component::Manager", "Registered component [w]$0[]", componentRegistry->getTypeidName());
componentRegistry->setIndex(_componentRegistries.size());
_componentRegistries.push_back(componentRegistry);

Expand Down Expand Up @@ -309,7 +308,6 @@ void Manager::createComponentPoolsFromRegistered() {
for (auto reg : _componentRegistries) {
// TODO Remove custom component registry when it is not loaded (pointer to random data)
if (!reg->getPoolCreated()) {
LOG_DEBUG("component::Manager", "Create component pool [w]$0[]", reg->getDescription().name);
createComponentPool(reg);
reg->setPoolCreated(true);
}
Expand All @@ -329,8 +327,8 @@ void Manager::createComponentPool(ComponentRegistry* componentRegistry) {

uint8_t* componentMemory = reinterpret_cast<uint8_t*>(_allocator->allocBytes(size, sizeofT));
DASSERT(componentMemory != nullptr, "Could not allocate component system memory for " + name);
LOG_INFO("component::Manager", "Allocated memory for component $0 ($1). $2MB ($5 instances) -> memory space:($3 $4)", name, typeidTName,
maxCount * sizeofT / (1024 * 1024.0f), (void*)(componentMemory), (void*)(componentMemory + maxCount * sizeofT), maxCount);
//LOG_INFO("component::Manager", "Allocated memory for component $0 ($1). $2MB ($5 instances) -> memory space:($3 $4)", name, typeidTName,
// maxCount * sizeofT / (1024 * 1024.0f), (void*)(componentMemory), (void*)(componentMemory + maxCount * sizeofT), maxCount);

// Create pool allocator
memory::registerAllocator(COMPONENT_POOL_SSID_BY_NAME(typeidTName),
Expand Down
20 changes: 14 additions & 6 deletions src/atta/graphics/drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@ Drawer& Drawer::getInstance() {
return drawer;
}

void Drawer::clear() { getInstance().clearImpl(); }
void Drawer::clearImpl() {
_currNumberOfLines = 0;
_currNumberOfPoints = 0;
_linesChanged = false;
_pointsChanged = false;
void Drawer::clear(StringId group) { getInstance().clearImpl(group); }
void Drawer::clearImpl(StringId group) {
if(group == "No group"_sid)
{
_currNumberOfLines = 0;
_currNumberOfPoints = 0;
_linesChanged = false;
_pointsChanged = false;
}
else
{
clearImpl<Line>(group);
clearImpl<Point>(group);
}
}

} // namespace atta::graphics
8 changes: 4 additions & 4 deletions src/atta/graphics/drawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Drawer {
static void add(T obj, StringId group = StringId("No group"));
template <typename T>
static void clear(StringId group = StringId("No group")); // Clear lines or points of specific group
static void clear(); // Clear all lines and points
static void clear(StringId group = StringId("No group")); // Clear specific group or all groups

// Get data
template <typename T>
Expand All @@ -65,10 +65,10 @@ class Drawer {

// Draw 3d objects implementation
template <typename T>
void addImpl(T obj, StringId group = StringId("No group"));
void addImpl(T obj, StringId group);
template <typename T>
void clearImpl(StringId group = StringId("No group"));
void clearImpl();
void clearImpl(StringId group);
void clearImpl(StringId group);

// Get data implementation
template <typename T>
Expand Down
2 changes: 0 additions & 2 deletions src/atta/resource/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ void Manager::loadResourcesRecursively(fs::path directory) {
// Load as meshe
for (auto& extension : meshExtensions)
if (extension == file.extension().string()) {
LOG_DEBUG("resource::Manager", "Resource mesh: [w]$0[]", file.string());
resource::get<Mesh>(file.string());
break;
}
// Load as image
for (auto& extension : imageExtensions)
if (extension == file.extension().string()) {
LOG_DEBUG("resource::Manager", "Resource image: [w]$0[]", file.string());
resource::get<Image>(file.string());
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/atta/script/compilers/linuxCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LinuxCompiler::~LinuxCompiler() {}

void LinuxCompiler::compileAll() {
std::chrono::time_point<std::chrono::system_clock> begin = std::chrono::system_clock::now();
LOG_DEBUG("script::LinuxCompiler", "Compile all targets");
//LOG_DEBUG("script::LinuxCompiler", "Compile all targets");

fs::path projectDir = file::getProject()->getDirectory();
fs::path buildDir = projectDir / "build";
Expand Down Expand Up @@ -54,13 +54,13 @@ void LinuxCompiler::compileAll() {
// Show time
std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
auto micro = std::chrono::duration_cast<std::chrono::microseconds>(end - begin);
LOG_INFO("script::LinuxCompiler", "Time to compile all: $0 ms", micro.count() / 1000.0f);
//LOG_INFO("script::LinuxCompiler", "Time to compile all: $0 ms", micro.count() / 1000.0f);
}

void LinuxCompiler::compileTarget(StringId target) {
std::chrono::time_point<std::chrono::system_clock> begin = std::chrono::system_clock::now();

LOG_DEBUG("script::LinuxCompiler", "Compile target $0", target);
//LOG_DEBUG("script::LinuxCompiler", "Compile target $0", target);
// Check target
if (_targetFiles.find(target) == _targetFiles.end()) {
LOG_WARN("script::LinuxCompiler", "Could not find target $0", target);
Expand Down Expand Up @@ -95,7 +95,7 @@ void LinuxCompiler::compileTarget(StringId target) {
// Show time
std::chrono::time_point<std::chrono::system_clock> end = std::chrono::system_clock::now();
auto micro = std::chrono::duration_cast<std::chrono::microseconds>(end - begin);
LOG_INFO("script::LinuxCompiler", "Time to compile target $1: $0 ms", micro.count() / 1000.0f, target);
//LOG_INFO("script::LinuxCompiler", "Time to compile target $1: $0 ms", micro.count() / 1000.0f, target);
}

void LinuxCompiler::updateTargets() {
Expand Down
2 changes: 1 addition & 1 deletion src/atta/script/linkers/linuxLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void LinuxLinker::linkTarget(StringId target, Script** script, ProjectScript** p
type = "Script " + name;
else
type = "Component";
LOG_INFO("script::LinuxLinker", "Time to link [w]$0[]: $1 ms ($2)", target, micro.count() / 1000.0f, type);
//LOG_INFO("script::LinuxLinker", "Time to link [w]$0[]: $1 ms ($2)", target, micro.count() / 1000.0f, type);
} else {
LOG_WARN("script::LinuxLinker", "Cannot open library $0. Error: $1", lib.filename(), dlerror());
return;
Expand Down
4 changes: 3 additions & 1 deletion src/atta/ui/layers/editor/editorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <atta/script/interface.h>
#include <atta/ui/layers/editor/editorLayer.h>
#include <imgui_internal.h>
#include <implot.h>

#include <atta/ui/layers/editor/moduleWindows/ioModuleWindow.h>
#include <atta/ui/layers/editor/moduleWindows/physicsModuleWindow.h>
Expand All @@ -33,8 +34,9 @@ void EditorLayer::onUIRender() {
_dockSpace.render();

// Demo
// bool demo = true;
bool demo = true;
// ImGui::ShowDemoWindow(&demo);
// ImPlot::ShowDemoWindow(&demo);

// Top interface
_topBar.render();
Expand Down
2 changes: 1 addition & 1 deletion src/atta/ui/layers/editor/windows/logWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
//--------------------------------------------------
#include <atta/ui/layers/editor/windows/logWindow.h>
#include <imgui.h>
#include <implot.h>

namespace atta::ui {

void LogWindow::render() {
ImGui::Begin("Log");
ImGui::Text("Logging not implemented yet");
ImGui::End();
}

Expand Down
4 changes: 2 additions & 2 deletions src/atta/ui/layers/uiLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
// ImGui backends
#include <backends/imgui_impl_glfw.h>
#include <backends/imgui_impl_opengl3.h>
// ImGui window managing
#include <GLFW/glfw3.h>
// ImGuizmo
#include <ImGuizmo.h>
#include <implot.h>

namespace atta::ui {

Expand All @@ -20,6 +19,7 @@ UILayer::UILayer() : graphics::Layer(StringId("GraphicsLayerUI")) {}
void UILayer::onAttach() {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImPlot::CreateContext();

ImGuiIO& io = ImGui::GetIO();
(void)io;
Expand Down

0 comments on commit f883d6a

Please sign in to comment.