now you can set optional ogl version through the first 2 parameters
This commit is contained in:
parent
9d35634c0c
commit
bc518f58ee
|
@ -10,7 +10,7 @@
|
||||||
#define VERTEX_INDEX_UV 1
|
#define VERTEX_INDEX_UV 1
|
||||||
|
|
||||||
#define VERTEX_COMPONENTS_XYZ 3
|
#define VERTEX_COMPONENTS_XYZ 3
|
||||||
#define VERTEX_COMPONENTS_UV 4
|
#define VERTEX_COMPONENTS_UV 2
|
||||||
|
|
||||||
#define VERTEX_SIZE_XYZ (sizeof(float) * VERTEX_COMPONENTS_XYZ)
|
#define VERTEX_SIZE_XYZ (sizeof(float) * VERTEX_COMPONENTS_XYZ)
|
||||||
#define VERTEX_SIZE_UV (sizeof(float) * VERTEX_COMPONENTS_UV)
|
#define VERTEX_SIZE_UV (sizeof(float) * VERTEX_COMPONENTS_UV)
|
||||||
|
@ -39,49 +39,49 @@ private:
|
||||||
// member
|
// member
|
||||||
private:
|
private:
|
||||||
// window
|
// window
|
||||||
GLFWwindow* pWindow;
|
GLFWwindow* pWindow = NULL;
|
||||||
std::string sWindowName;
|
std::string sWindowName = "MeshViewer 2.0 pre-alpha";
|
||||||
int iWidth;
|
int iWidth = 640;
|
||||||
int iHeight;
|
int iHeight = 480;
|
||||||
|
|
||||||
// init glfw
|
// init glfw
|
||||||
int iOglMajorVersion;
|
int iOglMajorVersion = 4;
|
||||||
int iOglMinorVersion;
|
int iOglMinorVersion = 5;
|
||||||
int iAntiAliasingLevel;
|
int iAntiAliasingLevel = 4;
|
||||||
|
|
||||||
// IDs ==========================
|
// IDs ====================================
|
||||||
//object data
|
//object data
|
||||||
GLuint gluiVertexArrayID;
|
GLuint gluiVertexArrayID = 0;
|
||||||
GLuint gluiInstanceBufferID;
|
GLuint gluiVertexBufferID = 0;
|
||||||
GLuint gluiVertexBufferID;
|
GLuint gluiInstanceBufferID = 0;
|
||||||
|
|
||||||
//obj color
|
//obj color
|
||||||
GLuint gluiTextureID;
|
GLuint gluiTextureID = 0;
|
||||||
GLuint gluiShaderPrgmID;
|
GLuint gluiShaderPrgmID = 0;
|
||||||
GLuint gluiSamplerID;
|
GLuint gluiSamplerID = 0;
|
||||||
|
|
||||||
//obj transformation
|
//obj transformation
|
||||||
GLuint gluiMatrixID;
|
GLuint gluiMatrixID = 0;
|
||||||
// ==============================
|
// ========================================
|
||||||
|
|
||||||
// data
|
// data
|
||||||
std::vector<Modl*> vModels;
|
std::vector<Modl*> vModels;
|
||||||
|
|
||||||
// transformation ===============
|
// transformation =========================
|
||||||
//values
|
//values
|
||||||
float fRotationX;
|
float fRotationX = 0;
|
||||||
float fRotationY;
|
float fRotationY = 0;
|
||||||
float fRotationZ;
|
float fRotationZ = 0;
|
||||||
double dTranslationX;
|
double dTranslationX = 0;
|
||||||
double dTranslationY;
|
double dTranslationY = 0;
|
||||||
double dTranslationZ;
|
double dTranslationZ = 5;
|
||||||
|
|
||||||
// ==============================
|
// ========================================
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
float fFOV;
|
float fFOV = 45.0f;
|
||||||
float fMinView;
|
float fMinView = 0.1f;
|
||||||
float fMaxView;
|
float fMaxView = 100.0f;
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -89,7 +89,6 @@ private:
|
||||||
private:
|
private:
|
||||||
void processInit();
|
void processInit();
|
||||||
|
|
||||||
void initDefault();
|
|
||||||
void startGLFW();
|
void startGLFW();
|
||||||
void createWindow();
|
void createWindow();
|
||||||
void startGLEW();
|
void startGLEW();
|
||||||
|
|
|
@ -50,8 +50,7 @@ OpenGLController::~OpenGLController()
|
||||||
|
|
||||||
OpenGLController::OpenGLController(int oglMajor, int oglMinor)
|
OpenGLController::OpenGLController(int oglMajor, int oglMinor)
|
||||||
{
|
{
|
||||||
// init variables
|
// adjust ogl version optional
|
||||||
initDefault();
|
|
||||||
iOglMajorVersion = oglMajor;
|
iOglMajorVersion = oglMajor;
|
||||||
iOglMinorVersion = oglMinor;
|
iOglMinorVersion = oglMinor;
|
||||||
|
|
||||||
|
@ -62,34 +61,6 @@ OpenGLController::OpenGLController(int oglMajor, int oglMinor)
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
// private functions
|
// private functions
|
||||||
|
|
||||||
void OpenGLController::initDefault()
|
|
||||||
{
|
|
||||||
pWindow = NULL;
|
|
||||||
sWindowName = "MeshViewer 2.0 pre-alpha";
|
|
||||||
iWidth = 640;
|
|
||||||
iHeight = 480;
|
|
||||||
|
|
||||||
iAntiAliasingLevel = 4;
|
|
||||||
|
|
||||||
gluiInstanceBufferID = 0;
|
|
||||||
gluiTextureID = 0;
|
|
||||||
gluiShaderPrgmID = 0;
|
|
||||||
gluiSamplerID = 0;
|
|
||||||
|
|
||||||
gluiMatrixID = 0;
|
|
||||||
|
|
||||||
fRotationX = 0;
|
|
||||||
fRotationY = 0;
|
|
||||||
fRotationZ = 0;
|
|
||||||
dTranslationX = 0;
|
|
||||||
dTranslationY = 0;
|
|
||||||
dTranslationZ = 5;
|
|
||||||
|
|
||||||
fFOV = 45.0f;
|
|
||||||
fMinView = 0.1f;
|
|
||||||
fMaxView = 100.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLController::processInit()
|
void OpenGLController::processInit()
|
||||||
{
|
{
|
||||||
startGLFW();
|
startGLFW();
|
||||||
|
@ -159,10 +130,10 @@ void OpenGLController::createWindow()
|
||||||
if (pWindow == NULL)
|
if (pWindow == NULL)
|
||||||
{
|
{
|
||||||
std::string message = "Your GPU does not support OpenGL ";
|
std::string message = "Your GPU does not support OpenGL ";
|
||||||
message += iOglMajorVersion;
|
message += std::to_string(iOglMajorVersion);
|
||||||
message += ".";
|
message += ".";
|
||||||
message += iOglMinorVersion;
|
message += std::to_string(iOglMinorVersion);
|
||||||
message += "\nTry to use older version";
|
message += "\nTry to use an other version";
|
||||||
|
|
||||||
MessageBox(NULL, message.c_str(), "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
MessageBox(NULL, message.c_str(), "MeshViewer 2.0 Error", MB_OK | MB_ICONERROR);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,18 @@
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
OpenGLController* scene = NULL;
|
||||||
|
|
||||||
|
if (argc == 3)
|
||||||
|
{
|
||||||
|
int major = atoi(argv[1]);
|
||||||
|
int minor = atoi(argv[2]);
|
||||||
|
scene = OpenGLController::getInstance(major, minor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
scene = OpenGLController::getInstance();
|
||||||
|
|
||||||
|
|
||||||
goto openGL;
|
goto openGL;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -26,8 +38,6 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
openGL:
|
openGL:
|
||||||
|
|
||||||
OpenGLController *scene = OpenGLController::getInstance();
|
|
||||||
|
|
||||||
scene->loadMsh("..\\Release\\Msh\\cubeTrans.msh");
|
scene->loadMsh("..\\Release\\Msh\\cubeTrans.msh");
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in New Issue