Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
/deps
/obj

# ImGUI
imgui.ini

# LaTeX compilation
*-eps-converted-to.pdf
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CPPFLAGS := -Iinclude -std=c++20 -Wall -Wextra -pedantic -Wshadow \
$(shell pkg-config --cflags glm) \
$(shell pkg-config --cflags gl) \
$(shell pkg-config --cflags tinyxml2) \
-Ilib/include
-Ilib/include -Ilib/include/imgui -Ilib/include/imgui/backends
LIBS := -lm \
$(shell pkg-config --libs glfw3) \
$(shell pkg-config --libs glm) \
Expand All @@ -46,13 +46,15 @@ PREFIX ?= $(HOME)/.local

# END OF CONFIGURATION

SOURCES = $(shell find "src" -name '*.cpp' -type f)
OBJECTS = $(patsubst src/%.cpp, $(OBJDIR)/%.o, $(SOURCES))
LIB_SOURCES = $(shell find "lib" -name '*.c' -type f)
LIB_OBJECTS = $(patsubst lib/%.c, $(OBJDIR)/%.o, $(LIB_SOURCES))
HEADERS = $(shell find "include" -name '*.hpp' -type f)
DEPENDS = $(patsubst src/%.cpp, $(DEPDIR)/%.d, $(SOURCES))
REPORTS = $(patsubst reports/%.tex, $(BUILDDIR)/%.pdf, $(shell find reports -name '*.tex' -type f))
SOURCES := $(shell find "src" -name '*.cpp' -type f)
OBJECTS := $(patsubst src/%.cpp, $(OBJDIR)/%.o, $(SOURCES))
HEADERS := $(shell find "include" -name '*.hpp' -type f)
DEPENDS := $(patsubst src/%.cpp, $(DEPDIR)/%.d, $(SOURCES))
REPORTS := $(patsubst reports/%.tex, $(BUILDDIR)/%.pdf, $(shell find reports -name '*.tex' -type f))

LIB_SOURCES := $(shell find "lib" -name '*.c' -or -name '*.cpp' -type f)
LIB_OBJECTS := $(patsubst lib/src/%.c, $(OBJDIR)/lib/%.o, $(LIB_SOURCES))
LIB_OBJECTS := $(patsubst lib/src/%.cpp, $(OBJDIR)/lib/%.o, $(LIB_OBJECTS))

ifeq ($(DEBUG), 1)
CPPFLAGS += $(DEBUG_CPPFLAGS)
Expand Down Expand Up @@ -95,10 +97,14 @@ $(OBJDIR)/%.o: src/%.cpp Makefile
@mkdir -p $$(dirname $@)
$(CPP) -MMD -MF $(patsubst src/%.cpp, $(DEPDIR)/%.d, $<) -c $< -o $@ $(CPPFLAGS)

$(OBJDIR)/%.o: lib/%.c Makefile
$(OBJDIR)/lib/%.o: lib/src/%.c Makefile
@mkdir -p $$(dirname $@)
$(CC) -c $< -o $@ $(CFLAGS)

$(OBJDIR)/lib/%.o: lib/src/%.cpp Makefile
@mkdir -p $$(dirname $@)
$(CPP) -c $< -o $@ $(CPPFLAGS)

$(BUILDDIR)/$(ENGINE_EXENAME) $(BUILDDIR)/$(GENERATOR_EXENAME) $(BUILDDIR)/build_type: \
$(OBJECTS) $(LIB_OBJECTS)
@mkdir -p $(BUILDDIR)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ First, you'll need to install the following dependencies:

Other libraries are already included in this repository:

- [GLAD](https://glad.dav1d.de/).
- [GLAD](https://glad.dav1d.de/);
- [Dear ImGui](https://github.com/ocornut/imgui).

Then, to compile the project, run:

Expand Down
4 changes: 3 additions & 1 deletion include/engine/camera/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class Camera {
float fov,
float nearPlane,
float farPlane);
virtual ~Camera() = default;

virtual void move(MovementDirection direction, float deltaTime) = 0;
virtual void setPosition(const glm::vec3 &pos);

glm::vec3 getPosition() const;
glm::mat4 getCameraMatrix(float aspectRatio) const;
};

Expand Down
1 change: 1 addition & 0 deletions include/engine/camera/FreeCamera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FreeCamera : public Camera {
float _far);

void move(MovementDirection direction, float deltaTime) override;
void setPosition(const glm::vec3 &newPosition) override;
};

}
1 change: 1 addition & 0 deletions include/engine/camera/OrbitalCamera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OrbitalCamera : public Camera {
float _far);

void move(MovementDirection direction, float deltaTime) override;
void setPosition(const glm::vec3 &newPosition) override;
};

}
2 changes: 2 additions & 0 deletions include/engine/window/SceneWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "engine/render/Axis.hpp"
#include "engine/render/RenderPipeline.hpp"
#include "engine/scene/Scene.hpp"
#include "engine/window/UI.hpp"
#include "engine/window/Window.hpp"

namespace engine::window {
Expand All @@ -28,6 +29,7 @@ class SceneWindow : public Window {
render::RenderPipeline pipeline;
scene::Scene scene;
render::Axis xAxis, yAxis, zAxis;
UI _UI;

public:
explicit SceneWindow(const std::string &sceneFile);
Expand Down
38 changes: 38 additions & 0 deletions include/engine/window/UI.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#pragma once
#include <engine/render/RenderPipeline.hpp>
#include <engine/scene/Scene.hpp>
#include <engine/window/Window.hpp>
#include <functional>

namespace engine::window {

class UI {
private:
camera::Camera &camera;
bool showAxes = true;

public:
UI(Window &window, camera::Camera &_camera);
void render();
~UI();

void setShowAxes(bool value);

bool isShowAxesEnabled() const;
};

}
3 changes: 1 addition & 2 deletions include/engine/window/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ class Window {

int getWidth() const;
int getHeight() const;

protected:
GLFWwindow *getHandle();

protected:
virtual void onUpdate(float time, float timeElapsed) = 0;
virtual void onRender() = 0;
virtual void onResize(int _width, int _height) = 0;
Expand Down
66 changes: 66 additions & 0 deletions lib/include/imgui/backends/imgui_impl_glfw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// dear imgui: Platform Backend for GLFW
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)

// Implemented features:
// [X] Platform: Clipboard support.
// [X] Platform: Mouse support. Can discriminate Mouse/TouchScreen/Pen (Windows only).
// [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values are obsolete since 1.87 and not supported since 1.91.5]
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Resizing cursors requires GLFW 3.4+! Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Missing features or Issues:
// [ ] Touch events are only correctly identified as Touch on Windows. This create issues with some interactions. GLFW doesn't provide a way to identify touch inputs from mouse inputs, we cannot call io.AddMouseSourceEvent() to identify the source. We provide a Windows-specific workaround.
// [ ] Missing ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress cursors.

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE

struct GLFWwindow;
struct GLFWmonitor;

// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks);
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();

// Emscripten related initialization phase methods (call after ImGui_ImplGlfw_InitForOpenGL)
#ifdef __EMSCRIPTEN__
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallEmscriptenCallbacks(GLFWwindow* window, const char* canvas_selector);
//static inline void ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback(const char* canvas_selector) { ImGui_ImplGlfw_InstallEmscriptenCallbacks(nullptr, canvas_selector); } } // Renamed in 1.91.0
#endif

// GLFW callbacks install
// - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
IMGUI_IMPL_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
IMGUI_IMPL_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);

// GFLW callbacks options:
// - Set 'chain_for_all_windows=true' to enable chaining callbacks for all windows (including secondary viewports created by backends or by user)
IMGUI_IMPL_API void ImGui_ImplGlfw_SetCallbacksChainForAllWindows(bool chain_for_all_windows);

// GLFW callbacks (individual callbacks to call yourself if you didn't install callbacks)
IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84
IMGUI_IMPL_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);

// GLFW helpers
IMGUI_IMPL_API void ImGui_ImplGlfw_Sleep(int milliseconds);

#endif // #ifndef IMGUI_DISABLE
66 changes: 66 additions & 0 deletions lib/include/imgui/backends/imgui_impl_opengl3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
// - Desktop GL: 2.x 3.x 4.x
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)

// Implemented features:
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
// [x] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset) [Desktop OpenGL only!]

// About WebGL/ES:
// - You need to '#define IMGUI_IMPL_OPENGL_ES2' or '#define IMGUI_IMPL_OPENGL_ES3' to use WebGL or OpenGL ES.
// - This is done automatically on iOS, Android and Emscripten targets.
// - For other targets, the define needs to be visible from the imgui_impl_opengl3.cpp compilation unit. If unsure, define globally or in imconfig.h.

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

// About GLSL version:
// The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.

#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE

// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);

// (Optional) Called by Init/NewFrame/Shutdown
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();

// Configuration flags to add in your imconfig file:
//#define IMGUI_IMPL_OPENGL_ES2 // Enable ES 2 (Auto-detected on Emscripten)
//#define IMGUI_IMPL_OPENGL_ES3 // Enable ES 3 (Auto-detected on iOS/Android)

// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
&& !defined(IMGUI_IMPL_OPENGL_ES3)

// Try to detect GLES on matching platforms
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
#elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
#else
// Otherwise imgui_impl_opengl3_loader.h will be used.
#endif

#endif

#endif // #ifndef IMGUI_DISABLE
Loading