managed old tutorial implementation with classes.

Bugs: nothing is displayed
This commit is contained in:
Anakin
2016-09-06 15:15:29 +02:00
commit 847b3cdee8
31 changed files with 1168 additions and 0 deletions

44
MshViewer/Header/Camera.h Normal file
View File

@@ -0,0 +1,44 @@
#pragma once
#include <gl\glew.h>
#include <gl\glfw3.h>
#include <glm\glm.hpp>
class Camera
{
public:
Camera(int width, int height);
~Camera();
private:
float fFOV;
float fMinView;
float fMaxView;
int iWidth;
int iHeight;
double dTranslationX;
double dTranslationY;
double dTranslationZ;
glm::mat4 m4x4Projection;
glm::mat4 m4x4View;
private:
void updateMatrices();
public:
glm::mat4 getMatrix();
void setFOV(float fov);
void setMinView(float distance);
void setMaxView(float distance);
void setSize(int width, int height);
void add2x(double value);
void add2y(double value);
void add2z(double value);
};

47
MshViewer/Header/Object.h Normal file
View File

@@ -0,0 +1,47 @@
#pragma once
#include <gl\glew.h>
#include <gl\glfw3.h>
#include <glm\glm.hpp>
#include <vector>
class Object
{
public:
Object(const char* path);
~Object();
private:
GLuint gluiVertexArrayID;
GLuint gluiVertexBufferID;
GLuint gluiUVBufferID;
GLuint gluiShaderPrgmID;
GLuint gluiTextureID;
std::vector<GLfloat> vfVertices;
std::vector<GLfloat> vfUV;
float fRotationX;
float fRotationY;
float fRotationZ;
glm::mat4 m4x4Model;
private:
void processTexture();
void calcMatrix();
void loadMesh2OGL();
public:
glm::mat4 getMatrix();
GLuint getShader() const;
GLuint getTextureID() const;
GLuint getVertexBufferID() const;
GLuint getUVBufferID() const;
int getVertexNumber() const;
void add2x(float value);
void add2y(float value);
void add2z(float value);
};

View File

@@ -0,0 +1,70 @@
#pragma once
#include <string>
#include <glm\glm.hpp>
#include <vector>
#include "Camera.h"
#include "Object.h"
class OpenGLController
{
public:
OpenGLController();
OpenGLController(int oglMajor, int oglMinor);
~OpenGLController();
private:
int iOglMajorVersion;
int iOglMinorVersion;
int iAntiAliasingLevel;
std::string sWindowName;
GLFWwindow* pWindow;
int iWidth;
int iHeight;
GLuint gluiMatrixID;
GLuint gluiSamplerID;
glm::mat4 m4x4Model;
glm::mat4 m4x4MVP;
Camera camera;
Object* object;
struct {
double posX;
double posY;
bool leftHold;
bool middleHold;
bool rightHold;
double speed;
} stcMouse;
private:
void initDefault();
void processInit();
void startGLFW();
void startGLEW();
void createWindow();
void setCallbackFunctions();
public:
glm::mat4 getMVPMatrix();
GLFWwindow* getWindow() const;
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);
void updateScene();
};

View File

@@ -0,0 +1,31 @@
#pragma once
#include <vector>
class TextureTGA
{
public:
TextureTGA(const char* filePath);
~TextureTGA();
private:
std::vector<std::uint8_t> vui8Pixels;
bool bCompressed;
std::uint32_t ui32IDLength;
bool bColorTabel;
std::uint32_t ui32PicType;
std::uint32_t ui32PaletteBegin;
std::uint32_t ui32PaletteLength;
std::uint32_t ui32PaletteBpP;
std::uint32_t ui32Width;
std::uint32_t ui32Height;
std::uint32_t ui32Size;
std::uint32_t ui32BpP;
std::uint32_t ui32Attribut;
public:
std::vector<std::uint8_t> getData() const;
bool hasAlpha() const;
std::uint32_t getWidth() const;
std::uint32_t getHeight() const;
};

View File

@@ -0,0 +1,11 @@
#pragma once
extern void windowResize(GLFWwindow * window, int width, int height);
extern void mouseButton(GLFWwindow *window, int button, int action, int mod);
extern void mouseMove(GLFWwindow *window, double xpos, double ypos);
extern void mouseWheel(GLFWwindow *window, double xoffset, double yoffset);
extern void keyPress(GLFWwindow *window, int key, int scancode, int action, int mods);

View File

@@ -0,0 +1,7 @@
#pragma once
#include <vector>
#include <gl\glew.h>
extern std::vector<GLfloat> loadData();
extern std::vector<GLfloat> loadUV();

View File

@@ -0,0 +1,6 @@
#ifndef SHADER_HPP
#define SHADER_HPP
GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path);
#endif