2016-09-06 13:15:29 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
2016-09-07 14:07:56 +00:00
|
|
|
#include <gl\glew.h>
|
|
|
|
#include <gl\glfw3.h>
|
2016-09-06 13:15:29 +00:00
|
|
|
#include <glm\glm.hpp>
|
|
|
|
#include <vector>
|
2016-10-30 13:22:08 +00:00
|
|
|
#include "Object.h"
|
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-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-10-30 13:22:08 +00:00
|
|
|
std::vector<Modl*> vModels;
|
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;
|
|
|
|
double dTranslationZ = 5;
|
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-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-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-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
|
|
|
|
|
|
|
};
|
|
|
|
|