[DEV] better mesh display using indec istead of direct drawing all point

This commit is contained in:
Edouard DUPIN 2013-03-14 21:50:17 +01:00
parent c870d2471e
commit 90bb349138
10 changed files with 255 additions and 126 deletions

View File

@ -55,7 +55,7 @@ void ewol::Compositing::Clear(void)
}
void ewol::Compositing::SetMatrix(mat4 mat)
void ewol::Compositing::SetMatrix(const mat4& mat)
{
m_matrixApply = mat;
}

View File

@ -59,7 +59,7 @@ namespace ewol
* @brief set the transformation matrix
* @param[in] mat The new matrix.
*/
virtual void SetMatrix(mat4 mat);
virtual void SetMatrix(const mat4& mat);
};
};

View File

@ -98,6 +98,47 @@ void ewol::Text::LoadProgram(void)
}
}
void ewol::Text::Draw(const mat4& transformationMatrix)
{
// draw BG in any case:
m_vectorialDraw.Draw();
if (m_coord.Size()<=0 || NULL == m_font) {
// TODO : a remÚtre ...
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_font == NULL) {
EWOL_WARNING("no font...");
return;
}
if (m_GLprogram==NULL) {
EWOL_ERROR("No shader ...");
return;
}
ewol::openGL::Disable(ewol::openGL::FLAG_DEPTH_TEST);
// set Matrix : translation/positionMatrix
mat4 projMatrix = ewol::openGL::GetMatrix();
mat4 camMatrix = ewol::openGL::GetCameraMatrix();
mat4 tmpMatrix = projMatrix * camMatrix * transformationMatrix;
m_GLprogram->Use();
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// TextureID
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
// position :
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
// Texture :
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
// color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// Request the draw od the elements :
ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_coord.Size());
m_GLprogram->UnUse();
ewol::openGL::Enable(ewol::openGL::FLAG_DEPTH_TEST);
}
void ewol::Text::Draw(void)
{
// draw BG in any case:

View File

@ -119,6 +119,7 @@ namespace ewol
* @brief Draw All the refistered text in the current element on openGL
*/
void Draw(void);
void Draw(const mat4& transformationMatrix);
/**
* @brief Clear all the registered element in the current element
*/

View File

@ -250,10 +250,23 @@ void ewol::openGL::DrawArrays(uint32_t mode, int32_t first, int32_t count)
glDrawArrays(mode, first, count);
}
void ewol::openGL::DrawElements(uint32_t mode, int32_t count, uint32_t type, const void* indices)
void ewol::openGL::DrawElements(uint32_t mode, const etk::Vector<uint32_t>& indices)
{
UpdateAllFlags();
glDrawElements(mode, count, type, indices);
//EWOL_DEBUG("Request draw of " << indices.Size() << "elements");
glDrawElements(mode, indices.Size(), GL_UNSIGNED_INT, &indices[0]);
}
void ewol::openGL::DrawElements16(uint32_t mode, const etk::Vector<uint16_t>& indices)
{
UpdateAllFlags();
glDrawElements(mode, indices.Size(), GL_UNSIGNED_SHORT, &indices[0]);
}
void ewol::openGL::DrawElements8(uint32_t mode, const etk::Vector<uint8_t>& indices)
{
UpdateAllFlags();
glDrawElements(mode, indices.Size(), GL_UNSIGNED_BYTE, &indices[0]);
}

View File

@ -10,6 +10,7 @@
#define __OPEN_GL_H__
#include <etk/types.h>
#include <etk/Vector.h>
#include <etk/math/Matrix4.h>
#ifdef __cplusplus
@ -166,7 +167,9 @@ namespace ewol {
* @brief draw a specific array ==> this enable mode difference ...
*/
void DrawArrays(uint32_t mode, int32_t first, int32_t count);
void DrawElements(uint32_t mode, int32_t count, uint32_t type, const void* indices);
void DrawElements (uint32_t mode, const etk::Vector<uint32_t>& indices);
void DrawElements16(uint32_t mode, const etk::Vector<uint16_t>& indices);
void DrawElements8 (uint32_t mode, const etk::Vector<uint8_t>& indices);
/**
* @brief Use openGL program
* @param[in] id Id of the program that might be used

View File

@ -110,9 +110,15 @@ ewol::Mesh::~Mesh(void)
void ewol::Mesh::Draw(mat4& positionMatrix)
{
if (m_numberOfElments<=0) {
return;
}
#ifndef USE_INDEXED_MESH
if (m_numberOfElments<=0) {
return;
}
#else
if (m_listIndexFaces.Size()<=0) {
return;
}
#endif
if (NULL == m_texture0) {
EWOL_WARNING("Texture does not exist ...");
return;
@ -139,13 +145,19 @@ void ewol::Mesh::Draw(mat4& positionMatrix)
// position :
m_GLprogram->SendAttributePointer(m_GLNormal, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_VERTICES_NORMAL);
// position :
m_GLprogram->SendAttributePointer(m_GLNormalFace, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_FACE_NORMAL);
#ifndef USE_INDEXED_MESH
m_GLprogram->SendAttributePointer(m_GLNormalFace, 3/*x,y,z*/, m_verticesVBO, MESH_VBO_FACE_NORMAL);
#endif
// draw materials :
m_material.Draw(m_GLprogram);
m_light.Draw(m_GLprogram);
// Request the draw od the elements :
ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_numberOfElments);
#ifndef USE_INDEXED_MESH
// Request the draw od the elements :
ewol::openGL::DrawArrays(GL_TRIANGLES, 0, m_numberOfElments);
#else
ewol::openGL::DrawElements(GL_TRIANGLES, m_listIndexFaces);
#endif
m_GLprogram->UnUse();
ewol::openGL::Disable(ewol::openGL::FLAG_DEPTH_TEST);
// TODO : UNDERSTAND why ... it is needed
@ -205,83 +217,128 @@ void ewol::Mesh::GenerateVBO(void)
// calculate the normal of all faces if needed
CalculateNormaleFace();
CalculateNormaleEdge();
// TODO : Set a better display system, this one is the worst I known ...
for (int32_t iii=0; iii<m_listFaces.Size() ; iii++) {
#ifdef PRINT_HALF
m_numberOfElments += 3*3;
#else
m_numberOfElments += m_listFaces[iii].m_nbElement*3;
#endif
// 2 possibilities : triangle or quad :
int32_t indice = 0;
vec2 tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 1;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 2;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
#ifndef PRINT_HALF
if (m_listFaces[iii].m_nbElement==4) {
indice = 0;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
#ifdef USE_INDEXED_MESH
// remove old elements
m_listIndexFaces.Clear();
// Generate element in 2 pass :
// - create new index dependeng a vertex is a unique componenet of position, texture, normal
// - the index list generation (can be dynamic ... (TODO later)
for (int32_t iii=0; iii<m_listFaces.Size() ; iii++) {
for(int32_t indice=0 ; indice<m_listFaces[iii].m_nbElement; indice++) {
vec3 position = m_listVertex[m_listFaces[iii].m_vertex[indice]];
vec3 normal = m_listVertexNormal[m_listFaces[iii].m_vertex[indice]];
vec2 texturepos(m_listUV[m_listFaces[iii].m_uv[indice]].x(),1.0f-m_listUV[m_listFaces[iii].m_uv[indice]].y());
// try to find it in the list :
bool elementFind = false;
for (int32_t jjj=0; jjj<m_verticesVBO->SizeOnBufferVec3(MESH_VBO_VERTICES); jjj++) {
if( m_verticesVBO->GetOnBufferVec3(MESH_VBO_VERTICES,jjj) == position
&& m_verticesVBO->GetOnBufferVec3(MESH_VBO_VERTICES_NORMAL,jjj) == normal
&& m_verticesVBO->GetOnBufferVec2(MESH_VBO_TEXTURE,jjj) == texturepos) {
m_listFaces[iii].m_vertexVBOId[indice] = jjj;
elementFind = true;
// stop searching ...
break;
}
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 2;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 3;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
if (false == elementFind) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES, position);
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL, normal);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, texturepos);
m_listFaces[iii].m_vertexVBOId[indice] = m_verticesVBO->SizeOnBufferVec3(MESH_VBO_VERTICES)-1;
}
}
#endif
}
}
for (int32_t iii=0; iii<m_listFaces.Size() ; iii++) {
m_listIndexFaces.PushBack(m_listFaces[iii].m_vertexVBOId[0]);
m_listIndexFaces.PushBack(m_listFaces[iii].m_vertexVBOId[1]);
m_listIndexFaces.PushBack(m_listFaces[iii].m_vertexVBOId[2]);
#ifndef PRINT_HALF
if (m_listFaces[iii].m_nbElement==4) {
m_listIndexFaces.PushBack(m_listFaces[iii].m_vertexVBOId[0]);
m_listIndexFaces.PushBack(m_listFaces[iii].m_vertexVBOId[2]);
m_listIndexFaces.PushBack(m_listFaces[iii].m_vertexVBOId[3]);
}
#endif
}
#else
// TODO : Set a better display system, this one is the worst I known ...
for (int32_t iii=0; iii<m_listFaces.Size() ; iii++) {
#ifdef PRINT_HALF
m_numberOfElments += 3*3;
#else
m_numberOfElments += m_listFaces[iii].m_nbElement*3;
#endif
// 2 possibilities : triangle or quad :
int32_t indice = 0;
vec2 tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 1;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 2;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
#ifndef PRINT_HALF
if (m_listFaces[iii].m_nbElement==4) {
indice = 0;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 2;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
indice = 3;
tmpUV = m_listUV[m_listFaces[iii].m_uv[indice]];
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES,m_listVertex[m_listFaces[iii].m_vertex[indice]]);
m_verticesVBO->PushOnBuffer(MESH_VBO_TEXTURE, vec2(tmpUV.x(),1.0f-tmpUV.y()));
if(true==m_enableVertexNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_VERTICES_NORMAL,m_listVertexNormal[m_listFaces[iii].m_vertex[indice]]);
}
if(true==m_enableFaceNormal) {
m_verticesVBO->PushOnBuffer(MESH_VBO_FACE_NORMAL,m_listFacesNormal[iii]);
}
}
#endif
}
#endif
// update all the VBO elements ...
m_verticesVBO->Flush();
}

View File

@ -23,10 +23,12 @@
#define MESH_VBO_TEXTURE (1)
// 3 "float" elements
#define MESH_VBO_VERTICES_NORMAL (2)
// Face normal position :
#define MESH_VBO_FACE_NORMAL (3)
// 4 "float" elements
#define MESH_VBO_COLOR (4)
#define USE_INDEXED_MESH
namespace ewol
{
class DisplacementTable
@ -104,6 +106,9 @@ namespace ewol
int32_t m_nbElement;
int32_t m_vertex[4];
int32_t m_uv[4];
#ifdef USE_INDEXED_MESH
int32_t m_vertexVBOId[4]; // used to be an entry point of the rework of the dynamic generating of mesh
#endif
public:
Face(void) {};
Face(int32_t v1, int32_t t1,
@ -158,6 +163,9 @@ namespace ewol
etk::Vector<Face> m_listFaces; //!< List of all Face for the mesh
etk::Vector<vec3> m_listFacesNormal; //!< List of all Face normal, when calculated
etk::Vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated
#ifdef USE_INDEXED_MESH
etk::Vector<uint32_t> m_listIndexFaces;
#endif
protected:
ewol::VirtualBufferObject* m_verticesVBO;
ewol::TextureFile* m_texture0;

View File

@ -11,13 +11,13 @@
#include <ewol/renderer/ResourceManager.h>
#include <ewol/renderer/resources/VirtualBufferObject.h>
ewol::VirtualBufferObject::VirtualBufferObject(const etk::UString& accesMode, int32_t nbElement):
ewol::VirtualBufferObject::VirtualBufferObject(const etk::UString& accesMode):
ewol::Resource(),
m_exist(false),
m_nbVBO(nbElement)
m_exist(false)
{
for (int32_t iii=0; iii<NB_VBO_MAX; iii++) {
m_vbo[iii]=0;
m_vboUsed[iii]=false;
}
m_resourceLevel = 3;
EWOL_DEBUG("OGL : load VBO mode=\"" << accesMode << "\"");
@ -40,15 +40,17 @@ void ewol::VirtualBufferObject::UpdateContext(void)
{
if (false==m_exist) {
// Allocate and assign a Vertex Array Object to our handle
glGenBuffers(m_nbVBO, m_vbo);
glGenBuffers(NB_VBO_MAX, m_vbo);
}
m_exist = true;
for (int32_t iii=0; iii<m_nbVBO; iii++) {
for (int32_t iii=0; iii<NB_VBO_MAX; iii++) {
EWOL_INFO("VBO : Add [" << m_uniqueId << "]=" << m_buffer[iii].Size() << "*sizeof(float) OGl_Id=" << m_vbo[iii]);
// select the buffer to set data inside it ...
if (m_buffer[iii].Size()>0) {
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[iii]);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*m_buffer[iii].Size(), &((m_buffer[iii])[0]), GL_STATIC_DRAW);
if (true == m_vboUsed[iii]) {
// select the buffer to set data inside it ...
if (m_buffer[iii].Size()>0) {
glBindBuffer(GL_ARRAY_BUFFER, m_vbo[iii]);
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*m_buffer[iii].Size(), &((m_buffer[iii])[0]), GL_STATIC_DRAW);
}
}
}
// un-bind it to permet to have no erreor in the next display ...
@ -68,7 +70,7 @@ void ewol::VirtualBufferObject::RemoveContext(void)
<< "/" << m_vbo[7]
<< "/" << m_vbo[8]
<< "/" << m_vbo[9]);
glDeleteBuffers(m_nbVBO, m_vbo);
glDeleteBuffers(NB_VBO_MAX, m_vbo);
m_exist = false;
for (int32_t iii=0; iii<NB_VBO_MAX; iii++) {
m_vbo[iii] = 0;
@ -97,34 +99,46 @@ void ewol::VirtualBufferObject::Flush(void)
ewol::resource::Update(this);
}
void ewol::VirtualBufferObject::PushOnBuffer(int32_t id, const ivec3& data)
{
EWOL_ERROR("Type does not supported yet...");
/*
m_buffer[id].PushBack(data.x());
m_buffer[id].PushBack(data.y());
m_buffer[id].PushBack(data.z());
*/
}
void ewol::VirtualBufferObject::PushOnBuffer(int32_t id, const vec3& data)
{
m_vboUsed[id] = true;
m_buffer[id].PushBack(data.x());
m_buffer[id].PushBack(data.y());
m_buffer[id].PushBack(data.z());
}
void ewol::VirtualBufferObject::PushOnBuffer(int32_t id, const ivec2& data)
vec3 ewol::VirtualBufferObject::GetOnBufferVec3(int32_t id, int32_t elementID)
{
EWOL_ERROR("Type does not supported yet...");
/*
m_buffer[id].PushBack(data.x());
m_buffer[id].PushBack(data.y());
*/
if (elementID*3>m_buffer[id].Size()) {
return vec3(0,0,0);
}
return vec3(m_buffer[id][3*elementID],
m_buffer[id][3*elementID+1],
m_buffer[id][3*elementID+2]);
}
int32_t ewol::VirtualBufferObject::SizeOnBufferVec3(int32_t id)
{
return m_buffer[id].Size()/3;
}
void ewol::VirtualBufferObject::PushOnBuffer(int32_t id, const vec2& data)
{
m_vboUsed[id] = true;
m_buffer[id].PushBack(data.x());
m_buffer[id].PushBack(data.y());
}
vec2 ewol::VirtualBufferObject::GetOnBufferVec2(int32_t id, int32_t elementID)
{
if (elementID*2>m_buffer[id].Size()) {
return vec2(0,0);
}
return vec2(m_buffer[id][2*elementID],
m_buffer[id][2*elementID+1]);
}
int32_t ewol::VirtualBufferObject::SizeOnBufferVec2(int32_t id)
{
return m_buffer[id].Size()/2;
}

View File

@ -26,15 +26,15 @@ namespace ewol
{
private :
bool m_exist; //!< This data is availlable in the Graphic card
int32_t m_nbVBO; //! number of simultaneous VBO
GLuint m_vbo[NB_VBO_MAX]; //!< OpenGl ID of this VBO
bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ...
etk::Vector<float> m_buffer[NB_VBO_MAX]; //!< data that is availlable in the VBO system ...
public:
/**
* @brief Constructor of this VBO.
* @param[in] accesMode Acces mode : ???
*/
VirtualBufferObject(const etk::UString& accesMode, int32_t nbElement=4);
VirtualBufferObject(const etk::UString& accesMode);
/**
* @brief Destructor of this VBO.
*/
@ -54,31 +54,23 @@ namespace ewol
* @param[in] id Id of the buffer requested
* @return A reference on the data.
*/
etk::Vector<float>& GetRefBuffer(int32_t id) { return m_buffer[id]; };
/**
* @brief push data on a buffer with a custum type :
* @param[in] id Id of the buffer requested.
* @param[in] data Direct data that might be set.
*/
void PushOnBuffer(int32_t id, const ivec3& data);
etk::Vector<float>& GetRefBuffer(int32_t id) { m_vboUsed[id] = true; return m_buffer[id]; };
/**
* @brief push data on a buffer with a custum type :
* @param[in] id Id of the buffer requested.
* @param[in] data Direct data that might be set.
*/
void PushOnBuffer(int32_t id, const vec3& data);
/**
* @brief push data on a buffer with a custum type :
* @param[in] id Id of the buffer requested.
* @param[in] data Direct data that might be set.
*/
void PushOnBuffer(int32_t id, const ivec2& data);
vec3 GetOnBufferVec3(int32_t id, int32_t elementID);
int32_t SizeOnBufferVec3(int32_t id);
/**
* @brief push data on a buffer with a custum type :
* @param[in] id Id of the buffer requested.
* @param[in] data Direct data that might be set.
*/
void PushOnBuffer(int32_t id, const vec2& data);
vec2 GetOnBufferVec2(int32_t id, int32_t elementID);
int32_t SizeOnBufferVec2(int32_t id);
/**
* @brief Get the data from the graphic card.
*/