[DEV] simplify VBO & program API
This commit is contained in:
parent
ec3c7b2902
commit
8ff2bfc20f
2
external/ege
vendored
2
external/ege
vendored
@ -1 +1 @@
|
||||
Subproject commit 6adec3434ea382c94554f5d8fac3b60573eae382
|
||||
Subproject commit eb762e5c93b8e20ac862b32879da7fb3e55b6fce
|
@ -330,7 +330,6 @@ void ewol::resource::Program::sendAttribute(int32_t _idElem,
|
||||
}
|
||||
|
||||
void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
|
||||
int32_t _nbElement,
|
||||
const std::shared_ptr<ewol::resource::VirtualBufferObject>& _vbo,
|
||||
int32_t _index,
|
||||
int32_t _jumpBetweenSample,
|
||||
@ -347,7 +346,7 @@ void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo->getGL_ID(_index));
|
||||
glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
|
||||
_nbElement, // number of elements per vertex, here (r,g,b,a)
|
||||
_vbo->getElementSize(_index), // number of elements per vertex, here (r,g,b,a)
|
||||
GL_FLOAT, // the type of each element
|
||||
GL_FALSE, // take our values as-is
|
||||
_jumpBetweenSample, // no extra data between each position
|
||||
|
@ -87,18 +87,17 @@ namespace ewol {
|
||||
const void* _pointer,
|
||||
int32_t _jumpBetweenSample=0);
|
||||
void sendAttributePointer(int32_t _idElem,
|
||||
int32_t _nbElement,
|
||||
const std::shared_ptr<ewol::resource::VirtualBufferObject>& _vbo,
|
||||
int32_t _index,
|
||||
int32_t _jumpBetweenSample=0,
|
||||
int32_t _offset=0);
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<vec2 >& _data) {
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<vec2>& _data) {
|
||||
sendAttribute(_idElem, 2/*u,v / x,y*/, &_data[0]);
|
||||
}
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<vec3 >& _data) {
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<vec3>& _data) {
|
||||
sendAttribute(_idElem, 3/*x,y,z,unused*/, &_data[0], 4*sizeof(btScalar));
|
||||
}
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<etk::Color<float> >& _data) {
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<etk::Color<float>>& _data) {
|
||||
sendAttribute(_idElem, 4/*r,g,b,a*/, &_data[0]);
|
||||
}
|
||||
inline void sendAttribute(int32_t _idElem, const std::vector<float>& _data) {
|
||||
|
@ -20,6 +20,7 @@ void ewol::resource::VirtualBufferObject::init(int32_t _number) {
|
||||
for (size_t iii=0; iii<NB_VBO_MAX; iii++) {
|
||||
m_vbo[iii]=0;
|
||||
m_vboUsed[iii]=false;
|
||||
m_vboSizeDataOffset[iii]=-1;
|
||||
}
|
||||
EWOL_DEBUG("OGL : load VBO count=\"" << _number << "\"");
|
||||
}
|
||||
@ -89,6 +90,12 @@ void ewol::resource::VirtualBufferObject::flush() {
|
||||
}
|
||||
|
||||
void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 3;
|
||||
} else if (m_vboSizeDataOffset[_id] != 3) {
|
||||
EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||
return;
|
||||
}
|
||||
m_vboUsed[_id] = true;
|
||||
m_buffer[_id].push_back(_data.x());
|
||||
m_buffer[_id].push_back(_data.y());
|
||||
@ -104,11 +111,20 @@ vec3 ewol::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _
|
||||
m_buffer[_id][3*_elementID+2]);
|
||||
}
|
||||
|
||||
int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec3(int32_t _id) {
|
||||
return m_buffer[_id].size()/3;
|
||||
int32_t ewol::resource::VirtualBufferObject::bufferSize(int32_t _id) {
|
||||
return m_buffer[_id].size()/m_vboSizeDataOffset[_id];
|
||||
}
|
||||
int32_t ewol::resource::VirtualBufferObject::getElementSize(int32_t _id) {
|
||||
return m_vboSizeDataOffset[_id];
|
||||
}
|
||||
|
||||
void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) {
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 2;
|
||||
} else if (m_vboSizeDataOffset[_id] != 2) {
|
||||
EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||
return;
|
||||
}
|
||||
m_vboUsed[_id] = true;
|
||||
m_buffer[_id].push_back(_data.x());
|
||||
m_buffer[_id].push_back(_data.y());
|
||||
@ -122,6 +138,54 @@ vec2 ewol::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _
|
||||
m_buffer[_id][2*_elementID+1]);
|
||||
}
|
||||
|
||||
int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec2(int32_t _id) {
|
||||
return m_buffer[_id].size()/2;
|
||||
|
||||
void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data) {
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 4;
|
||||
} else if (m_vboSizeDataOffset[_id] != 4) {
|
||||
EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||
return;
|
||||
}
|
||||
m_vboUsed[_id] = true;
|
||||
m_buffer[_id].push_back(_data.r());
|
||||
m_buffer[_id].push_back(_data.g());
|
||||
m_buffer[_id].push_back(_data.b());
|
||||
m_buffer[_id].push_back(_data.a());
|
||||
}
|
||||
|
||||
void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,3>& _data) {
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 3;
|
||||
} else if (m_vboSizeDataOffset[_id] != 3) {
|
||||
EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||
return;
|
||||
}
|
||||
m_vboUsed[_id] = true;
|
||||
m_buffer[_id].push_back(_data.r());
|
||||
m_buffer[_id].push_back(_data.g());
|
||||
m_buffer[_id].push_back(_data.b());
|
||||
}
|
||||
|
||||
void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,2>& _data) {
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 2;
|
||||
} else if (m_vboSizeDataOffset[_id] != 2) {
|
||||
EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||
return;
|
||||
}
|
||||
m_vboUsed[_id] = true;
|
||||
m_buffer[_id].push_back(_data.r());
|
||||
m_buffer[_id].push_back(_data.g());
|
||||
}
|
||||
|
||||
void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const etk::Color<float,1>& _data) {
|
||||
if (m_vboSizeDataOffset[_id] == -1) {
|
||||
m_vboSizeDataOffset[_id] = 1;
|
||||
} else if (m_vboSizeDataOffset[_id] != 1) {
|
||||
EWOL_WARNING("set multiType in VBO (Not supported ==> TODO : Maybe update it");
|
||||
return;
|
||||
}
|
||||
m_vboUsed[_id] = true;
|
||||
m_buffer[_id].push_back(_data.r());
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/resource/Resource.h>
|
||||
#include <ewol/openGL/openGL.h>
|
||||
#include <etk/Color.h>
|
||||
|
||||
// TODO : Remove this ...
|
||||
#define NB_VBO_MAX (20)
|
||||
|
||||
namespace ewol {
|
||||
@ -29,6 +31,7 @@ namespace ewol {
|
||||
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 ...
|
||||
std::vector<float> m_buffer[NB_VBO_MAX]; //!< data that is availlable in the VBO system ...
|
||||
int8_t m_vboSizeDataOffset[NB_VBO_MAX]; //!< Internal size of the VBO (dynamicly set)
|
||||
protected:
|
||||
/**
|
||||
* @brief Constructor of this VBO.
|
||||
@ -47,29 +50,56 @@ namespace ewol {
|
||||
* @brief get the real openGL ID.
|
||||
* @return the Ogl id reference of this VBO.
|
||||
*/
|
||||
GLuint getGL_ID(int32_t id) { return m_vbo[id]; };
|
||||
GLuint getGL_ID(int32_t _id) {
|
||||
return m_vbo[_id];
|
||||
};
|
||||
/**
|
||||
* @brief get a reference on hte buffer data for this VBO.
|
||||
* @param[in] id Id of the buffer requested
|
||||
* @return A reference on the data.
|
||||
*/
|
||||
std::vector<float>& getRefBuffer(int32_t id) { m_vboUsed[id] = true; return m_buffer[id]; };
|
||||
std::vector<float>& getRefBuffer(int32_t _id) {
|
||||
m_vboUsed[_id] = true;
|
||||
return m_buffer[_id];
|
||||
};
|
||||
/**
|
||||
* @brief Get the buffer Number of element.
|
||||
* @param[in] _id VBO Element
|
||||
* @return Number of Float in the buffer.
|
||||
*/
|
||||
int32_t bufferSize(int32_t _id);
|
||||
/**
|
||||
* @brief Get the offset between element.
|
||||
* @param[in] _id VBO Element
|
||||
* @return Number of Float to jump between target.
|
||||
*/
|
||||
int32_t getElementSize(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.
|
||||
* @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);
|
||||
vec3 getOnBufferVec3(int32_t id, int32_t elementID);
|
||||
int32_t sizeOnBufferVec3(int32_t id);
|
||||
void pushOnBuffer(int32_t _id, const vec3& _data);
|
||||
vec3 getOnBufferVec3(int32_t _id, int32_t _elementID);
|
||||
/**
|
||||
* @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.
|
||||
* @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);
|
||||
void pushOnBuffer(int32_t _id, const vec2& _data);
|
||||
vec2 getOnBufferVec2(int32_t _id, int32_t _elementID);
|
||||
/**
|
||||
* @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 (Color).
|
||||
*/
|
||||
void pushOnBuffer(int32_t _id, const etk::Color<float,4>& _data);
|
||||
//! @previous
|
||||
void pushOnBuffer(int32_t _id, const etk::Color<float,3>& _data);
|
||||
//! @previous
|
||||
void pushOnBuffer(int32_t _id, const etk::Color<float,2>& _data);
|
||||
//! @previous
|
||||
void pushOnBuffer(int32_t _id, const etk::Color<float,1>& _data);
|
||||
/**
|
||||
* @brief get the data from the graphic card.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user