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
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = tab
22 changes: 10 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/bin/
# Binaries
**/bin/
!vendor/premake/bin/
bin-int/
.vs/

# StarEngine files
*.log


*.user
*.vcxproj
*.filters
*.sln
*imgui.ini
/Sandbox/imgui.ini
/StarEngine/vendor/*/bin
Sandbox/StarEngineProfile*.json
/StarEngine/vendor/GLAD/bin**

# Visual Studio files and folder
.vs/
**.sln
**.vcxproj
**.vcxproj.filters
**.vcxproj.user
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[submodule "StarEngine/vendor/GLFW"]
path = StarEngine/vendor/GLFW
url = https://github.com/starbounded-dev/glfw
url = ../../starbounded-dev/glfw.git
[submodule "StarEngine/vendor/spdlog"]
path = StarEngine/vendor/spdlog
url = https://github.com/gabime/spdlog
url = ../../gabime/spdlog.git
[submodule "StarEngine/vendor/imgui"]
path = StarEngine/vendor/imgui
url = https://github.com/starbounded-dev/imgui
url = ../../starbounded-dev/imgui.git
branch = docking
[submodule "StarEngine/vendor/glm"]
path = StarEngine/vendor/glm
url = https://github.com/g-truc/glm
url = ../../g-truc/glm.git
49 changes: 49 additions & 0 deletions Sandbox/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
project "Sandbox"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"

targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}")

files
{
"src/**.h",
"src/**.cpp"
}

includedirs
{
"%{wks.location}/StarEngine/vendor/spdlog/include",
"%{wks.location}/StarEngine/src",
"%{wks.location}/StarEngine/vendor",
"%{IncludeDir.glm}",
"%{IncludeDir.entt}"
}

links
{
"StarEngine"
}

filter "system:windows"
systemversion "latest"

filter "configurations:Debug"
defines "SE_DEBUG"
runtime "Debug"
symbols "on"

filter "configurations:Release"
defines "SE_RELEASE"
runtime "Release"
optimize "on"

filter "configurations:Dist"
defines "SE_DIST"
runtime "Release"
optimize "on"

filter "action:vs2022"
buildoptions { "/utf-8" }
49 changes: 49 additions & 0 deletions StarEditor/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
project "StarEditor"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
staticruntime "on"

targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}")

files
{
"src/**.h",
"src/**.cpp"
}

includedirs
{
"%{wks.location}/StarEngine/vendor/spdlog/include",
"%{wks.location}/StarEngine/src",
"%{wks.location}/StarEngine/vendor",
"%{IncludeDir.glm}",
"%{IncludeDir.entt}"
}

links
{
"StarEngine"
}

filter "system:windows"
systemversion "latest"

filter "configurations:Debug"
defines "SE_DEBUG"
runtime "Debug"
symbols "on"

filter "configurations:Release"
defines "SE_RELEASE"
runtime "Release"
optimize "on"

filter "configurations:Dist"
defines "SE_DIST"
runtime "Release"
optimize "on"

filter "action:vs2022"
buildoptions { "/utf-8" }
10 changes: 5 additions & 5 deletions StarEditor/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ namespace StarEngine {
auto& transform = GetComponent<TransformComponent>().Transform;
float speed = 5.0f;

if (Input::IsKeyPressed(SE_KEY_A))
if (Input::IsKeyPressed(Key::A))
transform[3][0] -= speed * ts;
if (Input::IsKeyPressed(SE_KEY_D))
if (Input::IsKeyPressed(Key::D))
transform[3][0] += speed * ts;
if (Input::IsKeyPressed(SE_KEY_W))
if (Input::IsKeyPressed(Key::W))
transform[3][1] += speed * ts;
if (Input::IsKeyPressed(SE_KEY_S))
if (Input::IsKeyPressed(Key::S))
transform[3][1] -= speed * ts;
}
};
Expand Down Expand Up @@ -228,7 +228,7 @@ namespace StarEngine {

m_ViewportSize = { viewportPanelSize.x, viewportPanelSize.y };

uint32_t textureID = m_Framebuffer->GetColorAttachmentRendererID();
uint64_t textureID = m_Framebuffer->GetColorAttachmentRendererID();
ImGui::Image(textureID, ImVec2{ m_ViewportSize.x, m_ViewportSize.y }, ImVec2{0,1}, ImVec2{1,0});

ImGui::End();
Expand Down
76 changes: 76 additions & 0 deletions StarEngine/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
project "StarEngine"
kind "StaticLib"
language "C++"
cppdialect "C++17"
staticruntime "on"

targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}")

pchheader "sepch.h"
pchsource "src/sepch.cpp"

files
{
"src/**.h",
"src/**.cpp",
"vendor/stb_image/**.h",
"vendor/stb_image/**.cpp",
"vendor/glm/glm/**.hpp",
"vendor/glm/glm/**.inl"
}

defines
{
"_CRT_SECURE_NO_WARNINGS",
"GLFW_INCLUDE_NONE"
}

includedirs
{
"src",
"vendor/spdlog/include",
"%{IncludeDir.GLFW}",
"%{IncludeDir.GLAD}",
"%{IncludeDir.imgui}",
"%{IncludeDir.glm}",
"%{IncludeDir.stb_image}",
"%{IncludeDir.entt}"


}

links
{
"GLFW",
"GLAD",
"imgui",
"opengl32.lib",
"dwmapi.lib"
}

filter "system:windows"
systemversion "latest"

defines
{

}

filter "configurations:Debug"
defines "SE_DEBUG"
runtime "Debug"
symbols "on"

filter "configurations:Release"
defines "SE_RELEASE"
runtime "Release"
optimize "on"

filter "configurations:Dist"
defines "SE_DIST"
runtime "Release"
optimize "on"

filter "action:vs2022"
buildoptions { "/utf-8" }
8 changes: 1 addition & 7 deletions StarEngine/src/Platform/OpenGL/OpenGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ namespace StarEngine {
SE_CORE_INFO(" Renderer: {0}", (const char*)glGetString(GL_RENDERER));
SE_CORE_INFO(" Version: {0}", (const char*)glGetString(GL_VERSION));

#ifdef SS_ENABLE_ASSERTS
int versionMajor;
int versionMinor;
glGetIntegerv(GL_MAJOR_VERSION, &versionMajor);
glGetIntegerv(GL_MINOR_VERSION, &versionMinor);
SE_CORE_ASSERT(versionMajor > 4 || (versionMajor == 4 && versionMinor >= 5), "StarStudio requires at least OpenGL version 4.5!");
#endif
SE_CORE_ASSERT(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5), "Hazel requires at least OpenGL version 4.5!");
}

void OpenGLContext::SwapBuffers()
Expand Down
3 changes: 1 addition & 2 deletions StarEngine/src/Platform/OpenGL/OpenGLShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace StarEngine {
SE_PROFILE_FUNCTION();

std::string result;
std::ifstream in(filepath, std::ios::in | std::ios::binary);
std::ifstream in(filepath, std::ios::in | std::ios::binary); // ifstream closes itself due to RAII
if (in)
{
in.seekg(0, std::ios::end);
Expand All @@ -67,7 +67,6 @@ namespace StarEngine {
result.resize(size);
in.seekg(0, std::ios::beg);
in.read(&result[0], size);
in.close();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion StarEngine/src/Platform/OpenGL/OpenGLVertexArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace StarEngine {
ShaderDataTypeToOpenGLBaseType(element.Type),
element.Normalized ? GL_TRUE : GL_FALSE,
layout.GetStride(),
(const void*)(sizeof(float) * count * i));
(const void*)(element.Offset + sizeof(float) * count * i));
glVertexAttribDivisor(m_VertexBufferIndex, 1);
m_VertexBufferIndex++;
}
Expand Down
14 changes: 6 additions & 8 deletions StarEngine/src/Platform/Windows/WindowsInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

namespace StarEngine {

bool Input::IsKeyPressed(KeyCode key)
bool Input::IsKeyPressed(const KeyCode key)
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto state = glfwGetKey(window, static_cast<int32_t>(key));
return state == GLFW_PRESS || state == GLFW_REPEAT;
}

bool Input::IsMouseButtonPressed(MouseCode button)
bool Input::IsMouseButtonPressed(const MouseCode button)
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto state = glfwGetMouseButton(window, static_cast<int32_t>(button));
return state == GLFW_PRESS;
}

std::pair<float, float> Input::GetMousePosition()
glm::vec2 Input::GetMousePosition()
{
auto window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
auto* window = static_cast<GLFWwindow*>(Application::Get().GetWindow().GetNativeWindow());
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);

Expand All @@ -31,13 +31,11 @@ namespace StarEngine {

float Input::GetMouseX()
{
auto [x, y] = GetMousePosition();
return x;
return GetMousePosition().x;
}

float Input::GetMouseY()
{
auto [x, y] = GetMousePosition();
return y;
return GetMousePosition().y;
}
}
12 changes: 6 additions & 6 deletions StarEngine/src/Platform/Windows/WindowsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,19 @@ namespace StarEngine {
{
case GLFW_PRESS:
{
KeyPressedEvent event(static_cast<KeyCode>(key), 0);
KeyPressedEvent event(key, 0);
data.EventCallback(event);
break;
}
case GLFW_RELEASE:
{
KeyReleasedEvent event(static_cast<KeyCode>(key));
KeyReleasedEvent event(key);
data.EventCallback(event);
break;
}
case GLFW_REPEAT:
{
KeyPressedEvent event(static_cast<KeyCode>(key), 1);
KeyPressedEvent event(key, 1);
data.EventCallback(event);
break;
}
Expand All @@ -119,7 +119,7 @@ namespace StarEngine {
{
WindowData& data = *(WindowData*)glfwGetWindowUserPointer(window);

KeyTypedEvent event(static_cast<KeyCode>(keycode));
KeyTypedEvent event(keycode);
data.EventCallback(event);
});

Expand All @@ -131,13 +131,13 @@ namespace StarEngine {
{
case GLFW_PRESS:
{
MouseButtonPressedEvent event(static_cast<MouseCode>(button));
MouseButtonPressedEvent event(button);
data.EventCallback(event);
break;
}
case GLFW_RELEASE:
{
MouseButtonReleasedEvent event(static_cast<MouseCode>(button));
MouseButtonReleasedEvent event(button);
data.EventCallback(event);
break;
}
Expand Down
Loading
Loading