openMSX
Public Member Functions | List of all members
gl::PixelBuffer< T > Class Template Reference

Wrapper around a pixel buffer. More...

#include <GLUtil.hh>

Inheritance diagram for gl::PixelBuffer< T >:
Inheritance graph
[legend]

Public Member Functions

 PixelBuffer ()
 
 PixelBuffer (PixelBuffer &&other) noexcept
 
PixelBufferoperator= (PixelBuffer &&other) noexcept
 
 ~PixelBuffer ()
 
bool openGLSupported () const
 Are PBOs supported by this openGL implementation? This class implements a SW fallback in case PBOs are not directly supported by this openGL implementation, but it will probably be a lot slower. More...
 
void setImage (GLuint width, GLuint height)
 Sets the image for this buffer. More...
 
void bind () const
 Bind this PixelBuffer. More...
 
void unbind () const
 Unbind this buffer. More...
 
T * getOffset (GLuint x, GLuint y)
 Gets a pointer relative to the start of this buffer. More...
 
T * mapWrite ()
 Maps the contents of this buffer into memory. More...
 
void unmap () const
 Unmaps the contents of this buffer. More...
 

Detailed Description

template<typename T>
class gl::PixelBuffer< T >

Wrapper around a pixel buffer.

The pixel buffer will be allocated in VRAM if possible, in main RAM otherwise. The pixel type is templatized T.

Definition at line 149 of file GLUtil.hh.

Constructor & Destructor Documentation

◆ PixelBuffer() [1/2]

template<typename T >
gl::PixelBuffer< T >::PixelBuffer ( )

Definition at line 225 of file GLUtil.hh.

◆ PixelBuffer() [2/2]

template<typename T >
gl::PixelBuffer< T >::PixelBuffer ( PixelBuffer< T > &&  other)
noexcept

Definition at line 236 of file GLUtil.hh.

◆ ~PixelBuffer()

template<typename T >
gl::PixelBuffer< T >::~PixelBuffer ( )

Definition at line 256 of file GLUtil.hh.

Member Function Documentation

◆ bind()

template<typename T >
void gl::PixelBuffer< T >::bind ( ) const

Bind this PixelBuffer.

Must be called before the methods getOffset() or mapWrite() are used. (Is a wrapper around glBindBuffer).

Definition at line 286 of file GLUtil.hh.

Referenced by openmsx::GLHQScaler::uploadBlock(), and openmsx::GLHQLiteScaler::uploadBlock().

◆ getOffset()

template<typename T >
T * gl::PixelBuffer< T >::getOffset ( GLuint  x,
GLuint  y 
)

Gets a pointer relative to the start of this buffer.

You must not dereference this pointer, but you can pass it to glTexImage etc when this buffer is bound as the source.

Precondition
This PixelBuffer must be bound (see bind()) before calling this method.

Definition at line 302 of file GLUtil.hh.

Referenced by openmsx::GLHQScaler::uploadBlock(), and openmsx::GLHQLiteScaler::uploadBlock().

◆ mapWrite()

template<typename T >
T * gl::PixelBuffer< T >::mapWrite ( )

Maps the contents of this buffer into memory.

The returned buffer is write-only (reading could be very slow or even result in a segfault).

Returns
Pointer through which you can write pixels to this buffer, or 0 if the buffer could not be mapped.
Precondition
This PixelBuffer must be bound (see bind()) before calling this method.

Definition at line 315 of file GLUtil.hh.

Referenced by openmsx::GLHQScaler::uploadBlock(), and openmsx::GLHQLiteScaler::uploadBlock().

◆ openGLSupported()

template<typename T >
bool gl::PixelBuffer< T >::openGLSupported ( ) const

Are PBOs supported by this openGL implementation? This class implements a SW fallback in case PBOs are not directly supported by this openGL implementation, but it will probably be a lot slower.

Definition at line 262 of file GLUtil.hh.

◆ operator=()

template<typename T >
PixelBuffer< T > & gl::PixelBuffer< T >::operator= ( PixelBuffer< T > &&  other)
noexcept

Definition at line 246 of file GLUtil.hh.

◆ setImage()

template<typename T >
void gl::PixelBuffer< T >::setImage ( GLuint  width,
GLuint  height 
)

Sets the image for this buffer.

TODO: Actually, only image size for now; later, if we need it, image data too.

Definition at line 268 of file GLUtil.hh.

Referenced by openmsx::GLHQLiteScaler::GLHQLiteScaler(), and openmsx::GLHQScaler::GLHQScaler().

◆ unbind()

template<typename T >
void gl::PixelBuffer< T >::unbind ( ) const

Unbind this buffer.

Definition at line 294 of file GLUtil.hh.

Referenced by openmsx::GLHQScaler::uploadBlock(), and openmsx::GLHQLiteScaler::uploadBlock().

◆ unmap()

template<typename T >
void gl::PixelBuffer< T >::unmap ( ) const

Unmaps the contents of this buffer.

After this call, you must no longer use the pointer returned by mapWrite.

Definition at line 326 of file GLUtil.hh.

Referenced by openmsx::GLHQScaler::uploadBlock(), and openmsx::GLHQLiteScaler::uploadBlock().


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