Beatmup
Beatmup::GL::AtomicCounter Class Reference

#include <program.h>

Public Member Functions

 AtomicCounter (const GraphicPipeline &gpu)
 
 ~AtomicCounter ()
 
void set (unsigned int value)
 

Private Attributes

handle_t handle
 

Friends

class AbstractProgram
 

Detailed Description

Definition at line 121 of file program.h.

Constructor & Destructor Documentation

◆ AtomicCounter()

AtomicCounter::AtomicCounter ( const GraphicPipeline gpu)

Definition at line 191 of file program.cpp.

191  {
192  glGenBuffers(1, &handle);
193  glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, handle);
194  glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(GLuint), nullptr, GL_STATIC_DRAW);
195  GL::GLException::check("creating atomic counter");
196 }
static void check(const std::string &info)
Definition: bgl.h:62

◆ ~AtomicCounter()

AtomicCounter::~AtomicCounter ( )

Definition at line 199 of file program.cpp.

199  {
200  glDeleteBuffers(1, &handle);
201 }

Member Function Documentation

◆ set()

void AtomicCounter::set ( unsigned int  value)

Definition at line 204 of file program.cpp.

204  {
205  GLuint *data;
206  glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, handle);
207  data = (GLuint*)glMapBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(GLuint),
208  GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
209  data[0] = value;
210  glUnmapBuffer(GL_ATOMIC_COUNTER_BUFFER);
211  GL::GLException::check("setting atomic counter value");
212 }

Friends And Related Function Documentation

◆ AbstractProgram

friend class AbstractProgram
friend

Definition at line 122 of file program.h.

Member Data Documentation

◆ handle

handle_t Beatmup::GL::AtomicCounter::handle
private

Definition at line 124 of file program.h.


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