mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 09:34:16 +00:00
feat: rework few fonctions and change glew to glad
- game files deleted
This commit is contained in:
19
inc/EBO.hpp
19
inc/EBO.hpp
@@ -1,18 +1,21 @@
|
||||
#ifndef EBO_HPP
|
||||
#define EBO_HPP
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
|
||||
class EBO
|
||||
{
|
||||
private:
|
||||
GLuint id;
|
||||
private:
|
||||
GLuint id;
|
||||
|
||||
public:
|
||||
EBO(unsigned int* indices, size_t size);
|
||||
~EBO();
|
||||
public:
|
||||
EBO(unsigned int* indices, size_t size);
|
||||
~EBO();
|
||||
|
||||
void bind();
|
||||
void unbind();
|
||||
void bind();
|
||||
void unbind();
|
||||
};
|
||||
#endif
|
||||
26
inc/VAO.hpp
26
inc/VAO.hpp
@@ -1,23 +1,27 @@
|
||||
#ifndef VAO_HPP
|
||||
#define VAO_HPP
|
||||
|
||||
#include <gl/glew.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
class VAO
|
||||
{
|
||||
private:
|
||||
unsigned int id;
|
||||
private:
|
||||
unsigned int id;
|
||||
|
||||
public:
|
||||
VAO();
|
||||
~VAO();
|
||||
public:
|
||||
VAO();
|
||||
~VAO();
|
||||
|
||||
void bind();
|
||||
void unbind();
|
||||
void bind();
|
||||
void unbind();
|
||||
|
||||
void setAttributePointer(GLuint index, GLuint size, GLenum type, GLsizei stride, const void* offset);
|
||||
void drawElement(GLenum mode, GLsizei count, GLenum type, const void *indices);
|
||||
void drawArray(GLenum mode, GLint first, GLsizei count);
|
||||
void setAttributePointer(GLuint index, GLuint size, GLenum type,
|
||||
GLsizei stride, const void* offset);
|
||||
void drawElement(GLenum mode, GLsizei count, GLenum type,
|
||||
const void* indices);
|
||||
void drawArray(GLenum mode, GLint first, GLsizei count);
|
||||
};
|
||||
|
||||
#endif
|
||||
19
inc/VBO.hpp
19
inc/VBO.hpp
@@ -1,20 +1,21 @@
|
||||
#ifndef VBO_HPP
|
||||
#define VBO_HPP
|
||||
|
||||
#include <gl/glew.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "glad/glad.h"
|
||||
|
||||
class VBO
|
||||
{
|
||||
private:
|
||||
unsigned int id;
|
||||
private:
|
||||
unsigned int id;
|
||||
|
||||
public:
|
||||
VBO(GLfloat* vertices, size_t size);
|
||||
~VBO();
|
||||
|
||||
void bind();
|
||||
void unbind();
|
||||
public:
|
||||
VBO(GLfloat* vertices, size_t size);
|
||||
~VBO();
|
||||
|
||||
void bind();
|
||||
void unbind();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,44 +1,46 @@
|
||||
#ifndef CAMERA_HPP
|
||||
#define CAMERA_HPP
|
||||
|
||||
#include <glfw/glfw3.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include "glm/glm.hpp"
|
||||
#include "glm/gtc/matrix_transform.hpp"
|
||||
|
||||
class Camera {
|
||||
private:
|
||||
int screenWidth;
|
||||
int screenHeight;
|
||||
struct GLFWwindow;
|
||||
|
||||
double mousePosX;
|
||||
double mousePosY;
|
||||
bool firstMouse = true;
|
||||
class Camera
|
||||
{
|
||||
private:
|
||||
int screenWidth;
|
||||
int screenHeight;
|
||||
|
||||
float cameraYaw;
|
||||
float cameraPitch;
|
||||
double mousePosX;
|
||||
double mousePosY;
|
||||
bool firstMouse = true;
|
||||
|
||||
glm::vec3 cameraFront;
|
||||
glm::vec3 cameraUp;
|
||||
glm::vec3 cameraRight;
|
||||
glm::vec3 worldUp;
|
||||
float cameraYaw;
|
||||
float cameraPitch;
|
||||
|
||||
GLFWwindow* window;
|
||||
glm::vec3 cameraFront;
|
||||
glm::vec3 cameraUp;
|
||||
glm::vec3 cameraRight;
|
||||
glm::vec3 worldUp;
|
||||
|
||||
void processInput(float deltaTime);
|
||||
void processMouseMovement();
|
||||
void updateCameraVectors();
|
||||
GLFWwindow* window;
|
||||
|
||||
public:
|
||||
Camera(int width, int height, GLFWwindow* window, float sensitivity);
|
||||
void processInput(float deltaTime);
|
||||
void processMouseMovement();
|
||||
void updateCameraVectors();
|
||||
|
||||
void update(float deltaTime);
|
||||
glm::mat4 getViewMatrix();
|
||||
public:
|
||||
Camera(int width, int height, GLFWwindow* window, float sensitivity);
|
||||
|
||||
float speed;
|
||||
float cameraSensitivity;
|
||||
float fov;
|
||||
void update(float deltaTime);
|
||||
glm::mat4 getViewMatrix();
|
||||
|
||||
glm::vec3 cameraPosition;
|
||||
float speed;
|
||||
float cameraSensitivity;
|
||||
float fov;
|
||||
|
||||
glm::vec3 cameraPosition;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
12
inc/cube.hpp
12
inc/cube.hpp
@@ -1,16 +1,18 @@
|
||||
#ifndef CUBE_HPP
|
||||
#define CUBE_HPP
|
||||
|
||||
#include "vbo.hpp"
|
||||
#include <stddef.h>
|
||||
|
||||
#include "camera.hpp"
|
||||
#include "ebo.hpp"
|
||||
#include "vao.hpp"
|
||||
#include "shader.hpp"
|
||||
#include "texture.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "vao.hpp"
|
||||
#include "vbo.hpp"
|
||||
|
||||
class Cube
|
||||
{
|
||||
private:
|
||||
private:
|
||||
VBO vbo;
|
||||
EBO ebo;
|
||||
VAO vao;
|
||||
@@ -19,7 +21,7 @@ private:
|
||||
Shader shader;
|
||||
Texture texture;
|
||||
|
||||
public:
|
||||
public:
|
||||
Cube(Camera &camera);
|
||||
void loop(int width, int height);
|
||||
};
|
||||
|
||||
29
inc/game.hpp
29
inc/game.hpp
@@ -1,29 +0,0 @@
|
||||
#ifndef GAME_HPP
|
||||
#define GAME_HPP
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Game
|
||||
{
|
||||
private:
|
||||
int width;
|
||||
int height;
|
||||
const char *name;
|
||||
GLFWwindow *window;
|
||||
|
||||
public:
|
||||
Game(int width, int height, string name);
|
||||
~Game();
|
||||
|
||||
void run(bool (*func)(Game *g));
|
||||
|
||||
GLFWwindow *getWindow();
|
||||
const char *getName();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,28 +1,25 @@
|
||||
#ifndef SHADER_HPP
|
||||
#define SHADER_HPP
|
||||
|
||||
#include <gl/glew.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include "glad/glad.h"
|
||||
|
||||
class Shader
|
||||
{
|
||||
private:
|
||||
GLuint vertexShader;
|
||||
GLuint fragmentShader;
|
||||
GLuint shaderProgram;
|
||||
private:
|
||||
GLuint vertexShader;
|
||||
GLuint fragmentShader;
|
||||
GLuint shaderProgram;
|
||||
|
||||
void addVertShader(const char* vertexShaderSource);
|
||||
void addFragShader(const char* fragmentShaderSource);
|
||||
void compileInProgram();
|
||||
void addVertShader(const char* vertexShaderSource);
|
||||
void addFragShader(const char* fragmentShaderSource);
|
||||
void compileInProgram();
|
||||
|
||||
public:
|
||||
Shader(const char* vertexShaderSource, const char* fragmentShaderSource);
|
||||
~Shader();
|
||||
|
||||
GLuint getProgram() const;
|
||||
void use() const;
|
||||
public:
|
||||
Shader(const char* vertexShaderSource, const char* fragmentShaderSource);
|
||||
~Shader();
|
||||
|
||||
GLuint getProgram() const;
|
||||
void use() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TEXTUTE_HPP
|
||||
#define TEXTUTE_HPP
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include "glad/glad.h"
|
||||
#include <string>
|
||||
|
||||
class Texture
|
||||
|
||||
Reference in New Issue
Block a user