velage/engine/object.hpp
miri e659cd35ed first planet gen test
one side of cube sphere done
2024-01-20 11:37:50 +01:00

109 lines
No EOL
2.4 KiB
C++

#ifndef __GAMEOBJECT_H__
#define __GAMEOBJECT_H__
#include <GL/glew.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include <SDL2/SDL_video.h>
#include <glm/ext/vector_float3.hpp>
#include <glm/ext/vector_float4.hpp>
#include <vector>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "camera.hpp"
//#include "rendering.hpp"
#include "shader.hpp"
#include "vector.hpp"
#include "camera.hpp"
#include "light.hpp"
#include "largepos.hpp"
/*
* internal representation of vertices
* pain
*/
class vertex{
public:
vector3f pos;
vertex(GLfloat x, GLfloat y, GLfloat z);
};
/*
* absolute bare minimum to get rendering to
* sorta hacky work
*/
class gameobject{
public:
shader *rend_shader;
GLuint vao;
GLuint shadowVao;
GLuint element_number;
GLuint ebo;
GLuint *elements;
bool shadows=false;
GLuint vertice_number;
enum buffers{
VERTEX_BUFFER,
INDEX_BUFFER,
COLOR_BUFFER,
NUM_BUFFERS
};
GLuint vbo[NUM_BUFFERS];
vertex *vertices;
//void render();
void render(camera cam);
void render(camera cam, shader *shader);
void renderShadowCalc(camera cam, shader *shadowCalc);
void renderShadows(light light, GLuint SHADOW_WIDTH, GLuint SHADOW_HEIGHT, GLuint depthCubemap, shader *depthshd, GLuint dfbo, float farClipPlane,camera cam, bool first=false);
void genVbo(vertex vertices[], GLuint size);
void genVbo(glm::vec3 vertices[], GLuint size);
void genVboShadow();
void setVertexAtribPointer(std::string param, const void * pointer);
void setVertexAtribPointerShadow(std::string param, shader *depthshd, const void * pointer);
//void genVbo(std::vector<GLfloat> vertices);
void genEbo(GLuint elements[], GLuint size);
void genEboShadow();
void setBuffer(vertex vertices[], GLuint size, buffers buffer);
void setUniform(glm::mat4 matrix, std::string name);
void setUniform(glm::mat4 matrix, GLint name);
void setUniform(float matrix, std::string name);
void setUniform(float matrix, GLint name);
void setUniform(glm::vec3, std::string name);
void setUniform(glm::vec3, GLint name);
void updateMatrix(camera cam);
GLint shdViewId;
GLint shdProjId;
GLint shdTrnsId;
glm::mat4 scaleMatrix;
glm::mat4 rotationMatrix;
glm::mat4 positionMatrix;
GLfloat distmult = 1.0;
largePos spacePos;
bool spaceAct=false;
gameobject(shader *render_shader);
~gameobject();
private:
};
#endif