Skip to content

Commit

Permalink
style: run clang formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMcAvoy committed Oct 9, 2024
1 parent f5a81bc commit 471679d
Show file tree
Hide file tree
Showing 32 changed files with 1,669 additions and 1,482 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Jenjin (Engine/Editor)

A source available lightweight game engine built for beginners to teach programming for education purposes.

## Usage
Expand Down
10 changes: 5 additions & 5 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ file (GLOB_RECURSE SOURCES src/*.cpp)
add_library (JenjinEngine ${SOURCES})

target_include_directories(JenjinEngine
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
${CMAKE_SOURCE_DIR}/megasource/libs/glfw/include/
${CMAKE_SOURCE_DIR}/megasource/libs/glad/include/
${CMAKE_SOURCE_DIR}/megasource/libs/glm/
Expand All @@ -16,8 +16,8 @@ target_include_directories(JenjinEngine
${CMAKE_SOURCE_DIR}/megasource/libs/lua/include/
${CMAKE_SOURCE_DIR}/megasource/libs/sol2/include/
${CMAKE_SOURCE_DIR}/megasource/libs/
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(JenjinEngine PRIVATE glfw glad spdlog glm stb imgui lua54 sol2)
50 changes: 25 additions & 25 deletions engine/include/jenjin/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@

#include "jenjin/shader.h"

#include <glm/glm.hpp>
#include <glm/fwd.hpp>
#include <glm/glm.hpp>

namespace Jenjin {
// 2D Orthographic Camera
// NOTE: one day hybrid 2D/3D camera?
class Camera {
public:
Camera(Shader* shader, glm::vec2 size);
Camera(Shader *shader, glm::vec2 size);

void SetShader(Shader* shader);
void SetShader(Shader *shader);

void SetPosition(const glm::vec3& position);
void SetRotation(float rotation);
void SetZoom(float zoom);
void SetPosition(const glm::vec3 &position);
void SetRotation(float rotation);
void SetZoom(float zoom);

void Translate(const glm::vec3& translation);
void Rotate(float rotation);
void Zoom(float zoom);
void Translate(const glm::vec3 &translation);
void Rotate(float rotation);
void Zoom(float zoom);

void Resize(glm::vec2 size);
void Resize(glm::vec2 size);

void Update();
void Use();
void Update();
void Use();

const glm::vec3& GetPosition() const { return position; }
const float GetRotation() const { return rotation; }
const glm::mat4 GetViewProjection() const { return projection * view; }
const glm::vec3 &GetPosition() const { return position; }
const float GetRotation() const { return rotation; }
const glm::mat4 GetViewProjection() const { return projection * view; }

glm::vec3* GetPositionPointer() { return &position; }
float* GetZoomPointer() { return &zoom; }
float* GetRotationPointer() { return &rotation; }
glm::vec3 *GetPositionPointer() { return &position; }
float *GetZoomPointer() { return &zoom; }
float *GetRotationPointer() { return &rotation; }

private:
Shader* shader;
Shader *shader;

glm::vec3 position;
float rotation;
float zoom;
glm::vec3 position;
float rotation;
float zoom;

glm::mat4 projection;
glm::mat4 view;
glm::mat4 projection;
glm::mat4 view;
};
}
} // namespace Jenjin
48 changes: 24 additions & 24 deletions engine/include/jenjin/editor/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,37 @@ namespace Jenjin {
namespace Editor {
class Manager {
public:
Manager();
Manager();

void menu();
void welcome();
void menu();
void welcome();

void dockspace();
void dockspace();

void controls(Jenjin::Scene* scene);
void hierarchy(Jenjin::Scene* scene);
void inspector(Jenjin::Scene* scene);
void scene(Jenjin::Scene* scene);
void viewport(Jenjin::Scene* scene);
void explorer(Jenjin::Scene* scene);
void code(Jenjin::Scene* scene);
void controls(Jenjin::Scene *scene);
void hierarchy(Jenjin::Scene *scene);
void inspector(Jenjin::Scene *scene);
void scene(Jenjin::Scene *scene);
void viewport(Jenjin::Scene *scene);
void explorer(Jenjin::Scene *scene);
void code(Jenjin::Scene *scene);

void backup_prompts(Jenjin::Scene* scene);
void backup_prompts(Jenjin::Scene *scene);

void show_all(Jenjin::Scene* scene);
void show_all(Jenjin::Scene *scene);

struct {
std::string projectPath;
std::string openScenePath;
std::string liveScenePath;
std::string scriptsPath;
} paths;
struct {
std::string projectPath;
std::string openScenePath;
std::string liveScenePath;
std::string scriptsPath;
} paths;

private:
Jenjin::GameObject* selectedObject = nullptr;
bool selectedCamera = false;
Jenjin::GameObject *selectedObject = nullptr;
bool selectedCamera = false;

char renameGameObjectBuffer[256] = { 0 };
char renameGameObjectBuffer[256] = {0};
};
}
}
} // namespace Editor
} // namespace Jenjin
6 changes: 3 additions & 3 deletions engine/include/jenjin/editor/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Jenjin {
namespace Editor {
class State_t {
public:
GLuint renderTexture;
GLuint renderTexture;
} extern State;
}
}
} // namespace Editor
} // namespace Jenjin
6 changes: 3 additions & 3 deletions engine/include/jenjin/editor/utils.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glad/glad.h>

#include <imgui.h>
#include <imgui_impl_glfw.h>
Expand All @@ -13,5 +13,5 @@ namespace Jenjin {
namespace Editor {
void ensure_dir(std::string path);
std::string get_jendir();
}
}
} // namespace Editor
} // namespace Jenjin
4 changes: 3 additions & 1 deletion engine/include/jenjin/editor/widgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

#include "jenjin/gameobject.h"
namespace Jenjin::Editor::Widgets {
bool transformWidget(Jenjin::GameObject::Transform* transform); // Returns true if the transform was changed
bool transformWidget(
Jenjin::GameObject::Transform
*transform); // Returns true if the transform was changed
};
22 changes: 11 additions & 11 deletions engine/include/jenjin/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
#include "jenjin/scene.h"
#include "jenjin/target.h"

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glad/glad.h>

namespace Jenjin {
class Engine {
public:
Engine(GLFWwindow* window);
~Engine();
Engine(GLFWwindow *window);
~Engine();

void AddScene(std::shared_ptr<Scene> scene, bool defaultScene = false);
void AddScene(std::shared_ptr<Scene> scene, bool defaultScene = false);

void Render(Target* target); // Render directly to the target
void Render(Target *target); // Render directly to the target

GLFWwindow* glfwContext;
GLFWwindow *glfwContext;

Scene* GetCurrentScene() { return currentScene; }
Scene *GetCurrentScene() { return currentScene; }

private:
std::vector<std::shared_ptr<Scene>> scenes = {};
Scene* currentScene = nullptr;
std::vector<std::shared_ptr<Scene>> scenes = {};
Scene *currentScene = nullptr;
};

extern Engine* EngineRef;
}
extern Engine *EngineRef;
} // namespace Jenjin
18 changes: 9 additions & 9 deletions engine/include/jenjin/framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
namespace Jenjin {
class Framebuffer {
public:
Framebuffer();
~Framebuffer();
Framebuffer();
~Framebuffer();

void Bind();
void Unbind();
void Bind();
void Unbind();

void Resize(int width, int height);
void Resize(int width, int height);

GLuint texture;
GLuint texture;

private:
GLuint fbo;
GLuint rbo;
GLuint fbo;
GLuint rbo;
};
}
} // namespace Jenjin
78 changes: 39 additions & 39 deletions engine/include/jenjin/gameobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,63 @@

#include "jenjin/mesh.h"

#include <spdlog/spdlog.h>
#include <glm/glm.hpp>
#include <spdlog/spdlog.h>

#include <string>

namespace Jenjin {
class GameObject {
public:
GameObject(std::string name, Mesh mesh) : mesh(mesh), name(name) {}
~GameObject() { spdlog::trace("GameObject::~GameObject(\"{}\")", name); }
GameObject(std::string name, Mesh mesh) : mesh(mesh), name(name) {}
~GameObject() { spdlog::trace("GameObject::~GameObject(\"{}\")", name); }

std::string name;
std::string name;

// Transform
struct Transform {
glm::vec2 position;
glm::vec2 scale;
float rotation;
} transform = { glm::vec2(0.0f), glm::vec2(1.0f), 0.0f };
// Transform
struct Transform {
glm::vec2 position;
glm::vec2 scale;
float rotation;
} transform = {glm::vec2(0.0f), glm::vec2(1.0f), 0.0f};

// Appearance
glm::vec3 color = glm::vec3(1.0f);
// Appearance
glm::vec3 color = glm::vec3(1.0f);

Mesh mesh;
std::string texturePath = "";
Mesh mesh;
std::string texturePath = "";

int meshReferenceID = -1;
int meshReferenceID = -1;

bool mixColor = false;
bool mixColor = false;

// TODO: hierarchy
// TODO: hierarchy
#ifdef false
GameObject* parent = nullptr;
std::vector<GameObject*> children = {};
GameObject *parent = nullptr;
std::vector<GameObject *> children = {};
#endif

// Getters
std::string GetName() { return name; }
glm::vec2 GetPosition() { return transform.position; }
glm::vec2 GetScale() { return transform.scale; }
float GetRotation() { return transform.rotation; }
// Getters
std::string GetName() { return name; }
glm::vec2 GetPosition() { return transform.position; }
glm::vec2 GetScale() { return transform.scale; }
float GetRotation() { return transform.rotation; }

// Setters
void SetName(std::string name) { this->name = name; }
void SetPosition(glm::vec2 position) { transform.position = position; }
void SetScale(glm::vec2 scale) { transform.scale = scale; }
void SetRotation(float rotation) { transform.rotation = rotation; }
// Setters
void SetName(std::string name) { this->name = name; }
void SetPosition(glm::vec2 position) { transform.position = position; }
void SetScale(glm::vec2 scale) { transform.scale = scale; }
void SetRotation(float rotation) { transform.rotation = rotation; }

// Pointer getters
std::string* GetNamePointer() { return &name; }
glm::vec2* GetPositionPointer() { return &transform.position; }
glm::vec2* GetScalePointer() { return &transform.scale; }
float* GetRotationPointer() { return &transform.rotation; }
// Pointer getters
std::string *GetNamePointer() { return &name; }
glm::vec2 *GetPositionPointer() { return &transform.position; }
glm::vec2 *GetScalePointer() { return &transform.scale; }
float *GetRotationPointer() { return &transform.rotation; }

// Modifiers
void Translate(glm::vec2 translation) { transform.position += translation; }
void Scale(glm::vec2 scale) { transform.scale *= scale; }
void Rotate(float rotation) { transform.rotation += rotation; }
// Modifiers
void Translate(glm::vec2 translation) { transform.position += translation; }
void Scale(glm::vec2 scale) { transform.scale *= scale; }
void Rotate(float rotation) { transform.rotation += rotation; }
};
}
} // namespace Jenjin
12 changes: 6 additions & 6 deletions engine/include/jenjin/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include "jenjin/mesh.h"

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glad/glad.h>

namespace Jenjin {
namespace Helpers {
GLFWwindow* CreateWindow(int width, int height, const char* title);
void CheckWindow(GLFWwindow* window);
void InitiateImGui(GLFWwindow* window);
GLFWwindow *CreateWindow(int width, int height, const char *title);
void CheckWindow(GLFWwindow *window);
void InitiateImGui(GLFWwindow *window);

Mesh CreateQuad(int width, int height);
}
}
} // namespace Helpers
} // namespace Jenjin
Loading

0 comments on commit 471679d

Please sign in to comment.