"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer0/GenericBuffer.h" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

GenericBuffer.h  (pymol-open-source-2.2.0):GenericBuffer.h  (pymol-open-source-2.3.0)
skipping to change at line 69 skipping to change at line 69
UINT_INT_TO_PICK_DATA, UINT_INT_TO_PICK_DATA,
UB1_INTERP_TO_CAP, UB1_INTERP_TO_CAP,
FLOAT1_TO_INTERP, FLOAT1_TO_INTERP,
UB4_TO_UB4, UB4_TO_UB4,
PICK_DATA_TO_PICK_DATA, PICK_DATA_TO_PICK_DATA,
CYL_CAP_TO_CAP, CYL_CAP_TO_CAP,
FLOAT1_INTERP_TO_CAP, FLOAT1_INTERP_TO_CAP,
UB1_TO_INTERP, UB1_TO_INTERP,
CYL_CAPS_ARE_ROUND, CYL_CAPS_ARE_ROUND,
CYL_CAPS_ARE_FLAT, CYL_CAPS_ARE_FLAT,
CYL_CAPS_ARE_CUSTOM CYL_CAPS_ARE_CUSTOM,
FLOAT4_TO_UB4
}; };
struct AttribDesc; struct AttribDesc;
typedef void (*AttribOpFuncDataFunctionPtr)(void *varData, const float * pc, voi d *globalData, int idx); typedef void (*AttribOpFuncDataFunctionPtr)(void *varData, const float * pc, voi d *globalData, int idx);
/* AttribOpFuncData : This structure holds information a callback that sets/post -processes /* AttribOpFuncData : This structure holds information a callback that sets/post -processes
data for a particular attribute. Currently, a list of the se functions data for a particular attribute. Currently, a list of the se functions
are attached to the AttribOp so that when vertices are cre ated (i.e., incr_vertices > 0) are attached to the AttribOp so that when vertices are cre ated (i.e., incr_vertices > 0)
then for each vertex, this function is called for the part icular attribute attribName. then for each vertex, this function is called for the part icular attribute attribName.
skipping to change at line 114 skipping to change at line 115
* op - the CGO operation * op - the CGO operation
* order - the order for this operation to be executed for the given CGO operati on * order - the order for this operation to be executed for the given CGO operati on
* offset - the offset into the CGO operation to copy * offset - the offset into the CGO operation to copy
* conv_type - type of copy (can be general or specific, see above, e.g. FLOAT3_ TO_FLOAT3, UB1_TO_INTERP) * conv_type - type of copy (can be general or specific, see above, e.g. FLOAT3_ TO_FLOAT3, UB1_TO_INTERP)
* incr_vertices - the number of vertices (if any) that are generated for the VB O after this operation * incr_vertices - the number of vertices (if any) that are generated for the VB O after this operation
* is executed. * is executed.
* *
*/ */
struct AttribOp { struct AttribOp {
AttribOp(unsigned short _op, size_t _order, size_t _conv_type, size_t _offset, size_t _incr_vertices=0, int _copyFromAttr=-1) AttribOp(unsigned short _op, size_t _order, size_t _conv_type, size_t _offset, size_t _incr_vertices=0, int _copyFromAttr=-1)
: op(_op), offset(_offset), conv_type(_conv_type), order(_order), incr_verti : op(_op)
ces(_incr_vertices), copyFromAttr(_copyFromAttr){} , order(_order)
, offset(_offset)
, conv_type(_conv_type)
, incr_vertices(_incr_vertices)
, copyFromAttr(_copyFromAttr)
{}
unsigned short op { 0 }; unsigned short op { 0 };
size_t order { 0 }; size_t order { 0 };
size_t offset { 0 }; size_t offset { 0 };
size_t conv_type { 0 }; size_t conv_type { 0 };
size_t incr_vertices { 0 }; size_t incr_vertices { 0 };
int copyFromAttr { -1 }; int copyFromAttr { -1 };
struct AttribDesc *desc { 0 }; struct AttribDesc *desc { 0 };
struct AttribDesc *copyAttribDesc { 0 }; struct AttribDesc *copyAttribDesc { 0 };
std::vector<AttribOpFuncData> funcDataConversions; std::vector<AttribOpFuncData> funcDataConversions;
}; };
skipping to change at line 148 skipping to change at line 155
* repeat_value/repeat_value_length - specified if the attribute has repeating v alues * repeat_value/repeat_value_length - specified if the attribute has repeating v alues
* repeat_value - a pointer to the type and d ata for repeat values * repeat_value - a pointer to the type and d ata for repeat values
* repeat_value_length - number of repeat val ues * repeat_value_length - number of repeat val ues
* type_size - size of type for this attribute (e.g., GL_FLOAT, GL_UNSIGNED_BYTE ) * type_size - size of type for this attribute (e.g., GL_FLOAT, GL_UNSIGNED_BYTE )
* type_dim - number of primitives (i.e., type_size) for each vertex of this att ribute * type_dim - number of primitives (i.e., type_size) for each vertex of this att ribute
* data_norm - whether this attribute is normalized when passed to the VBO (GL_T RUE or GL_FALSE) * data_norm - whether this attribute is normalized when passed to the VBO (GL_T RUE or GL_FALSE)
* *
*/ */
struct AttribDesc { struct AttribDesc {
AttribDesc(const char * _attr_name, GLenum _type_size, size_t _type_dim, bool _data_norm, AttribDataOp _attrOps={}) AttribDesc(const char * _attr_name, GLenum _type_size, size_t _type_dim, bool _data_norm, AttribDataOp _attrOps={})
: attr_name(_attr_name), type_size(_type_size), type_dim(_type_dim), data_no : attr_name(_attr_name)
rm(_data_norm), attrOps(_attrOps), default_value(NULL){} , attrOps(_attrOps)
, default_value(NULL)
, type_size(_type_size)
, type_dim(_type_dim)
, data_norm(_data_norm)
{}
const char * attr_name { nullptr }; const char * attr_name { nullptr };
int order { 0 }; int order { 0 };
AttribDataOp attrOps { }; AttribDataOp attrOps { };
unsigned char *default_value { nullptr }; unsigned char *default_value { nullptr };
unsigned char *repeat_value { nullptr }; unsigned char *repeat_value { nullptr };
int repeat_value_length { 0 }; int repeat_value_length { 0 };
GLenum type_size { GL_FLOAT }; GLenum type_size { GL_FLOAT };
size_t type_dim { 0 }; size_t type_dim { 0 };
bool data_norm { false }; bool data_norm { false };
}; };
skipping to change at line 208 skipping to change at line 221
enum buffer_layout { enum buffer_layout {
SEPARATE, // multiple vbos SEPARATE, // multiple vbos
SEQUENTIAL, // single vbo SEQUENTIAL, // single vbo
INTERLEAVED // single vbo INTERLEAVED // single vbo
}; };
GenericBuffer( buffer_layout layout = SEPARATE, GLenum usage = GL_STATIC_DRAW ) : GenericBuffer( buffer_layout layout = SEPARATE, GLenum usage = GL_STATIC_DRAW ) :
m_buffer_usage(usage), m_layout(layout) {} m_buffer_usage(usage), m_layout(layout) {}
~GenericBuffer() { ~GenericBuffer() {
if (m_generated)
freeBuffers();
}
bool freeBuffers() {
for (auto &d : m_desc) { for (auto &d : m_desc) {
if (d.gl_id) { if (d.gl_id) {
glDeleteBuffers(1, &d.gl_id); glDeleteBuffers(1, &d.gl_id);
} }
} }
if (m_interleavedID) { if (m_interleavedID) {
glDeleteBuffers(1, &m_interleavedID); glDeleteBuffers(1, &m_interleavedID);
} }
m_generated = false;
return true;
} }
/*********************************************************************** /***********************************************************************
* bufferData * bufferData
*---------------------------------------------------------------------- *----------------------------------------------------------------------
* Takes a vector of the struct at the top of this file which describes * Takes a vector of the struct at the top of this file which describes
* the layout of the vbo object. The supplied data ptr in the struct can * the layout of the vbo object. The supplied data ptr in the struct can
* be zero, in which case if the default usage is STATIC_DRAW then no * be zero, in which case if the default usage is STATIC_DRAW then no
* opengl buffer will be generated for that, else it is assumed that the * opengl buffer will be generated for that, else it is assumed that the
* data will be supplied at a later point because it's dynamic draw. * data will be supplied at a later point because it's dynamic draw.
skipping to change at line 312 skipping to change at line 318
for ( auto &d : m_desc ) { for ( auto &d : m_desc ) {
// If the specified size is 0 but we have a valid pointer // If the specified size is 0 but we have a valid pointer
// then we are going to glVertexAttribXfv X in {1,2,3,4} // then we are going to glVertexAttribXfv X in {1,2,3,4}
if (d.data_ptr && (m_buffer_usage == GL_STATIC_DRAW)) { if (d.data_ptr && (m_buffer_usage == GL_STATIC_DRAW)) {
if (d.data_size) { if (d.data_size) {
if (!genBuffer(d.gl_id, d.data_size, d.data_ptr)) if (!genBuffer(d.gl_id, d.data_size, d.data_ptr))
return false; return false;
} }
} }
} }
m_generated = true;
return true; return true;
} }
bool seqBufferData() { bool seqBufferData() {
// this is only going to use a single opengl vbo // this is only going to use a single opengl vbo
m_interleaved = true; m_interleaved = true;
size_t buffer_size { 0 }; size_t buffer_size { 0 };
for ( auto & d : m_desc ) { for ( auto & d : m_desc ) {
buffer_size += d.data_size; buffer_size += d.data_size;
skipping to change at line 339 skipping to change at line 344
for ( auto & d : m_desc ) { for ( auto & d : m_desc ) {
d.offset = offset; d.offset = offset;
if (d.data_ptr) if (d.data_ptr)
memcpy(data_ptr, d.data_ptr, d.data_size); memcpy(data_ptr, d.data_ptr, d.data_size);
else else
memset(data_ptr, 0, d.data_size); memset(data_ptr, 0, d.data_size);
data_ptr += d.data_size; data_ptr += d.data_size;
offset += d.data_size; offset += d.data_size;
} }
m_generated = true;
bool ok = true; bool ok = true;
ok = genBuffer(m_interleavedID, buffer_size, buffer_data); ok = genBuffer(m_interleavedID, buffer_size, buffer_data);
m_generated = true;
delete[] buffer_data; delete[] buffer_data;
return ok; return ok;
} }
bool interleaveBufferData() { bool interleaveBufferData() {
size_t interleaved_size = 0; size_t interleaved_size = 0;
const size_t buffer_count = m_desc.size(); const size_t buffer_count = m_desc.size();
size_t stride = 0; size_t stride = 0;
std::vector<uint8_t *> data_table(buffer_count); std::vector<uint8_t *> data_table(buffer_count);
std::vector<uint8_t *> ptr_table(buffer_count); std::vector<uint8_t *> ptr_table(buffer_count);
skipping to change at line 403 skipping to change at line 406
memcpy( i_ptr, ptr_table[i], size_table[i] ); memcpy( i_ptr, ptr_table[i], size_table[i] );
ptr_table[i] += size_table[i]; ptr_table[i] += size_table[i];
} }
i_ptr += size_table[i]; i_ptr += size_table[i];
} }
} }
bool ok = true; bool ok = true;
ok = genBuffer(m_interleavedID, interleaved_size, interleaved_data); ok = genBuffer(m_interleavedID, interleaved_size, interleaved_data);
m_interleaved = true; m_interleaved = true;
m_generated = true;
free(interleaved_data); free(interleaved_data);
return ok; return ok;
} }
bool genBuffer(GLuint &id, size_t size, const void * ptr) { bool genBuffer(GLuint &id, size_t size, const void * ptr) {
glGenBuffers(1, &id); glGenBuffers(1, &id);
if (!glCheckOkay()) if (!glCheckOkay())
return false; return false;
glBindBuffer(TYPE, id); glBindBuffer(TYPE, id);
if (!glCheckOkay()) if (!glCheckOkay())
return false; return false;
glBufferData(TYPE, size, ptr, GL_STATIC_DRAW); glBufferData(TYPE, size, ptr, GL_STATIC_DRAW);
if (!glCheckOkay()) if (!glCheckOkay())
return false; return false;
return true; return true;
} }
protected: protected:
bool m_status { false }; bool m_status { false };
bool m_generated { false };
bool m_interleaved { false }; bool m_interleaved { false };
GLuint m_interleavedID { 0 }; GLuint m_interleavedID { 0 };
const GLenum m_buffer_usage { GL_STATIC_DRAW }; const GLenum m_buffer_usage { GL_STATIC_DRAW };
const buffer_layout m_layout { SEPARATE }; const buffer_layout m_layout { SEPARATE };
size_t m_stride { 0 }; size_t m_stride { 0 };
BufferDataDesc m_desc; BufferDataDesc m_desc;
}; };
/* /*
* Vertex buffer specialization * Vertex buffer specialization
 End of changes. 10 change blocks. 
17 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)