1
0
Fork 0

Refactoring

This commit is contained in:
MrDev023 2016-10-07 14:06:50 +02:00
parent 1498f4e21e
commit 9b1b3a5c97
24 changed files with 124 additions and 13 deletions

View file

@ -6,7 +6,7 @@
- Maths libraries (Vector 2,3 and 4, Quaternion, Transform and Matrix4f)
- Window manager
- Input manager with SDL_event
- Multiple renderer (VAO,VBO,DisplayList and Direct Rendering) [coming soon]
- Multiple renderer (VAO,VBO)
- Texture
- Network TCP [coming soon]
- Network UDP [coming soon]

View file

@ -1,6 +1,6 @@
#include "window.h"
#include "audio.h"
#include "renderer.h"
#include "display/window.h"
#include "audio/audio.h"
#include "render/renderer.h"
void event(SDL_Event e){
switch( e.type ){

View file

@ -1,2 +0,0 @@
#include "physics.h"

View file

@ -1,6 +0,0 @@
#ifndef PHYSICS_H
#define PHYSICS_H
#endif

View file

@ -1,7 +1,8 @@
#ifndef RENDERER_H
#define RENDERER_H
#include "math.h"
#include "../math/math.h"
#include <iostream>
#include <vector>
@ -25,6 +26,43 @@ bool fileExists(const std::string&);
class Shader;
class Texture;
class Image;
class VBO;
class VAO;
class VAO{
public:
static const int VERTEX_DATA = 0,COLOR_DATA = 1,TEX_COORD_DATA = 2,NORMAL_DATA = 3;
std::vector<VBO*> data;
GLuint id;
GLuint typeRender;
VAO(GLuint);
~VAO();
void addData(int,float*,int);
void bufferData();
void render2D();
void render3D();
};
class VBO{
public:
GLuint id;
GLuint typeRender;
std::vector<float> data;
int size;
VBO();
VBO(GLuint);
~VBO();
void addData(float*,int);
void bufferData();
void render2D();
void render3D();
void bindBuffer();
void unBindBuffer();
};
class Image{
public:

34
src/render/vao.cpp Normal file
View file

@ -0,0 +1,34 @@
#include "renderer.h"
VAO::VAO(GLuint typeRender){
this->typeRender = typeRender;
this->data.push_back(new VBO(typeRender));
this->data.push_back(new VBO(typeRender));
this->data.push_back(new VBO(typeRender));
this->data.push_back(new VBO(typeRender));
}
VAO::~VAO(){
for(int i = 0;i < 4;i++){
delete this->data[i];
}
this->data.clear();
}
void VAO::addData(int type,float* data,int size){
this->data[type]->addData(data,size);
}
void VAO::bufferData(){
for(int i = 0;i < 4;i++){
this->data[i]->bufferData();
}
}
void VAO::render2D(){
}
void VAO::render3D(){
}

47
src/render/vbo.cpp Normal file
View file

@ -0,0 +1,47 @@
#include "renderer.h"
VBO::VBO(){
this->typeRender = GL_TRIANGLE_STRIP;
glGenBuffers(1,&this->id);
this->size = 0;
}
VBO::VBO(GLuint typeRender){
this->typeRender = typeRender;
glGenBuffers(1,&this->id);
this->size = 0;
}
VBO::~VBO(){
this->data.clear();
glDeleteBuffers(1,&this->id);
}
void VBO::addData(float* data,int size){
for(int i = 0;i < size;i++){
this->data.push_back(data[i]);
}
this->size += size;
}
void VBO::bufferData(){
glBindBuffer(GL_ARRAY_BUFFER,this->id);
glBufferData(GL_ARRAY_BUFFER, this->size,&this->data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,0);
}
void VBO::bindBuffer(){
glBindBuffer(GL_ARRAY_BUFFER,this->id);
}
void VBO::unBindBuffer(){
glBindBuffer(GL_ARRAY_BUFFER,0);
}
void VBO::render2D(){
// Plus tard pas besoin pour l instant
}
void VBO::render3D(){
// Plus tard pas besoin pour l instant
}