@ -53,6 +53,9 @@
# endif
# endif
using namespace cv ;
using namespace cv : : gpu ;
namespace
{
# ifndef HAVE_OPENGL
@ -80,7 +83,7 @@ namespace
# endif
}
bool cv : : checkGl Error ( const char * file , const int line , const char * func )
bool cv : : ogl : : checkError ( const char * file , const int line , const char * func )
{
# ifndef HAVE_OPENGL
( void ) file ;
@ -307,17 +310,17 @@ namespace
# endif
////////////////////////////////////////////////////////////////////////
// Gl Buffer
// ogl:: Buffer
# ifndef HAVE_OPENGL
class cv : : Gl Buffer: : Impl
class cv : : ogl : : Buffer : : Impl
{
} ;
# else
class cv : : Gl Buffer: : Impl
class cv : : ogl : : Buffer : : Impl
{
public :
static const Ptr < Impl > & empty ( ) ;
@ -359,21 +362,21 @@ private:
# endif
} ;
const cv : : Ptr < cv : : Gl Buffer: : Impl > & cv : : Gl Buffer: : Impl : : empty ( )
const Ptr < cv : : ogl : : Buffer : : Impl > & cv : : ogl : : Buffer : : Impl : : empty ( )
{
static Ptr < Impl > p ( new Impl ) ;
return p ;
}
cv : : Gl Buffer: : Impl : : Impl ( ) : bufId_ ( 0 ) , autoRelease_ ( true )
cv : : ogl : : Buffer : : Impl : : Impl ( ) : bufId_ ( 0 ) , autoRelease_ ( true )
{
}
cv : : Gl Buffer: : Impl : : Impl ( GLuint abufId , bool autoRelease ) : bufId_ ( abufId ) , autoRelease_ ( autoRelease )
cv : : ogl : : Buffer : : Impl : : Impl ( GLuint abufId , bool autoRelease ) : bufId_ ( abufId ) , autoRelease_ ( autoRelease )
{
}
cv : : Gl Buffer: : Impl : : Impl ( GLsizeiptr size , const GLvoid * data , GLenum target , bool autoRelease ) : bufId_ ( 0 ) , autoRelease_ ( autoRelease )
cv : : ogl : : Buffer : : Impl : : Impl ( GLsizeiptr size , const GLvoid * data , GLenum target , bool autoRelease ) : bufId_ ( 0 ) , autoRelease_ ( autoRelease )
{
gl : : GenBuffers ( 1 , & bufId_ ) ;
CV_CheckGlError ( ) ;
@ -390,19 +393,19 @@ cv::GlBuffer::Impl::Impl(GLsizeiptr size, const GLvoid* data, GLenum target, boo
CV_CheckGlError ( ) ;
}
cv : : Gl Buffer: : Impl : : ~ Impl ( )
cv : : ogl : : Buffer : : Impl : : ~ Impl ( )
{
if ( autoRelease_ & & bufId_ )
gl : : DeleteBuffers ( 1 , & bufId_ ) ;
}
void cv : : Gl Buffer: : Impl : : bind ( GLenum target ) const
void cv : : ogl : : Buffer : : Impl : : bind ( GLenum target ) const
{
gl : : BindBuffer ( target , bufId_ ) ;
CV_CheckGlError ( ) ;
}
void cv : : Gl Buffer: : Impl : : copyFrom ( GLuint srcBuf , GLsizeiptr size )
void cv : : ogl : : Buffer : : Impl : : copyFrom ( GLuint srcBuf , GLsizeiptr size )
{
gl : : BindBuffer ( gl : : COPY_WRITE_BUFFER , bufId_ ) ;
CV_CheckGlError ( ) ;
@ -414,7 +417,7 @@ void cv::GlBuffer::Impl::copyFrom(GLuint srcBuf, GLsizeiptr size)
CV_CheckGlError ( ) ;
}
void cv : : Gl Buffer: : Impl : : copyFrom ( GLsizeiptr size , const GLvoid * data )
void cv : : ogl : : Buffer : : Impl : : copyFrom ( GLsizeiptr size , const GLvoid * data )
{
gl : : BindBuffer ( gl : : COPY_WRITE_BUFFER , bufId_ ) ;
CV_CheckGlError ( ) ;
@ -423,7 +426,7 @@ void cv::GlBuffer::Impl::copyFrom(GLsizeiptr size, const GLvoid* data)
CV_CheckGlError ( ) ;
}
void cv : : Gl Buffer: : Impl : : copyTo ( GLsizeiptr size , GLvoid * data ) const
void cv : : ogl : : Buffer : : Impl : : copyTo ( GLsizeiptr size , GLvoid * data ) const
{
gl : : BindBuffer ( gl : : COPY_READ_BUFFER , bufId_ ) ;
CV_CheckGlError ( ) ;
@ -432,7 +435,7 @@ void cv::GlBuffer::Impl::copyTo(GLsizeiptr size, GLvoid* data) const
CV_CheckGlError ( ) ;
}
void * cv : : Gl Buffer: : Impl : : mapHost ( GLenum access )
void * cv : : ogl : : Buffer : : Impl : : mapHost ( GLenum access )
{
gl : : BindBuffer ( gl : : COPY_READ_BUFFER , bufId_ ) ;
CV_CheckGlError ( ) ;
@ -443,31 +446,31 @@ void* cv::GlBuffer::Impl::mapHost(GLenum access)
return data ;
}
void cv : : Gl Buffer: : Impl : : unmapHost ( )
void cv : : ogl : : Buffer : : Impl : : unmapHost ( )
{
gl : : UnmapBuffer ( gl : : COPY_READ_BUFFER ) ;
}
# ifdef HAVE_CUDA
void cv : : Gl Buffer: : Impl : : copyFrom ( const void * src , size_t spitch , size_t width , size_t height , cudaStream_t stream )
void cv : : ogl : : Buffer : : Impl : : copyFrom ( const void * src , size_t spitch , size_t width , size_t height , cudaStream_t stream )
{
cudaResource_ . registerBuffer ( bufId_ ) ;
cudaResource_ . copyFrom ( src , spitch , width , height , stream ) ;
}
void cv : : Gl Buffer: : Impl : : copyTo ( void * dst , size_t dpitch , size_t width , size_t height , cudaStream_t stream ) const
void cv : : ogl : : Buffer : : Impl : : copyTo ( void * dst , size_t dpitch , size_t width , size_t height , cudaStream_t stream ) const
{
cudaResource_ . registerBuffer ( bufId_ ) ;
cudaResource_ . copyTo ( dst , dpitch , width , height , stream ) ;
}
void * cv : : Gl Buffer: : Impl : : mapDevice ( cudaStream_t stream )
void * cv : : ogl : : Buffer : : Impl : : mapDevice ( cudaStream_t stream )
{
cudaResource_ . registerBuffer ( bufId_ ) ;
return cudaResource_ . map ( stream ) ;
}
void cv : : Gl Buffer: : Impl : : unmapDevice ( cudaStream_t stream )
void cv : : ogl : : Buffer : : Impl : : unmapDevice ( cudaStream_t stream )
{
cudaResource_ . unmap ( stream ) ;
}
@ -475,7 +478,7 @@ void cv::GlBuffer::Impl::unmapHost()
# endif // HAVE_OPENGL
cv : : Gl Buffer: : Gl Buffer( ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
cv : : ogl : : Buffer : : Buffer ( ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -484,7 +487,7 @@ cv::GlBuffer::GlBuffer() : rows_(0), cols_(0), type_(0)
# endif
}
cv : : Gl Buffer: : Gl Buffer( int arows , int acols , int atype , unsigned int abufId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
cv : : ogl : : Buffer : : Buffer ( int arows , int acols , int atype , unsigned int abufId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
{
# ifndef HAVE_OPENGL
( void ) arows ;
@ -501,7 +504,7 @@ cv::GlBuffer::GlBuffer(int arows, int acols, int atype, unsigned int abufId, boo
# endif
}
cv : : Gl Buffer: : Gl Buffer( Size asize , int atype , unsigned int abufId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
cv : : ogl : : Buffer : : Buffer ( Size asize , int atype , unsigned int abufId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
{
# ifndef HAVE_OPENGL
( void ) asize ;
@ -517,17 +520,17 @@ cv::GlBuffer::GlBuffer(Size asize, int atype, unsigned int abufId, bool autoRele
# endif
}
cv : : Gl Buffer: : Gl Buffer( int arows , int acols , int atype , Target target , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
cv : : ogl : : Buffer : : Buffer ( int arows , int acols , int atype , Target target , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
{
create ( arows , acols , atype , target , autoRelease ) ;
}
cv : : Gl Buffer: : Gl Buffer( Size asize , int atype , Target target , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
cv : : ogl : : Buffer : : Buffer ( Size asize , int atype , Target target , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
{
create ( asize , atype , target , autoRelease ) ;
}
cv : : Gl Buffer: : Gl Buffer( InputArray arr , Target target , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
cv : : ogl : : Buffer : : Buffer ( InputArray arr , Target target , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , type_ ( 0 )
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -545,7 +548,7 @@ cv::GlBuffer::GlBuffer(InputArray arr, Target target, bool autoRelease) : rows_(
break ;
}
case _InputArray : : OPENGL_TEXTURE2D :
case _InputArray : : OPENGL_TEXTURE :
{
copyFrom ( arr , target , autoRelease ) ;
break ;
@ -572,7 +575,7 @@ cv::GlBuffer::GlBuffer(InputArray arr, Target target, bool autoRelease) : rows_(
# endif
}
void cv : : Gl Buffer: : create ( int arows , int acols , int atype , Target target , bool autoRelease )
void cv : : ogl : : Buffer : : create ( int arows , int acols , int atype , Target target , bool autoRelease )
{
# ifndef HAVE_OPENGL
( void ) arows ;
@ -593,7 +596,7 @@ void cv::GlBuffer::create(int arows, int acols, int atype, Target target, bool a
# endif
}
void cv : : Gl Buffer: : release ( )
void cv : : ogl : : Buffer : : release ( )
{
# ifdef HAVE_OPENGL
if ( * impl_ . refcount = = 1 )
@ -605,7 +608,7 @@ void cv::GlBuffer::release()
# endif
}
void cv : : Gl Buffer: : setAutoRelease ( bool flag )
void cv : : ogl : : Buffer : : setAutoRelease ( bool flag )
{
# ifndef HAVE_OPENGL
( void ) flag ;
@ -615,7 +618,7 @@ void cv::GlBuffer::setAutoRelease(bool flag)
# endif
}
void cv : : Gl Buffer: : copyFrom ( InputArray arr , Target target , bool autoRelease )
void cv : : ogl : : Buffer : : copyFrom ( InputArray arr , Target target , bool autoRelease )
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -625,9 +628,9 @@ void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
# else
const int kind = arr . kind ( ) ;
if ( kind = = _InputArray : : OPENGL_TEXTURE2D )
if ( kind = = _InputArray : : OPENGL_TEXTURE )
{
Gl Texture2D tex = arr . getGlTexture2D ( ) ;
ogl : : Texture2D tex = arr . getO GlTexture2D ( ) ;
tex . copyTo ( * this ) ;
setAutoRelease ( autoRelease ) ;
return ;
@ -641,7 +644,7 @@ void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
{
case _InputArray : : OPENGL_BUFFER :
{
Gl Buffer buf = arr . getGlBuffer ( ) ;
ogl : : Buffer buf = arr . getO GlBuffer ( ) ;
impl_ - > copyFrom ( buf . bufId ( ) , asize . area ( ) * CV_ELEM_SIZE ( atype ) ) ;
break ;
}
@ -668,7 +671,7 @@ void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
# endif
}
void cv : : Gl Buffer: : copyTo ( OutputArray arr , Target target , bool autoRelease ) const
void cv : : ogl : : Buffer : : copyTo ( OutputArray arr , Target target , bool autoRelease ) const
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -682,13 +685,13 @@ void cv::GlBuffer::copyTo(OutputArray arr, Target target, bool autoRelease) cons
{
case _InputArray : : OPENGL_BUFFER :
{
arr . getGlBufferRef ( ) . copyFrom ( * this , target , autoRelease ) ;
arr . getO GlBufferRef ( ) . copyFrom ( * this , target , autoRelease ) ;
break ;
}
case _InputArray : : OPENGL_TEXTURE2D :
case _InputArray : : OPENGL_TEXTURE :
{
arr . getGlTexture2DRef ( ) . copyFrom ( * this , autoRelease ) ;
arr . getO GlTexture2DRef ( ) . copyFrom ( * this , autoRelease ) ;
break ;
}
@ -716,21 +719,21 @@ void cv::GlBuffer::copyTo(OutputArray arr, Target target, bool autoRelease) cons
# endif
}
cv : : Gl Buffer cv : : Gl Buffer: : clone ( Target target , bool autoRelease ) const
cv : : ogl : : Buffer cv : : ogl : : Buffer : : clone ( Target target , bool autoRelease ) const
{
# ifndef HAVE_OPENGL
( void ) target ;
( void ) autoRelease ;
throw_nogl ( ) ;
return Gl Buffer( ) ;
return cv : : ogl : : Buffer ( ) ;
# else
Gl Buffer buf ;
ogl : : Buffer buf ;
buf . copyFrom ( * this , target , autoRelease ) ;
return buf ;
# endif
}
void cv : : Gl Buffer: : bind ( Target target ) const
void cv : : ogl : : Buffer : : bind ( Target target ) const
{
# ifndef HAVE_OPENGL
( void ) target ;
@ -740,7 +743,7 @@ void cv::GlBuffer::bind(Target target) const
# endif
}
void cv : : Gl Buffer: : unbind ( Target target )
void cv : : ogl : : Buffer : : unbind ( Target target )
{
# ifndef HAVE_OPENGL
( void ) target ;
@ -751,18 +754,18 @@ void cv::GlBuffer::unbind(Target target)
# endif
}
cv : : Mat cv : : Gl Buffer: : mapHost ( Access access )
Mat cv : : ogl : : Buffer : : mapHost ( Access access )
{
# ifndef HAVE_OPENGL
( void ) access ;
throw_nogl ( ) ;
return cv : : Mat ( ) ;
return Mat ( ) ;
# else
return cv : : Mat ( rows_ , cols_ , type_ , impl_ - > mapHost ( access ) ) ;
return Mat ( rows_ , cols_ , type_ , impl_ - > mapHost ( access ) ) ;
# endif
}
void cv : : Gl Buffer: : unmapHost ( )
void cv : : ogl : : Buffer : : unmapHost ( )
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -771,22 +774,22 @@ void cv::GlBuffer::unmapHost()
# endif
}
cv : : gpu : : GpuMat cv : : Gl Buffer: : mapDevice ( )
GpuMat cv : : ogl : : Buffer : : mapDevice ( )
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
return cv : : gpu : : GpuMat ( ) ;
return GpuMat ( ) ;
# else
# if !defined HAVE_CUDA || defined(CUDA_DISABLER)
throw_nocuda ( ) ;
return cv : : gpu : : GpuMat ( ) ;
return GpuMat ( ) ;
# else
return cv : : gpu : : GpuMat ( rows_ , cols_ , type_ , impl_ - > mapDevice ( ) ) ;
return GpuMat ( rows_ , cols_ , type_ , impl_ - > mapDevice ( ) ) ;
# endif
# endif
}
void cv : : Gl Buffer: : unmapDevice ( )
void cv : : ogl : : Buffer : : unmapDevice ( )
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -799,7 +802,7 @@ void cv::GlBuffer::unmapDevice()
# endif
}
unsigned int cv : : Gl Buffer: : bufId ( ) const
unsigned int cv : : ogl : : Buffer : : bufId ( ) const
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -809,23 +812,23 @@ unsigned int cv::GlBuffer::bufId() const
# endif
}
template < > void cv : : Ptr < cv : : Gl Buffer: : Impl > : : delete_obj ( )
template < > void cv : : Ptr < cv : : ogl : : Buffer : : Impl > : : delete_obj ( )
{
if ( obj ) delete obj ;
}
//////////////////////////////////////////////////////////////////////////////////////////
// GlTexture2D
// ogl::Texture
# ifndef HAVE_OPENGL
class cv : : Gl Texture2D: : Impl
class cv : : ogl : : Texture2D : : Impl
{
} ;
# else
class cv : : Gl Texture2D: : Impl
class cv : : ogl : : Texture2D : : Impl
{
public :
static const Ptr < Impl > empty ( ) ;
@ -850,21 +853,21 @@ private:
bool autoRelease_ ;
} ;
const cv : : Ptr < cv : : Gl Texture2D: : Impl > cv : : Gl Texture2D: : Impl : : empty ( )
const Ptr < cv : : ogl : : Texture2D : : Impl > cv : : ogl : : Texture2D : : Impl : : empty ( )
{
static Ptr < Impl > p ( new Impl ) ;
return p ;
}
cv : : Gl Texture2D: : Impl : : Impl ( ) : texId_ ( 0 ) , autoRelease_ ( true )
cv : : ogl : : Texture2D : : Impl : : Impl ( ) : texId_ ( 0 ) , autoRelease_ ( true )
{
}
cv : : Gl Texture2D: : Impl : : Impl ( GLuint atexId , bool autoRelease ) : texId_ ( atexId ) , autoRelease_ ( autoRelease )
cv : : ogl : : Texture2D : : Impl : : Impl ( GLuint atexId , bool autoRelease ) : texId_ ( atexId ) , autoRelease_ ( autoRelease )
{
}
cv : : Gl Texture2D: : Impl : : Impl ( GLint internalFormat , GLsizei width , GLsizei height , GLenum format , GLenum type , const GLvoid * pixels , bool autoRelease ) : texId_ ( 0 ) , autoRelease_ ( autoRelease )
cv : : ogl : : Texture2D : : Impl : : Impl ( GLint internalFormat , GLsizei width , GLsizei height , GLenum format , GLenum type , const GLvoid * pixels , bool autoRelease ) : texId_ ( 0 ) , autoRelease_ ( autoRelease )
{
gl : : GenTextures ( 1 , & texId_ ) ;
CV_CheckGlError ( ) ;
@ -884,13 +887,13 @@ cv::GlTexture2D::Impl::Impl(GLint internalFormat, GLsizei width, GLsizei height,
CV_CheckGlError ( ) ;
}
cv : : Gl Texture2D: : Impl : : ~ Impl ( )
cv : : ogl : : Texture2D : : Impl : : ~ Impl ( )
{
if ( autoRelease_ & & texId_ )
gl : : DeleteTextures ( 1 , & texId_ ) ;
}
void cv : : Gl Texture2D: : Impl : : copyFrom ( GLsizei width , GLsizei height , GLenum format , GLenum type , const GLvoid * pixels )
void cv : : ogl : : Texture2D : : Impl : : copyFrom ( GLsizei width , GLsizei height , GLenum format , GLenum type , const GLvoid * pixels )
{
gl : : BindTexture ( gl : : TEXTURE_2D , texId_ ) ;
CV_CheckGlError ( ) ;
@ -905,7 +908,7 @@ void cv::GlTexture2D::Impl::copyFrom(GLsizei width, GLsizei height, GLenum forma
CV_CheckGlError ( ) ;
}
void cv : : Gl Texture2D: : Impl : : copyTo ( GLenum format , GLenum type , GLvoid * pixels ) const
void cv : : ogl : : Texture2D : : Impl : : copyTo ( GLenum format , GLenum type , GLvoid * pixels ) const
{
gl : : BindTexture ( gl : : TEXTURE_2D , texId_ ) ;
CV_CheckGlError ( ) ;
@ -917,7 +920,7 @@ void cv::GlTexture2D::Impl::copyTo(GLenum format, GLenum type, GLvoid* pixels) c
CV_CheckGlError ( ) ;
}
void cv : : Gl Texture2D: : Impl : : bind ( ) const
void cv : : ogl : : Texture2D : : Impl : : bind ( ) const
{
gl : : BindTexture ( gl : : TEXTURE_2D , texId_ ) ;
CV_CheckGlError ( ) ;
@ -925,7 +928,7 @@ void cv::GlTexture2D::Impl::bind() const
# endif // HAVE_OPENGL
cv : : Gl Texture2D: : Gl Texture2D( ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
cv : : ogl : : Texture2D : : Texture2D ( ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -934,7 +937,7 @@ cv::GlTexture2D::GlTexture2D() : rows_(0), cols_(0), format_(NONE)
# endif
}
cv : : Gl Texture2D: : Gl Texture2D( int arows , int acols , Format aformat , unsigned int atexId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
cv : : ogl : : Texture2D : : Texture2D ( int arows , int acols , Format aformat , unsigned int atexId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
{
# ifndef HAVE_OPENGL
( void ) arows ;
@ -951,7 +954,7 @@ cv::GlTexture2D::GlTexture2D(int arows, int acols, Format aformat, unsigned int
# endif
}
cv : : Gl Texture2D: : Gl Texture2D( Size asize , Format aformat , unsigned int atexId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
cv : : ogl : : Texture2D : : Texture2D ( Size asize , Format aformat , unsigned int atexId , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
{
# ifndef HAVE_OPENGL
( void ) asize ;
@ -967,17 +970,17 @@ cv::GlTexture2D::GlTexture2D(Size asize, Format aformat, unsigned int atexId, bo
# endif
}
cv : : Gl Texture2D: : Gl Texture2D( int arows , int acols , Format aformat , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
cv : : ogl : : Texture2D : : Texture2D ( int arows , int acols , Format aformat , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
{
create ( arows , acols , aformat , autoRelease ) ;
}
cv : : Gl Texture2D: : Gl Texture2D( Size asize , Format aformat , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
cv : : ogl : : Texture2D : : Texture2D ( Size asize , Format aformat , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
{
create ( asize , aformat , autoRelease ) ;
}
cv : : Gl Texture2D: : Gl Texture2D( InputArray arr , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
cv : : ogl : : Texture2D : : Texture2D ( InputArray arr , bool autoRelease ) : rows_ ( 0 ) , cols_ ( 0 ) , format_ ( NONE )
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -1008,10 +1011,10 @@ cv::GlTexture2D::GlTexture2D(InputArray arr, bool autoRelease) : rows_(0), cols_
{
case _InputArray : : OPENGL_BUFFER :
{
Gl Buffer buf = arr . getGlBuffer ( ) ;
buf . bind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer buf = arr . getO GlBuffer ( ) ;
buf . bind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ = new Impl ( internalFormats [ cn ] , asize . width , asize . height , srcFormats [ cn ] , gl_types [ depth ] , 0 , autoRelease ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
break ;
}
@ -1021,10 +1024,10 @@ cv::GlTexture2D::GlTexture2D(InputArray arr, bool autoRelease) : rows_(0), cols_
throw_nocuda ( ) ;
# else
GpuMat dmat = arr . getGpuMat ( ) ;
GlBuffer buf ( dmat , Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
buf . bind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer buf ( dmat , ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
buf . bind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ = new Impl ( internalFormats [ cn ] , asize . width , asize . height , srcFormats [ cn ] , gl_types [ depth ] , 0 , autoRelease ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
# endif
break ;
@ -1034,7 +1037,7 @@ cv::GlTexture2D::GlTexture2D(InputArray arr, bool autoRelease) : rows_(0), cols_
{
Mat mat = arr . getMat ( ) ;
CV_Assert ( mat . isContinuous ( ) ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ = new Impl ( internalFormats [ cn ] , asize . width , asize . height , srcFormats [ cn ] , gl_types [ depth ] , mat . data , autoRelease ) ;
break ;
}
@ -1046,7 +1049,7 @@ cv::GlTexture2D::GlTexture2D(InputArray arr, bool autoRelease) : rows_(0), cols_
# endif
}
void cv : : Gl Texture2D: : create ( int arows , int acols , Format aformat , bool autoRelease )
void cv : : ogl : : Texture2D : : create ( int arows , int acols , Format aformat , bool autoRelease )
{
# ifndef HAVE_OPENGL
( void ) arows ;
@ -1057,7 +1060,7 @@ void cv::GlTexture2D::create(int arows, int acols, Format aformat, bool autoRele
# else
if ( rows_ ! = arows | | cols_ ! = acols | | format_ ! = aformat )
{
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ = new Impl ( aformat , acols , arows , aformat , gl : : FLOAT , 0 , autoRelease ) ;
rows_ = arows ;
cols_ = acols ;
@ -1066,7 +1069,7 @@ void cv::GlTexture2D::create(int arows, int acols, Format aformat, bool autoRele
# endif
}
void cv : : Gl Texture2D: : release ( )
void cv : : ogl : : Texture2D : : release ( )
{
# ifdef HAVE_OPENGL
if ( * impl_ . refcount = = 1 )
@ -1078,7 +1081,7 @@ void cv::GlTexture2D::release()
# endif
}
void cv : : Gl Texture2D: : setAutoRelease ( bool flag )
void cv : : ogl : : Texture2D : : setAutoRelease ( bool flag )
{
# ifndef HAVE_OPENGL
( void ) flag ;
@ -1088,7 +1091,7 @@ void cv::GlTexture2D::setAutoRelease(bool flag)
# endif
}
void cv : : Gl Texture2D: : copyFrom ( InputArray arr , bool autoRelease )
void cv : : ogl : : Texture2D : : copyFrom ( InputArray arr , bool autoRelease )
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -1121,10 +1124,10 @@ void cv::GlTexture2D::copyFrom(InputArray arr, bool autoRelease)
{
case _InputArray : : OPENGL_BUFFER :
{
Gl Buffer buf = arr . getGlBuffer ( ) ;
buf . bind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer buf = arr . getO GlBuffer ( ) ;
buf . bind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ - > copyFrom ( asize . width , asize . height , srcFormats [ cn ] , gl_types [ depth ] , 0 ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
break ;
}
@ -1134,10 +1137,10 @@ void cv::GlTexture2D::copyFrom(InputArray arr, bool autoRelease)
throw_nocuda ( ) ;
# else
GpuMat dmat = arr . getGpuMat ( ) ;
GlBuffer buf ( dmat , Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
buf . bind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer buf ( dmat , ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
buf . bind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ - > copyFrom ( asize . width , asize . height , srcFormats [ cn ] , gl_types [ depth ] , 0 ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
# endif
break ;
@ -1147,14 +1150,14 @@ void cv::GlTexture2D::copyFrom(InputArray arr, bool autoRelease)
{
Mat mat = arr . getMat ( ) ;
CV_Assert ( mat . isContinuous ( ) ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_UNPACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_UNPACK_BUFFER ) ;
impl_ - > copyFrom ( asize . width , asize . height , srcFormats [ cn ] , gl_types [ depth ] , mat . data ) ;
}
}
# endif
}
void cv : : Gl Texture2D: : copyTo ( OutputArray arr , int ddepth , bool autoRelease ) const
void cv : : ogl : : Texture2D : : copyTo ( OutputArray arr , int ddepth , bool autoRelease ) const
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -1171,11 +1174,11 @@ void cv::GlTexture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) cons
{
case _InputArray : : OPENGL_BUFFER :
{
Gl Buffer& buf = arr . getGlBufferRef ( ) ;
buf . create ( rows_ , cols_ , CV_MAKE_TYPE ( ddepth , cn ) , Gl Buffer: : PIXEL_PACK_BUFFER , autoRelease ) ;
buf . bind ( Gl Buffer: : PIXEL_PACK_BUFFER ) ;
ogl : : Buffer & buf = arr . getO GlBufferRef ( ) ;
buf . create ( rows_ , cols_ , CV_MAKE_TYPE ( ddepth , cn ) , ogl : : Buffer : : PIXEL_PACK_BUFFER , autoRelease ) ;
buf . bind ( ogl : : Buffer : : PIXEL_PACK_BUFFER ) ;
impl_ - > copyTo ( dstFormat , gl_types [ ddepth ] , 0 ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_PACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_PACK_BUFFER ) ;
break ;
}
@ -1184,10 +1187,10 @@ void cv::GlTexture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) cons
# if !defined HAVE_CUDA || defined(CUDA_DISABLER)
throw_nocuda ( ) ;
# else
GlBuffer buf ( rows_ , cols_ , CV_MAKE_TYPE ( ddepth , cn ) , Gl Buffer: : PIXEL_PACK_BUFFER ) ;
buf . bind ( Gl Buffer: : PIXEL_PACK_BUFFER ) ;
ogl : : Buffer buf ( rows_ , cols_ , CV_MAKE_TYPE ( ddepth , cn ) , ogl : : Buffer : : PIXEL_PACK_BUFFER ) ;
buf . bind ( ogl : : Buffer : : PIXEL_PACK_BUFFER ) ;
impl_ - > copyTo ( dstFormat , gl_types [ ddepth ] , 0 ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_PACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_PACK_BUFFER ) ;
buf . copyTo ( arr ) ;
# endif
@ -1199,14 +1202,14 @@ void cv::GlTexture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) cons
arr . create ( rows_ , cols_ , CV_MAKE_TYPE ( ddepth , cn ) ) ;
Mat mat = arr . getMat ( ) ;
CV_Assert ( mat . isContinuous ( ) ) ;
Gl Buffer: : unbind ( Gl Buffer: : PIXEL_PACK_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : PIXEL_PACK_BUFFER ) ;
impl_ - > copyTo ( dstFormat , gl_types [ ddepth ] , mat . data ) ;
}
}
# endif
}
void cv : : Gl Texture2D: : bind ( ) const
void cv : : ogl : : Texture2D : : bind ( ) const
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -1215,7 +1218,7 @@ void cv::GlTexture2D::bind() const
# endif
}
unsigned int cv : : Gl Texture2D: : texId ( ) const
unsigned int cv : : ogl : : Texture2D : : texId ( ) const
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -1225,19 +1228,19 @@ unsigned int cv::GlTexture2D::texId() const
# endif
}
template < > void cv : : Ptr < cv : : Gl Texture2D: : Impl > : : delete_obj ( )
template < > void cv : : Ptr < cv : : ogl : : Texture2D : : Impl > : : delete_obj ( )
{
if ( obj ) delete obj ;
}
////////////////////////////////////////////////////////////////////////
// Gl Arrays
// ogl:: Arrays
cv : : Gl Arrays: : Gl Arrays( ) : size_ ( 0 )
cv : : ogl : : Arrays : : Arrays ( ) : size_ ( 0 )
{
}
void cv : : Gl Arrays: : setVertexArray ( InputArray vertex )
void cv : : ogl : : Arrays : : setVertexArray ( InputArray vertex )
{
const int cn = vertex . channels ( ) ;
const int depth = vertex . depth ( ) ;
@ -1246,37 +1249,37 @@ void cv::GlArrays::setVertexArray(InputArray vertex)
CV_Assert ( depth = = CV_16S | | depth = = CV_32S | | depth = = CV_32F | | depth = = CV_64F ) ;
if ( vertex . kind ( ) = = _InputArray : : OPENGL_BUFFER )
vertex_ = vertex . getGlBuffer ( ) ;
vertex_ = vertex . getO GlBuffer ( ) ;
else
vertex_ . copyFrom ( vertex ) ;
size_ = vertex_ . size ( ) . area ( ) ;
}
void cv : : Gl Arrays: : resetVertexArray ( )
void cv : : ogl : : Arrays : : resetVertexArray ( )
{
vertex_ . release ( ) ;
size_ = 0 ;
}
void cv : : Gl Arrays: : setColorArray ( InputArray color )
void cv : : ogl : : Arrays : : setColorArray ( InputArray color )
{
const int cn = color . channels ( ) ;
CV_Assert ( cn = = 3 | | cn = = 4 ) ;
if ( color . kind ( ) = = _InputArray : : OPENGL_BUFFER )
color_ = color . getGlBuffer ( ) ;
color_ = color . getO GlBuffer ( ) ;
else
color_ . copyFrom ( color ) ;
}
void cv : : Gl Arrays: : resetColorArray ( )
void cv : : ogl : : Arrays : : resetColorArray ( )
{
color_ . release ( ) ;
}
void cv : : Gl Arrays: : setNormalArray ( InputArray normal )
void cv : : ogl : : Arrays : : setNormalArray ( InputArray normal )
{
const int cn = normal . channels ( ) ;
const int depth = normal . depth ( ) ;
@ -1285,17 +1288,17 @@ void cv::GlArrays::setNormalArray(InputArray normal)
CV_Assert ( depth = = CV_8S | | depth = = CV_16S | | depth = = CV_32S | | depth = = CV_32F | | depth = = CV_64F ) ;
if ( normal . kind ( ) = = _InputArray : : OPENGL_BUFFER )
normal_ = normal . getGlBuffer ( ) ;
normal_ = normal . getO GlBuffer ( ) ;
else
normal_ . copyFrom ( normal ) ;
}
void cv : : Gl Arrays: : resetNormalArray ( )
void cv : : ogl : : Arrays : : resetNormalArray ( )
{
normal_ . release ( ) ;
}
void cv : : Gl Arrays: : setTexCoordArray ( InputArray texCoord )
void cv : : ogl : : Arrays : : setTexCoordArray ( InputArray texCoord )
{
const int cn = texCoord . channels ( ) ;
const int depth = texCoord . depth ( ) ;
@ -1304,17 +1307,17 @@ void cv::GlArrays::setTexCoordArray(InputArray texCoord)
CV_Assert ( depth = = CV_16S | | depth = = CV_32S | | depth = = CV_32F | | depth = = CV_64F ) ;
if ( texCoord . kind ( ) = = _InputArray : : OPENGL_BUFFER )
texCoord_ = texCoord . getGlBuffer ( ) ;
texCoord_ = texCoord . getO GlBuffer ( ) ;
else
texCoord_ . copyFrom ( texCoord ) ;
}
void cv : : Gl Arrays: : resetTexCoordArray ( )
void cv : : ogl : : Arrays : : resetTexCoordArray ( )
{
texCoord_ . release ( ) ;
}
void cv : : Gl Arrays: : release ( )
void cv : : ogl : : Arrays : : release ( )
{
resetVertexArray ( ) ;
resetColorArray ( ) ;
@ -1322,7 +1325,7 @@ void cv::GlArrays::release()
resetTexCoordArray ( ) ;
}
void cv : : Gl Arrays: : setAutoRelease ( bool flag )
void cv : : ogl : : Arrays : : setAutoRelease ( bool flag )
{
vertex_ . setAutoRelease ( flag ) ;
color_ . setAutoRelease ( flag ) ;
@ -1330,7 +1333,7 @@ void cv::GlArrays::setAutoRelease(bool flag)
texCoord_ . setAutoRelease ( flag ) ;
}
void cv : : Gl Arrays: : bind ( ) const
void cv : : ogl : : Arrays : : bind ( ) const
{
# ifndef HAVE_OPENGL
throw_nogl ( ) ;
@ -1349,7 +1352,7 @@ void cv::GlArrays::bind() const
gl : : EnableClientState ( gl : : TEXTURE_COORD_ARRAY ) ;
CV_CheckGlError ( ) ;
texCoord_ . bind ( Gl Buffer: : ARRAY_BUFFER ) ;
texCoord_ . bind ( ogl : : Buffer : : ARRAY_BUFFER ) ;
gl : : TexCoordPointer ( texCoord_ . channels ( ) , gl_types [ texCoord_ . depth ( ) ] , 0 , 0 ) ;
CV_CheckGlError ( ) ;
@ -1365,7 +1368,7 @@ void cv::GlArrays::bind() const
gl : : EnableClientState ( gl : : NORMAL_ARRAY ) ;
CV_CheckGlError ( ) ;
normal_ . bind ( Gl Buffer: : ARRAY_BUFFER ) ;
normal_ . bind ( ogl : : Buffer : : ARRAY_BUFFER ) ;
gl : : NormalPointer ( gl_types [ normal_ . depth ( ) ] , 0 , 0 ) ;
CV_CheckGlError ( ) ;
@ -1381,7 +1384,7 @@ void cv::GlArrays::bind() const
gl : : EnableClientState ( gl : : COLOR_ARRAY ) ;
CV_CheckGlError ( ) ;
color_ . bind ( Gl Buffer: : ARRAY_BUFFER ) ;
color_ . bind ( ogl : : Buffer : : ARRAY_BUFFER ) ;
const int cn = color_ . channels ( ) ;
@ -1399,20 +1402,20 @@ void cv::GlArrays::bind() const
gl : : EnableClientState ( gl : : VERTEX_ARRAY ) ;
CV_CheckGlError ( ) ;
vertex_ . bind ( Gl Buffer: : ARRAY_BUFFER ) ;
vertex_ . bind ( ogl : : Buffer : : ARRAY_BUFFER ) ;
gl : : VertexPointer ( vertex_ . channels ( ) , gl_types [ vertex_ . depth ( ) ] , 0 , 0 ) ;
CV_CheckGlError ( ) ;
}
Gl Buffer: : unbind ( Gl Buffer: : ARRAY_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : ARRAY_BUFFER ) ;
# endif
}
////////////////////////////////////////////////////////////////////////
// Rendering
void cv : : render ( const Gl Texture2D& tex , Rect_ < double > wndRect , Rect_ < double > texRect )
void cv : : ogl : : render ( const ogl : : Texture2D & tex , Rect_ < double > wndRect , Rect_ < double > texRect )
{
# ifndef HAVE_OPENGL
( void ) tex ;
@ -1460,7 +1463,7 @@ void cv::render(const GlTexture2D& tex, Rect_<double> wndRect, Rect_<double> tex
texRect . x + texRect . width , texRect . y
} ;
Gl Buffer: : unbind ( Gl Buffer: : ARRAY_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : ARRAY_BUFFER ) ;
gl : : EnableClientState ( gl : : TEXTURE_COORD_ARRAY ) ;
CV_CheckGlError ( ) ;
@ -1478,13 +1481,13 @@ void cv::render(const GlTexture2D& tex, Rect_<double> wndRect, Rect_<double> tex
gl : : VertexPointer ( 3 , gl : : FLOAT , 0 , vertex ) ;
CV_CheckGlError ( ) ;
gl : : DrawArrays ( cv : : RenderMode : : QUADS , 0 , 4 ) ;
gl : : DrawArrays ( gl : : QUADS , 0 , 4 ) ;
CV_CheckGlError ( ) ;
}
# endif
}
void cv : : render ( const Gl Arrays& arr , int mode , Scalar color )
void cv : : ogl : : render ( const ogl : : Arrays & arr , int mode , Scalar color )
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -1503,7 +1506,7 @@ void cv::render(const GlArrays& arr, int mode, Scalar color)
# endif
}
void cv : : render ( const Gl Arrays& arr , InputArray indices , int mode , Scalar color )
void cv : : ogl : : render ( const ogl : : Arrays & arr , InputArray indices , int mode , Scalar color )
{
# ifndef HAVE_OPENGL
( void ) arr ;
@ -1524,7 +1527,7 @@ void cv::render(const GlArrays& arr, InputArray indices, int mode, Scalar color)
{
case _InputArray : : OPENGL_BUFFER :
{
Gl Buffer buf = indices . getGlBuffer ( ) ;
ogl : : Buffer buf = indices . getO GlBuffer ( ) ;
const int depth = buf . depth ( ) ;
@ -1539,11 +1542,11 @@ void cv::render(const GlArrays& arr, InputArray indices, int mode, Scalar color)
else
type = gl : : UNSIGNED_INT ;
buf . bind ( Gl Buffer: : ELEMENT_ARRAY_BUFFER ) ;
buf . bind ( ogl : : Buffer : : ELEMENT_ARRAY_BUFFER ) ;
gl : : DrawElements ( mode , buf . size ( ) . area ( ) , type , 0 ) ;
Gl Buffer: : unbind ( Gl Buffer: : ELEMENT_ARRAY_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : ELEMENT_ARRAY_BUFFER ) ;
break ;
}
@ -1566,7 +1569,7 @@ void cv::render(const GlArrays& arr, InputArray indices, int mode, Scalar color)
else
type = gl : : UNSIGNED_INT ;
Gl Buffer: : unbind ( Gl Buffer: : ELEMENT_ARRAY_BUFFER ) ;
ogl : : Buffer : : unbind ( ogl : : Buffer : : ELEMENT_ARRAY_BUFFER ) ;
gl : : DrawElements ( mode , mat . size ( ) . area ( ) , type , mat . data ) ;
}