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>
|
|
|
|
|
|
|
|
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-09-06 13:15:29 +00:00
|
|
|
GLFWwindow* pWindow;
|
2016-09-07 14:07:56 +00:00
|
|
|
std::string sWindowName;
|
2016-09-06 13:15:29 +00:00
|
|
|
int iWidth;
|
|
|
|
int iHeight;
|
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
// init glfw
|
|
|
|
int iOglMajorVersion;
|
|
|
|
int iOglMinorVersion;
|
|
|
|
int iAntiAliasingLevel;
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
// IDs ==========================
|
|
|
|
//object data
|
|
|
|
GLuint gluiVertexArrayID;
|
|
|
|
GLuint gluiVertexBufferID;
|
|
|
|
|
|
|
|
//obj color
|
|
|
|
GLuint gluiUVBufferID;
|
|
|
|
GLuint gluiTextureID;
|
|
|
|
GLuint gluiShaderPrgmID;
|
2016-09-06 13:15:29 +00:00
|
|
|
GLuint gluiSamplerID;
|
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
//obj transformation
|
|
|
|
GLuint gluiMatrixID;
|
|
|
|
// ==============================
|
|
|
|
|
|
|
|
// data
|
|
|
|
std::vector<GLfloat> vfVertices;
|
|
|
|
std::vector<GLfloat> vfUV;
|
|
|
|
|
|
|
|
// transformation ===============
|
|
|
|
//values
|
|
|
|
float fRotationX;
|
|
|
|
float fRotationY;
|
|
|
|
float fRotationZ;
|
|
|
|
double dTranslationX;
|
|
|
|
double dTranslationY;
|
|
|
|
double dTranslationZ;
|
|
|
|
|
|
|
|
//matrices
|
2016-09-06 13:15:29 +00:00
|
|
|
glm::mat4 m4x4Model;
|
2016-09-07 14:07:56 +00:00
|
|
|
glm::mat4 m4x4View;
|
|
|
|
glm::mat4 m4x4Projection;
|
|
|
|
// ==============================
|
2016-09-06 13:15:29 +00:00
|
|
|
|
2016-09-07 14:07:56 +00:00
|
|
|
// camera
|
|
|
|
float fFOV;
|
|
|
|
float fMinView;
|
|
|
|
float fMaxView;
|
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
|
|
|
|
|
|
|
void initDefault();
|
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();
|
|
|
|
|
|
|
|
glm::mat4 getMVPMatrix();
|
|
|
|
|
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
|
|
|
|
|
|
|
};
|
|
|
|
|