Linux fix
* Fixed lWindow # Fixed the key and mouse button events # Decleared the 'PollEvents' function # Decleared the 'OnEvent' function * Fixed GraphicsContext (typo) # Changed the GraphicsContext::OpenGL to GraphicsAPI::OpenGL * Fixed 'QuadRendererProgram' (linux) # Removed 'QuadRendererVertex''s forward decleration * Fixed 'TextureRendererProgram' (linux) # Removed 'TextureRendererProgram''s forward decleration * Added __builtin_trap on 'LT_*_ASSERT's for linux platforms
This commit is contained in:
parent
033a3b1dd1
commit
3363239c8d
6 changed files with 57 additions and 29 deletions
|
@ -19,15 +19,18 @@
|
|||
#if defined(LIGHT_PLATFORM_WINDOWS)
|
||||
#define LT_BUILD_PLATFORM "Windows"
|
||||
#define LT_WIN(x) x
|
||||
|
||||
#elif defined(LIGHT_PLATFORM_LINUX)
|
||||
#define LT_BUILD_PLATFORM "Linux"
|
||||
|
||||
#define LT_LIN(x) x
|
||||
|
||||
#elif defined(LIGHT_PLATFORM_MAC)
|
||||
#error "Unsupported platform: MAC"
|
||||
#define LT_MAC(x) x
|
||||
|
||||
#else
|
||||
#error "Unsupported platform: Unknown"
|
||||
|
||||
#endif
|
||||
|
||||
#define BIT(x) 1 << x
|
||||
|
@ -36,7 +39,8 @@
|
|||
#if defined(LIGHT_PLATFORM_WINDOWS)
|
||||
#define LT_ENGINE_ASSERT(x, ...) { if(!(x)) { LT_ENGINE_CRITICAL(__VA_ARGS__); __debugbreak(); throw ::Light::FailedAssertion(__FILE__, __LINE__); } }
|
||||
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); __debugbreak(); } }
|
||||
|
||||
#elif defined(LIGHT_PLATFORM_LINUX)
|
||||
#define LT_ENGINE_ASSERT(x, ...) { if(!(x)) { LT_ENGINE_CRITICAL(__VA_ARGS__); /* #todo: implement break */ throw ::Light::FailedAssertion(__FILE__, __LINE__); } }
|
||||
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); /* #todo: implement break */ } }
|
||||
#define LT_ENGINE_ASSERT(x, ...) { if(!(x)) { LT_ENGINE_CRITICAL(__VA_ARGS__); __builtin_trap(); throw ::Light::FailedAssertion(__FILE__, __LINE__); } }
|
||||
#define LT_CLIENT_ASSERT(x, ...) { if(!(x)) { LT_CLIENT_CRITICAL(__VA_ARGS__); __builtin_trap(); } }
|
||||
#endif
|
|
@ -36,7 +36,7 @@ namespace Light {
|
|||
#if defined(LIGHT_PLATFORM_WINDOWS)
|
||||
api = GraphicsAPI::DirectX;
|
||||
#elif defined(LIGHT_PLATFORM_LINUX)
|
||||
api = GraphicsContext::OpenGL;
|
||||
api = GraphicsAPI::OpenGL;
|
||||
#elif defined(LIGHT_PLATFORM_MAC)
|
||||
// #todo:
|
||||
#endif
|
||||
|
|
|
@ -18,19 +18,6 @@ namespace Light {
|
|||
|
||||
class QuadRendererProgram : RendererProgram
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<Shader> m_Shader;
|
||||
std::shared_ptr<VertexBuffer> m_VertexBuffer;
|
||||
std::shared_ptr<IndexBuffer> m_IndexBuffer;
|
||||
std::shared_ptr<VertexLayout> m_VertexLayout;
|
||||
|
||||
struct QuadVertexData; // <-- forward declaration
|
||||
QuadVertexData* m_MapCurrent = nullptr;
|
||||
QuadVertexData* m_MapEnd = nullptr;
|
||||
|
||||
unsigned int m_QuadCount = 0u;
|
||||
unsigned int m_MaxVertices = 0u;
|
||||
|
||||
public:
|
||||
struct QuadVertexData
|
||||
{
|
||||
|
@ -38,6 +25,19 @@ namespace Light {
|
|||
glm::vec4 tint;
|
||||
};
|
||||
|
||||
private:
|
||||
std::shared_ptr<Shader> m_Shader;
|
||||
std::shared_ptr<VertexBuffer> m_VertexBuffer;
|
||||
std::shared_ptr<IndexBuffer> m_IndexBuffer;
|
||||
std::shared_ptr<VertexLayout> m_VertexLayout;
|
||||
|
||||
QuadVertexData* m_MapCurrent = nullptr;
|
||||
QuadVertexData* m_MapEnd = nullptr;
|
||||
|
||||
unsigned int m_QuadCount = 0u;
|
||||
unsigned int m_MaxVertices = 0u;
|
||||
|
||||
public:
|
||||
QuadRendererProgram(unsigned int maxVertices, std::shared_ptr<SharedContext> sharedContext);
|
||||
|
||||
bool Advance();
|
||||
|
|
|
@ -18,13 +18,19 @@ namespace Light {
|
|||
|
||||
class TextureRendererProgram : RendererProgram
|
||||
{
|
||||
public:
|
||||
struct TextureVertexData
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec2 texcoord;
|
||||
};
|
||||
|
||||
private:
|
||||
std::shared_ptr<Shader> m_Shader;
|
||||
std::shared_ptr<VertexBuffer> m_VertexBuffer;
|
||||
std::shared_ptr<IndexBuffer> m_IndexBuffer;
|
||||
std::shared_ptr<VertexLayout> m_VertexLayout;
|
||||
|
||||
struct TextureVertexData; // <-- forward declaration
|
||||
TextureVertexData* m_MapCurrent = nullptr;
|
||||
TextureVertexData* m_MapEnd = nullptr;
|
||||
|
||||
|
@ -32,12 +38,6 @@ namespace Light {
|
|||
unsigned int m_MaxVertices = 0u;
|
||||
|
||||
public:
|
||||
struct TextureVertexData
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec2 texcoord;
|
||||
};
|
||||
|
||||
TextureRendererProgram(unsigned int maxVertices, std::shared_ptr<SharedContext> sharedContext);
|
||||
|
||||
bool Advance();
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace Light {
|
|||
LT_ENGINE_ASSERT(glfwInit(), "lWindow::lWindow: failed to initialize 'glfw'");
|
||||
|
||||
// create window
|
||||
glfwWindowHint(GLFW_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_VERSION_MINOR, 5);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||
|
||||
|
@ -46,6 +46,27 @@ namespace Light {
|
|||
glfwDestroyWindow(m_Handle);
|
||||
}
|
||||
|
||||
void lWindow::PollEvents()
|
||||
{
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
void lWindow::OnEvent(const Event& event)
|
||||
{
|
||||
switch (event.GetEventType())
|
||||
{
|
||||
// closed
|
||||
case EventType::WindowClosed:
|
||||
b_Closed = true;
|
||||
break;
|
||||
|
||||
// resized
|
||||
case EventType::WindowResized:
|
||||
m_GraphicsContext->OnWindowResize((const WindowResizedEvent&)event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lWindow::SetProperties(const WindowProperties& properties, bool affectsVisiblity /* = false */)
|
||||
{
|
||||
// save the visibility status and re-assign if 'affectVisibility' is false
|
||||
|
@ -115,7 +136,7 @@ namespace Light {
|
|||
ButtonPressedEvent event(button);
|
||||
callback(event);
|
||||
}
|
||||
else
|
||||
else if(action == GLFW_RELEASE)
|
||||
{
|
||||
ButtonReleasedEvent event(button);
|
||||
callback(event);
|
||||
|
@ -142,7 +163,7 @@ namespace Light {
|
|||
KeyPressedEvent event(key);
|
||||
callback(event);
|
||||
}
|
||||
else
|
||||
else if(action == GLFW_RELEASE)
|
||||
{
|
||||
KeyReleasedEvent event(key);
|
||||
callback(event);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "Events/MouseEvents.h"
|
||||
#include "Events/KeyboardEvents.h"
|
||||
#include "Events/WindowEvents.h"
|
||||
|
||||
|
||||
#include "Graphics/GraphicsContext.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
@ -20,6 +20,9 @@ namespace Light {
|
|||
wWindow::wWindow(std::function<void(Event&)> callback)
|
||||
: m_EventCallback(callback)
|
||||
{
|
||||
LT_ENGINE_TRACE("Pressed");
|
||||
|
||||
|
||||
// init glfw
|
||||
LT_ENGINE_ASSERT(glfwInit(), "wWindow::wWindow: failed to initialize 'glfw'");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue