2016-09-06 13:15:29 +00:00
|
|
|
#pragma once
|
2016-09-07 14:07:56 +00:00
|
|
|
#include <gl\glew.h>
|
|
|
|
#include <gl\glfw3.h>
|
2016-10-30 13:22:08 +00:00
|
|
|
#include "Object.h"
|
2016-11-12 11:05:03 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-11-01 10:51:04 +00:00
|
|
|
#define VERTEX_INDEX_XYZ 0
|
|
|
|
#define VERTEX_INDEX_UV 1
|
|
|
|
|
|
|
|
#define VERTEX_COMPONENTS_XYZ 3
|
2016-11-01 13:16:18 +00:00
|
|
|
#define VERTEX_COMPONENTS_UV 2
|
2016-11-01 10:51:04 +00:00
|
|
|
|
|
|
|
#define VERTEX_SIZE_XYZ (sizeof(float) * VERTEX_COMPONENTS_XYZ)
|
|
|
|
#define VERTEX_SIZE_UV (sizeof(float) * VERTEX_COMPONENTS_UV)
|
|
|
|
|
|
|
|
#define VERTEX_OFFSET_XYZ 0
|
|
|
|
#define VERTEX_OFFSET_UV (VERTEX_SIZE_XYZ)
|
|
|
|
|
|
|
|
struct Vertex {
|
|
|
|
GLfloat position[3];
|
|
|
|
GLfloat uv[2];
|
|
|
|
};
|
|
|
|
|
2016-11-08 15:42:05 +00:00
|
|
|
struct textureData {
|
|
|
|
bool alpha;
|
|
|
|
std::uint32_t width;
|
|
|
|
std::uint32_t height;
|
2016-11-08 16:06:50 +00:00
|
|
|
std::vector<std::uint8_t>* data;
|
2016-11-08 15:42:05 +00:00
|
|
|
};
|
|
|
|
|
2016-09-06 13:15:29 +00:00
|
|
|
class OpenGLController
|
|
|
|
{
|
2016-09-07 14:07:56 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// constructor/destructor
|
2016-09-06 13:15:29 +00:00
|
|
|
public:
|
2016-09-08 09:36:57 +00:00
|
|
|
static OpenGLController* getInstance(int oglMajor = 4, int oglMinor = 5);
|
2016-09-06 13:15:29 +00:00
|
|
|
~OpenGLController();
|
|
|
|
|
2016-09-07 10:46:34 +00:00
|
|
|
private:
|
|
|
|
OpenGLController() {};
|
|
|
|
OpenGLController(int oglMajor, int oglMinor);
|
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// member
|
2016-09-06 13:15:29 +00:00
|
|
|
private:
|
2016-09-07 14:07:56 +00:00
|
|
|
// window
|
2016-11-01 13:16:18 +00:00
|
|
|
GLFWwindow* pWindow = NULL;
|
|
|
|
std::string sWindowName = "MeshViewer 2.0 pre-alpha";
|
|
|
|
int iWidth = 640;
|
|
|
|
int iHeight = 480;
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
// init glfw
|
2016-11-01 13:16:18 +00:00
|
|
|
int iOglMajorVersion = 4;
|
|
|
|
int iOglMinorVersion = 5;
|
|
|
|
int iAntiAliasingLevel = 4;
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-11-01 13:16:18 +00:00
|
|
|
// IDs ====================================
|
2016-09-07 14:07:56 +00:00
|
|
|
//object data
|
2016-11-01 13:16:18 +00:00
|
|
|
GLuint gluiVertexArrayID = 0;
|
|
|
|
GLuint gluiVertexBufferID = 0;
|
2016-09-07 14:07:56 +00:00
|
|
|
|
|
|
|
//obj color
|
2016-11-01 13:16:18 +00:00
|
|
|
GLuint gluiTextureID = 0;
|
|
|
|
GLuint gluiShaderPrgmID = 0;
|
|
|
|
GLuint gluiSamplerID = 0;
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
//obj transformation
|
2016-11-01 13:16:18 +00:00
|
|
|
GLuint gluiMatrixID = 0;
|
|
|
|
// ========================================
|
2016-09-07 14:07:56 +00:00
|
|
|
|
|
|
|
// data
|
2016-11-25 15:14:33 +00:00
|
|
|
std::vector<Modl*>* vModels = NULL;
|
2016-11-08 15:42:05 +00:00
|
|
|
std::vector<textureData*> vTextures;
|
2016-12-01 18:51:11 +00:00
|
|
|
Bbox sceneBoundingBox;
|
2016-09-07 14:07:56 +00:00
|
|
|
|
2016-11-01 13:16:18 +00:00
|
|
|
// transformation =========================
|
2016-09-07 14:07:56 +00:00
|
|
|
//values
|
2016-11-01 13:16:18 +00:00
|
|
|
float fRotationX = 0;
|
|
|
|
float fRotationY = 0;
|
|
|
|
float fRotationZ = 0;
|
|
|
|
double dTranslationX = 0;
|
|
|
|
double dTranslationY = 0;
|
2016-12-02 11:10:52 +00:00
|
|
|
double dTranslationZ = 3;
|
2016-09-07 14:07:56 +00:00
|
|
|
|
2016-11-01 13:16:18 +00:00
|
|
|
// ========================================
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
// camera
|
2016-11-01 13:16:18 +00:00
|
|
|
float fFOV = 45.0f;
|
|
|
|
float fMinView = 0.1f;
|
|
|
|
float fMaxView = 100.0f;
|
2016-09-06 13:15:29 +00:00
|
|
|
|
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// private functions
|
2016-09-06 13:15:29 +00:00
|
|
|
private:
|
|
|
|
void processInit();
|
2016-11-12 11:17:46 +00:00
|
|
|
void deleteVectors();
|
2016-09-07 14:07:56 +00:00
|
|
|
|
2016-09-06 13:15:29 +00:00
|
|
|
void startGLFW();
|
|
|
|
void createWindow();
|
2016-09-07 14:07:56 +00:00
|
|
|
void startGLEW();
|
2016-09-06 13:15:29 +00:00
|
|
|
void setCallbackFunctions();
|
|
|
|
|
2016-11-12 10:54:44 +00:00
|
|
|
glm::mat4 getModelMatrix(unsigned int index);
|
2016-11-07 11:06:55 +00:00
|
|
|
glm::mat4 getMVPMatrix(unsigned int index);
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// public functions
|
|
|
|
public:
|
|
|
|
|
|
|
|
// callback
|
2016-09-06 13:15:29 +00:00
|
|
|
void resize(int width, int height);
|
|
|
|
void addRotX(float value);
|
|
|
|
void addRotY(float value);
|
|
|
|
void addTransX(double value);
|
|
|
|
void addTransY(double value);
|
|
|
|
void addTransZ(double value);
|
2016-11-12 12:53:49 +00:00
|
|
|
void resetView();
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
// main routine
|
|
|
|
GLFWwindow* getWindow() const;
|
2016-09-06 13:15:29 +00:00
|
|
|
void updateScene();
|
2016-09-07 14:07:56 +00:00
|
|
|
void loadMsh(const char* path);
|
2016-09-06 13:15:29 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|