asteroidgen/src/Application.h

98 lines
2.0 KiB
C
Raw Normal View History

2017-10-29 05:16:22 +01:00
#pragma once
#include "Density.h"
#include "Polygoniser.h"
#include "TextureMapper.h"
2017-11-02 03:44:44 +01:00
#include "ProgressMonitor.h"
2017-10-29 05:16:22 +01:00
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
#include <string>
2017-11-02 03:44:44 +01:00
#include <thread>
2017-10-29 05:16:22 +01:00
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;
2017-11-02 03:44:44 +01:00
vec3v_t vertices;
vec3v_t normals;
vec2v_t texcoords;
uvec3v_t indices;
2017-10-29 05:16:22 +01:00
size_t meteoridCount;
float meteroidMinRadius;
float meteroidMaxRadius;
int meteroidSizeExponent;
float densityFrequency, densityOctave;
glm::vec3 densityScale;
float resolution;
2017-11-02 03:44:44 +01:00
bool smoothMesh;
2017-10-29 05:16:22 +01:00
float viewDistance;
glm::mat4 fpsTrafo;
bool fpsMode;
2017-10-29 06:25:04 +01:00
double lastMouseX, lastMouseY;
2017-11-02 03:44:44 +01:00
glm::mat4 modelTrafo;
ProgressMonitor meshProgress, textureProgress;
std::thread meshThread, textureThread;
bool meshUploadRequest, textureUploadRequest;
2017-10-29 05:16:22 +01:00
void toogleFpsMode();
public:
Application();
~Application();
static Application &instance();
void init();
void shutdown();
void KeyCallback(GLFWwindow* window, int key, int scancode, int action,
int mods);
2017-10-29 06:25:04 +01:00
void CursorCallback(GLFWwindow* window, double x, double y);
2017-10-29 05:16:22 +01:00
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();
void loadShader();
void uploadMesh();
2017-11-02 03:44:44 +01:00
void uploadTexture();
2017-10-29 05:16:22 +01:00
void renderMesh();
void prepareShader();
void gui();
void run();
};