Forgot to push all code for last commit
This commit is contained in:
parent
794246eb02
commit
779df14f67
|
@ -1,7 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/GL.h>
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
#include "vbo.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/GL.h>
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
namespace simpleengine::gfx {
|
||||
class VBO {
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace simpleengine {
|
|||
private:
|
||||
using super = simpleengine::Event;
|
||||
public:
|
||||
explicit Renderable(std::shared_ptr<GLFWwindow> window = nullptr) : super(window) {}
|
||||
explicit Renderable(GLFWwindow* window = nullptr) : super(window) {}
|
||||
virtual ~Renderable() = default;
|
||||
};
|
||||
}
|
|
@ -1,7 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
@ -104,7 +109,7 @@ namespace simpleengine {
|
|||
|
||||
}
|
||||
|
||||
virtual void render(std::shared_ptr<GLFWwindow> target) {
|
||||
virtual void render(GLFWwindow* target) {
|
||||
glUseProgram(*program);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
@ -44,6 +49,6 @@ namespace simpleengine::shapes_2d {
|
|||
|
||||
virtual void update(const float& delta_time) override;
|
||||
|
||||
virtual void render(std::shared_ptr<GLFWwindow> target) override;
|
||||
virtual void render(GLFWwindow* target) override;
|
||||
};
|
||||
}
|
|
@ -1,7 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
@ -40,6 +45,6 @@ namespace simpleengine::shapes_2d {
|
|||
void set_texture(gfx::Texture texture);
|
||||
|
||||
virtual void update(const float& delta_time) override;
|
||||
virtual void render(std::shared_ptr<GLFWwindow> target) override;
|
||||
virtual void render(GLFWwindow* target) override;
|
||||
};
|
||||
}
|
|
@ -88,15 +88,15 @@ namespace simpleengine {
|
|||
}
|
||||
|
||||
static glm::mat4 rotation_x_matrix(float degrees) {
|
||||
return rotation_axis(degrees, glm::vec3(1.f, 0.f, 0.f));
|
||||
return rotation_matrix(degrees, glm::vec3(1.f, 0.f, 0.f));
|
||||
}
|
||||
|
||||
static glm::mat4 rotation_y_matrix(float degrees) {
|
||||
return rotation_axis(degrees, glm::vec3(0.f, 1.f, 0.f));
|
||||
return rotation_matrix(degrees, glm::vec3(0.f, 1.f, 0.f));
|
||||
}
|
||||
|
||||
static glm::mat4 rotation_z_matrix(float degrees) {
|
||||
return rotation_axis(degrees, glm::vec3(0.f, 0.f, 1.f));
|
||||
return rotation_matrix(degrees, glm::vec3(0.f, 0.f, 1.f));
|
||||
}
|
||||
|
||||
void rotate(float degrees, glm::vec3 rotation_axis) {
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
|
25
src/game.cpp
25
src/game.cpp
|
@ -3,29 +3,34 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GL/gl.h>
|
||||
#elif
|
||||
#include <gl/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <gl/gl.h>
|
||||
#endif
|
||||
|
||||
simpleengine::Game::Game(int w, int h, const std::string& window_name, const int& gl_profile, const int& major_version,
|
||||
const int& minor_version, const bool& resizeable, const int& forward_compat) : window_resizeable(resizeable) {
|
||||
initialize(gl_profile, major_version, minor_version, window_resizeable, forward_compat);
|
||||
|
||||
// Create a window
|
||||
window = std::shared_ptr<GLFWwindow>(glfwCreateWindow(w, h, window_name.c_str(), NULL, NULL));
|
||||
window = glfwCreateWindow(w, h, window_name.c_str(), NULL, NULL);
|
||||
|
||||
// If we're not resizeable, we need to set the viewport size.
|
||||
if (!resizeable) {
|
||||
int fbWidth;
|
||||
int fbHeight;
|
||||
glfwGetFramebufferSize(window.get(), &fbWidth, &fbHeight);
|
||||
glfwGetFramebufferSize(window, &fbWidth, &fbHeight);
|
||||
glViewport(0, 0, fbWidth, fbHeight);
|
||||
} else {
|
||||
glfwSetFramebufferSizeCallback(window.get(), simpleengine::Game::framebuffer_resize_callback);
|
||||
glfwSetFramebufferSizeCallback(window, simpleengine::Game::framebuffer_resize_callback);
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window.get());
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
glewExperimental = GL_TRUE;
|
||||
|
||||
|
@ -48,7 +53,7 @@ void simpleengine::Game::initialize(const int& gl_profile, const int& major_vers
|
|||
}
|
||||
|
||||
simpleengine::Game::~Game() {
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
}
|
||||
|
||||
void simpleengine::Game::add_event(std::shared_ptr<simpleengine::Event> event) {
|
||||
|
@ -81,7 +86,7 @@ void simpleengine::Game::render_items() {
|
|||
}
|
||||
|
||||
int simpleengine::Game::run() {
|
||||
while (!glfwWindowShouldClose(window.get())) {
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
// Update input
|
||||
glfwPollEvents();
|
||||
|
||||
|
@ -90,19 +95,19 @@ int simpleengine::Game::run() {
|
|||
render_window();
|
||||
|
||||
// End draw
|
||||
glfwSwapBuffers(window.get());
|
||||
glfwSwapBuffers(window);
|
||||
glFlush();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<GLFWwindow> simpleengine::Game::get_window() {
|
||||
GLFWwindow* simpleengine::Game::get_window() {
|
||||
return window;
|
||||
}
|
||||
|
||||
void simpleengine::Game::exit() {
|
||||
glfwSetWindowShouldClose(window.get(), true);
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace simpleengine::shapes_2d {
|
|||
|
||||
}
|
||||
|
||||
void Square::render(std::shared_ptr<GLFWwindow> target) {
|
||||
void Square::render(GLFWwindow* target) {
|
||||
shader.use();
|
||||
|
||||
// If theres a texture set, tell the fragment shader that and bind to the texture for drawing.
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace simpleengine::shapes_2d {
|
|||
} */
|
||||
}
|
||||
|
||||
void Triangle::render(std::shared_ptr<GLFWwindow> target) {
|
||||
void Triangle::render(GLFWwindow* target) {
|
||||
shader.use();
|
||||
|
||||
if (texture.has_value()) {
|
||||
|
|
Loading…
Reference in New Issue