67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#ifndef PHONGENTITY_H
|
|
#define PHONGENTITY_H
|
|
|
|
#include <glew/glew.h>
|
|
#include <glm/mat4x4.hpp>
|
|
#include <vector>
|
|
#include "lights.h"
|
|
|
|
class Mesh;
|
|
class Material;
|
|
class Shader;
|
|
|
|
class PhongEntity
|
|
{
|
|
protected:
|
|
Mesh* mesh;
|
|
|
|
// modern opengl :
|
|
|
|
enum {
|
|
// required buffers
|
|
POSITION_BUFFER,
|
|
// optionnal buffers :
|
|
NORMAL_BUFFER, TEXCOORD_BUFFER, TANGENT_BUFFER,
|
|
// indices buffers
|
|
INDICES_BUFFER
|
|
};
|
|
|
|
GLuint vao;
|
|
int nb_buffers;
|
|
GLuint* vbo;
|
|
|
|
void modernInit(bool isDynamic);
|
|
void drawGroup(int groupId);
|
|
void modernDraw(const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix, Lights::Light* dirLight, Lights* pointLights);
|
|
|
|
// old opengl :
|
|
|
|
GLuint displayList;
|
|
|
|
void crappyInit();
|
|
void crappyDraw(const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix, Lights::Light* dirLight, Lights* pointLights);
|
|
|
|
public:
|
|
/**
|
|
* @brief the model matrix is public, so the user can manipulate it in any way he desires.
|
|
*/
|
|
glm::mat4 modelMatrix;
|
|
|
|
PhongEntity(Mesh* myMesh);
|
|
|
|
void draw(const glm::mat4 &viewMatrix, const glm::mat4 &projectionMatrix, Lights::Light* dirLight, Lights* pointLights);
|
|
|
|
void initGL(bool isDynamic = false);
|
|
void destroyGL();
|
|
|
|
Mesh* getMesh() {return mesh;}
|
|
|
|
/**
|
|
* @brief this method returns a clone of the current entity.
|
|
* The same VAO will be used to render both, so there is no need to call initGL on the clone
|
|
*/
|
|
PhongEntity* clone();
|
|
};
|
|
|
|
#endif // PHONGENTITY_H
|