clean up code

This commit is contained in:
Anakin 2016-11-12 12:05:03 +01:00
parent 2524971d19
commit b4bd314450
7 changed files with 19 additions and 47 deletions

View File

@ -3,7 +3,6 @@
#include <list> #include <list>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <gl\glew.h>
#include <glm\gtc\matrix_transform.hpp> #include <glm\gtc\matrix_transform.hpp>
enum Mtyp { enum Mtyp {
@ -22,16 +21,16 @@ struct ChunkHeader {
}; };
struct Modl { struct Modl {
std::string name; std::string name = "";
std::string parent; std::string parent = "";
Mtyp type; Mtyp type = null;
std::uint32_t renderFlags; std::int32_t renderFlags = -1;
glm::mat4 m4x4Translation; glm::mat4 m4x4Translation = glm::mat4(1.0f);
std::string texture; std::string texture = "";
float* vertex; float* vertex = nullptr;
float* uv; float* uv = nullptr;
std::uint32_t* mesh; std::uint32_t* mesh = nullptr;
std::uint32_t meshSize; std::uint32_t meshSize = 0;
}; };
@ -49,7 +48,6 @@ private:
private: private:
void setModlDefault(Modl* model);
void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t end); void loadChunks(std::list<ChunkHeader*> &destination, std::streampos start, const std::uint32_t end);
void analyseMsh2Chunks(std::list<ChunkHeader*> &chunkList); void analyseMsh2Chunks(std::list<ChunkHeader*> &chunkList);
void analyseMatdChunks(std::list<ChunkHeader*> &chunkList); void analyseMatdChunks(std::list<ChunkHeader*> &chunkList);

View File

@ -1,11 +1,9 @@
#pragma once #pragma once
#include <string>
#include <gl\glew.h> #include <gl\glew.h>
#include <gl\glfw3.h> #include <gl\glfw3.h>
#include <glm\glm.hpp>
#include <vector>
#include "Object.h" #include "Object.h"
#include "Texture.h" #include <vector>
#define VERTEX_INDEX_XYZ 0 #define VERTEX_INDEX_XYZ 0
#define VERTEX_INDEX_UV 1 #define VERTEX_INDEX_UV 1

View File

@ -1,5 +1,7 @@
#include "Object.h" #include "Object.h"
#include <iostream> #include <iostream>
#define PI (4.0*atan(1.0)) #define PI (4.0*atan(1.0))
@ -72,20 +74,6 @@ Object::~Object()
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// private functions // private functions
void Object::setModlDefault(Modl * model)
{
model->name = "";
model->parent = "";
model->type = null;
model->renderFlags = -1;
model->m4x4Translation = glm::mat4(1.0f);
model->texture = "";
model->vertex = NULL;
model->uv = NULL;
model->mesh = NULL;
model->meshSize = 0;
}
void Object::loadChunks(std::list<ChunkHeader*>& destination, std::streampos start, const std::uint32_t end) void Object::loadChunks(std::list<ChunkHeader*>& destination, std::streampos start, const std::uint32_t end)
{ {
// jump to first chunk // jump to first chunk
@ -170,7 +158,6 @@ void Object::analyseMsh2Chunks(std::list<ChunkHeader*>& chunkList)
if (!strcmp("MODL", (*it)->name)) if (!strcmp("MODL", (*it)->name))
{ {
Modl* tempModl = new Modl; Modl* tempModl = new Modl;
setModlDefault(tempModl);
// get all subchunks // get all subchunks
std::list<ChunkHeader*> tempChunks; std::list<ChunkHeader*> tempChunks;

View File

@ -1,17 +1,14 @@
#include <gl\glew.h>
#include <gl\glfw3.h>
#include <Windows.h>
#include "OpenGLController.h" #include "OpenGLController.h"
#include "callback.h" #include "callback.h"
#include <glm\gtc\matrix_transform.hpp>
#include "shader.hpp" #include "shader.hpp"
#include "Texture.h" #include "Texture.h"
#include <iostream> #include <Windows.h>
#include <string>
#include <glm\gtc\matrix_transform.hpp>
#define VERTEX_SHADER "Shader/TextureShader.vert" #define VERTEX_SHADER "Shader/TextureShader.vert"
#define FRAGMENT_SHADER "Shader/TextureShader.frag" #define FRAGMENT_SHADER "Shader/TextureShader.frag"
#define MAX_MODEL_COUNT 1000
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// public constructor/destructor // public constructor/destructor
@ -282,7 +279,7 @@ void OpenGLController::updateScene()
int instanceOffset(0); int instanceOffset(0);
for (int modelIndex = 0; modelIndex < vModels.size(); modelIndex++) for (unsigned int modelIndex = 0; modelIndex < vModels.size(); modelIndex++)
{ {
// give texture to the shader // give texture to the shader
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,

View File

@ -1,7 +1,5 @@
#include "Texture.h" #include "Texture.h"
#include <iostream>
#include <fstream> #include <fstream>
#include <Windows.h>
TextureTGA::TextureTGA(const char * filePath) TextureTGA::TextureTGA(const char * filePath)
{ {

View File

@ -1,6 +1,3 @@
//#include "callback.h"
#include <gl\glew.h>
#include <gl\glfw3.h>
#include "OpenGLController.h" #include "OpenGLController.h"

View File

@ -3,9 +3,6 @@
#endif // DEBUG #endif // DEBUG
#include "OpenGLController.h" #include "OpenGLController.h"
#include "Object.h"
#include <iostream>
#include <Windows.h>
int main(int argc, char** argv) int main(int argc, char** argv)
{ {