Skip to content

Commit

Permalink
Finishing some small ToDos
Browse files Browse the repository at this point in the history
  • Loading branch information
drsnuggles8 committed Jul 9, 2023
1 parent 31c1fb0 commit 254435f
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 21 deletions.
21 changes: 20 additions & 1 deletion OloEditor/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "OloEngine/Math/Math.h"
#include "OloEngine/Renderer/Font.h"
#include "OloEngine/Scripting/C#/ScriptEngine.h"
#include "OloEngine/Scene/SceneCamera.h"
#include "OloEngine/Scene/SceneSerializer.h"
#include "OloEngine/Utils/PlatformUtils.h"

Expand Down Expand Up @@ -673,7 +674,25 @@ namespace OloEngine
Renderer2D::DrawCircle(transform, glm::vec4(1, 1, 1, 1), 0.03f);
}

// TODO(olbu): Add outline for camera?
if (selection.HasComponent<CameraComponent>())
{
auto const& cc = selection.GetComponent<CameraComponent>();

if (cc.Camera.GetProjectionType() == SceneCamera::ProjectionType::Orthographic)
{
// For orthographic cameras, we can still use a rectangle as an indicator
glm::mat4 transform = glm::translate(glm::mat4(1.0f), tc.Translation)
* glm::toMat4(glm::quat(tc.Rotation))
* glm::scale(glm::mat4(1.0f), glm::vec3(cc.Camera.GetOrthographicSize(), cc.Camera.GetOrthographicSize(), 1.0f) + glm::vec3(0.03f));
Renderer2D::DrawRect(transform, glm::vec4(1, 1, 1, 1));
}
else if (cc.Camera.GetProjectionType() == SceneCamera::ProjectionType::Perspective)
{
//auto position = glm::vec3(tc.Translation.x, tc.Translation.y, 0.0f);
//auto size = glm::vec2(0.5f); // adjust as needed
// TODO(olbu): Draw the selected camera properly once the Renderer2D can draw triangles/points
}
}
}
}

Expand Down
28 changes: 27 additions & 1 deletion OloEditor/src/Panels/ContentBrowserPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,33 @@ namespace OloEngine
ImGui::SliderFloat("Thumbnail Size", &thumbnailSize, 16, 512);
ImGui::SliderFloat("Padding", &padding, 0, 32);

// TODO(olbu): status bar
// Get the total count of the files in the current directory.
int totalCount = 0;
for (auto& _ : std::filesystem::directory_iterator(m_CurrentDirectory))
{
totalCount++;
}

ImGui::Separator(); // Draw a line to separate the status bar from the rest of the content.

// Change the background color for the status bar.
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.20f, 0.25f, 0.29f, 0.5f));

// Create a child window for the status bar.
ImGui::BeginChild("status_bar", ImVec2(0, ImGui::GetTextLineHeightWithSpacing() + 20), true, 0);

// Change the text color for the status bar.
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(255, 255, 255, 255));

// Add status bar information.
ImGui::Text("Total files: %d", totalCount);
ImGui::SameLine();
ImGui::Text("Current path: %s", m_CurrentDirectory.string().c_str());

// Restore the colors we changed.
ImGui::PopStyleColor(2);

ImGui::EndChild(); // End of child window.
ImGui::End();
}

Expand Down
1 change: 1 addition & 0 deletions OloEngine/src/OloEngine/Renderer/Framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace OloEngine
virtual void ClearAttachment(u32 attachmentIndex, int value) = 0;

[[nodiscard("Store this!")]] virtual u32 GetColorAttachmentRendererID(u32 index) const = 0;
[[nodiscard("Store this!")]] virtual u32 GetDepthAttachmentRendererID() const = 0;

[[nodiscard("Store this!")]] virtual const FramebufferSpecification& GetSpecification() const = 0;

Expand Down
4 changes: 0 additions & 4 deletions OloEngine/src/OloEngine/Renderer/Renderer2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,7 @@ namespace OloEngine
const auto dataSize = static_cast<u32>(reinterpret_cast<u8*>(s_Data.TextVertexBufferPtr) - reinterpret_cast<u8*>(s_Data.TextVertexBufferBase));
VertexData data = { s_Data.TextVertexBufferBase, dataSize };
s_Data.TextVertexBuffer->SetData(data);

// TODO(olbu): Find out wtf this buf is
//auto buf = s_Data.TextVertexBufferBase;
s_Data.FontAtlasTexture->Bind(0);

s_Data.TextShader->Bind();
RenderCommand::DrawIndexed(s_Data.TextVertexArray, s_Data.TextIndexCount);
++s_Data.Stats.DrawCalls;
Expand Down
2 changes: 0 additions & 2 deletions OloEngine/src/OloEngine/Renderer/Renderer2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace OloEngine
static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const glm::vec4& color);
static void DrawQuad(const glm::vec2& position, const glm::vec2& size, const Ref<Texture2D>& texture, f32 tilingFactor = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f));
static void DrawQuad(const glm::vec3& position, const glm::vec2& size, const Ref<Texture2D>& texture, f32 tilingFactor = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f));

static void DrawQuad(const glm::mat4& transform, const glm::vec4& color, int entityID = -1);
static void DrawQuad(const glm::mat4& transform, const Ref<Texture2D>& texture, f32 tilingFactor = 1.0f, const glm::vec4& tintColor = glm::vec4(1.0f), int entityID = -1);

Expand All @@ -42,7 +41,6 @@ namespace OloEngine
static void DrawRect(const glm::vec3& position, const glm::vec2& size, const glm::vec4& color, int entityID = -1);
static void DrawRect(const glm::mat4& transform, const glm::vec4& color, int entityID = -1);


static void DrawSprite(const glm::mat4& transform, SpriteRendererComponent const& src, int entityID);

struct TextParams
Expand Down
6 changes: 1 addition & 5 deletions OloEngine/src/OloEngine/Scene/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,6 @@ namespace OloEngine
RenderScene(camera);
}

// TODO(olbu): Implement these as tests, rest from Renderer2D.cpp too
// Renderer2D::DrawLine(glm::vec3(0.0f), glm::vec3(5.0f), glm::vec4(1, 0, 1, 1));
// Renderer2D::DrawRect(glm::vec3(0.0f), glm::vec2(5.0f), glm::vec4(1, 1, 1, 1));

void Scene::OnViewportResize(const u32 width, const u32 height)
{
if ((m_ViewportWidth == width) && (m_ViewportHeight == height))
Expand Down Expand Up @@ -592,7 +588,7 @@ namespace OloEngine
}

template<>
void Scene::OnComponentAdded<TextComponent>(Entity entity, TextComponent& component)
void Scene::OnComponentAdded<TextComponent>(Entity, TextComponent&)
{
}

Expand Down
8 changes: 2 additions & 6 deletions OloEngine/src/OloEngine/Scripting/C#/ScriptGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ namespace OloEngine

static void NativeLog_Vector(glm::vec3 const* parameter, glm::vec3* outResult)
{
// TODO(olbu): Fix the logger, glm::vec3* is not valid type, need to provide a formatter<T> specialization
//https://fmt.dev/latest/api.html#udt
//OLO_CORE_WARN("Value: {0}", *parameter);
OLO_CORE_WARN("Value: {0}", *parameter);
*outResult = glm::normalize(*parameter);
}

[[nodiscard("Store this!")]] static f32 NativeLog_VectorDot(glm::vec3 const* parameter)
{
// TODO(olbu): Fix the logger, glm::vec3* is not valid type, need to provide a formatter<T> specialization
//https://fmt.dev/latest/api.html#udt
//OLO_CORE_WARN("Value: {0}", *parameter);
OLO_CORE_WARN("Value: {0}", *parameter);
return glm::dot(*parameter, *parameter);
}

Expand Down
2 changes: 1 addition & 1 deletion OloEngine/src/Platform/OpenGL/OpenGLFramebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace OloEngine
void ClearAttachment(u32 attachmentIndex, int value) override;

[[nodiscard("Store this!")]] u32 GetColorAttachmentRendererID(const u32 index) const override { OLO_CORE_ASSERT(index < m_ColorAttachments.size()); return m_ColorAttachments[index]; }
// TODO(olbu): Add GetDepthAttachmentRendererID
[[nodiscard]] u32 GetDepthAttachmentRendererID() const override { return m_DepthAttachment; }
[[nodiscard("Store this!")]] const FramebufferSpecification& GetSpecification() const override { return m_Specification; }
private:
u32 m_RendererID = 0;
Expand Down
9 changes: 8 additions & 1 deletion OloEngine/src/Platform/OpenGL/OpenGLShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ namespace OloEngine

[[nodiscard("Store this!")]] static const char* GetCacheDirectory()
{
// TODO(olbu): make sure the assets directory is valid
const std::filesystem::path assetsDirectory = "assets";
if (!std::filesystem::exists(assetsDirectory))
{
OLO_CORE_ERROR("The assets directory does not exist.");
return nullptr; // Or return some default path.
}

return "assets/cache/shader/opengl";
}


static void CreateCacheDirectoryIfNeeded()
{
const std::filesystem::path cacheDirectory = GetCacheDirectory();
Expand Down

0 comments on commit 254435f

Please sign in to comment.