Skip to content

BufferRelease

RAII utility to unbind a specific type of buffer upon construction and restore it upon destruction. More...

#include "Utils/Timers.h"

Public Functions

Name
BufferRelease()<br>Constructor that unbinds the currently bound buffer if one is bound.
~BufferRelease()<br>Destructor that rebinds the previously bound buffer, if it existed.

Detailed Description

cpp
template <int target,
int query>
class BufferRelease;
template <int target,
int query>
class BufferRelease;

RAII utility to unbind a specific type of buffer upon construction and restore it upon destruction.

Template Parameters:

  • target The OpenGL buffer target (e.g., GL_QUERY_BUFFER).
  • query The OpenGL parameter used to retrieve the current binding (e.g., GL_QUERY_BUFFER_BINDING).

This template class captures the currently bound buffer of a given target upon construction, unbinds it, and then rebinds the previously bound buffer on destruction. Useful for ensuring buffers are correctly unbound during certain operations (e.g., timing queries).

Public Functions Documentation

function BufferRelease

cpp
inline BufferRelease()
inline BufferRelease()

Constructor that unbinds the currently bound buffer if one is bound.

Retrieves the currently bound buffer for the specified target via glGetIntegerv, stores it in buffer, and unbinds it if it is greater than 0.

function ~BufferRelease

cpp
inline ~BufferRelease()
inline ~BufferRelease()

Destructor that rebinds the previously bound buffer, if it existed.


Updated on 2025-05-31 at 12:55:30 +0000