OpenCV453
公開型 | 公開メンバ関数 | 静的公開メンバ関数 | 全メンバ一覧
cv::ogl::Buffer クラス

Smart pointer for OpenGL buffer object with reference counting. [詳解]

#include <opengl.hpp>

公開型

enum  Target { ARRAY_BUFFER = 0x8892 , ELEMENT_ARRAY_BUFFER = 0x8893 , PIXEL_PACK_BUFFER = 0x88EB , PIXEL_UNPACK_BUFFER = 0x88EC }
 The target defines how you intend to use the buffer object. [詳解]
 
enum  Access { READ_ONLY = 0x88B8 , WRITE_ONLY = 0x88B9 , READ_WRITE = 0x88BA }
 

公開メンバ関数

 Buffer ()
 The constructors. [詳解]
 
 Buffer (int arows, int acols, int atype, unsigned int abufId, bool autoRelease=false)
 
 Buffer (Size asize, int atype, unsigned int abufId, bool autoRelease=false)
 
 Buffer (int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
 Buffer (Size asize, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
 Buffer (InputArray arr, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
void create (int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 Allocates memory for ogl::Buffer object. [詳解]
 
void create (Size asize, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
void release ()
 Decrements the reference counter and destroys the buffer object if needed. [詳解]
 
void setAutoRelease (bool flag)
 Sets auto release mode. [詳解]
 
void copyFrom (InputArray arr, Target target=ARRAY_BUFFER, bool autoRelease=false)
 Copies from host/device memory to OpenGL buffer. [詳解]
 
void copyFrom (InputArray arr, cuda::Stream &stream, Target target=ARRAY_BUFFER, bool autoRelease=false)
 
void copyTo (OutputArray arr) const
 Copies from OpenGL buffer to host/device memory or another OpenGL buffer object. [詳解]
 
void copyTo (OutputArray arr, cuda::Stream &stream) const
 
Buffer clone (Target target=ARRAY_BUFFER, bool autoRelease=false) const
 Creates a full copy of the buffer object and the underlying data. [詳解]
 
void bind (Target target) const
 Binds OpenGL buffer to the specified buffer binding point. [詳解]
 
Mat mapHost (Access access)
 Maps OpenGL buffer to host memory. [詳解]
 
void unmapHost ()
 Unmaps OpenGL buffer.
 
cuda::GpuMat mapDevice ()
 map to device memory (blocking)
 
void unmapDevice ()
 
cuda::GpuMat mapDevice (cuda::Stream &stream)
 Maps OpenGL buffer to CUDA device memory. [詳解]
 
void unmapDevice (cuda::Stream &stream)
 Unmaps OpenGL buffer.
 
int rows () const
 
int cols () const
 
Size size () const
 
bool empty () const
 
int type () const
 
int depth () const
 
int channels () const
 
int elemSize () const
 
int elemSize1 () const
 
unsigned int bufId () const
 get OpenGL opject id
 

静的公開メンバ関数

static void unbind (Target target)
 Unbind any buffers from the specified binding point. [詳解]
 

詳解

Smart pointer for OpenGL buffer object with reference counting.

Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL context. These can be used to store vertex data, pixel data retrieved from images or the framebuffer, and a variety of other things.

ogl::Buffer has interface similar with Mat interface and represents 2D array memory.

ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory.

列挙型メンバ詳解

◆ Target

The target defines how you intend to use the buffer object.

列挙値
ARRAY_BUFFER 

The buffer will be used as a source for vertex data

ELEMENT_ARRAY_BUFFER 

The buffer will be used for indices (in glDrawElements, for example)

PIXEL_PACK_BUFFER 

The buffer will be used for reading from OpenGL textures

PIXEL_UNPACK_BUFFER 

The buffer will be used for writing to OpenGL textures

構築子と解体子

◆ Buffer() [1/6]

cv::ogl::Buffer::Buffer ( )

The constructors.

Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId parameter), allocates memory for ogl::Buffer object or copies from host/device memory.

◆ Buffer() [2/6]

cv::ogl::Buffer::Buffer ( int  arows,
int  acols,
int  atype,
unsigned int  abufId,
bool  autoRelease = false 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
arowsNumber of rows in a 2D array.
acolsNumber of columns in a 2D array.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
abufIdBuffer object name.
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ Buffer() [3/6]

cv::ogl::Buffer::Buffer ( Size  asize,
int  atype,
unsigned int  abufId,
bool  autoRelease = false 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
asize2D array size.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
abufIdBuffer object name.
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ Buffer() [4/6]

cv::ogl::Buffer::Buffer ( int  arows,
int  acols,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
arowsNumber of rows in a 2D array.
acolsNumber of columns in a 2D array.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ Buffer() [5/6]

cv::ogl::Buffer::Buffer ( Size  asize,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
asize2D array size.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ Buffer() [6/6]

cv::ogl::Buffer::Buffer ( InputArray  arr,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)
explicit

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

関数詳解

◆ bind()

void cv::ogl::Buffer::bind ( Target  target) const

Binds OpenGL buffer to the specified buffer binding point.

引数
targetBinding point. See cv::ogl::Buffer::Target .

◆ clone()

Buffer cv::ogl::Buffer::clone ( Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
) const

Creates a full copy of the buffer object and the underlying data.

引数
targetBuffer usage for destination buffer.
autoReleaseAuto release mode for destination buffer.

◆ copyFrom() [1/2]

void cv::ogl::Buffer::copyFrom ( InputArray  arr,
cuda::Stream stream,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

◆ copyFrom() [2/2]

void cv::ogl::Buffer::copyFrom ( InputArray  arr,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

Copies from host/device memory to OpenGL buffer.

引数
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ copyTo() [1/2]

void cv::ogl::Buffer::copyTo ( OutputArray  arr) const

Copies from OpenGL buffer to host/device memory or another OpenGL buffer object.

引数
arrDestination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or ogl::Buffer ).

◆ copyTo() [2/2]

void cv::ogl::Buffer::copyTo ( OutputArray  arr,
cuda::Stream stream 
) const

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

◆ create() [1/2]

void cv::ogl::Buffer::create ( int  arows,
int  acols,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

Allocates memory for ogl::Buffer object.

引数
arowsNumber of rows in a 2D array.
acolsNumber of columns in a 2D array.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ create() [2/2]

void cv::ogl::Buffer::create ( Size  asize,
int  atype,
Target  target = ARRAY_BUFFER,
bool  autoRelease = false 
)

これはオーバーロードされたメンバ関数です。利便性のために用意されています。元の関数との違いは引き数のみです。

引数
asize2D array size.
atypeArray type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
targetBuffer usage. See cv::ogl::Buffer::Target .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

◆ mapDevice()

cuda::GpuMat cv::ogl::Buffer::mapDevice ( cuda::Stream stream)

Maps OpenGL buffer to CUDA device memory.

This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time.

A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used.

◆ mapHost()

Mat cv::ogl::Buffer::mapHost ( Access  access)

Maps OpenGL buffer to host memory.

mapHost maps to the client's address space the entire data store of the buffer object. The data can then be directly read and/or written relative to the returned pointer, depending on the specified access policy.

A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used.

This operation can lead to memory transfers between host and device.

Only one buffer object can be mapped at a time.

引数
accessAccess policy, indicating whether it will be possible to read from, write to, or both read from and write to the buffer object's mapped data store. The symbolic constant must be ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE .

◆ release()

void cv::ogl::Buffer::release ( )

Decrements the reference counter and destroys the buffer object if needed.

The function will call setAutoRelease(true) .

◆ setAutoRelease()

void cv::ogl::Buffer::setAutoRelease ( bool  flag)

Sets auto release mode.

The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was bound to a window it could be released at any time (user can close a window). If object's destructor is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). This function can force ogl::Buffer destructor to destroy OpenGL object.

引数
flagAuto release mode (if true, release will be called in object's destructor).

◆ unbind()

static void cv::ogl::Buffer::unbind ( Target  target)
static

Unbind any buffers from the specified binding point.

引数
targetBinding point. See cv::ogl::Buffer::Target .

このクラス詳解は次のファイルから抽出されました: