gKit2 light
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
UpdateBuffer Class Reference

buffer unique de copie / mise a jour des vertex buffers statiques. singleton. tous les meshs utilisent le meme buffer de copie... More...

Public Member Functions

void copy (GLenum target, const size_t offset, const size_t length, const void *data)
 transfere les donnees dans un buffer statique. More...
 
 ~UpdateBuffer ()
 detruit le buffer. More...
 
void release ()
 detruit le buffer. More...
 

Static Public Member Functions

static UpdateBuffermanager ()
 acces au singleton. More...
 

Protected Member Functions

 UpdateBuffer ()
 constructeur prive. singleton. More...
 

Protected Attributes

GLuint m_buffer
 
size_t m_size
 

Detailed Description

buffer unique de copie / mise a jour des vertex buffers statiques. singleton. tous les meshs utilisent le meme buffer de copie...

Definition at line 524 of file mesh.cpp.

Constructor & Destructor Documentation

◆ ~UpdateBuffer()

UpdateBuffer::~UpdateBuffer ( )
inline

detruit le buffer.

Definition at line 552 of file mesh.cpp.

553  {
554  release();
555  }
void release()
detruit le buffer.
Definition: mesh.cpp:558

◆ UpdateBuffer()

UpdateBuffer::UpdateBuffer ( )
inlineprotected

constructeur prive. singleton.

Definition at line 574 of file mesh.cpp.

574 : m_buffer(0), m_size(0) {}

Member Function Documentation

◆ copy()

void UpdateBuffer::copy ( GLenum  target,
const size_t  offset,
const size_t  length,
const void *  data 
)
inline

transfere les donnees dans un buffer statique.

Definition at line 528 of file mesh.cpp.

529  {
530  if(m_buffer == 0)
531  glGenBuffers(1, &m_buffer);
532 
533  assert(m_buffer);
534  glBindBuffer(GL_COPY_READ_BUFFER, m_buffer);
535  if(length > m_size)
536  {
537  m_size= (length / (16*1024*1024) + 1) * (16*1024*1024); // alloue par bloc de 16Mo
538  assert(m_size >= length);
539 
540  // alloue un buffer intermediaire dynamique...
541  glBufferData(GL_COPY_READ_BUFFER, m_size, nullptr, GL_DYNAMIC_DRAW);
542  printf("[UpdateBuffer] allocate %dMo staging buffer...\n", int(m_size / 1024 / 1024));
543  }
544 
545  // place les donnees dans le buffer intermediaire
546  glBufferSubData(GL_COPY_READ_BUFFER, 0, length, data);
547  // copie les donnees dans le vertex buffer statique
548  glCopyBufferSubData(GL_COPY_READ_BUFFER, target, 0, offset, length);
549  }
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
Definition: text.cpp:140
float length(const Vector &v)
renvoie la longueur d'un vecteur.
Definition: vec.cpp:142

◆ release()

void UpdateBuffer::release ( )
inline

detruit le buffer.

Definition at line 558 of file mesh.cpp.

559  {
560  glDeleteBuffers(1, &m_buffer);
561  m_buffer= 0;
562  m_size= 0;
563  }

◆ manager()

static UpdateBuffer& UpdateBuffer::manager ( )
inlinestatic

acces au singleton.

Definition at line 566 of file mesh.cpp.

567  {
568  static UpdateBuffer buffer;
569  return buffer;
570  }
buffer unique de copie / mise a jour des vertex buffers statiques. singleton. tous les meshs utilisen...
Definition: mesh.cpp:525

The documentation for this class was generated from the following file: