opencv on mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers opengl.hpp Source File

opengl.hpp

00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
00015 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 #ifndef __OPENCV_CORE_OPENGL_HPP__
00044 #define __OPENCV_CORE_OPENGL_HPP__
00045 
00046 #ifndef __cplusplus
00047 #  error opengl.hpp header must be compiled as C++
00048 #endif
00049 
00050 #include "opencv2/core.hpp"
00051 #include "ocl.hpp"
00052 
00053 namespace cv { namespace ogl {
00054 
00055 /** @addtogroup core_opengl
00056 This section describes OpenGL interoperability.
00057 
00058 To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is
00059 supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not
00060 supported). For GTK backend gtkglext-1.0 library is required.
00061 
00062 To use OpenGL functionality you should first create OpenGL context (window or frame buffer). You can
00063 do this with namedWindow function or with other OpenGL toolkit (GLUT, for example).
00064 */
00065 //! @{
00066 
00067 /////////////////// OpenGL Objects ///////////////////
00068 
00069 /** @brief Smart pointer for OpenGL buffer object with reference counting.
00070 
00071 Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL
00072 context. These can be used to store vertex data, pixel data retrieved from images or the
00073 framebuffer, and a variety of other things.
00074 
00075 ogl::Buffer has interface similar with Mat interface and represents 2D array memory.
00076 
00077 ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory.
00078  */
00079 class CV_EXPORTS Buffer
00080 {
00081 public:
00082     /** @brief The target defines how you intend to use the buffer object.
00083     */
00084     enum Target
00085     {
00086         ARRAY_BUFFER         = 0x8892, //!< The buffer will be used as a source for vertex data
00087         ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example)
00088         PIXEL_PACK_BUFFER    = 0x88EB, //!< The buffer will be used for reading from OpenGL textures
00089         PIXEL_UNPACK_BUFFER  = 0x88EC  //!< The buffer will be used for writing to OpenGL textures
00090     };
00091 
00092     enum Access
00093     {
00094         READ_ONLY  = 0x88B8,
00095         WRITE_ONLY = 0x88B9,
00096         READ_WRITE = 0x88BA
00097     };
00098 
00099     /** @brief The constructors.
00100 
00101     Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId
00102     parameter), allocates memory for ogl::Buffer object or copies from host/device memory.
00103      */
00104     Buffer();
00105 
00106     /** @overload
00107     @param arows Number of rows in a 2D array.
00108     @param acols Number of columns in a 2D array.
00109     @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
00110     @param abufId Buffer object name.
00111     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00112     */
00113     Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
00114 
00115     /** @overload
00116     @param asize 2D array size.
00117     @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
00118     @param abufId Buffer object name.
00119     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00120     */
00121     Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
00122 
00123     /** @overload
00124     @param arows Number of rows in a 2D array.
00125     @param acols Number of columns in a 2D array.
00126     @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
00127     @param target Buffer usage. See cv::ogl::Buffer::Target .
00128     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00129     */
00130     Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
00131 
00132     /** @overload
00133     @param asize 2D array size.
00134     @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
00135     @param target Buffer usage. See cv::ogl::Buffer::Target .
00136     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00137     */
00138     Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
00139 
00140     /** @overload
00141     @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
00142     @param target Buffer usage. See cv::ogl::Buffer::Target .
00143     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00144     */
00145     explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
00146 
00147     /** @brief Allocates memory for ogl::Buffer object.
00148 
00149     @param arows Number of rows in a 2D array.
00150     @param acols Number of columns in a 2D array.
00151     @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
00152     @param target Buffer usage. See cv::ogl::Buffer::Target .
00153     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00154      */
00155     void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
00156 
00157     /** @overload
00158     @param asize 2D array size.
00159     @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
00160     @param target Buffer usage. See cv::ogl::Buffer::Target .
00161     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00162     */
00163     void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
00164 
00165     /** @brief Decrements the reference counter and destroys the buffer object if needed.
00166 
00167     The function will call setAutoRelease(true) .
00168      */
00169     void release();
00170 
00171     /** @brief Sets auto release mode.
00172 
00173     The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was
00174     bound to a window it could be released at any time (user can close a window). If object's destructor
00175     is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy
00176     OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context).
00177     This function can force ogl::Buffer destructor to destroy OpenGL object.
00178     @param flag Auto release mode (if true, release will be called in object's destructor).
00179      */
00180     void setAutoRelease(bool flag);
00181 
00182     /** @brief Copies from host/device memory to OpenGL buffer.
00183     @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
00184     @param target Buffer usage. See cv::ogl::Buffer::Target .
00185     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00186      */
00187     void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
00188 
00189     /** @overload */
00190     void copyFrom(InputArray arr, cuda::Stream& stream, Target target = ARRAY_BUFFER, bool autoRelease = false);
00191 
00192     /** @brief Copies from OpenGL buffer to host/device memory or another OpenGL buffer object.
00193 
00194     @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or
00195     ogl::Buffer ).
00196      */
00197     void copyTo(OutputArray arr) const;
00198 
00199     /** @overload */
00200     void copyTo(OutputArray arr, cuda::Stream& stream) const;
00201 
00202     /** @brief Creates a full copy of the buffer object and the underlying data.
00203 
00204     @param target Buffer usage for destination buffer.
00205     @param autoRelease Auto release mode for destination buffer.
00206      */
00207     Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
00208 
00209     /** @brief Binds OpenGL buffer to the specified buffer binding point.
00210 
00211     @param target Binding point. See cv::ogl::Buffer::Target .
00212      */
00213     void bind(Target target) const;
00214 
00215     /** @brief Unbind any buffers from the specified binding point.
00216 
00217     @param target Binding point. See cv::ogl::Buffer::Target .
00218      */
00219     static void unbind(Target target);
00220 
00221     /** @brief Maps OpenGL buffer to host memory.
00222 
00223     mapHost maps to the client's address space the entire data store of the buffer object. The data can
00224     then be directly read and/or written relative to the returned pointer, depending on the specified
00225     access policy.
00226 
00227     A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used.
00228 
00229     This operation can lead to memory transfers between host and device.
00230 
00231     Only one buffer object can be mapped at a time.
00232     @param access Access policy, indicating whether it will be possible to read from, write to, or both
00233     read from and write to the buffer object's mapped data store. The symbolic constant must be
00234     ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE .
00235      */
00236     Mat mapHost(Access access);
00237 
00238     /** @brief Unmaps OpenGL buffer.
00239     */
00240     void unmapHost();
00241 
00242     //! map to device memory (blocking)
00243     cuda::GpuMat mapDevice();
00244     void unmapDevice();
00245 
00246     /** @brief Maps OpenGL buffer to CUDA device memory.
00247 
00248     This operatation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time.
00249 
00250     A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used.
00251      */
00252     cuda::GpuMat mapDevice(cuda::Stream& stream);
00253 
00254     /** @brief Unmaps OpenGL buffer.
00255     */
00256     void unmapDevice(cuda::Stream& stream);
00257 
00258     int rows() const;
00259     int cols() const;
00260     Size size() const;
00261     bool empty() const;
00262 
00263     int type() const;
00264     int depth() const;
00265     int channels() const;
00266     int elemSize() const;
00267     int elemSize1() const;
00268 
00269     //! get OpenGL opject id
00270     unsigned int bufId() const;
00271 
00272     class Impl;
00273 
00274 private:
00275     Ptr<Impl>  impl_;
00276     int rows_;
00277     int cols_;
00278     int type_;
00279 };
00280 
00281 /** @brief Smart pointer for OpenGL 2D texture memory with reference counting.
00282  */
00283 class CV_EXPORTS Texture2D
00284 {
00285 public:
00286     /** @brief An Image Format describes the way that the images in Textures store their data.
00287     */
00288     enum Format
00289     {
00290         NONE            = 0,
00291         DEPTH_COMPONENT = 0x1902, //!< Depth
00292         RGB             = 0x1907, //!< Red, Green, Blue
00293         RGBA            = 0x1908  //!< Red, Green, Blue, Alpha
00294     };
00295 
00296     /** @brief The constructors.
00297 
00298     Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from
00299     host/device memory.
00300      */
00301     Texture2D();
00302 
00303     /** @overload */
00304     Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
00305 
00306     /** @overload */
00307     Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
00308 
00309     /** @overload
00310     @param arows Number of rows.
00311     @param acols Number of columns.
00312     @param aformat Image format. See cv::ogl::Texture2D::Format .
00313     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00314     */
00315     Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
00316 
00317     /** @overload
00318     @param asize 2D array size.
00319     @param aformat Image format. See cv::ogl::Texture2D::Format .
00320     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00321     */
00322     Texture2D(Size asize, Format aformat, bool autoRelease = false);
00323 
00324     /** @overload
00325     @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
00326     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00327     */
00328     explicit Texture2D(InputArray arr, bool autoRelease = false);
00329 
00330     /** @brief Allocates memory for ogl::Texture2D object.
00331 
00332     @param arows Number of rows.
00333     @param acols Number of columns.
00334     @param aformat Image format. See cv::ogl::Texture2D::Format .
00335     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00336      */
00337     void create(int arows, int acols, Format aformat, bool autoRelease = false);
00338     /** @overload
00339     @param asize 2D array size.
00340     @param aformat Image format. See cv::ogl::Texture2D::Format .
00341     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00342     */
00343     void create(Size asize, Format aformat, bool autoRelease = false);
00344 
00345     /** @brief Decrements the reference counter and destroys the texture object if needed.
00346 
00347     The function will call setAutoRelease(true) .
00348      */
00349     void release();
00350 
00351     /** @brief Sets auto release mode.
00352 
00353     @param flag Auto release mode (if true, release will be called in object's destructor).
00354 
00355     The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was
00356     bound to a window it could be released at any time (user can close a window). If object's destructor
00357     is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't
00358     destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL
00359     context). This function can force ogl::Texture2D destructor to destroy OpenGL object.
00360      */
00361     void setAutoRelease(bool flag);
00362 
00363     /** @brief Copies from host/device memory to OpenGL texture.
00364 
00365     @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
00366     @param autoRelease Auto release mode (if true, release will be called in object's destructor).
00367      */
00368     void copyFrom(InputArray arr, bool autoRelease = false);
00369 
00370     /** @brief Copies from OpenGL texture to host/device memory or another OpenGL texture object.
00371 
00372     @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or
00373     ogl::Texture2D ).
00374     @param ddepth Destination depth.
00375     @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture).
00376      */
00377     void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const;
00378 
00379     /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target.
00380     */
00381     void bind() const;
00382 
00383     int rows() const;
00384     int cols() const;
00385     Size size() const;
00386     bool empty() const;
00387 
00388     Format format() const;
00389 
00390     //! get OpenGL opject id
00391     unsigned int texId() const;
00392 
00393     class Impl;
00394 
00395 private:
00396     Ptr<Impl>  impl_;
00397     int rows_;
00398     int cols_;
00399     Format format_;
00400 };
00401 
00402 /** @brief Wrapper for OpenGL Client-Side Vertex arrays.
00403 
00404 ogl::Arrays stores vertex data in ogl::Buffer objects.
00405  */
00406 class CV_EXPORTS Arrays
00407 {
00408 public:
00409     /** @brief Default constructor
00410      */
00411     Arrays();
00412 
00413     /** @brief Sets an array of vertex coordinates.
00414     @param vertex array with vertex coordinates, can be both host and device memory.
00415     */
00416     void setVertexArray(InputArray vertex);
00417 
00418     /** @brief Resets vertex coordinates.
00419     */
00420     void resetVertexArray();
00421 
00422     /** @brief Sets an array of vertex colors.
00423     @param color array with vertex colors, can be both host and device memory.
00424      */
00425     void setColorArray(InputArray color);
00426 
00427     /** @brief Resets vertex colors.
00428     */
00429     void resetColorArray();
00430 
00431     /** @brief Sets an array of vertex normals.
00432     @param normal array with vertex normals, can be both host and device memory.
00433      */
00434     void setNormalArray(InputArray normal);
00435 
00436     /** @brief Resets vertex normals.
00437     */
00438     void resetNormalArray();
00439 
00440     /** @brief Sets an array of vertex texture coordinates.
00441     @param texCoord array with vertex texture coordinates, can be both host and device memory.
00442      */
00443     void setTexCoordArray(InputArray texCoord);
00444 
00445     /** @brief Resets vertex texture coordinates.
00446     */
00447     void resetTexCoordArray();
00448 
00449     /** @brief Releases all inner buffers.
00450     */
00451     void release();
00452 
00453     /** @brief Sets auto release mode all inner buffers.
00454     @param flag Auto release mode.
00455      */
00456     void setAutoRelease(bool flag);
00457 
00458     /** @brief Binds all vertex arrays.
00459     */
00460     void bind() const;
00461 
00462     /** @brief Returns the vertex count.
00463     */
00464     int size() const;
00465     bool empty() const;
00466 
00467 private:
00468     int size_;
00469     Buffer vertex_;
00470     Buffer color_;
00471     Buffer normal_;
00472     Buffer texCoord_;
00473 };
00474 
00475 /////////////////// Render Functions ///////////////////
00476 
00477 //! render mode
00478 enum RenderModes {
00479     POINTS         = 0x0000,
00480     LINES          = 0x0001,
00481     LINE_LOOP      = 0x0002,
00482     LINE_STRIP     = 0x0003,
00483     TRIANGLES      = 0x0004,
00484     TRIANGLE_STRIP = 0x0005,
00485     TRIANGLE_FAN   = 0x0006,
00486     QUADS          = 0x0007,
00487     QUAD_STRIP     = 0x0008,
00488     POLYGON        = 0x0009
00489 };
00490 
00491 /** @brief Render OpenGL texture or primitives.
00492 @param tex Texture to draw.
00493 @param wndRect Region of window, where to draw a texture (normalized coordinates).
00494 @param texRect Region of texture to draw (normalized coordinates).
00495  */
00496 CV_EXPORTS void render(const Texture2D& tex,
00497     Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
00498     Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
00499 
00500 /** @overload
00501 @param arr Array of privitives vertices.
00502 @param mode Render mode. One of cv::ogl::RenderModes
00503 @param color Color for all vertices. Will be used if arr doesn't contain color array.
00504 */
00505 CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar  color = Scalar::all(255));
00506 
00507 /** @overload
00508 @param arr Array of privitives vertices.
00509 @param indices Array of vertices indices (host or device memory).
00510 @param mode Render mode. One of cv::ogl::RenderModes
00511 @param color Color for all vertices. Will be used if arr doesn't contain color array.
00512 */
00513 CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar  color = Scalar::all(255));
00514 
00515 /////////////////// CL-GL Interoperability Functions ///////////////////
00516 
00517 namespace ocl {
00518 using namespace cv::ocl;
00519 
00520 // TODO static functions in the Context class
00521 /** @brief Creates OpenCL context from GL.
00522 @return Returns reference to OpenCL Context
00523  */
00524 CV_EXPORTS Context& initializeContextFromGL();
00525 
00526 } // namespace cv::ogl::ocl
00527 
00528 /** @brief Converts InputArray to Texture2D object.
00529 @param src     - source InputArray.
00530 @param texture - destination Texture2D object.
00531  */
00532 CV_EXPORTS void convertToGLTexture2D(InputArray src, Texture2D& texture);
00533 
00534 /** @brief Converts Texture2D object to OutputArray.
00535 @param texture - source Texture2D object.
00536 @param dst     - destination OutputArray.
00537  */
00538 CV_EXPORTS void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst);
00539 
00540 /** @brief Maps Buffer object to process on CL side (convert to UMat).
00541 
00542 Function creates CL buffer from GL one, and then constructs UMat that can be used
00543 to process buffer data with OpenCV functions. Note that in current implementation
00544 UMat constructed this way doesn't own corresponding GL buffer object, so it is
00545 the user responsibility to close down CL/GL buffers relationships by explicitly
00546 calling unmapGLBuffer() function.
00547 @param buffer      - source Buffer object.
00548 @param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE).
00549 @return Returns UMat object
00550  */
00551 CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, int accessFlags = ACCESS_READ|ACCESS_WRITE);
00552 
00553 /** @brief Unmaps Buffer object (releases UMat, previously mapped from Buffer).
00554 
00555 Function must be called explicitly by the user for each UMat previously constructed
00556 by the call to mapGLBuffer() function.
00557 @param u           - source UMat, created by mapGLBuffer().
00558  */
00559 CV_EXPORTS void unmapGLBuffer(UMat& u);
00560 
00561 }} // namespace cv::ogl
00562 
00563 namespace cv { namespace cuda {
00564 
00565 //! @addtogroup cuda
00566 //! @{
00567 
00568 /** @brief Sets a CUDA device and initializes it for the current thread with OpenGL interoperability.
00569 
00570 This function should be explicitly called after OpenGL context creation and before any CUDA calls.
00571 @param device System index of a CUDA device starting with 0.
00572 @ingroup core_opengl
00573  */
00574 CV_EXPORTS void setGlDevice(int device = 0);
00575 
00576 //! @}
00577 
00578 }}
00579 
00580 //! @cond IGNORED
00581 
00582 ////////////////////////////////////////////////////////////////////////
00583 ////////////////////////////////////////////////////////////////////////
00584 ////////////////////////////////////////////////////////////////////////
00585 
00586 inline
00587 cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0)
00588 {
00589     create(arows, acols, atype, target, autoRelease);
00590 }
00591 
00592 inline
00593 cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0)
00594 {
00595     create(asize, atype, target, autoRelease);
00596 }
00597 
00598 inline
00599 void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease)
00600 {
00601     create(asize.height, asize.width, atype, target, autoRelease);
00602 }
00603 
00604 inline
00605 int cv::ogl::Buffer::rows() const
00606 {
00607     return rows_;
00608 }
00609 
00610 inline
00611 int cv::ogl::Buffer::cols() const
00612 {
00613     return cols_;
00614 }
00615 
00616 inline
00617 cv::Size cv::ogl::Buffer::size() const
00618 {
00619     return Size(cols_, rows_);
00620 }
00621 
00622 inline
00623 bool cv::ogl::Buffer::empty() const
00624 {
00625     return rows_ == 0 || cols_ == 0;
00626 }
00627 
00628 inline
00629 int cv::ogl::Buffer::type() const
00630 {
00631     return type_;
00632 }
00633 
00634 inline
00635 int cv::ogl::Buffer::depth() const
00636 {
00637     return CV_MAT_DEPTH(type_);
00638 }
00639 
00640 inline
00641 int cv::ogl::Buffer::channels() const
00642 {
00643     return CV_MAT_CN(type_);
00644 }
00645 
00646 inline
00647 int cv::ogl::Buffer::elemSize() const
00648 {
00649     return CV_ELEM_SIZE(type_);
00650 }
00651 
00652 inline
00653 int cv::ogl::Buffer::elemSize1() const
00654 {
00655     return CV_ELEM_SIZE1(type_);
00656 }
00657 
00658 ///////
00659 
00660 inline
00661 cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE)
00662 {
00663     create(arows, acols, aformat, autoRelease);
00664 }
00665 
00666 inline
00667 cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE)
00668 {
00669     create(asize, aformat, autoRelease);
00670 }
00671 
00672 inline
00673 void cv::ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease)
00674 {
00675     create(asize.height, asize.width, aformat, autoRelease);
00676 }
00677 
00678 inline
00679 int cv::ogl::Texture2D::rows() const
00680 {
00681     return rows_;
00682 }
00683 
00684 inline
00685 int cv::ogl::Texture2D::cols() const
00686 {
00687     return cols_;
00688 }
00689 
00690 inline
00691 cv::Size cv::ogl::Texture2D::size() const
00692 {
00693     return Size(cols_, rows_);
00694 }
00695 
00696 inline
00697 bool cv::ogl::Texture2D::empty() const
00698 {
00699     return rows_ == 0 || cols_ == 0;
00700 }
00701 
00702 inline
00703 cv::ogl::Texture2D::Format cv::ogl::Texture2D::format() const
00704 {
00705     return format_;
00706 }
00707 
00708 ///////
00709 
00710 inline
00711 cv::ogl::Arrays::Arrays() : size_(0)
00712 {
00713 }
00714 
00715 inline
00716 int cv::ogl::Arrays::size() const
00717 {
00718     return size_;
00719 }
00720 
00721 inline
00722 bool cv::ogl::Arrays::empty() const
00723 {
00724     return size_ == 0;
00725 }
00726 
00727 //! @endcond
00728 
00729 #endif /* __OPENCV_CORE_OPENGL_HPP__ */
00730