95 lines
2.9 KiB
C++
95 lines
2.9 KiB
C++
#ifndef __FISHBOWL_DRAW_H__
|
|
#define __FISHBOWL_DRAW_H__
|
|
|
|
#include <fishbone/pre.h>
|
|
|
|
namespace fishbone {
|
|
class Texture;
|
|
class Mesh;
|
|
class Renderer;
|
|
}; // namespace fishbone
|
|
|
|
#include <fishbone/window.h>
|
|
#include <fishbone/meshldr.h>
|
|
#include <fishbone/textureldr.h>
|
|
#include <fishbone/math.h>
|
|
|
|
namespace fishbone {
|
|
class Texture {
|
|
void init(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height);
|
|
|
|
struct Impl;
|
|
Impl* impl;
|
|
|
|
public:
|
|
Texture(fishbone::Renderer* renderer, unsigned char* rgba, int width, int height) {
|
|
this->init(renderer, rgba, width, height);
|
|
}
|
|
Texture(fishbone::Renderer* renderer, fishbone::TextureData* data) {
|
|
this->init(renderer, data->rgba, data->width, data->height);
|
|
}
|
|
~Texture();
|
|
|
|
void begin();
|
|
void end();
|
|
};
|
|
|
|
class Mesh {
|
|
void init(fishbone::Renderer* renderer, std::vector<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals);
|
|
|
|
struct Impl;
|
|
Impl* impl;
|
|
|
|
public:
|
|
Mesh(fishbone::Renderer* renderer, std::vector<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals) {
|
|
this->init(renderer, vertices, texcoords, normals);
|
|
}
|
|
Mesh(fishbone::Renderer* renderer, fishbone::MeshData* data) {
|
|
this->init(renderer, data->vertices, data->texcoords, data->normals);
|
|
}
|
|
~Mesh();
|
|
|
|
void draw();
|
|
void draw(struct fishbone::Vector3 pos);
|
|
void draw(struct fishbone::Vector3 pos, struct fishbone::Vector3 rot);
|
|
|
|
fishbone::Texture* texture;
|
|
};
|
|
|
|
class Renderer {
|
|
struct Impl;
|
|
Impl* impl;
|
|
|
|
public:
|
|
Renderer(fishbone::Window* window);
|
|
~Renderer();
|
|
|
|
void prepare();
|
|
void quad(std::vector<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals) {
|
|
std::vector<struct fishbone::Vector3> v;
|
|
std::vector<struct fishbone::Vector2> t;
|
|
std::vector<struct fishbone::Vector3> n;
|
|
|
|
v = fishbone::quadToTriangle<struct fishbone::Vector3>(vertices);
|
|
t = fishbone::quadToTriangle<struct fishbone::Vector2>(texcoords);
|
|
n = fishbone::quadToTriangle<struct fishbone::Vector3>(normals);
|
|
|
|
this->triangle(v, t, n);
|
|
}
|
|
void triangle(std::vector<struct fishbone::Vector3> vertices, std::vector<struct fishbone::Vector2> texcoords, std::vector<struct fishbone::Vector3> normals);
|
|
void quad(std::vector<struct fishbone::Vector2> vertices, std::vector<struct fishbone::Vector2> texcoords) {
|
|
std::vector<struct fishbone::Vector2> v;
|
|
std::vector<struct fishbone::Vector2> t;
|
|
|
|
v = fishbone::quadToTriangle<struct fishbone::Vector2>(vertices);
|
|
t = fishbone::quadToTriangle<struct fishbone::Vector2>(texcoords);
|
|
|
|
this->triangle(v, t);
|
|
}
|
|
void triangle(std::vector<struct fishbone::Vector2> vertices, std::vector<struct fishbone::Vector2> texcoords);
|
|
};
|
|
|
|
static float maxDistance = 64;
|
|
}; // namespace fishbone
|
|
|
|
#endif
|