scenewalker-libretro/mesh.hpp

90 lines
2.1 KiB
C++
Raw Normal View History

2013-05-10 16:59:30 +00:00
#ifndef MESH_HPP__
#define MESH_HPP__
#include "gl.hpp"
#include "shader.hpp"
#include "texture.hpp"
#include <vector>
#include <cstddef>
#include <memory>
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/type_ptr.hpp"
#include "shared.hpp"
2013-05-10 16:59:30 +00:00
namespace GL
{
struct Vertex
{
glm::vec3 vert;
glm::vec3 normal;
glm::vec2 tex;
2013-05-10 16:59:30 +00:00
};
struct Material
{
Material() :
ambient(0, 0, 0),
diffuse(0, 0, 0),
specular(0, 0, 0),
specular_power(60.0),
alpha_mod(1.0f)
{}
glm::vec3 ambient;
glm::vec3 diffuse;
glm::vec3 specular;
float specular_power;
float alpha_mod;
std1::shared_ptr<Texture> diffuse_map;
2013-05-12 11:28:39 +00:00
std1::shared_ptr<Texture> ambient_map;
};
2013-05-10 16:59:30 +00:00
class Mesh
{
public:
Mesh();
~Mesh();
std1::shared_ptr<std::vector<Vertex> > get_vertex() const { return vertex; }
2013-05-14 00:33:51 +00:00
const Material& get_material() const { return material; }
void set_vertices(std::vector<Vertex> vertex);
void set_vertices(const std1::shared_ptr<std::vector<Vertex> >& vertex);
void set_vertex_type(GLenum type);
void set_material(const Material& material);
2013-05-12 19:46:08 +00:00
void set_blank(const std1::shared_ptr<Texture>& blank);
void set_shader(const std1::shared_ptr<Shader>& shader);
2013-05-10 16:59:30 +00:00
void set_model(const glm::mat4& model);
void set_view(const glm::mat4& view);
void set_projection(const glm::mat4& projection);
2013-05-14 00:07:53 +00:00
void set_eye(const glm::vec3& eye_pos);
2013-05-10 16:59:30 +00:00
2013-05-14 00:07:53 +00:00
void set_light_pos(const glm::vec3& light_pos);
void set_light_ambient(const glm::vec3& light_ambient);
2013-05-10 16:59:30 +00:00
void render();
private:
GLuint vbo;
GLenum vertex_type;
std1::shared_ptr<std::vector<Vertex> > vertex;
std1::shared_ptr<Shader> shader;
2013-05-12 19:46:08 +00:00
std1::shared_ptr<Texture> blank;
Material material;
2013-05-14 00:07:53 +00:00
glm::vec3 light_pos;
glm::vec3 light_ambient;
2013-05-14 00:07:53 +00:00
glm::vec3 eye_pos;
2013-05-10 16:59:30 +00:00
glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;
glm::mat4 mvp;
};
}
#endif