Move & symbol to the left when its part of the type
This commit is contained in:
@@ -132,14 +132,14 @@ namespace Inferno {
|
||||
dbg() << "Application shutdown";
|
||||
}
|
||||
|
||||
void Application::onEvent(Event &e)
|
||||
void Application::onEvent(Event& e)
|
||||
{
|
||||
EventDispatcher dispatcher(e);
|
||||
dispatcher.dispatch<WindowCloseEvent>(NF_BIND_EVENT(Application::onWindowClose));
|
||||
dispatcher.dispatch<WindowResizeEvent>(NF_BIND_EVENT(Application::onWindowResize));
|
||||
}
|
||||
|
||||
bool Application::onWindowClose(WindowCloseEvent &e)
|
||||
bool Application::onWindowClose(WindowCloseEvent& e)
|
||||
{
|
||||
// Suppress unused warning
|
||||
(void)e;
|
||||
@@ -151,7 +151,7 @@ namespace Inferno {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Application::onWindowResize(WindowResizeEvent &e)
|
||||
bool Application::onWindowResize(WindowResizeEvent& e)
|
||||
{
|
||||
// Suppress unused warning
|
||||
(void)e;
|
||||
|
||||
@@ -67,19 +67,19 @@ namespace Inferno {
|
||||
|
||||
class EventDispatcher {
|
||||
public:
|
||||
EventDispatcher(Event &e) : m_event(e) {}
|
||||
EventDispatcher(Event& e) : m_event(e) {}
|
||||
|
||||
// Easily dispatch all type of Events, call with:
|
||||
// dispatch<T>(std::bind(&F, this, std::placeholders::_1));
|
||||
// T is the type of Event
|
||||
// F is the function to call, signature: bool name(T &e);
|
||||
// F is the function to call, signature: bool name(T& e);
|
||||
template<typename T, typename F>
|
||||
bool dispatch(const F &function)
|
||||
bool dispatch(const F& function)
|
||||
{
|
||||
// If <constructed> type is same as member variable type
|
||||
if (T::getTypeStatic() == m_event.getType()) {
|
||||
// Call the function
|
||||
m_event.handled = function(static_cast<T &>(m_event));
|
||||
m_event.handled = function(static_cast<T& >(m_event));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace Inferno {
|
||||
}
|
||||
|
||||
private:
|
||||
Event &m_event;
|
||||
Event& m_event;
|
||||
};
|
||||
|
||||
// Add class type functions macro
|
||||
@@ -101,7 +101,7 @@ namespace Inferno {
|
||||
virtual char getCategoryFlags() const override { return category; }
|
||||
|
||||
// Make Events easily printable
|
||||
inline std::ostream& operator<<(std::ostream &os, const Event &e)
|
||||
inline std::ostream& operator<<(std::ostream& os, const Event& e)
|
||||
{
|
||||
return os << e.toString();
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace Inferno {
|
||||
|
||||
class File {
|
||||
public:
|
||||
static std::string read(const std::string &path);
|
||||
static std::string read(const std::string& path);
|
||||
|
||||
template<typename T>
|
||||
static void ioRead(T &t, const std::string &path)
|
||||
static void ioRead(T& t, const std::string& path)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
ASSERT(file.is_open(), "File could not open! {}", path.c_str());
|
||||
@@ -28,7 +28,7 @@ namespace Inferno {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void ioWrite(T &t, const std::string &path)
|
||||
static void ioWrite(T& t, const std::string& path)
|
||||
{
|
||||
std::ofstream file (path);
|
||||
ASSERT(file.is_open(), "File could not open! {}", path.c_str());
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Inferno {
|
||||
m_yOffset = 0.0f;
|
||||
}
|
||||
|
||||
bool Input::onMousePosition(MousePositionEvent &e)
|
||||
bool Input::onMousePosition(MousePositionEvent& e)
|
||||
{
|
||||
// Prevent weird jump on first cursor window enter
|
||||
if(m_firstMousePos) {
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Inferno {
|
||||
public:
|
||||
static void update();
|
||||
|
||||
static bool onMousePosition(MousePositionEvent &e);
|
||||
static bool onMousePosition(MousePositionEvent& e);
|
||||
|
||||
static bool isKeyPressed(int key);
|
||||
static bool isMouseButtonPressed(int button);
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Inferno {
|
||||
|
||||
// -----------------------------------------
|
||||
|
||||
BufferLayout::BufferLayout(const std::initializer_list<BufferElement> &elements) :
|
||||
BufferLayout::BufferLayout(const std::initializer_list<BufferElement>& elements) :
|
||||
m_elements(elements), m_stride(0)
|
||||
{
|
||||
this->calculateOffsetsAndStride();
|
||||
@@ -104,7 +104,7 @@ namespace Inferno {
|
||||
void BufferLayout::calculateOffsetsAndStride()
|
||||
{
|
||||
m_stride = 0;
|
||||
for (auto &element : m_elements) {
|
||||
for (auto& element : m_elements) {
|
||||
element.setOffset(m_stride);
|
||||
m_stride += element.getSize();
|
||||
}
|
||||
@@ -189,13 +189,13 @@ namespace Inferno {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void VertexArray::addVertexBuffer(const std::shared_ptr<VertexBuffer> &vertexBuffer)
|
||||
void VertexArray::addVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer)
|
||||
{
|
||||
this->bind();
|
||||
vertexBuffer->bind();
|
||||
|
||||
uint32_t index = 0;
|
||||
for (const auto &element : vertexBuffer->getLayout()) {
|
||||
for (const auto& element : vertexBuffer->getLayout()) {
|
||||
glEnableVertexAttribArray(index);
|
||||
glVertexAttribPointer(
|
||||
index,
|
||||
@@ -213,7 +213,7 @@ namespace Inferno {
|
||||
vertexBuffer->unbind();
|
||||
}
|
||||
|
||||
void VertexArray::setIndexBuffer(const std::shared_ptr<IndexBuffer> &indexBuffer)
|
||||
void VertexArray::setIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer)
|
||||
{
|
||||
this->bind();
|
||||
indexBuffer->bind();
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Inferno {
|
||||
inline uint32_t getOffset() const { return m_offset; }
|
||||
inline bool getNormalized() const { return m_normalized; }
|
||||
|
||||
inline void setType(const BufferElementType &type) { m_type = type; }
|
||||
inline void setName(const std::string &name) { m_name = name; }
|
||||
inline void setSize(const uint32_t &size) { m_size = size; }
|
||||
inline void setOffset(const uint32_t &offset) { m_offset = offset; }
|
||||
inline void setNormalized(const bool &normalized) { m_normalized = normalized; }
|
||||
inline void setType(const BufferElementType& type) { m_type = type; }
|
||||
inline void setName(const std::string& name) { m_name = name; }
|
||||
inline void setSize(const uint32_t& size) { m_size = size; }
|
||||
inline void setOffset(const uint32_t& offset) { m_offset = offset; }
|
||||
inline void setNormalized(const bool& normalized) { m_normalized = normalized; }
|
||||
|
||||
private:
|
||||
BufferElementType m_type;
|
||||
@@ -56,9 +56,9 @@ namespace Inferno {
|
||||
class BufferLayout {
|
||||
public:
|
||||
BufferLayout() {}
|
||||
BufferLayout(const std::initializer_list<BufferElement> &elements);
|
||||
BufferLayout(const std::initializer_list<BufferElement>& elements);
|
||||
|
||||
inline const std::vector<BufferElement> &getElements() const { return m_elements; }
|
||||
inline const std::vector<BufferElement>& getElements() const { return m_elements; }
|
||||
inline uint32_t getStride() const { return m_stride; }
|
||||
|
||||
// Iterators
|
||||
@@ -86,9 +86,9 @@ namespace Inferno {
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline BufferLayout const &getLayout() const { return m_layout; }
|
||||
inline const BufferLayout& getLayout() const { return m_layout; }
|
||||
|
||||
inline void setLayout(const BufferLayout &layout) { m_layout = layout; }
|
||||
inline void setLayout(const BufferLayout& layout) { m_layout = layout; }
|
||||
|
||||
private:
|
||||
uint32_t m_id;
|
||||
@@ -124,11 +124,11 @@ namespace Inferno {
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
void addVertexBuffer(const std::shared_ptr<VertexBuffer> &vertexBuffer);
|
||||
void setIndexBuffer(const std::shared_ptr<IndexBuffer> &indexBuffer);
|
||||
void addVertexBuffer(const std::shared_ptr<VertexBuffer>& vertexBuffer);
|
||||
void setIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer);
|
||||
|
||||
const std::vector<std::shared_ptr<VertexBuffer>> &getVertexBuffers() const { return m_vertexBuffers; }
|
||||
const std::shared_ptr<IndexBuffer> &getIndexBuffer() const { return m_indexBuffer; }
|
||||
const std::vector<std::shared_ptr<VertexBuffer>>& getVertexBuffers() const { return m_vertexBuffers; }
|
||||
const std::shared_ptr<IndexBuffer>& getIndexBuffer() const { return m_indexBuffer; }
|
||||
|
||||
private:
|
||||
uint32_t m_id;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Inferno {
|
||||
"Inferno requires at least OpenGL version 4.5!");
|
||||
#endif
|
||||
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(m_window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(m_window);
|
||||
|
||||
// Disable vsync
|
||||
if (!w.isVSync()) {
|
||||
|
||||
@@ -46,49 +46,49 @@ namespace Inferno {
|
||||
return location;
|
||||
}
|
||||
|
||||
void Shader::setInt(const std::string &name, int value)
|
||||
void Shader::setInt(const std::string& name, int value)
|
||||
{
|
||||
// Set unifrom int
|
||||
glUniform1i(findUniform(name), value);
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, float value) const
|
||||
void Shader::setFloat(const std::string& name, float value) const
|
||||
{
|
||||
// Set uniform float
|
||||
glUniform1f(findUniform(name), value);
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, float v1, float v2, float v3, float v4) const
|
||||
void Shader::setFloat(const std::string& name, float v1, float v2, float v3, float v4) const
|
||||
{
|
||||
// Set uniform vec4 data
|
||||
glUniform4f(findUniform(name), v1, v2, v3, v4);
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, glm::vec2 value) const
|
||||
void Shader::setFloat(const std::string& name, glm::vec2 value) const
|
||||
{
|
||||
// Set uniform vec2 data
|
||||
glUniform2f(findUniform(name), value.x, value.y);
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, glm::vec3 value) const
|
||||
void Shader::setFloat(const std::string& name, glm::vec3 value) const
|
||||
{
|
||||
// Set uniform vec3 data
|
||||
glUniform3f(findUniform(name), value.x, value.y, value.z);
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, glm::vec4 value) const
|
||||
void Shader::setFloat(const std::string& name, glm::vec4 value) const
|
||||
{
|
||||
// Set uniform vec4 data
|
||||
glUniform4f(findUniform(name), value.x, value.y, value.z, value.w);
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, glm::mat3 matrix) const
|
||||
void Shader::setFloat(const std::string& name, glm::mat3 matrix) const
|
||||
{
|
||||
// Set uniform mat3 data
|
||||
glUniformMatrix3fv(findUniform(name), 1, GL_FALSE, glm::value_ptr(matrix));
|
||||
}
|
||||
|
||||
void Shader::setFloat(const std::string &name, glm::mat4 matrix) const
|
||||
void Shader::setFloat(const std::string& name, glm::mat4 matrix) const
|
||||
{
|
||||
// Set uniform mat4 data
|
||||
glUniformMatrix4fv(findUniform(name), 1, GL_FALSE, glm::value_ptr(matrix));
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Inferno {
|
||||
|
||||
// Window close callback
|
||||
glfwSetWindowCloseCallback(m_window, [](GLFWwindow* window) {
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
|
||||
WindowCloseEvent event;
|
||||
w.m_eventCallback(event);
|
||||
@@ -86,7 +86,7 @@ namespace Inferno {
|
||||
|
||||
// Window resize callback
|
||||
glfwSetWindowSizeCallback(m_window, [](GLFWwindow* window, int width, int height) {
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
|
||||
w.m_windowProperties.width = width;
|
||||
w.m_windowProperties.height = height;
|
||||
@@ -101,7 +101,7 @@ namespace Inferno {
|
||||
(void)scanCode;
|
||||
(void)mods;
|
||||
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
|
||||
switch (action) {
|
||||
case GLFW_PRESS: {
|
||||
@@ -127,7 +127,7 @@ namespace Inferno {
|
||||
// Suppress unused warning
|
||||
(void)mods;
|
||||
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
|
||||
switch (action) {
|
||||
case GLFW_PRESS: {
|
||||
@@ -145,7 +145,7 @@ namespace Inferno {
|
||||
|
||||
// Mouse position callback
|
||||
glfwSetCursorPosCallback(m_window, [](GLFWwindow* window, double xPos, double yPos) {
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
|
||||
MousePositionEvent event(xPos, yPos);
|
||||
w.m_eventCallback(event);
|
||||
@@ -153,7 +153,7 @@ namespace Inferno {
|
||||
|
||||
// Mouse scroll callback
|
||||
glfwSetScrollCallback(m_window, [](GLFWwindow* window, double xOffset, double yOffset) {
|
||||
Window &w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
Window& w = *(Window*)glfwGetWindowUserPointer(window);
|
||||
|
||||
MouseScrollEvent event(xOffset, yOffset);
|
||||
w.m_eventCallback(event);
|
||||
|
||||
Reference in New Issue
Block a user