diff --git a/Sandbox/src/Sandbox2D.cpp b/Sandbox/src/Sandbox2D.cpp index f81dacca..2c755bfa 100644 --- a/Sandbox/src/Sandbox2D.cpp +++ b/Sandbox/src/Sandbox2D.cpp @@ -1,6 +1,6 @@ #include "Sandbox2D.h" -#include "imgui/imgui.h" +#include #include #include diff --git a/Sandbox/src/SandboxApp.cpp b/Sandbox/src/SandboxApp.cpp index 39dc10aa..8ae03ecf 100644 --- a/Sandbox/src/SandboxApp.cpp +++ b/Sandbox/src/SandboxApp.cpp @@ -1,15 +1,12 @@ #include #include -#include "Platform/OpenGL/OpenGLShader.h" +#include "StarStudio/Renderer/OrthographicCameraController.h" +#include "Sandbox2D.h" -#include "imgui/imgui.h" +#include #include - -#include "Sandbox2D.h" - -#include "StarStudio/Renderer/OrthographicCameraController.h" #include "glm/gtc/type_ptr.hpp" class ExampleLayer : public StarStudio::Layer @@ -26,8 +23,7 @@ class ExampleLayer : public StarStudio::Layer 0.0f, 0.5f, 0.0f, 0.8f, 0.8f, 0.2f, 1.0f }; - StarStudio::Ref vertexBuffer; - vertexBuffer.reset(StarStudio::VertexBuffer::Create(vertices, sizeof(vertices))); + StarStudio::Ref vertexBuffer = StarStudio::VertexBuffer::Create(vertices, sizeof(vertices)); StarStudio::BufferLayout layout = { { StarStudio::ShaderDataType::Float3, "a_Position" }, { StarStudio::ShaderDataType::Float4, "a_Color" } @@ -36,8 +32,7 @@ class ExampleLayer : public StarStudio::Layer m_VertexArray->AddVertexBuffer(vertexBuffer); uint32_t indices[3] = { 0, 1, 2 }; - StarStudio::Ref indexBuffer; - indexBuffer.reset(StarStudio::IndexBuffer::Create(indices, sizeof(indices) / sizeof(uint32_t))); + StarStudio::Ref indexBuffer = StarStudio::IndexBuffer::Create(indices, sizeof(indices) / sizeof(uint32_t)); m_VertexArray->SetIndexBuffer(indexBuffer); m_SquareVA = StarStudio::VertexArray::Create(); @@ -49,8 +44,7 @@ class ExampleLayer : public StarStudio::Layer -0.5f, 0.5f, 0.0f ,0.0f, 1.0f }; - StarStudio::Ref squareVB; - squareVB.reset(StarStudio::VertexBuffer::Create(squareVertices, sizeof(squareVertices))); + StarStudio::Ref squareVB = StarStudio::VertexBuffer::Create(squareVertices, sizeof(squareVertices)); squareVB->SetLayout({ { StarStudio::ShaderDataType::Float3, "a_Position" }, { StarStudio::ShaderDataType::Float2, "a_TexCoord" } @@ -58,8 +52,7 @@ class ExampleLayer : public StarStudio::Layer m_SquareVA->AddVertexBuffer(squareVB); uint32_t squareIndices[6] = { 0, 1, 2, 2, 3, 0 }; - StarStudio::Ref squareIB; - squareIB.reset(StarStudio::IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(uint32_t))); + StarStudio::Ref squareIB = StarStudio::IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(uint32_t)); m_SquareVA->SetIndexBuffer(squareIB); std::string vertexSrc = R"( @@ -137,8 +130,8 @@ class ExampleLayer : public StarStudio::Layer m_Texture = StarStudio::Texture2D::Create("assets/textures/Checkerboard.png"); m_starLogTexture = StarStudio::Texture2D::Create("assets/textures/starLogo.png"); - std::dynamic_pointer_cast(textureShader)->Bind(); - std::dynamic_pointer_cast(textureShader)->UploadUniformInt("u_Texture", 0); + textureShader->Bind(); + textureShader->SetInt("u_Texture", 0); } @@ -155,8 +148,8 @@ class ExampleLayer : public StarStudio::Layer glm::mat4 scale = glm::scale(glm::mat4(1.0f), glm::vec3(0.1f)); - std::dynamic_pointer_cast(m_FlatColorShader)->Bind(); - std::dynamic_pointer_cast(m_FlatColorShader)->UploadUniformFloat3("u_Color", m_SquareColor); + m_FlatColorShader->Bind(); + m_FlatColorShader->SetFloat3("u_Color", m_SquareColor); /*for (int y = 0; y < 20; y++) { diff --git a/StarStudio/src/Platform/OpenGL/OpenGLBuffer.cpp b/StarStudio/src/Platform/OpenGL/OpenGLBuffer.cpp index b433181e..dd7c9821 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLBuffer.cpp +++ b/StarStudio/src/Platform/OpenGL/OpenGLBuffer.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OpenGLBuffer.h" +#include "Platform/OpenGL/OpenGLBuffer.h" #include diff --git a/StarStudio/src/Platform/OpenGL/OpenGLContext.cpp b/StarStudio/src/Platform/OpenGL/OpenGLContext.cpp index 6f1466ab..49d412a3 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLContext.cpp +++ b/StarStudio/src/Platform/OpenGL/OpenGLContext.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OpenGLContext.h" +#include "Platform/OpenGL/OpenGLContext.h" #include #include diff --git a/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.cpp b/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.cpp index 0126dcc7..294d3ca6 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.cpp +++ b/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OpenGLRendererAPI.h" +#include "Platform/OpenGL/OpenGLRendererAPI.h" #include diff --git a/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.h b/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.h index 7226160f..bb74f154 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.h +++ b/StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.h @@ -1,6 +1,5 @@ #pragma once - #include "StarStudio/Renderer/RendererAPI.h" namespace StarStudio diff --git a/StarStudio/src/Platform/OpenGL/OpenGLShader.cpp b/StarStudio/src/Platform/OpenGL/OpenGLShader.cpp index 7173a380..58709ce3 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLShader.cpp +++ b/StarStudio/src/Platform/OpenGL/OpenGLShader.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OpenGLShader.h" +#include "Platform/OpenGL/OpenGLShader.h" #include #include @@ -53,11 +53,18 @@ namespace StarStudio { if (in) { in.seekg(0, std::ios::end); - result.resize(in.tellg()); - in.seekg(0, std::ios::beg); - in.read(&result[0], result.size()); - in.close(); - ; + size_t size = in.tellg(); + if (size != -1) + { + result.resize(size); + in.seekg(0, std::ios::beg); + in.read(&result[0], size); + in.close(); + } + else + { + SS_CORE_ERROR("Could not read from file '{0}'", filepath); + } } else { diff --git a/StarStudio/src/Platform/OpenGL/OpenGLTexture.cpp b/StarStudio/src/Platform/OpenGL/OpenGLTexture.cpp index 725f34fc..7c1a3875 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLTexture.cpp +++ b/StarStudio/src/Platform/OpenGL/OpenGLTexture.cpp @@ -1,7 +1,7 @@ #include "sspch.h" -#include "OpenGLTexture.h" +#include "Platform/OpenGL/OpenGLTexture.h" -#include "stb_image.h" +#include namespace StarStudio { diff --git a/StarStudio/src/Platform/OpenGL/OpenGLVertexArray.cpp b/StarStudio/src/Platform/OpenGL/OpenGLVertexArray.cpp index 8c15b86f..ed0855f4 100644 --- a/StarStudio/src/Platform/OpenGL/OpenGLVertexArray.cpp +++ b/StarStudio/src/Platform/OpenGL/OpenGLVertexArray.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OpenGLVertexArray.h" +#include "Platform/OpenGL/OpenGLVertexArray.h" #include diff --git a/StarStudio/src/Platform/Windows/WindowsInput.cpp b/StarStudio/src/Platform/Windows/WindowsInput.cpp index e7b340e8..0ad913f5 100644 --- a/StarStudio/src/Platform/Windows/WindowsInput.cpp +++ b/StarStudio/src/Platform/Windows/WindowsInput.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "WindowsInput.h" +#include "Platform/Windows/WindowsInput.h" #include "StarStudio/Core/Application.h" #include diff --git a/StarStudio/src/Platform/Windows/WindowsWindow.cpp b/StarStudio/src/Platform/Windows/WindowsWindow.cpp index 6428467c..a6203442 100644 --- a/StarStudio/src/Platform/Windows/WindowsWindow.cpp +++ b/StarStudio/src/Platform/Windows/WindowsWindow.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "WindowsWindow.h" +#include "Platform/Windows/WindowsWindow.h" #include "StarStudio/Events/ApplicationEvent.h" #include "StarStudio/Events/MouseEvent.h" @@ -16,9 +16,9 @@ namespace StarStudio { SS_CORE_ERROR("GLFW Error ({0}): {1}", error, description); } - Window* Window::Create(const WindowProps& props) + Scope Window::Create(const WindowProps& props) { - return new WindowsWindow(props); + return CreateScope(props); } WindowsWindow::WindowsWindow(const WindowProps& props) @@ -41,7 +41,6 @@ namespace StarStudio { if (s_GLFWWindowCount == 0) { - SS_CORE_INFO("Initializing GLFW"); int success = glfwInit(); SS_CORE_ASSERT(success, "Could not intialize GLFW!"); glfwSetErrorCallback(GLFWErrorCallback); @@ -50,7 +49,7 @@ namespace StarStudio { m_Window = glfwCreateWindow((int)props.Width, (int)props.Height, m_Data.Title.c_str(), nullptr, nullptr); ++s_GLFWWindowCount; - m_Context = CreateScope(m_Window); + m_Context = GraphicsContext::Create(m_Window); m_Context->Init(); glfwSetWindowUserPointer(m_Window, &m_Data); @@ -146,10 +145,10 @@ namespace StarStudio { void WindowsWindow::Shutdown() { glfwDestroyWindow(m_Window); + --s_GLFWWindowCount; - if (--s_GLFWWindowCount == 0) + if (s_GLFWWindowCount == 0) { - SS_CORE_INFO("Terminating GLFW"); glfwTerminate(); } } diff --git a/StarStudio/src/StarStudio/Core/Application.cpp b/StarStudio/src/StarStudio/Core/Application.cpp index 386349a0..c866726a 100644 --- a/StarStudio/src/StarStudio/Core/Application.cpp +++ b/StarStudio/src/StarStudio/Core/Application.cpp @@ -1,16 +1,14 @@ #include "sspch.h" -#include "Application.h" +#include "StarStudio/Core/Application.h" #include "StarStudio/Core/Log.h" -#include "Input.h" +#include "StarStudio/Core/Input.h" #include "StarStudio/Renderer/Renderer.h" #include namespace StarStudio - -#define BIND_EVENT_FN(x) std::bind(&Application::x, this, std::placeholders::_1) { Application* Application::s_Instance = nullptr; @@ -19,15 +17,19 @@ namespace StarStudio SS_CORE_ASSERT(!s_Instance, "Application already exists!"); s_Instance = this; - m_Window = std::unique_ptr(Window::Create()); - m_Window->SetEventCallback(BIND_EVENT_FN(OnEvent)); - + m_Window = Window::Create(); + m_Window->SetEventCallback(SS_BIND_EVENT_FN(Application::OnEvent)); Renderer::Init(); m_ImGuiLayer = new ImGuiLayer(); PushOverlay(m_ImGuiLayer); } + Application::~Application() + { + Renderer::Shutdown(); + } + void Application::PushLayer(Layer* layer) { m_LayerStack.PushLayer(layer); @@ -41,8 +43,8 @@ namespace StarStudio void Application::OnEvent(Event& e) { EventDispatcher dispatcher(e); - dispatcher.Dispatch(BIND_EVENT_FN(OnWindowClose)); - dispatcher.Dispatch(BIND_EVENT_FN(OnWindowResize)); + dispatcher.Dispatch(SS_BIND_EVENT_FN(Application::OnWindowResize)); + dispatcher.Dispatch(SS_BIND_EVENT_FN(Application::OnWindowResize)); for (auto it = m_LayerStack.end(); it != m_LayerStack.begin(); ) { diff --git a/StarStudio/src/StarStudio/Core/Application.h b/StarStudio/src/StarStudio/Core/Application.h index 35c62642..3f9d31ef 100644 --- a/StarStudio/src/StarStudio/Core/Application.h +++ b/StarStudio/src/StarStudio/Core/Application.h @@ -1,8 +1,8 @@ #pragma once -#include "Core.h" +#include "StarStudio/Core/Core.h" -#include "Window.h" +#include "StarStudio/Core/Window.h" #include "StarStudio/Core/LayerStack.h" #include "StarStudio/Events/Event.h" #include "StarStudio/Events/ApplicationEvent.h" @@ -17,7 +17,7 @@ namespace StarStudio { public: Application(); - virtual ~Application() = default; + virtual ~Application(); void Run(); diff --git a/StarStudio/src/StarStudio/Core/Core.h b/StarStudio/src/StarStudio/Core/Core.h index d4d100ac..355588bb 100644 --- a/StarStudio/src/StarStudio/Core/Core.h +++ b/StarStudio/src/StarStudio/Core/Core.h @@ -43,22 +43,6 @@ #error "Unknown platform!" #endif // End of platform detection - -// DLL support -#ifdef SS_PLATFORM_WINDOWS -#if SS_DYNAMIC_LINK -#ifdef SS_BUILD_DLL -#define STARSTUDIO_API __declspec(dllexport) -#else -#define STARSTUDIO_API __declspec(dllimport) -#endif -#else -#define STARSTUDIO_API -#endif -#else -#error StarStudio only supports Windows! -#endif // End of DLL support - #ifdef SS_DEBUG #define SS_ENABLE_ASSERTS #endif diff --git a/StarStudio/src/StarStudio/Core/EntryPoint.h b/StarStudio/src/StarStudio/Core/EntryPoint.h index 77b6044d..ca5f20e6 100644 --- a/StarStudio/src/StarStudio/Core/EntryPoint.h +++ b/StarStudio/src/StarStudio/Core/EntryPoint.h @@ -1,4 +1,5 @@ #pragma once +#include "StarStudio/Core/Core.h" #ifdef SS_PLATFORM_WINDOWS diff --git a/StarStudio/src/StarStudio/Core/Input.h b/StarStudio/src/StarStudio/Core/Input.h index 21bbdc5f..e16575a6 100644 --- a/StarStudio/src/StarStudio/Core/Input.h +++ b/StarStudio/src/StarStudio/Core/Input.h @@ -4,7 +4,7 @@ namespace StarStudio { - class STARSTUDIO_API Input + class Input { protected: Input() = default; diff --git a/StarStudio/src/StarStudio/Core/Layer.cpp b/StarStudio/src/StarStudio/Core/Layer.cpp index 38ac5cb5..ab21d8e1 100644 --- a/StarStudio/src/StarStudio/Core/Layer.cpp +++ b/StarStudio/src/StarStudio/Core/Layer.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "Layer.h" +#include "StarStudio/Core/Layer.h" namespace StarStudio { diff --git a/StarStudio/src/StarStudio/Core/Layer.h b/StarStudio/src/StarStudio/Core/Layer.h index c1054ab9..1f0cfa78 100644 --- a/StarStudio/src/StarStudio/Core/Layer.h +++ b/StarStudio/src/StarStudio/Core/Layer.h @@ -6,7 +6,7 @@ namespace StarStudio { - class STARSTUDIO_API Layer + class Layer { public: Layer(const std::string& name = "Layer"); diff --git a/StarStudio/src/StarStudio/Core/LayerStack.cpp b/StarStudio/src/StarStudio/Core/LayerStack.cpp index c8618fa2..8d66e00b 100644 --- a/StarStudio/src/StarStudio/Core/LayerStack.cpp +++ b/StarStudio/src/StarStudio/Core/LayerStack.cpp @@ -1,13 +1,8 @@ #include "sspch.h" -#include "LayerStack.h" +#include "StarStudio/Core/LayerStack.h" namespace StarStudio { - LayerStack::LayerStack() - { - - } - LayerStack::~LayerStack() { for (Layer* layer : m_Layers) diff --git a/StarStudio/src/StarStudio/Core/LayerStack.h b/StarStudio/src/StarStudio/Core/LayerStack.h index dfcac95f..11780afe 100644 --- a/StarStudio/src/StarStudio/Core/LayerStack.h +++ b/StarStudio/src/StarStudio/Core/LayerStack.h @@ -1,14 +1,14 @@ #pragma once #include "StarStudio/Core/Core.h" -#include "Layer.h" +#include "StarStudio/Core/Layer.h" #include namespace StarStudio { - class STARSTUDIO_API LayerStack + class LayerStack { public: - LayerStack(); + LayerStack() = default; ~LayerStack(); void PushLayer(Layer* layer); diff --git a/StarStudio/src/StarStudio/Core/Log.cpp b/StarStudio/src/StarStudio/Core/Log.cpp index fff5a19f..79d1a31f 100644 --- a/StarStudio/src/StarStudio/Core/Log.cpp +++ b/StarStudio/src/StarStudio/Core/Log.cpp @@ -1,7 +1,7 @@ #include "sspch.h" -#include "Log.h" -#include "spdlog/sinks/stdout_color_sinks.h" +#include "StarStudio/Core/Log.h" +#include namespace StarStudio { diff --git a/StarStudio/src/StarStudio/Core/Log.h b/StarStudio/src/StarStudio/Core/Log.h index d220b702..7cdf0a42 100644 --- a/StarStudio/src/StarStudio/Core/Log.h +++ b/StarStudio/src/StarStudio/Core/Log.h @@ -1,12 +1,13 @@ #pragma once -#include "Core.h" +#include "StarStudio/Core/Core.h" + #include "spdlog/spdlog.h" #include "spdlog/fmt/ostr.h" namespace StarStudio { - class STARSTUDIO_API Log + class Log { public: static void Init(); diff --git a/StarStudio/src/StarStudio/Core/Window.h b/StarStudio/src/StarStudio/Core/Window.h index 3e4dbc99..2e4311e1 100644 --- a/StarStudio/src/StarStudio/Core/Window.h +++ b/StarStudio/src/StarStudio/Core/Window.h @@ -22,7 +22,7 @@ namespace StarStudio { }; // Interface representing a desktop system based Window - class STARSTUDIO_API Window + class Window { public: using EventCallbackFn = std::function; @@ -41,7 +41,7 @@ namespace StarStudio { virtual void* GetNativeWindow() const = 0; - static Window* Create(const WindowProps& props = WindowProps()); + static Scope Create(const WindowProps& props = WindowProps()); }; } \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Events/ApplicationEvent.h b/StarStudio/src/StarStudio/Events/ApplicationEvent.h index f1f18b0f..83ce1e48 100644 --- a/StarStudio/src/StarStudio/Events/ApplicationEvent.h +++ b/StarStudio/src/StarStudio/Events/ApplicationEvent.h @@ -1,9 +1,9 @@ #pragma once -#include "Event.h" +#include "StarStudio/Events/Event.h" namespace StarStudio { - class STARSTUDIO_API WindowResizeEvent : public Event + class WindowResizeEvent : public Event { public: WindowResizeEvent(unsigned int width, unsigned int height) @@ -27,37 +27,37 @@ namespace StarStudio { unsigned int m_Width, m_Height; }; - class STARSTUDIO_API WindowCloseEvent : public Event + class WindowCloseEvent : public Event { public: - WindowCloseEvent() {} + WindowCloseEvent() = default; EVENT_CLASS_TYPE(WindowClose) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; - class STARSTUDIO_API AppTickEvent : public Event + class AppTickEvent : public Event { public: - AppTickEvent() {} + AppTickEvent() = default; EVENT_CLASS_TYPE(AppTick) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; - class STARSTUDIO_API AppUpdateEvent : public Event + class AppUpdateEvent : public Event { public: - AppUpdateEvent() {} + AppUpdateEvent() = default; EVENT_CLASS_TYPE(AppUpdate) EVENT_CLASS_CATEGORY(EventCategoryApplication) }; - class STARSTUDIO_API AppRenderEvent : public Event + class AppRenderEvent : public Event { public: - AppRenderEvent() {} + AppRenderEvent() = default; EVENT_CLASS_TYPE(AppRender) EVENT_CLASS_CATEGORY(EventCategoryApplication) diff --git a/StarStudio/src/StarStudio/Events/Event.h b/StarStudio/src/StarStudio/Events/Event.h index 4fcf30b4..85363594 100644 --- a/StarStudio/src/StarStudio/Events/Event.h +++ b/StarStudio/src/StarStudio/Events/Event.h @@ -35,7 +35,7 @@ namespace StarStudio { #define EVENT_CLASS_CATEGORY(category) virtual int GetCategoryFlags() const override { return category; } - class STARSTUDIO_API Event + class Event { public: bool Handled = false; diff --git a/StarStudio/src/StarStudio/Events/KeyEvent.h b/StarStudio/src/StarStudio/Events/KeyEvent.h index 49e0bd15..aa777a20 100644 --- a/StarStudio/src/StarStudio/Events/KeyEvent.h +++ b/StarStudio/src/StarStudio/Events/KeyEvent.h @@ -1,10 +1,10 @@ #pragma once -#include "Event.h" +#include "StarStudio/Events/Event.h" namespace StarStudio { - class STARSTUDIO_API KeyEvent : public Event + class KeyEvent : public Event { public: inline int GetKeyCode() const { return m_KeyCode; } @@ -18,7 +18,7 @@ namespace StarStudio { int m_KeyCode; }; - class STARSTUDIO_API KeyPressedEvent : public KeyEvent + class KeyPressedEvent : public KeyEvent { public: KeyPressedEvent(int keycode, int repeatCount) @@ -39,7 +39,7 @@ namespace StarStudio { int m_RepeatCount; }; - class STARSTUDIO_API KeyReleasedEvent : public KeyEvent + class KeyReleasedEvent : public KeyEvent { public: KeyReleasedEvent(int keycode) @@ -56,7 +56,7 @@ namespace StarStudio { EVENT_CLASS_TYPE(KeyReleased) }; - class STARSTUDIO_API KeyTypedEvent : public KeyEvent + class KeyTypedEvent : public KeyEvent { public: KeyTypedEvent(int keycode) diff --git a/StarStudio/src/StarStudio/Events/MouseEvent.h b/StarStudio/src/StarStudio/Events/MouseEvent.h index ae99c3ed..d3f6838d 100644 --- a/StarStudio/src/StarStudio/Events/MouseEvent.h +++ b/StarStudio/src/StarStudio/Events/MouseEvent.h @@ -1,10 +1,10 @@ #pragma once -#include "Event.h" +#include "StarStudio/Events/Event.h" namespace StarStudio { - class STARSTUDIO_API MouseMovedEvent : public Event + class MouseMovedEvent : public Event { public: MouseMovedEvent(float x, float y) @@ -27,7 +27,7 @@ namespace StarStudio { float m_MouseX, m_MouseY; }; - class STARSTUDIO_API MouseScrolledEvent : public Event + class MouseScrolledEvent : public Event { public: MouseScrolledEvent(float xOffset, float yOffset) @@ -50,7 +50,7 @@ namespace StarStudio { float m_XOffset, m_YOffset; }; - class STARSTUDIO_API MouseButtonEvent : public Event + class MouseButtonEvent : public Event { public: inline int GetMouseButton() const { return m_Button; } @@ -64,7 +64,7 @@ namespace StarStudio { int m_Button; }; - class STARSTUDIO_API MouseButtonPressedEvent : public MouseButtonEvent + class MouseButtonPressedEvent : public MouseButtonEvent { public: MouseButtonPressedEvent(int button) @@ -81,7 +81,7 @@ namespace StarStudio { EVENT_CLASS_TYPE(MouseButtonPressed) }; - class STARSTUDIO_API MouseButtonReleasedEvent : public MouseButtonEvent + class MouseButtonReleasedEvent : public MouseButtonEvent { public: MouseButtonReleasedEvent(int button) diff --git a/StarStudio/src/StarStudio/ImGui/ImGuiBuild.cpp b/StarStudio/src/StarStudio/ImGui/ImGuiBuild.cpp index a9b0900a..014d3c27 100644 --- a/StarStudio/src/StarStudio/ImGui/ImGuiBuild.cpp +++ b/StarStudio/src/StarStudio/ImGui/ImGuiBuild.cpp @@ -1,5 +1,5 @@ #include "sspch.h" #define IMGUI_IMPL_OPENGL_LOADER_GLAD -#include "backends/imgui_impl_opengl3.cpp" -#include "backends/imgui_impl_glfw.cpp" \ No newline at end of file +#include +#include \ No newline at end of file diff --git a/StarStudio/src/StarStudio/ImGui/ImGuiLayer.cpp b/StarStudio/src/StarStudio/ImGui/ImGuiLayer.cpp index e145e454..e641169a 100644 --- a/StarStudio/src/StarStudio/ImGui/ImGuiLayer.cpp +++ b/StarStudio/src/StarStudio/ImGui/ImGuiLayer.cpp @@ -1,9 +1,9 @@ #include "sspch.h" -#include "ImGuiLayer.h" +#include "StarStudio/ImGui/ImGuiLayer.h" -#include "imgui.h" -#include "backends/imgui_impl_glfw.h" -#include "backends/imgui_impl_opengl3.h" +#include +#include +#include #include "StarStudio/Core/Application.h" diff --git a/StarStudio/src/StarStudio/ImGui/ImGuiLayer.h b/StarStudio/src/StarStudio/ImGui/ImGuiLayer.h index e3adb6e2..ad8b5ea5 100644 --- a/StarStudio/src/StarStudio/ImGui/ImGuiLayer.h +++ b/StarStudio/src/StarStudio/ImGui/ImGuiLayer.h @@ -8,7 +8,7 @@ namespace StarStudio { - class STARSTUDIO_API ImGuiLayer : public Layer + class ImGuiLayer : public Layer { public: ImGuiLayer(); diff --git a/StarStudio/src/StarStudio/Renderer/Buffer.cpp b/StarStudio/src/StarStudio/Renderer/Buffer.cpp index d9f06a33..b090a27b 100644 --- a/StarStudio/src/StarStudio/Renderer/Buffer.cpp +++ b/StarStudio/src/StarStudio/Renderer/Buffer.cpp @@ -1,30 +1,30 @@ #include "sspch.h" -#include "Buffer.h" +#include "StarStudio/Renderer/Buffer.h" -#include "Renderer.h" +#include "StarStudio/Renderer/Renderer.h" #include "Platform/OpenGL/OpenGLBuffer.h" namespace StarStudio { - VertexBuffer* VertexBuffer::Create(float* vertices, uint32_t size) { + Ref VertexBuffer::Create(float* vertices, uint32_t size) { switch (Renderer::GetAPI()) { case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported") return nullptr; - case RendererAPI::API::OpenGL: return new OpenGLVertexBuffer(vertices, size); + case RendererAPI::API::OpenGL: return CreateRef(vertices, size); } SS_CORE_ASSERT(false, "Unknown RendererAPI!"); return nullptr; } - IndexBuffer* IndexBuffer::Create(uint32_t* indices, uint32_t size) { + Ref IndexBuffer::Create(uint32_t* indices, uint32_t size) { switch (Renderer::GetAPI()) { - case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported") return nullptr; - case RendererAPI::API::OpenGL: return new OpenGLIndexBuffer(indices, size); + case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported") return nullptr; + case RendererAPI::API::OpenGL: return CreateRef(indices, size); } SS_CORE_ASSERT(false, "Unknown RendererAPI!"); diff --git a/StarStudio/src/StarStudio/Renderer/Buffer.h b/StarStudio/src/StarStudio/Renderer/Buffer.h index 0d9d413c..ff1744af 100644 --- a/StarStudio/src/StarStudio/Renderer/Buffer.h +++ b/StarStudio/src/StarStudio/Renderer/Buffer.h @@ -115,7 +115,7 @@ namespace StarStudio { virtual const BufferLayout& GetLayout() const = 0; virtual void SetLayout(const BufferLayout& layout) = 0; - static VertexBuffer* Create(float* vertices, uint32_t size); + static Ref Create(float* vertices, uint32_t size); }; class IndexBuffer @@ -128,6 +128,6 @@ namespace StarStudio { virtual uint32_t GetCount() const = 0; - static IndexBuffer* Create(uint32_t* indices, uint32_t size); + static Ref Create(uint32_t* indices, uint32_t size); }; } \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Renderer/GraphicsContext.cpp b/StarStudio/src/StarStudio/Renderer/GraphicsContext.cpp new file mode 100644 index 00000000..bbfd08e2 --- /dev/null +++ b/StarStudio/src/StarStudio/Renderer/GraphicsContext.cpp @@ -0,0 +1,19 @@ +#include "sspch.h" +#include "StarStudio/Renderer/GraphicsContext.h" + +#include "StarStudio/Renderer/Renderer.h" +#include "Platform/OpenGL/OpenGLContext.h" + +namespace StarStudio +{ + Scope GraphicsContext::Create(void* window) + { + switch (Renderer::GetAPI()) + { + case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported!"); return nullptr; + case RendererAPI::API::OpenGL: return CreateScope(static_cast(window)); + } + SS_CORE_ASSERT(false, "Unknown RendererAPI!"); + return nullptr; + } +} \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Renderer/GraphicsContext.h b/StarStudio/src/StarStudio/Renderer/GraphicsContext.h index 41cd634e..b176ba21 100644 --- a/StarStudio/src/StarStudio/Renderer/GraphicsContext.h +++ b/StarStudio/src/StarStudio/Renderer/GraphicsContext.h @@ -6,5 +6,7 @@ namespace StarStudio { public: virtual void Init() = 0; virtual void SwapBuffers() = 0; + + static Scope Create(void* window); }; } \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Renderer/OrthographicCamera.cpp b/StarStudio/src/StarStudio/Renderer/OrthographicCamera.cpp index 1baabca6..2f97e592 100644 --- a/StarStudio/src/StarStudio/Renderer/OrthographicCamera.cpp +++ b/StarStudio/src/StarStudio/Renderer/OrthographicCamera.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OrthographicCamera.h" +#include "StarStudio/Renderer/OrthographicCamera.h" #include diff --git a/StarStudio/src/StarStudio/Renderer/OrthographicCameraController.cpp b/StarStudio/src/StarStudio/Renderer/OrthographicCameraController.cpp index 599d8bfa..d5c734a8 100644 --- a/StarStudio/src/StarStudio/Renderer/OrthographicCameraController.cpp +++ b/StarStudio/src/StarStudio/Renderer/OrthographicCameraController.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "OrthographicCameraController.h" +#include "StarStudio/Renderer/OrthographicCameraController.h" #include "StarStudio/Core/Input.h" #include "StarStudio/Core/KeyCodes.h" diff --git a/StarStudio/src/StarStudio/Renderer/RenderCommand.cpp b/StarStudio/src/StarStudio/Renderer/RenderCommand.cpp index ce3a29df..3ca0f87e 100644 --- a/StarStudio/src/StarStudio/Renderer/RenderCommand.cpp +++ b/StarStudio/src/StarStudio/Renderer/RenderCommand.cpp @@ -1,9 +1,7 @@ #include "sspch.h" -#include "RenderCommand.h" - -#include "Platform/OpenGL/OpenGLRendererAPI.h" +#include "StarStudio/Renderer/RenderCommand.h" namespace StarStudio { - Scope RenderCommand::s_RendererAPI = CreateScope(); + Scope RenderCommand::s_RendererAPI = RendererAPI::Create(); } \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Renderer/RenderCommand.h b/StarStudio/src/StarStudio/Renderer/RenderCommand.h index f6307fae..726a18c9 100644 --- a/StarStudio/src/StarStudio/Renderer/RenderCommand.h +++ b/StarStudio/src/StarStudio/Renderer/RenderCommand.h @@ -1,6 +1,6 @@ #pragma once -#include "RendererAPI.h" +#include "StarStudio/Renderer/RendererAPI.h" namespace StarStudio { diff --git a/StarStudio/src/StarStudio/Renderer/Renderer.cpp b/StarStudio/src/StarStudio/Renderer/Renderer.cpp index a6b54188..ee9f6df7 100644 --- a/StarStudio/src/StarStudio/Renderer/Renderer.cpp +++ b/StarStudio/src/StarStudio/Renderer/Renderer.cpp @@ -1,10 +1,7 @@ #include "sspch.h" -#include "Renderer.h" -#include "Renderer2D.h" - -#include "Platform/OpenGL/OpenGLShader.h" -#include "Platform/OpenGL/OpenGLShader.h" +#include "StarStudio/Renderer/Renderer.h" +#include "StarStudio/Renderer/Renderer2D.h" namespace StarStudio { @@ -16,6 +13,11 @@ namespace StarStudio { Renderer2D::Init(); } + void Renderer::Shutdown() + { + Renderer2D::Shutdown(); + } + void Renderer::OnWindowResize(uint32_t width, uint32_t height) { RenderCommand::SetViewport(0, 0, width, height); @@ -35,8 +37,8 @@ namespace StarStudio { { shader->Bind(); - std::dynamic_pointer_cast(shader)->UploadUniformMat4("u_ViewProjection", s_SceneData->ViewProjectionMatrix); - std::dynamic_pointer_cast(shader)->UploadUniformMat4("u_Transform", transform); + shader->SetMat4("u_ViewProjection", s_SceneData->ViewProjectionMatrix); + shader->SetMat4("u_Transform", transform); vertexArray->Bind(); RenderCommand::DrawIndexed(vertexArray); diff --git a/StarStudio/src/StarStudio/Renderer/Renderer.h b/StarStudio/src/StarStudio/Renderer/Renderer.h index bf927ab4..a3d2d4b7 100644 --- a/StarStudio/src/StarStudio/Renderer/Renderer.h +++ b/StarStudio/src/StarStudio/Renderer/Renderer.h @@ -1,10 +1,9 @@ #pragma once -#include "RenderCommand.h" -#include "RendererAPI.h" +#include "StarStudio/Renderer/RenderCommand.h" -#include "OrthographicCamera.h" -#include "Shader.h" +#include "StarStudio/Renderer/OrthographicCamera.h" +#include "StarStudio/Renderer/Shader.h" namespace StarStudio { @@ -12,6 +11,8 @@ namespace StarStudio { { public: static void Init(); + static void Shutdown(); + static void OnWindowResize(uint32_t width, uint32_t height); static void BeginScene(OrthographicCamera& camera); diff --git a/StarStudio/src/StarStudio/Renderer/Renderer2D.cpp b/StarStudio/src/StarStudio/Renderer/Renderer2D.cpp index 42439918..b7ffade2 100644 --- a/StarStudio/src/StarStudio/Renderer/Renderer2D.cpp +++ b/StarStudio/src/StarStudio/Renderer/Renderer2D.cpp @@ -1,5 +1,5 @@ #include "sspch.h" -#include "Renderer2D.h" +#include "StarStudio/Renderer/Renderer2D.h" #include "StarStudio/Renderer/VertexArray.h" #include "StarStudio/Renderer/Shader.h" @@ -30,8 +30,7 @@ namespace StarStudio { -0.5f, 0.5f, 0.0f, 0.0f, 1.0f }; - Ref squareVB; - squareVB.reset(VertexBuffer::Create(squareVertices, sizeof(squareVertices))); + Ref squareVB = VertexBuffer::Create(squareVertices, sizeof(squareVertices)); squareVB->SetLayout({ { ShaderDataType::Float3, "a_Position" }, { ShaderDataType::Float2, "a_TexCoord" } @@ -39,8 +38,7 @@ namespace StarStudio { s_Data->QuadVertexArray->AddVertexBuffer(squareVB); uint32_t squareIndices[6] = { 0, 1, 2, 2, 3, 0 }; - Ref squareIB; - squareIB.reset(IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(uint32_t))); + Ref squareIB = IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(uint32_t)); s_Data->QuadVertexArray->SetIndexBuffer(squareIB); s_Data->WhiteTexture = Texture2D::Create(1, 1); diff --git a/StarStudio/src/StarStudio/Renderer/Renderer2D.h b/StarStudio/src/StarStudio/Renderer/Renderer2D.h index a65d8272..8165d687 100644 --- a/StarStudio/src/StarStudio/Renderer/Renderer2D.h +++ b/StarStudio/src/StarStudio/Renderer/Renderer2D.h @@ -1,8 +1,8 @@ #pragma once -#include "OrthographicCamera.h" +#include "StarStudio/Renderer/OrthographicCamera.h" -#include "Texture.h" +#include "StarStudio/Renderer/Texture.h" namespace StarStudio { class Renderer2D diff --git a/StarStudio/src/StarStudio/Renderer/RendererAPI.cpp b/StarStudio/src/StarStudio/Renderer/RendererAPI.cpp index 1c78512e..322126bb 100644 --- a/StarStudio/src/StarStudio/Renderer/RendererAPI.cpp +++ b/StarStudio/src/StarStudio/Renderer/RendererAPI.cpp @@ -1,7 +1,22 @@ #include "sspch.h" -#include "RendererAPI.h" +#include "StarStudio/Renderer/RendererAPI.h" + +#include "Platform/OpenGL/OpenGLRendererAPI.h" + +namespace StarStudio { -namespace StarStudio -{ RendererAPI::API RendererAPI::s_API = RendererAPI::API::OpenGL; + + Scope RendererAPI::Create() + { + switch (s_API) + { + case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported!"); return nullptr; + case RendererAPI::API::OpenGL: return CreateScope(); + } + + SS_CORE_ASSERT(false, "Unknown RendererAPI!"); + return nullptr; + } + } \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Renderer/RendererAPI.h b/StarStudio/src/StarStudio/Renderer/RendererAPI.h index 1d8ce5c8..cb64ff7d 100644 --- a/StarStudio/src/StarStudio/Renderer/RendererAPI.h +++ b/StarStudio/src/StarStudio/Renderer/RendererAPI.h @@ -1,10 +1,11 @@ #pragma once #include -#include "VertexArray.h" -namespace StarStudio -{ +#include "StarStudio/Renderer/VertexArray.h" + +namespace StarStudio { + class RendererAPI { public: @@ -21,7 +22,10 @@ namespace StarStudio virtual void DrawIndexed(const Ref& vertexArray) = 0; inline static API GetAPI() { return s_API; } + static Scope Create(); + private: static API s_API; }; + } \ No newline at end of file diff --git a/StarStudio/src/StarStudio/Renderer/Shader.cpp b/StarStudio/src/StarStudio/Renderer/Shader.cpp index 8ed8b8bb..a4a7c532 100644 --- a/StarStudio/src/StarStudio/Renderer/Shader.cpp +++ b/StarStudio/src/StarStudio/Renderer/Shader.cpp @@ -1,7 +1,7 @@ #include "sspch.h" -#include "Shader.h" +#include "StarStudio/Renderer/Shader.h" -#include "Renderer.h" +#include "StarStudio/Renderer/Renderer.h" #include "Platform/OpenGL/OpenGLShader.h" namespace StarStudio { @@ -11,7 +11,7 @@ namespace StarStudio { switch (Renderer::GetAPI()) { case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported!"); return nullptr; - case RendererAPI::API::OpenGL: return std::make_shared(filepath); + case RendererAPI::API::OpenGL: return CreateRef(filepath); } SS_CORE_ASSERT(false, "Unknown RendererAPI!"); @@ -24,7 +24,7 @@ namespace StarStudio { switch (Renderer::GetAPI()) { case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported!"); return nullptr; - case RendererAPI::API::OpenGL: return std::make_shared(name, vertexSrc, fragmentSrc);; + case RendererAPI::API::OpenGL: return CreateRef(name, vertexSrc, fragmentSrc);; } SS_CORE_ASSERT(false, "Unknown RendererAPI!"); diff --git a/StarStudio/src/StarStudio/Renderer/Texture.cpp b/StarStudio/src/StarStudio/Renderer/Texture.cpp index e99f9bdb..10bb611d 100644 --- a/StarStudio/src/StarStudio/Renderer/Texture.cpp +++ b/StarStudio/src/StarStudio/Renderer/Texture.cpp @@ -1,7 +1,7 @@ #include "sspch.h" -#include "Texture.h" +#include "StarStudio/Renderer/Texture.h" -#include "Renderer.h" +#include "StarStudio/Renderer/Renderer.h" #include "Platform/OpenGL/OpenGLTexture.h" namespace StarStudio diff --git a/StarStudio/src/StarStudio/Renderer/VertexArray.cpp b/StarStudio/src/StarStudio/Renderer/VertexArray.cpp index 0bf3fb74..a58f7a7f 100644 --- a/StarStudio/src/StarStudio/Renderer/VertexArray.cpp +++ b/StarStudio/src/StarStudio/Renderer/VertexArray.cpp @@ -1,7 +1,7 @@ #include "sspch.h" -#include "VertexArray.h" +#include "StarStudio/Renderer/VertexArray.h" -#include "Renderer.h" +#include "StarStudio/Renderer/Renderer.h" #include "Platform/OpenGL/OpenGLVertexArray.h" namespace StarStudio { @@ -11,7 +11,7 @@ namespace StarStudio { switch (Renderer::GetAPI()) { case RendererAPI::API::None: SS_CORE_ASSERT(false, "RendererAPI::None is currently not supported") return nullptr; - case RendererAPI::API::OpenGL: return std::make_shared(); + case RendererAPI::API::OpenGL: return CreateRef(); } SS_CORE_ASSERT(false, "Unknown RendererAPI!");