Adding more input handlers
This commit is contained in:
parent
4a84df7c3e
commit
7ec13a7020
@ -10,6 +10,11 @@ links{
|
|||||||
"nfd"
|
"nfd"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
targetdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}"
|
||||||
|
objdir "%{wks.location}/%{prj.name}/build/%{cfg.buildcfg}/intermediates/"
|
||||||
|
|
||||||
includedirs{
|
includedirs{
|
||||||
|
|
||||||
"../YoggieEngine/build/Debug",
|
"../YoggieEngine/build/Debug",
|
||||||
|
@ -123,7 +123,6 @@ public:
|
|||||||
bool OnKey(int key, int mode) override {
|
bool OnKey(int key, int mode) override {
|
||||||
|
|
||||||
if (SceneisFocused) {
|
if (SceneisFocused) {
|
||||||
spdlog::info("update camera!");
|
|
||||||
if (key == YOGGIE_KEY_UP)
|
if (key == YOGGIE_KEY_UP)
|
||||||
camera->Rotation.x += movement_speed;
|
camera->Rotation.x += movement_speed;
|
||||||
|
|
||||||
@ -413,7 +412,7 @@ public:
|
|||||||
// spdlog::info("{0}x{1}", ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
// spdlog::info("{0}x{1}", ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||||
SceneisFocused = ImGui::IsWindowFocused() || ImGui::IsWindowHovered();
|
SceneisFocused = ImGui::IsWindowFocused() || ImGui::IsWindowHovered();
|
||||||
ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
|
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});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
project "EngineTests"
|
project "EngineTests"
|
||||||
kind "ConsoleApp"
|
kind "ConsoleApp"
|
||||||
language "C++"
|
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"}
|
files{"**.h", "**.cpp"}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ project "YoggieEngine"
|
|||||||
pchsource "src/YoggieEngine.cpp"
|
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"
|
buildmessage "Building Yoggie Engine"
|
||||||
disablewarnings{
|
disablewarnings{
|
||||||
"4099" -- Ignore the missing debug signals for GLFW warning
|
"4099" -- Ignore the missing debug signals for GLFW warning
|
||||||
|
@ -19,15 +19,19 @@ namespace YoggieEngine {
|
|||||||
void GuiEnd();
|
void GuiEnd();
|
||||||
|
|
||||||
void PushLayer(Layer* layer);
|
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 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:
|
protected:
|
||||||
std::string m_AppName;
|
std::string m_AppName;
|
||||||
NativeWindow* appWindow;
|
NativeWindow* appWindow;
|
||||||
|
|
||||||
LayerStack AppLayerstack;
|
LayerStack AppLayerstack;
|
||||||
|
Layer* guiLayer;
|
||||||
|
static Application* instance ;
|
||||||
|
|
||||||
|
friend class ImGuiLayer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,11 +1,38 @@
|
|||||||
#include <YoggieEngine.h>
|
#include <YoggieEngine.h>
|
||||||
#include "OpenglAPI.h"
|
#include "OpenglAPI.h"
|
||||||
namespace YoggieEngine {
|
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) {
|
void OpenGLApi::DrawTriangles(Render3DComponent rc) {
|
||||||
|
|
||||||
glBindVertexArray(rc.VAO);
|
glBindVertexArray(rc.VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, rc.IBO);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, rc.IBO);
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<unsigned int> (rc.mesh.elements.size()), GL_UNSIGNED_INT, 0);
|
glDrawElements(GL_TRIANGLES, static_cast<unsigned int> (rc.mesh.elements.size()), GL_UNSIGNED_INT, 0);
|
||||||
|
glCheckError();
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,9 +42,10 @@ namespace YoggieEngine {
|
|||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, CubeTexture.getID());
|
glBindTexture(GL_TEXTURE_CUBE_MAP, CubeTexture.getID());
|
||||||
|
//glCheckError(); // INVALID ENUM FOR SOME REASON
|
||||||
glBindVertexArray(VertexAttributeObject);
|
glBindVertexArray(VertexAttributeObject);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||||
|
//glCheckError();
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
@ -6,10 +6,6 @@ public:
|
|||||||
~Layer() { OnDestroy(); }
|
~Layer() { OnDestroy(); }
|
||||||
Layer() { OnCreate(); }
|
Layer() { OnCreate(); }
|
||||||
|
|
||||||
Layer(const std::string name )
|
|
||||||
: Name(name) {}
|
|
||||||
|
|
||||||
|
|
||||||
virtual void OnUpdate(){}
|
virtual void OnUpdate(){}
|
||||||
virtual void OnUI(){}
|
virtual void OnUI(){}
|
||||||
|
|
||||||
@ -18,6 +14,13 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool OnMouseButton(int button, int action) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool OnScroll(int xoffset, int yoffset) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnStartup(){}
|
virtual void OnStartup(){}
|
||||||
|
|
||||||
@ -26,9 +29,6 @@ public:
|
|||||||
virtual void OnCreate() {}
|
virtual void OnCreate() {}
|
||||||
virtual void OnDestroy(){}
|
virtual void OnDestroy(){}
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::string Name;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user