Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sandbox/src/Sandbox2D.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "Sandbox2D.h"

#include "imgui/imgui.h"
#include <imgui/imgui.h>

#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
Expand Down
29 changes: 11 additions & 18 deletions Sandbox/src/SandboxApp.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#include <StarStudio.h>
#include <StarStudio/Core/EntryPoint.h>

#include "Platform/OpenGL/OpenGLShader.h"
#include "StarStudio/Renderer/OrthographicCameraController.h"
#include "Sandbox2D.h"

#include "imgui/imgui.h"
#include <imgui/imgui.h>

#include <glm/gtc/matrix_transform.hpp>

#include "Sandbox2D.h"

#include "StarStudio/Renderer/OrthographicCameraController.h"
#include "glm/gtc/type_ptr.hpp"

class ExampleLayer : public StarStudio::Layer
Expand All @@ -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<StarStudio::VertexBuffer> vertexBuffer;
vertexBuffer.reset(StarStudio::VertexBuffer::Create(vertices, sizeof(vertices)));
StarStudio::Ref<StarStudio::VertexBuffer> vertexBuffer = StarStudio::VertexBuffer::Create(vertices, sizeof(vertices));
StarStudio::BufferLayout layout = {
{ StarStudio::ShaderDataType::Float3, "a_Position" },
{ StarStudio::ShaderDataType::Float4, "a_Color" }
Expand All @@ -36,8 +32,7 @@ class ExampleLayer : public StarStudio::Layer
m_VertexArray->AddVertexBuffer(vertexBuffer);

uint32_t indices[3] = { 0, 1, 2 };
StarStudio::Ref<StarStudio::IndexBuffer> indexBuffer;
indexBuffer.reset(StarStudio::IndexBuffer::Create(indices, sizeof(indices) / sizeof(uint32_t)));
StarStudio::Ref<StarStudio::IndexBuffer> indexBuffer = StarStudio::IndexBuffer::Create(indices, sizeof(indices) / sizeof(uint32_t));
m_VertexArray->SetIndexBuffer(indexBuffer);

m_SquareVA = StarStudio::VertexArray::Create();
Expand All @@ -49,17 +44,15 @@ class ExampleLayer : public StarStudio::Layer
-0.5f, 0.5f, 0.0f ,0.0f, 1.0f
};

StarStudio::Ref<StarStudio::VertexBuffer> squareVB;
squareVB.reset(StarStudio::VertexBuffer::Create(squareVertices, sizeof(squareVertices)));
StarStudio::Ref<StarStudio::VertexBuffer> squareVB = StarStudio::VertexBuffer::Create(squareVertices, sizeof(squareVertices));
squareVB->SetLayout({
{ StarStudio::ShaderDataType::Float3, "a_Position" },
{ StarStudio::ShaderDataType::Float2, "a_TexCoord" }
});
m_SquareVA->AddVertexBuffer(squareVB);

uint32_t squareIndices[6] = { 0, 1, 2, 2, 3, 0 };
StarStudio::Ref<StarStudio::IndexBuffer> squareIB;
squareIB.reset(StarStudio::IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(uint32_t)));
StarStudio::Ref<StarStudio::IndexBuffer> squareIB = StarStudio::IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(uint32_t));
m_SquareVA->SetIndexBuffer(squareIB);

std::string vertexSrc = R"(
Expand Down Expand Up @@ -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<StarStudio::OpenGLShader>(textureShader)->Bind();
std::dynamic_pointer_cast<StarStudio::OpenGLShader>(textureShader)->UploadUniformInt("u_Texture", 0);
textureShader->Bind();
textureShader->SetInt("u_Texture", 0);

}

Expand All @@ -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<StarStudio::OpenGLShader>(m_FlatColorShader)->Bind();
std::dynamic_pointer_cast<StarStudio::OpenGLShader>(m_FlatColorShader)->UploadUniformFloat3("u_Color", m_SquareColor);
m_FlatColorShader->Bind();
m_FlatColorShader->SetFloat3("u_Color", m_SquareColor);

/*for (int y = 0; y < 20; y++)
{
Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/Platform/OpenGL/OpenGLBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "OpenGLBuffer.h"
#include "Platform/OpenGL/OpenGLBuffer.h"

#include <glad/glad.h>

Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/Platform/OpenGL/OpenGLContext.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "OpenGLContext.h"
#include "Platform/OpenGL/OpenGLContext.h"

#include <GLFW/glfw3.h>
#include <glad/glad.h>
Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "OpenGLRendererAPI.h"
#include "Platform/OpenGL/OpenGLRendererAPI.h"

#include <glad/glad.h>

Expand Down
1 change: 0 additions & 1 deletion StarStudio/src/Platform/OpenGL/OpenGLRendererAPI.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once


#include "StarStudio/Renderer/RendererAPI.h"

namespace StarStudio
Expand Down
19 changes: 13 additions & 6 deletions StarStudio/src/Platform/OpenGL/OpenGLShader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "OpenGLShader.h"
#include "Platform/OpenGL/OpenGLShader.h"

#include <fstream>
#include <glad/glad.h>
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions StarStudio/src/Platform/OpenGL/OpenGLTexture.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "sspch.h"
#include "OpenGLTexture.h"
#include "Platform/OpenGL/OpenGLTexture.h"

#include "stb_image.h"
#include <stb_image.h>

namespace StarStudio {

Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/Platform/OpenGL/OpenGLVertexArray.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "OpenGLVertexArray.h"
#include "Platform/OpenGL/OpenGLVertexArray.h"


#include <glad/glad.h>
Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/Platform/Windows/WindowsInput.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "WindowsInput.h"
#include "Platform/Windows/WindowsInput.h"

#include "StarStudio/Core/Application.h"
#include <GLFW/glfw3.h>
Expand Down
13 changes: 6 additions & 7 deletions StarStudio/src/Platform/Windows/WindowsWindow.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -16,9 +16,9 @@ namespace StarStudio {
SS_CORE_ERROR("GLFW Error ({0}): {1}", error, description);
}

Window* Window::Create(const WindowProps& props)
Scope<Window> Window::Create(const WindowProps& props)
{
return new WindowsWindow(props);
return CreateScope<WindowsWindow>(props);
}

WindowsWindow::WindowsWindow(const WindowProps& props)
Expand All @@ -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);
Expand All @@ -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<OpenGLContext>(m_Window);
m_Context = GraphicsContext::Create(m_Window);
m_Context->Init();

glfwSetWindowUserPointer(m_Window, &m_Data);
Expand Down Expand Up @@ -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();
}
}
Expand Down
20 changes: 11 additions & 9 deletions StarStudio/src/StarStudio/Core/Application.cpp
Original file line number Diff line number Diff line change
@@ -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 <GLFW/glfw3.h>

namespace StarStudio

#define BIND_EVENT_FN(x) std::bind(&Application::x, this, std::placeholders::_1)
{
Application* Application::s_Instance = nullptr;

Expand All @@ -19,15 +17,19 @@ namespace StarStudio
SS_CORE_ASSERT(!s_Instance, "Application already exists!");
s_Instance = this;

m_Window = std::unique_ptr<Window>(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);
Expand All @@ -41,8 +43,8 @@ namespace StarStudio
void Application::OnEvent(Event& e)
{
EventDispatcher dispatcher(e);
dispatcher.Dispatch<WindowCloseEvent>(BIND_EVENT_FN(OnWindowClose));
dispatcher.Dispatch<WindowResizeEvent>(BIND_EVENT_FN(OnWindowResize));
dispatcher.Dispatch<WindowResizeEvent>(SS_BIND_EVENT_FN(Application::OnWindowResize));
dispatcher.Dispatch<WindowResizeEvent>(SS_BIND_EVENT_FN(Application::OnWindowResize));

for (auto it = m_LayerStack.end(); it != m_LayerStack.begin(); )
{
Expand Down
6 changes: 3 additions & 3 deletions StarStudio/src/StarStudio/Core/Application.h
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -17,7 +17,7 @@ namespace StarStudio
{
public:
Application();
virtual ~Application() = default;
virtual ~Application();

void Run();

Expand Down
16 changes: 0 additions & 16 deletions StarStudio/src/StarStudio/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions StarStudio/src/StarStudio/Core/EntryPoint.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "StarStudio/Core/Core.h"

#ifdef SS_PLATFORM_WINDOWS

Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/StarStudio/Core/Input.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace StarStudio {

class STARSTUDIO_API Input
class Input
{
protected:
Input() = default;
Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/StarStudio/Core/Layer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sspch.h"
#include "Layer.h"
#include "StarStudio/Core/Layer.h"

namespace StarStudio {

Expand Down
2 changes: 1 addition & 1 deletion StarStudio/src/StarStudio/Core/Layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace StarStudio
{
class STARSTUDIO_API Layer
class Layer
{
public:
Layer(const std::string& name = "Layer");
Expand Down
7 changes: 1 addition & 6 deletions StarStudio/src/StarStudio/Core/LayerStack.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions StarStudio/src/StarStudio/Core/LayerStack.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#pragma once

#include "StarStudio/Core/Core.h"
#include "Layer.h"
#include "StarStudio/Core/Layer.h"

#include <vector>
namespace StarStudio {
class STARSTUDIO_API LayerStack
class LayerStack
{
public:
LayerStack();
LayerStack() = default;
~LayerStack();

void PushLayer(Layer* layer);
Expand Down
4 changes: 2 additions & 2 deletions StarStudio/src/StarStudio/Core/Log.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "sspch.h"

#include "Log.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "StarStudio/Core/Log.h"
#include <spdlog/sinks/stdout_color_sinks.h>

namespace StarStudio
{
Expand Down
Loading
Loading