Adding more input handlers

This commit is contained in:
Nigel Barink 2023-05-17 19:41:48 +02:00
parent 4a84df7c3e
commit 7ec13a7020
7 changed files with 56 additions and 15 deletions

View File

@ -10,6 +10,11 @@ links{
"nfd"
}
targetdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}"
objdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}/intermediates/"
includedirs{
"../YoggieEngine/build/Debug",

View File

@ -123,7 +123,6 @@ public:
bool OnKey(int key, int mode) override {
if (SceneisFocused) {
spdlog::info("update camera!");
if (key == YOGGIE_KEY_UP)
camera->Rotation.x += movement_speed;
@ -413,7 +412,7 @@ public:
// spdlog::info("{0}x{1}", ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
SceneisFocused = ImGui::IsWindowFocused() || ImGui::IsWindowHovered();
ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()},ImVec2{1,1}, ImVec2{0,0});

View File

@ -1,7 +1,10 @@
project "EngineTests"
kind "ConsoleApp"
language "C++"
targetdir "bin/%{cfg.buildcfg}"
targetdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}"
objdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}/intermediates/"
files{"**.h", "**.cpp"}

View File

@ -5,6 +5,8 @@ project "YoggieEngine"
pchsource "src/YoggieEngine.cpp"
targetdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}"
objdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}/intermediates/"
buildmessage "Building Yoggie Engine"
disablewarnings{
"4099" -- Ignore the missing debug signals for GLFW warning

View File

@ -19,15 +19,19 @@ namespace YoggieEngine {
void GuiEnd();
void PushLayer(Layer* layer);
static Application& Get() { return *Application::instance; }
static void HandleKey(GLFWwindow* window, int key, int scancode, int action, int mods);
static void HandleMouseButton(GLFWwindow* window, int button, int action, int mods);
static void HandleScroll(GLFWwindow* window, double xoffset, double yoffset);
protected:
std::string m_AppName;
NativeWindow* appWindow;
LayerStack AppLayerstack;
Layer* guiLayer;
static Application* instance ;
friend class ImGuiLayer;
};

View File

@ -1,11 +1,38 @@
#include <YoggieEngine.h>
#include "OpenglAPI.h"
namespace YoggieEngine {
GLenum glCheckError_(const char* file, int line) {
GLenum errorCode;
while ((errorCode = glGetError()) != GL_NO_ERROR) {
std::string error;
switch (errorCode)
{
case GL_INVALID_ENUM: error = "INVALID_ENUM"; break;
case GL_INVALID_VALUE: error = "INVALID_VALUE"; break;
case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break;
case GL_STACK_OVERFLOW: error = "STACK_OVERFLOW"; break;
case GL_STACK_UNDERFLOW: error = "STACK_UNDERFLOW"; break;
case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break;
case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break;
};
spdlog::error("{0} | {1} ({2})", error, file, line);
}
return errorCode;
}
#ifdef DEBUG
#define glCheckError() glCheckError_(__FILE__, __LINE__)
#else
#define glCheckError()
#endif
void OpenGLApi::DrawTriangles(Render3DComponent rc) {
glBindVertexArray(rc.VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, rc.IBO);
glDrawElements(GL_TRIANGLES, static_cast<unsigned int> (rc.mesh.elements.size()), GL_UNSIGNED_INT, 0);
glCheckError();
glBindVertexArray(0);
}
@ -15,9 +42,10 @@ namespace YoggieEngine {
glDepthMask(GL_FALSE);
glBindTexture(GL_TEXTURE_CUBE_MAP, CubeTexture.getID());
//glCheckError(); // INVALID ENUM FOR SOME REASON
glBindVertexArray(VertexAttributeObject);
glDrawArrays(GL_TRIANGLES, 0, 36);
//glCheckError();
glBindVertexArray(0);
glDepthMask(GL_TRUE);

View File

@ -6,10 +6,6 @@ public:
~Layer() { OnDestroy(); }
Layer() { OnCreate(); }
Layer(const std::string name )
: Name(name) {}
virtual void OnUpdate(){}
virtual void OnUI(){}
@ -18,6 +14,13 @@ public:
return false;
}
virtual bool OnMouseButton(int button, int action) {
return false;
}
virtual bool OnScroll(int xoffset, int yoffset) {
return false;
}
virtual void OnStartup(){}
@ -26,9 +29,6 @@ public:
virtual void OnCreate() {}
virtual void OnDestroy(){}
private:
std::string Name;
};