Compare commits

..

No commits in common. "58be5709a39e2865bdc3142958fa00fc3073d35d" and "f7f5ffa4e425bbb7b2ec04b052ab0bc1c6fcc6f8" have entirely different histories.

2 changed files with 189 additions and 12 deletions

View File

@ -14,7 +14,7 @@ extern GameObject *g_SelectedObject; // Pointer to the currently selected object
extern std::shared_ptr<CameraComponent> g_RuntimeCameraObject; extern std::shared_ptr<CameraComponent> g_RuntimeCameraObject;
#include "Engine/AssetManager.h" #include "Engine/AssetManager.h"
extern AssetManager g_AssetManager; extern AssetManager *g_AssetManager;
extern LoggerWindow *g_LoggerWindow; extern LoggerWindow *g_LoggerWindow;
void InspectorWindow::Show() void InspectorWindow::Show()
@ -428,7 +428,7 @@ void InspectorWindow::Show()
mesh->MeshPath = buffer; mesh->MeshPath = buffer;
} }
if (ImGui::Button("Reload Mesh")) { if (ImGui::Button("Reload Mesh")) {
std::shared_ptr<Model> model = g_AssetManager.loadAsset<Model>(AssetType::MODEL, mesh->MeshPath.c_str()); std::shared_ptr<Model> model = g_AssetManager->loadAsset<Model>(AssetType::MODEL, mesh->MeshPath.c_str());
} }

View File

@ -33,6 +33,157 @@ extern std::shared_ptr<CameraComponent> g_RuntimeCameraObject;
extern int g_GPU_Triangles_drawn_to_screen; extern int g_GPU_Triangles_drawn_to_screen;
// Example cube data (position + UVs)
static float g_CubeVertices[] =
{
// FRONT (z=+1)
-1.f,
-1.f,
1.f,
0.f,
0.f,
1.f,
-1.f,
1.f,
1.f,
0.f,
1.f,
1.f,
1.f,
1.f,
1.f,
-1.f,
1.f,
1.f,
0.f,
1.f,
// BACK (z=-1)
-1.f,
-1.f,
-1.f,
1.f,
0.f,
1.f,
-1.f,
-1.f,
0.f,
0.f,
1.f,
1.f,
-1.f,
0.f,
1.f,
-1.f,
1.f,
-1.f,
1.f,
1.f,
// LEFT (x=-1)
-1.f,
-1.f,
-1.f,
0.f,
0.f,
-1.f,
-1.f,
1.f,
1.f,
0.f,
-1.f,
1.f,
1.f,
1.f,
1.f,
-1.f,
1.f,
-1.f,
0.f,
1.f,
// RIGHT (x=+1)
1.f,
-1.f,
-1.f,
1.f,
0.f,
1.f,
-1.f,
1.f,
0.f,
0.f,
1.f,
1.f,
1.f,
0.f,
1.f,
1.f,
1.f,
-1.f,
1.f,
1.f,
// TOP (y=+1)
-1.f,
1.f,
-1.f,
0.f,
0.f,
1.f,
1.f,
-1.f,
1.f,
0.f,
1.f,
1.f,
1.f,
1.f,
1.f,
-1.f,
1.f,
1.f,
0.f,
1.f,
// BOTTOM (y=-1)
-1.f,
-1.f,
-1.f,
1.f,
0.f,
1.f,
-1.f,
-1.f,
0.f,
0.f,
1.f,
-1.f,
1.f,
0.f,
1.f,
-1.f,
-1.f,
1.f,
1.f,
1.f,
};
static unsigned int g_CubeIndices[] =
{
// Front
0, 1, 2, 2, 3, 0,
// Back
4, 5, 6, 6, 7, 4,
// Left
8, 9, 10, 10, 11, 8,
// Right
12, 13, 14, 14, 15, 12,
// Top
16, 17, 18, 18, 19, 16,
// Bottom
20, 21, 22, 22, 23, 20};
bool PlayPauseButton(const char *label, bool *isPlaying, ImVec2 Size) bool PlayPauseButton(const char *label, bool *isPlaying, ImVec2 Size)
{ {
// Define button size // Define button size
@ -94,9 +245,14 @@ bool PlayPauseButton(const char *label, bool *isPlaying, ImVec2 Size)
return false; // No toggle occurred return false; // No toggle occurred
} }
void RenderWindow::Show(bool *GameRunning) void RenderWindow::Show(bool *GameRunning)
{ {
ImGui::Begin(ICON_FA_GAMEPAD " Editor##EditorWindow"); ImGui::Begin(ICON_FA_GAMEPAD " Editor##EditorWindow");
if (!m_Initialized) if (!m_Initialized)
{ {
@ -148,6 +304,11 @@ void RenderWindow::Show(bool *GameRunning)
ImGui::End(); ImGui::End();
} }
void RenderWindow::InitGLResources() void RenderWindow::InitGLResources()
{ {
// ---------------------------------------------------- // ----------------------------------------------------
@ -165,6 +326,31 @@ void RenderWindow::InitGLResources()
m_ShaderPtr = shaderAsset.get(); m_ShaderPtr = shaderAsset.get();
} }
// ----------------------------------------------------
// 2) Create VAO/VBO/EBO for the cube
// ----------------------------------------------------
glGenVertexArrays(1, &m_VAO);
glBindVertexArray(m_VAO);
glGenBuffers(1, &m_VBO);
glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_CubeVertices), g_CubeVertices, GL_STATIC_DRAW);
glGenBuffers(1, &m_EBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(g_CubeIndices), g_CubeIndices, GL_STATIC_DRAW);
// Position = location 0, UV = location 1
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
5 * sizeof(float), (void *)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,
5 * sizeof(float), (void *)(3 * sizeof(float)));
glEnableVertexAttribArray(1);
glBindVertexArray(0);
// ---------------------------------------------------- // ----------------------------------------------------
// 3) Load TEXTURE from the asset manager // 3) Load TEXTURE from the asset manager
// ---------------------------------------------------- // ----------------------------------------------------
@ -212,11 +398,6 @@ void RenderWindow::RenderSceneToFBO(bool *GameRunning)
m_FBO.Bind(); m_FBO.Bind();
glViewport(0, 0, m_LastWidth, m_LastHeight); glViewport(0, 0, m_LastWidth, m_LastHeight);
#if TRANSPERANCY
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#endif
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glClearColor(0.f, 0.f, 0.f, 1.f); glClearColor(0.f, 0.f, 0.f, 1.f);
@ -345,10 +526,6 @@ void RenderWindow::RenderSceneToFBO(bool *GameRunning)
} }
// Cleanup: Unbind the shader program // Cleanup: Unbind the shader program
#if TRANSPERANCY
glDisable(GL_BLEND);
#endif
glUseProgram(0); glUseProgram(0);
// Unbind the FBO // Unbind the FBO