1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
22 //
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
26 //
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42
43 #ifndef OPENCV_CORE_OPENGL_HPP
44 #define OPENCV_CORE_OPENGL_HPP
45
46 #ifndef __cplusplus
47 # error opengl.hpp header must be compiled as C++
48 #endif
49
50 #include "opencv2/core.hpp"
51 #include "ocl.hpp"
52
53 namespace cv { namespace ogl {
54
55 /** @addtogroup core_opengl
56 This section describes OpenGL interoperability.
57
58 To enable OpenGL support, configure OpenCV using CMake with WITH_OPENGL=ON . Currently OpenGL is
59 supported only with WIN32, GTK and Qt backends on Windows and Linux (MacOS and Android are not
60 supported). For GTK backend gtkglext-1.0 library is required.
61
62 To use OpenGL functionality you should first create OpenGL context (window or frame buffer). You can
63 do this with namedWindow function or with other OpenGL toolkit (GLUT, for example).
64 */
65 //! @{
66
67 /////////////////// OpenGL Objects ///////////////////
68
69 /** @brief Smart pointer for OpenGL buffer object with reference counting.
70
71 Buffer Objects are OpenGL objects that store an array of unformatted memory allocated by the OpenGL
72 context. These can be used to store vertex data, pixel data retrieved from images or the
73 framebuffer, and a variety of other things.
74
75 ogl::Buffer has interface similar with Mat interface and represents 2D array memory.
76
77 ogl::Buffer supports memory transfers between host and device and also can be mapped to CUDA memory.
78 */
79 class CV_EXPORTS Buffer
80 {
81 public:
82 /** @brief The target defines how you intend to use the buffer object.
83 */
84 enum Target
85 {
86 ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data
87 ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example)
88 PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures
89 PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures
90 };
91
92 enum Access
93 {
94 READ_ONLY = 0x88B8,
95 WRITE_ONLY = 0x88B9,
96 READ_WRITE = 0x88BA
97 };
98
99 /** @brief The constructors.
100
101 Creates empty ogl::Buffer object, creates ogl::Buffer object from existed buffer ( abufId
102 parameter), allocates memory for ogl::Buffer object or copies from host/device memory.
103 */
104 Buffer();
105
106 /** @overload
107 @param arows Number of rows in a 2D array.
108 @param acols Number of columns in a 2D array.
109 @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
110 @param abufId Buffer object name.
111 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
112 */
113 Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
114
115 /** @overload
116 @param asize 2D array size.
117 @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
118 @param abufId Buffer object name.
119 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
120 */
121 Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
122
123 /** @overload
124 @param arows Number of rows in a 2D array.
125 @param acols Number of columns in a 2D array.
126 @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
127 @param target Buffer usage. See cv::ogl::Buffer::Target .
128 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
129 */
130 Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
131
132 /** @overload
133 @param asize 2D array size.
134 @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
135 @param target Buffer usage. See cv::ogl::Buffer::Target .
136 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
137 */
138 Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
139
140 /** @overload
141 @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
142 @param target Buffer usage. See cv::ogl::Buffer::Target .
143 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
144 */
145 explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
146
147 /** @brief Allocates memory for ogl::Buffer object.
148
149 @param arows Number of rows in a 2D array.
150 @param acols Number of columns in a 2D array.
151 @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
152 @param target Buffer usage. See cv::ogl::Buffer::Target .
153 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
154 */
155 void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
156
157 /** @overload
158 @param asize 2D array size.
159 @param atype Array type ( CV_8UC1, ..., CV_64FC4 ). See Mat for details.
160 @param target Buffer usage. See cv::ogl::Buffer::Target .
161 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
162 */
163 void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
164
165 /** @brief Decrements the reference counter and destroys the buffer object if needed.
166
167 The function will call setAutoRelease(true) .
168 */
169 void release();
170
171 /** @brief Sets auto release mode.
172
173 The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was
174 bound to a window it could be released at any time (user can close a window). If object's destructor
175 is called after destruction of the context it will cause an error. Thus ogl::Buffer doesn't destroy
176 OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL context).
177 This function can force ogl::Buffer destructor to destroy OpenGL object.
178 @param flag Auto release mode (if true, release will be called in object's destructor).
179 */
180 void setAutoRelease(bool flag);
181
182 /** @brief Copies from host/device memory to OpenGL buffer.
183 @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or std::vector ).
184 @param target Buffer usage. See cv::ogl::Buffer::Target .
185 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
186 */
187 void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
188
189 /** @overload */
190 void copyFrom(InputArray arr, cuda::Stream& stream, Target target = ARRAY_BUFFER, bool autoRelease = false);
191
192 /** @brief Copies from OpenGL buffer to host/device memory or another OpenGL buffer object.
193
194 @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , std::vector or
195 ogl::Buffer ).
196 */
197 void copyTo(OutputArray arr) const;
198
199 /** @overload */
200 void copyTo(OutputArray arr, cuda::Stream& stream) const;
201
202 /** @brief Creates a full copy of the buffer object and the underlying data.
203
204 @param target Buffer usage for destination buffer.
205 @param autoRelease Auto release mode for destination buffer.
206 */
207 Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
208
209 /** @brief Binds OpenGL buffer to the specified buffer binding point.
210
211 @param target Binding point. See cv::ogl::Buffer::Target .
212 */
213 void bind(Target target) const;
214
215 /** @brief Unbind any buffers from the specified binding point.
216
217 @param target Binding point. See cv::ogl::Buffer::Target .
218 */
219 static void unbind(Target target);
220
221 /** @brief Maps OpenGL buffer to host memory.
222
223 mapHost maps to the client's address space the entire data store of the buffer object. The data can
224 then be directly read and/or written relative to the returned pointer, depending on the specified
225 access policy.
226
227 A mapped data store must be unmapped with ogl::Buffer::unmapHost before its buffer object is used.
228
229 This operation can lead to memory transfers between host and device.
230
231 Only one buffer object can be mapped at a time.
232 @param access Access policy, indicating whether it will be possible to read from, write to, or both
233 read from and write to the buffer object's mapped data store. The symbolic constant must be
234 ogl::Buffer::READ_ONLY , ogl::Buffer::WRITE_ONLY or ogl::Buffer::READ_WRITE .
235 */
236 Mat mapHost(Access access);
237
238 /** @brief Unmaps OpenGL buffer.
239 */
240 void unmapHost();
241
242 //! map to device memory (blocking)
243 cuda::GpuMat mapDevice();
244 void unmapDevice();
245
246 /** @brief Maps OpenGL buffer to CUDA device memory.
247
248 This operation doesn't copy data. Several buffer objects can be mapped to CUDA memory at a time.
249
250 A mapped data store must be unmapped with ogl::Buffer::unmapDevice before its buffer object is used.
251 */
252 cuda::GpuMat mapDevice(cuda::Stream& stream);
253
254 /** @brief Unmaps OpenGL buffer.
255 */
256 void unmapDevice(cuda::Stream& stream);
257
258 int rows() const;
259 int cols() const;
260 Size size() const;
261 bool empty() const;
262
263 int type() const;
264 int depth() const;
265 int channels() const;
266 int elemSize() const;
267 int elemSize1() const;
268
269 //! get OpenGL opject id
270 unsigned int bufId() const;
271
272 class Impl;
273
274 private:
275 Ptr<Impl> impl_;
276 int rows_;
277 int cols_;
278 int type_;
279 };
280
281 /** @brief Smart pointer for OpenGL 2D texture memory with reference counting.
282 */
283 class CV_EXPORTS Texture2D
284 {
285 public:
286 /** @brief An Image Format describes the way that the images in Textures store their data.
287 */
288 enum Format
289 {
290 NONE = 0,
291 DEPTH_COMPONENT = 0x1902, //!< Depth
292 RGB = 0x1907, //!< Red, Green, Blue
293 RGBA = 0x1908 //!< Red, Green, Blue, Alpha
294 };
295
296 /** @brief The constructors.
297
298 Creates empty ogl::Texture2D object, allocates memory for ogl::Texture2D object or copies from
299 host/device memory.
300 */
301 Texture2D();
302
303 /** @overload */
304 Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
305
306 /** @overload */
307 Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
308
309 /** @overload
310 @param arows Number of rows.
311 @param acols Number of columns.
312 @param aformat Image format. See cv::ogl::Texture2D::Format .
313 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
314 */
315 Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
316
317 /** @overload
318 @param asize 2D array size.
319 @param aformat Image format. See cv::ogl::Texture2D::Format .
320 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
321 */
322 Texture2D(Size asize, Format aformat, bool autoRelease = false);
323
324 /** @overload
325 @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
326 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
327 */
328 explicit Texture2D(InputArray arr, bool autoRelease = false);
329
330 /** @brief Allocates memory for ogl::Texture2D object.
331
332 @param arows Number of rows.
333 @param acols Number of columns.
334 @param aformat Image format. See cv::ogl::Texture2D::Format .
335 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
336 */
337 void create(int arows, int acols, Format aformat, bool autoRelease = false);
338 /** @overload
339 @param asize 2D array size.
340 @param aformat Image format. See cv::ogl::Texture2D::Format .
341 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
342 */
343 void create(Size asize, Format aformat, bool autoRelease = false);
344
345 /** @brief Decrements the reference counter and destroys the texture object if needed.
346
347 The function will call setAutoRelease(true) .
348 */
349 void release();
350
351 /** @brief Sets auto release mode.
352
353 @param flag Auto release mode (if true, release will be called in object's destructor).
354
355 The lifetime of the OpenGL object is tied to the lifetime of the context. If OpenGL context was
356 bound to a window it could be released at any time (user can close a window). If object's destructor
357 is called after destruction of the context it will cause an error. Thus ogl::Texture2D doesn't
358 destroy OpenGL object in destructor by default (all OpenGL resources will be released with OpenGL
359 context). This function can force ogl::Texture2D destructor to destroy OpenGL object.
360 */
361 void setAutoRelease(bool flag);
362
363 /** @brief Copies from host/device memory to OpenGL texture.
364
365 @param arr Input array (host or device memory, it can be Mat , cuda::GpuMat or ogl::Buffer ).
366 @param autoRelease Auto release mode (if true, release will be called in object's destructor).
367 */
368 void copyFrom(InputArray arr, bool autoRelease = false);
369
370 /** @brief Copies from OpenGL texture to host/device memory or another OpenGL texture object.
371
372 @param arr Destination array (host or device memory, can be Mat , cuda::GpuMat , ogl::Buffer or
373 ogl::Texture2D ).
374 @param ddepth Destination depth.
375 @param autoRelease Auto release mode for destination buffer (if arr is OpenGL buffer or texture).
376 */
377 void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const;
378
379 /** @brief Binds texture to current active texture unit for GL_TEXTURE_2D target.
380 */
381 void bind() const;
382
383 int rows() const;
384 int cols() const;
385 Size size() const;
386 bool empty() const;
387
388 Format format() const;
389
390 //! get OpenGL opject id
391 unsigned int texId() const;
392
393 class Impl;
394
395 private:
396 Ptr<Impl> impl_;
397 int rows_;
398 int cols_;
399 Format format_;
400 };
401
402 /** @brief Wrapper for OpenGL Client-Side Vertex arrays.
403
404 ogl::Arrays stores vertex data in ogl::Buffer objects.
405 */
406 class CV_EXPORTS Arrays
407 {
408 public:
409 /** @brief Default constructor
410 */
411 Arrays();
412
413 /** @brief Sets an array of vertex coordinates.
414 @param vertex array with vertex coordinates, can be both host and device memory.
415 */
416 void setVertexArray(InputArray vertex);
417
418 /** @brief Resets vertex coordinates.
419 */
420 void resetVertexArray();
421
422 /** @brief Sets an array of vertex colors.
423 @param color array with vertex colors, can be both host and device memory.
424 */
425 void setColorArray(InputArray color);
426
427 /** @brief Resets vertex colors.
428 */
429 void resetColorArray();
430
431 /** @brief Sets an array of vertex normals.
432 @param normal array with vertex normals, can be both host and device memory.
433 */
434 void setNormalArray(InputArray normal);
435
436 /** @brief Resets vertex normals.
437 */
438 void resetNormalArray();
439
440 /** @brief Sets an array of vertex texture coordinates.
441 @param texCoord array with vertex texture coordinates, can be both host and device memory.
442 */
443 void setTexCoordArray(InputArray texCoord);
444
445 /** @brief Resets vertex texture coordinates.
446 */
447 void resetTexCoordArray();
448
449 /** @brief Releases all inner buffers.
450 */
451 void release();
452
453 /** @brief Sets auto release mode all inner buffers.
454 @param flag Auto release mode.
455 */
456 void setAutoRelease(bool flag);
457
458 /** @brief Binds all vertex arrays.
459 */
460 void bind() const;
461
462 /** @brief Returns the vertex count.
463 */
464 int size() const;
465 bool empty() const;
466
467 private:
468 int size_;
469 Buffer vertex_;
470 Buffer color_;
471 Buffer normal_;
472 Buffer texCoord_;
473 };
474
475 /////////////////// Render Functions ///////////////////
476
477 //! render mode
478 enum RenderModes {
479 POINTS = 0x0000,
480 LINES = 0x0001,
481 LINE_LOOP = 0x0002,
482 LINE_STRIP = 0x0003,
483 TRIANGLES = 0x0004,
484 TRIANGLE_STRIP = 0x0005,
485 TRIANGLE_FAN = 0x0006,
486 QUADS = 0x0007,
487 QUAD_STRIP = 0x0008,
488 POLYGON = 0x0009
489 };
490
491 /** @brief Render OpenGL texture or primitives.
492 @param tex Texture to draw.
493 @param wndRect Region of window, where to draw a texture (normalized coordinates).
494 @param texRect Region of texture to draw (normalized coordinates).
495 */
496 CV_EXPORTS void render(const Texture2D& tex,
497 Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
498 Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
499
500 /** @overload
501 @param arr Array of privitives vertices.
502 @param mode Render mode. One of cv::ogl::RenderModes
503 @param color Color for all vertices. Will be used if arr doesn't contain color array.
504 */
505 CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255));
506
507 /** @overload
508 @param arr Array of privitives vertices.
509 @param indices Array of vertices indices (host or device memory).
510 @param mode Render mode. One of cv::ogl::RenderModes
511 @param color Color for all vertices. Will be used if arr doesn't contain color array.
512 */
513 CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255));
514
515 /////////////////// CL-GL Interoperability Functions ///////////////////
516
517 namespace ocl {
518 using namespace cv::ocl;
519
520 // TODO static functions in the Context class
521 /** @brief Creates OpenCL context from GL.
522 @return Returns reference to OpenCL Context
523 */
524 CV_EXPORTS Context& initializeContextFromGL();
525
526 } // namespace cv::ogl::ocl
527
528 /** @brief Converts InputArray to Texture2D object.
529 @param src - source InputArray.
530 @param texture - destination Texture2D object.
531 */
532 CV_EXPORTS void convertToGLTexture2D(InputArray src, Texture2D& texture);
533
534 /** @brief Converts Texture2D object to OutputArray.
535 @param texture - source Texture2D object.
536 @param dst - destination OutputArray.
537 */
538 CV_EXPORTS void convertFromGLTexture2D(const Texture2D& texture, OutputArray dst);
539
540 /** @brief Maps Buffer object to process on CL side (convert to UMat).
541
542 Function creates CL buffer from GL one, and then constructs UMat that can be used
543 to process buffer data with OpenCV functions. Note that in current implementation
544 UMat constructed this way doesn't own corresponding GL buffer object, so it is
545 the user responsibility to close down CL/GL buffers relationships by explicitly
546 calling unmapGLBuffer() function.
547 @param buffer - source Buffer object.
548 @param accessFlags - data access flags (ACCESS_READ|ACCESS_WRITE).
549 @return Returns UMat object
550 */
551 CV_EXPORTS UMat mapGLBuffer(const Buffer& buffer, AccessFlag accessFlags = ACCESS_READ | ACCESS_WRITE);
552
553 /** @brief Unmaps Buffer object (releases UMat, previously mapped from Buffer).
554
555 Function must be called explicitly by the user for each UMat previously constructed
556 by the call to mapGLBuffer() function.
557 @param u - source UMat, created by mapGLBuffer().
558 */
559 CV_EXPORTS void unmapGLBuffer(UMat& u);
560
561 //! @}
562 }} // namespace cv::ogl
563
564 namespace cv { namespace cuda {
565
566 /** @brief Sets a CUDA device and initializes it for the current thread with OpenGL interoperability.
567
568 This function should be explicitly called after OpenGL context creation and before any CUDA calls.
569 @param device System index of a CUDA device starting with 0.
570 @ingroup core_opengl
571 */
572 CV_EXPORTS void setGlDevice(int device = 0);
573
574 }}
575
576 //! @cond IGNORED
577
578 ////////////////////////////////////////////////////////////////////////
579 ////////////////////////////////////////////////////////////////////////
580 ////////////////////////////////////////////////////////////////////////
581
582 inline
Buffer(int arows,int acols,int atype,Target target,bool autoRelease)583 cv::ogl::Buffer::Buffer(int arows, int acols, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0)
584 {
585 create(arows, acols, atype, target, autoRelease);
586 }
587
588 inline
Buffer(Size asize,int atype,Target target,bool autoRelease)589 cv::ogl::Buffer::Buffer(Size asize, int atype, Target target, bool autoRelease) : rows_(0), cols_(0), type_(0)
590 {
591 create(asize, atype, target, autoRelease);
592 }
593
594 inline
create(Size asize,int atype,Target target,bool autoRelease)595 void cv::ogl::Buffer::create(Size asize, int atype, Target target, bool autoRelease)
596 {
597 create(asize.height, asize.width, atype, target, autoRelease);
598 }
599
600 inline
rows() const601 int cv::ogl::Buffer::rows() const
602 {
603 return rows_;
604 }
605
606 inline
cols() const607 int cv::ogl::Buffer::cols() const
608 {
609 return cols_;
610 }
611
612 inline
size() const613 cv::Size cv::ogl::Buffer::size() const
614 {
615 return Size(cols_, rows_);
616 }
617
618 inline
empty() const619 bool cv::ogl::Buffer::empty() const
620 {
621 return rows_ == 0 || cols_ == 0;
622 }
623
624 inline
type() const625 int cv::ogl::Buffer::type() const
626 {
627 return type_;
628 }
629
630 inline
depth() const631 int cv::ogl::Buffer::depth() const
632 {
633 return CV_MAT_DEPTH(type_);
634 }
635
636 inline
channels() const637 int cv::ogl::Buffer::channels() const
638 {
639 return CV_MAT_CN(type_);
640 }
641
642 inline
elemSize() const643 int cv::ogl::Buffer::elemSize() const
644 {
645 return CV_ELEM_SIZE(type_);
646 }
647
648 inline
elemSize1() const649 int cv::ogl::Buffer::elemSize1() const
650 {
651 return CV_ELEM_SIZE1(type_);
652 }
653
654 ///////
655
656 inline
Texture2D(int arows,int acols,Format aformat,bool autoRelease)657 cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE)
658 {
659 create(arows, acols, aformat, autoRelease);
660 }
661
662 inline
Texture2D(Size asize,Format aformat,bool autoRelease)663 cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, bool autoRelease) : rows_(0), cols_(0), format_(NONE)
664 {
665 create(asize, aformat, autoRelease);
666 }
667
668 inline
create(Size asize,Format aformat,bool autoRelease)669 void cv::ogl::Texture2D::create(Size asize, Format aformat, bool autoRelease)
670 {
671 create(asize.height, asize.width, aformat, autoRelease);
672 }
673
674 inline
rows() const675 int cv::ogl::Texture2D::rows() const
676 {
677 return rows_;
678 }
679
680 inline
cols() const681 int cv::ogl::Texture2D::cols() const
682 {
683 return cols_;
684 }
685
686 inline
size() const687 cv::Size cv::ogl::Texture2D::size() const
688 {
689 return Size(cols_, rows_);
690 }
691
692 inline
empty() const693 bool cv::ogl::Texture2D::empty() const
694 {
695 return rows_ == 0 || cols_ == 0;
696 }
697
698 inline
format() const699 cv::ogl::Texture2D::Format cv::ogl::Texture2D::format() const
700 {
701 return format_;
702 }
703
704 ///////
705
706 inline
Arrays()707 cv::ogl::Arrays::Arrays() : size_(0)
708 {
709 }
710
711 inline
size() const712 int cv::ogl::Arrays::size() const
713 {
714 return size_;
715 }
716
717 inline
empty() const718 bool cv::ogl::Arrays::empty() const
719 {
720 return size_ == 0;
721 }
722
723 //! @endcond
724
725 #endif /* OPENCV_CORE_OPENGL_HPP */
726