asteroidgen/src/Application.h

90 lines
1.7 KiB
C++

#pragma once
#include "Density.h"
#include "Polygoniser.h"
#include "TextureMapper.h"
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
#include <string>
struct GLFWwindow;
class Application {
GLFWwindow* window;
int width, height;
Density density;
float densityIsolevel;
Polygonizer polygonizer;
float textureSize;
TextureMapper texturemapper;
unsigned int vertexArrayId, vPositionId, vTexCoordId, vNormalId,
indexBufferId, programId, tAlbedoId, tNormalId, tRoughnessId,
tMetalicId;
int MVPloc, Vloc, Mloc, MVloc, LightPosition_worldspaceloc;
int vPositionLoc, vTexCoordLoc, vNormalLoc, tAlbedoLoc, tNormalLoc,
tRoughnessLoc, tMetalicLoc;
std::vector<glm::vec3> vertices;
std::vector<glm::vec3> normals;
std::vector<glm::vec2> texcoords;
std::vector<glm::uvec3> indices;
size_t meteoridCount;
float meteroidMinRadius;
float meteroidMaxRadius;
int meteroidSizeExponent;
float densityFrequency, densityOctave;
glm::vec3 densityScale;
float resolution;
float viewDistance;
glm::mat4 fpsTrafo;
bool fpsMode;
void toogleFpsMode();
public:
Application();
~Application();
static Application &instance();
void init();
void shutdown();
void KeyCallback(GLFWwindow* window, int key, int scancode, int action,
int mods);
void MouseButtonCallback(GLFWwindow* window, int button, int action,
int mods);
void ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
void CharCallback(GLFWwindow* window, unsigned int c);
void generateAsteroid();
bool bindVertexAttrib(unsigned int id, int loc, unsigned int size);
void updateVertexArrayObject();
unsigned int loadProgram(const std::string &name);
void loadShader();
void uploadMesh();
void renderMesh();
void prepareShader();
void gui();
void run();
};