asteroidgen/src/Application.h

102 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-11-03 03:00:32 +01:00
#include "SkyBox.h"
2017-11-03 00:22:38 +01:00
#include "gl.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;
2017-11-03 00:22:38 +01:00
int vPositionLoc, vTexCoordLoc, vNormalLoc;
unsigned int programId, tAlbedoId, tNormalId, tRoughnessId, tMetalicId;
2017-10-29 05:16:22 +01:00
int MVPloc, Vloc, Mloc, MVloc, LightPosition_worldspaceloc;
2017-11-03 00:22:38 +01:00
int tAlbedoLoc, tNormalLoc, tRoughnessLoc, tMetalicLoc;
2017-10-29 05:16:22 +01:00
2017-11-03 00:22:38 +01:00
Mesh mesh;
GLMesh glMesh;
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();
2017-11-03 03:00:32 +01:00
glm::mat4 perspective, view, mvp;
SkyBox skybox;
2017-10-29 05:16:22 +01:00
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();
2017-11-03 03:00:32 +01:00
void updateMatrices();
2017-10-29 05:16:22 +01:00
void prepareShader();
void gui();
void run();
};