OpenCV  4.1.2
Open Source Computer Vision
Public Types | Public Member Functions | List of all members
cv::ogl::Texture2D Class Reference

Smart pointer for OpenGL 2D texture memory with reference counting. More...

#include <opencv2/core/opengl.hpp>

Public Types

enum  Format {
  NONE = 0,
  DEPTH_COMPONENT = 0x1902,
  RGB = 0x1907,
  RGBA = 0x1908
}
 An Image Format describes the way that the images in Textures store their data. More...
 

Public Member Functions

 Texture2D ()
 The constructors. More...
 
 Texture2D (int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease=false)
 
 Texture2D (Size asize, Format aformat, unsigned int atexId, bool autoRelease=false)
 
 Texture2D (int arows, int acols, Format aformat, bool autoRelease=false)
 
 Texture2D (Size asize, Format aformat, bool autoRelease=false)
 
 Texture2D (InputArray arr, bool autoRelease=false)
 
void bind () const
 Binds texture to current active texture unit for GL_TEXTURE_2D target. More...
 
int cols () const
 
void copyFrom (InputArray arr, bool autoRelease=false)
 Copies from host/device memory to OpenGL texture. More...
 
void copyTo (OutputArray arr, int ddepth=CV_32F, bool autoRelease=false) const
 Copies from OpenGL texture to host/device memory or another OpenGL texture object. More...
 
void create (int arows, int acols, Format aformat, bool autoRelease=false)
 Allocates memory for ogl::Texture2D object. More...
 
void create (Size asize, Format aformat, bool autoRelease=false)
 
bool empty () const
 
Format format () const
 
void release ()
 Decrements the reference counter and destroys the texture object if needed. More...
 
int rows () const
 
void setAutoRelease (bool flag)
 Sets auto release mode. More...
 
Size size () const
 
unsigned int texId () const
 get OpenGL opject id More...
 

Detailed Description

Smart pointer for OpenGL 2D texture memory with reference counting.

Member Enumeration Documentation

§ Format

An Image Format describes the way that the images in Textures store their data.

Enumerator
NONE 
DEPTH_COMPONENT 

Depth.

RGB 

Red, Green, Blue.

RGBA 

Red, Green, Blue, Alpha.

Constructor & Destructor Documentation

§ Texture2D() [1/6]

cv::ogl::Texture2D::Texture2D ( )

The constructors.

Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from host/device memory.

§ Texture2D() [2/6]

cv::ogl::Texture2D::Texture2D ( int  arows,
int  acols,
Format  aformat,
unsigned int  atexId,
bool  autoRelease = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ Texture2D() [3/6]

cv::ogl::Texture2D::Texture2D ( Size  asize,
Format  aformat,
unsigned int  atexId,
bool  autoRelease = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ Texture2D() [4/6]

cv::ogl::Texture2D::Texture2D ( int  arows,
int  acols,
Format  aformat,
bool  autoRelease = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arowsNumber of rows.
acolsNumber of columns.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

§ Texture2D() [5/6]

cv::ogl::Texture2D::Texture2D ( Size  asize,
Format  aformat,
bool  autoRelease = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

§ Texture2D() [6/6]

cv::ogl::Texture2D::Texture2D ( InputArray  arr,
bool  autoRelease = false 
)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
autoReleaseAuto release mode (if true, release will be called in object's destructor).

Member Function Documentation

§ bind()

void cv::ogl::Texture2D::bind ( ) const

Binds texture to current active texture unit for GL_TEXTURE_2D target.

§ cols()

int cv::ogl::Texture2D::cols ( ) const

§ copyFrom()

void cv::ogl::Texture2D::copyFrom ( InputArray  arr,
bool  autoRelease = false 
)

Copies from host/device memory to OpenGL texture.

Parameters
arrInput array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
autoReleaseAuto release mode (if true, release will be called in object's destructor).

§ copyTo()

void cv::ogl::Texture2D::copyTo ( OutputArray  arr,
int  ddepth = CV_32F,
bool  autoRelease = false 
) const

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

Parameters
arrDestination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or ogl::Texture2D ).
ddepthDestination depth.
autoReleaseAuto release mode for destination buffer (if arr is OpenGL buffer or texture).

§ create() [1/2]

void cv::ogl::Texture2D::create ( int  arows,
int  acols,
Format  aformat,
bool  autoRelease = false 
)

Allocates memory for ogl::Texture2D object.

Parameters
arowsNumber of rows.
acolsNumber of columns.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

§ create() [2/2]

void cv::ogl::Texture2D::create ( Size  asize,
Format  aformat,
bool  autoRelease = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
asize2D array size.
aformatImage format. See cv::ogl::Texture2D::Format .
autoReleaseAuto release mode (if true, release will be called in object's destructor).

§ empty()

bool cv::ogl::Texture2D::empty ( ) const

§ format()

Format cv::ogl::Texture2D::format ( ) const

§ release()

void cv::ogl::Texture2D::release ( )

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

The function will call setAutoRelease(true) .

§ rows()

int cv::ogl::Texture2D::rows ( ) const

§ setAutoRelease()

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

Sets auto release mode.

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

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::Texture2D doesn't destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context). This function can force ogl::Texture2D destructor to destroy OpenGL object.

§ size()

Size cv::ogl::Texture2D::size ( ) const

§ texId()

unsigned int cv::ogl::Texture2D::texId ( ) const

get OpenGL opject id


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