diff --git a/README.md b/README.md index 6e1e224..529ac2e 100644 --- a/README.md +++ b/README.md @@ -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] diff --git a/src/audio.cpp b/src/audio/audio.cpp similarity index 100% rename from src/audio.cpp rename to src/audio/audio.cpp diff --git a/src/audio.h b/src/audio/audio.h similarity index 100% rename from src/audio.h rename to src/audio/audio.h diff --git a/src/window.cpp b/src/display/window.cpp similarity index 100% rename from src/window.cpp rename to src/display/window.cpp diff --git a/src/window.h b/src/display/window.h similarity index 100% rename from src/window.h rename to src/display/window.h diff --git a/src/main.cpp b/src/main.cpp index 16cceef..85721c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 ){ diff --git a/src/math.cpp b/src/math/math.cpp similarity index 100% rename from src/math.cpp rename to src/math/math.cpp diff --git a/src/math.h b/src/math/math.h similarity index 100% rename from src/math.h rename to src/math/math.h diff --git a/src/matrix4f.cpp b/src/math/matrix4f.cpp similarity index 100% rename from src/matrix4f.cpp rename to src/math/matrix4f.cpp diff --git a/src/quaternion.cpp b/src/math/quaternion.cpp similarity index 100% rename from src/quaternion.cpp rename to src/math/quaternion.cpp diff --git a/src/transform.cpp b/src/math/transform.cpp similarity index 100% rename from src/transform.cpp rename to src/math/transform.cpp diff --git a/src/vector2f.cpp b/src/math/vector2f.cpp similarity index 100% rename from src/vector2f.cpp rename to src/math/vector2f.cpp diff --git a/src/vector3f.cpp b/src/math/vector3f.cpp similarity index 100% rename from src/vector3f.cpp rename to src/math/vector3f.cpp diff --git a/src/vector4f.cpp b/src/math/vector4f.cpp similarity index 100% rename from src/vector4f.cpp rename to src/math/vector4f.cpp diff --git a/src/physics.cpp b/src/physics.cpp deleted file mode 100644 index 5f4f488..0000000 --- a/src/physics.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "physics.h" - diff --git a/src/physics.h b/src/physics.h deleted file mode 100644 index f7ae543..0000000 --- a/src/physics.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PHYSICS_H -#define PHYSICS_H - - - -#endif \ No newline at end of file diff --git a/src/image.cpp b/src/render/image.cpp similarity index 100% rename from src/image.cpp rename to src/render/image.cpp diff --git a/src/lodepng.cpp b/src/render/lodepng.cpp similarity index 100% rename from src/lodepng.cpp rename to src/render/lodepng.cpp diff --git a/src/lodepng.h b/src/render/lodepng.h similarity index 100% rename from src/lodepng.h rename to src/render/lodepng.h diff --git a/src/renderer.h b/src/render/renderer.h similarity index 69% rename from src/renderer.h rename to src/render/renderer.h index ca0db0c..34723aa 100644 --- a/src/renderer.h +++ b/src/render/renderer.h @@ -1,7 +1,8 @@ #ifndef RENDERER_H #define RENDERER_H -#include "math.h" +#include "../math/math.h" + #include #include @@ -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 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 data; + int size; + + VBO(); + VBO(GLuint); + ~VBO(); + void addData(float*,int); + void bufferData(); + void render2D(); + void render3D(); + void bindBuffer(); + void unBindBuffer(); +}; class Image{ public: diff --git a/src/shader.cpp b/src/render/shader.cpp similarity index 100% rename from src/shader.cpp rename to src/render/shader.cpp diff --git a/src/texture.cpp b/src/render/texture.cpp similarity index 100% rename from src/texture.cpp rename to src/render/texture.cpp diff --git a/src/render/vao.cpp b/src/render/vao.cpp new file mode 100644 index 0000000..f3af98c --- /dev/null +++ b/src/render/vao.cpp @@ -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(){ + +} \ No newline at end of file diff --git a/src/render/vbo.cpp b/src/render/vbo.cpp new file mode 100644 index 0000000..d8ccfce --- /dev/null +++ b/src/render/vbo.cpp @@ -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 +} \ No newline at end of file