[DEV] start to work on VBO integration
This commit is contained in:
parent
5592c02b28
commit
ba5bbea967
@ -336,7 +336,7 @@ bool ewol::resource::Keep(etk::UString& filename, ewol::MeshObj*& object)
|
||||
}
|
||||
|
||||
|
||||
bool ewol::resource::Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& object)
|
||||
bool ewol::resource::Keep(const etk::UString& accesMode, ewol::VirtualBufferObject*& object)
|
||||
{
|
||||
// this element create a new one every time ....
|
||||
object = new ewol::VirtualBufferObject(accesMode);
|
||||
@ -458,3 +458,10 @@ void ewol::resource::Release(ewol::Colored3DObject*& object)
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
|
||||
void ewol::resource::Release(ewol::VirtualBufferObject*& object)
|
||||
{
|
||||
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||
Release(object2);
|
||||
object = NULL;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace ewol
|
||||
bool Keep(etk::UString& filename, ewol::Shader*& object);
|
||||
bool Keep(ewol::Texture*& object); // no name needed here ...
|
||||
bool Keep(etk::UString& filename, ewol::TextureFile*& object, ivec2 size);
|
||||
bool Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& object);
|
||||
bool Keep(const etk::UString& accesMode, ewol::VirtualBufferObject*& object);
|
||||
bool Keep(etk::UString& filename, ewol::MeshObj*& object);
|
||||
bool Keep(etk::UString& filename, ewol::ConfigFile*& object);
|
||||
bool Keep(ewol::Colored3DObject*& object);
|
||||
|
@ -25,6 +25,7 @@ ewol::Mesh::Mesh(etk::UString genName) :
|
||||
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||
}
|
||||
//ewol::resource::Keep("w", m_verticesVBO);
|
||||
}
|
||||
|
||||
ewol::Mesh::~Mesh(void)
|
||||
@ -34,6 +35,7 @@ ewol::Mesh::~Mesh(void)
|
||||
ewol::resource::Release(m_texture1);
|
||||
}
|
||||
ewol::resource::Release(m_GLprogram);
|
||||
//ewol::resource::Release(m_verticesVBO);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <ewol/renderer/resources/Image.h>
|
||||
#include <ewol/renderer/resources/Shader.h>
|
||||
#include <ewol/renderer/resources/Program.h>
|
||||
#include <ewol/renderer/resources/VirtualBufferObject.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
@ -28,6 +29,7 @@ namespace ewol
|
||||
int32_t m_GLtexID;
|
||||
public:
|
||||
etk::Vector<uint32_t> m_indices;
|
||||
ewol::VirtualBufferObject* m_verticesVBO;
|
||||
etk::Vector<vec3> m_vertices;
|
||||
etk::Vector<vec2> m_uvTextures;
|
||||
etk::Vector<vec3> m_normals;
|
||||
|
@ -181,6 +181,9 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) :
|
||||
|
||||
// Put the attributes in buffers
|
||||
m_vertices.PushBack(vertices[vertexIndex-1]);
|
||||
m_verticesVBO->GetRefBuffer().PushBack(vertices[vertexIndex-1].x);
|
||||
m_verticesVBO->GetRefBuffer().PushBack(vertices[vertexIndex-1].y);
|
||||
m_verticesVBO->GetRefBuffer().PushBack(vertices[vertexIndex-1].z);
|
||||
m_uvTextures.PushBack(uvTextures[uvIndex-1]);
|
||||
draw::Color tmpppp(0xFFFFFFFF);
|
||||
draw::Colorf tmppppp(tmpppp);
|
||||
@ -191,6 +194,7 @@ ewol::MeshObj::MeshObj(etk::UString _fileName) :
|
||||
m_normals.PushBack(normals[normalIndex-1]);
|
||||
}
|
||||
}
|
||||
m_verticesVBO->Flush();
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,20 +12,13 @@
|
||||
|
||||
|
||||
|
||||
ewol::VirtualBufferObject::VirtualBufferObject(etk::UString& accesMode):
|
||||
ewol::VirtualBufferObject::VirtualBufferObject(const etk::UString& accesMode):
|
||||
ewol::Resource(),
|
||||
m_exist(false),
|
||||
m_vbo(0)
|
||||
{
|
||||
m_resourceLevel = 3;
|
||||
EWOL_DEBUG("OGL : load VBO mode\"" << accesMode << "\"");
|
||||
// load data from file "all the time ..."
|
||||
|
||||
/*
|
||||
glGenBuffers(1, &m_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertices), cube_vertices, GL_STATIC_DRAW);
|
||||
*/
|
||||
EWOL_DEBUG("OGL : load VBO mode=\"" << accesMode << "\"");
|
||||
}
|
||||
|
||||
|
||||
@ -48,16 +41,24 @@ void ewol::VirtualBufferObject::UpdateContext(void)
|
||||
if (m_buffer.Size()<=0) {
|
||||
RemoveContext();
|
||||
} else {
|
||||
EWOL_INFO("VBO: Update [" << m_uniqueId << "]=" << m_buffer.Size() << "*sizeof(float) OGl_Id=" << m_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*m_buffer.Size(), &m_buffer[0], GL_STATIC_DRAW);
|
||||
//
|
||||
}
|
||||
} else {
|
||||
// create the Buffer
|
||||
if (m_buffer.Size()>0) {
|
||||
// Allocate and assign a Vertex Array Object to our handle
|
||||
glGenVertexArrays(1, &m_vao);
|
||||
glGenBuffers(1, &m_vbo);
|
||||
EWOL_INFO("VBO: Add [" << m_uniqueId << "]=" << m_buffer.Size() << "*sizeof(float) OGl_Id=" << m_vbo);
|
||||
m_exist = true;
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*m_buffer.Size(), &m_buffer[0], GL_STATIC_DRAW);
|
||||
//glEnableVertexAttribArray(0);
|
||||
//glDisableVertexAttribArray(0);
|
||||
}
|
||||
// Note we did not create the buffer when no data is needed
|
||||
}
|
||||
@ -66,6 +67,7 @@ void ewol::VirtualBufferObject::UpdateContext(void)
|
||||
void ewol::VirtualBufferObject::RemoveContext(void)
|
||||
{
|
||||
if (true==m_exist) {
|
||||
EWOL_INFO("VBO: Remove [" << m_uniqueId << "]=" << m_buffer.Size() << "*sizeof(float) OGl_Id=" << m_vbo);
|
||||
glDeleteBuffers(1, &m_vbo);
|
||||
m_exist = false;
|
||||
m_vbo = 0;
|
||||
|
@ -25,13 +25,14 @@ namespace ewol
|
||||
private :
|
||||
bool m_exist; //!< This data is availlable in the Graphic card
|
||||
GLuint m_vbo; //!< OpenGl ID of this VBO
|
||||
GLuint m_vao;
|
||||
etk::Vector<float> m_buffer; //!< data that is availlable in the VBO system ...
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor of this VBO.
|
||||
* @param[in] accesMode Acces mode : ???
|
||||
*/
|
||||
VirtualBufferObject(etk::UString& accesMode);
|
||||
VirtualBufferObject(const etk::UString& accesMode);
|
||||
/**
|
||||
* @brief Destructor of this VBO.
|
||||
*/
|
||||
@ -58,7 +59,7 @@ namespace ewol
|
||||
/**
|
||||
* @brief Send the data to the graphic card.
|
||||
*/
|
||||
void Flush(void) {};
|
||||
void Flush(void) { UpdateContext(); };
|
||||
/**
|
||||
* @brief This load/reload the data in the opengl context, needed when removed previously.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user