class SparseMat;
typedef Mat MatND;
+namespace ogl {
+ class Buffer;
+ class Texture2D;
+ class Arrays;
+}
+
+// < Deprecated
class GlBuffer;
class GlTexture;
class GlArrays;
class GlCamera;
+// >
namespace gpu {
class GpuMat;
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
_InputArray(const Scalar& s);
_InputArray(const double& val);
+ // < Deprecated
_InputArray(const GlBuffer& buf);
_InputArray(const GlTexture& tex);
+ // >
_InputArray(const gpu::GpuMat& d_mat);
+ _InputArray(const ogl::Buffer& buf);
+ _InputArray(const ogl::Texture2D& tex);
virtual Mat getMat(int i=-1) const;
virtual void getMatVector(vector<Mat>& mv) const;
+ // < Deprecated
virtual GlBuffer getGlBuffer() const;
virtual GlTexture getGlTexture() const;
+ // >
virtual gpu::GpuMat getGpuMat() const;
+ /*virtual*/ ogl::Buffer getOGlBuffer() const;
+ /*virtual*/ ogl::Texture2D getOGlTexture2D() const;
virtual int kind() const;
virtual Size size(int i=-1) const;
template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx);
template<typename _Tp> _OutputArray(_Tp* vec, int n);
_OutputArray(gpu::GpuMat& d_mat);
- _OutputArray(GlBuffer& buf);
- _OutputArray(GlTexture& tex);
+ _OutputArray(ogl::Buffer& buf);
+ _OutputArray(ogl::Texture2D& tex);
_OutputArray(const Mat& m);
template<typename _Tp> _OutputArray(const vector<_Tp>& vec);
template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx);
template<typename _Tp> _OutputArray(const _Tp* vec, int n);
_OutputArray(const gpu::GpuMat& d_mat);
- _OutputArray(const GlBuffer& buf);
- _OutputArray(const GlTexture& tex);
+ _OutputArray(const ogl::Buffer& buf);
+ _OutputArray(const ogl::Texture2D& tex);
virtual bool fixedSize() const;
virtual bool fixedType() const;
virtual bool needed() const;
virtual Mat& getMatRef(int i=-1) const;
/*virtual*/ gpu::GpuMat& getGpuMatRef() const;
- /*virtual*/ GlBuffer& getGlBufferRef() const;
- /*virtual*/ GlTexture& getGlTextureRef() const;
+ /*virtual*/ ogl::Buffer& getOGlBufferRef() const;
+ /*virtual*/ ogl::Texture2D& getOGlTexture2DRef() const;
virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
+#ifdef __cplusplus
+
+// Deprecated
+
+class CV_EXPORTS CvOpenGlFuncTab
+{
+public:
+ virtual ~CvOpenGlFuncTab();
+
+ virtual void genBuffers(int n, unsigned int* buffers) const = 0;
+ virtual void deleteBuffers(int n, const unsigned int* buffers) const = 0;
+
+ virtual void bufferData(unsigned int target, ptrdiff_t size, const void* data, unsigned int usage) const = 0;
+ virtual void bufferSubData(unsigned int target, ptrdiff_t offset, ptrdiff_t size, const void* data) const = 0;
+
+ virtual void bindBuffer(unsigned int target, unsigned int buffer) const = 0;
+
+ virtual void* mapBuffer(unsigned int target, unsigned int access) const = 0;
+ virtual void unmapBuffer(unsigned int target) const = 0;
+
+ virtual void generateBitmapFont(const std::string& family, int height, int weight, bool italic, bool underline, int start, int count, int base) const = 0;
+
+ virtual bool isGlContextInitialized() const = 0;
+};
+
+CV_EXPORTS void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab);
+
+CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* func = "");
+
+#endif //__cplusplus
+
#endif // __OPENCV_CORE_INTERNAL_HPP__
#include "opencv2/core/core.hpp"
-namespace cv {
+namespace cv { namespace ogl {
-CV_EXPORTS bool checkGlError(const char* file, const int line, const char* func = "");
+CV_EXPORTS bool checkError(const char* file, const int line, const char* func = "");
#if defined(__GNUC__)
- #define CV_CheckGlError() CV_DbgAssert( (cv::checkGlError(__FILE__, __LINE__, __func__)) )
+ #define CV_CheckGlError() CV_DbgAssert( (cv::gl::checkError(__FILE__, __LINE__, __func__)) )
#else
- #define CV_CheckGlError() CV_DbgAssert( (cv::checkGlError(__FILE__, __LINE__)) )
+ #define CV_CheckGlError() CV_DbgAssert( (cv::gl::checkError(__FILE__, __LINE__)) )
#endif
/////////////////// OpenGL Objects ///////////////////
//! Smart pointer for OpenGL buffer memory with reference counting.
-class CV_EXPORTS GlBuffer
+class CV_EXPORTS Buffer
{
public:
enum Target
};
//! create empty buffer
- GlBuffer();
+ Buffer();
//! create buffer from existed buffer id
- GlBuffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
- GlBuffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
+ Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
+ Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
//! create buffer
- GlBuffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
- GlBuffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
+ Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
+ Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
//! copy from host/device memory
- explicit GlBuffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
+ explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
//! create buffer
void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
void copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const;
//! create copy of current buffer
- GlBuffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
+ Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
//! bind buffer for specified target
void bind(Target target) const;
int type_;
};
-template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
-
//! Smart pointer for OpenGL 2D texture memory with reference counting.
-class CV_EXPORTS GlTexture
+class CV_EXPORTS Texture2D
{
public:
enum Format
};
//! create empty texture
- GlTexture();
+ Texture2D();
//! create texture from existed texture id
- GlTexture(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
- GlTexture(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
+ Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
+ Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
//! create texture
- GlTexture(int arows, int acols, Format aformat, bool autoRelease = false);
- GlTexture(Size asize, Format aformat, bool autoRelease = false);
+ Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
+ Texture2D(Size asize, Format aformat, bool autoRelease = false);
//! copy from host/device memory
- explicit GlTexture(InputArray arr, bool autoRelease = false);
+ explicit Texture2D(InputArray arr, bool autoRelease = false);
//! create texture
void create(int arows, int acols, Format aformat, bool autoRelease = false);
Format format_;
};
-template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
-
//! OpenGL Arrays
-class CV_EXPORTS GlArrays
+class CV_EXPORTS Arrays
{
public:
- GlArrays();
+ Arrays();
void setVertexArray(InputArray vertex);
void resetVertexArray();
private:
int size_;
- GlBuffer vertex_;
- GlBuffer color_;
- GlBuffer normal_;
- GlBuffer texCoord_;
+ Buffer vertex_;
+ Buffer color_;
+ Buffer normal_;
+ Buffer texCoord_;
};
/////////////////// Render Functions ///////////////////
//! render texture rectangle in window
-CV_EXPORTS void render(const GlTexture& tex,
+CV_EXPORTS void render(const Texture2D& tex,
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
//! render mode
-namespace RenderMode {
- enum {
- POINTS = 0x0000,
- LINES = 0x0001,
- LINE_LOOP = 0x0002,
- LINE_STRIP = 0x0003,
- TRIANGLES = 0x0004,
- TRIANGLE_STRIP = 0x0005,
- TRIANGLE_FAN = 0x0006,
- QUADS = 0x0007,
- QUAD_STRIP = 0x0008,
- POLYGON = 0x0009
- };
-}
+enum {
+ POINTS = 0x0000,
+ LINES = 0x0001,
+ LINE_LOOP = 0x0002,
+ LINE_STRIP = 0x0003,
+ TRIANGLES = 0x0004,
+ TRIANGLE_STRIP = 0x0005,
+ TRIANGLE_FAN = 0x0006,
+ QUADS = 0x0007,
+ QUAD_STRIP = 0x0008,
+ POLYGON = 0x0009
+};
//! render OpenGL arrays
-CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
-CV_EXPORTS void render(const GlArrays& arr, InputArray indices, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
+CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255));
+CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255));
-namespace gpu {
- //! set a CUDA device to use OpenGL interoperability
- CV_EXPORTS void setGlDevice(int device = 0);
-}
+}} // namespace cv::gl
-} // namespace cv
+namespace cv { namespace gpu {
+
+//! set a CUDA device to use OpenGL interoperability
+CV_EXPORTS void setGlDevice(int device = 0);
+
+}}
+
+namespace cv {
+
+template <> CV_EXPORTS void Ptr<cv::ogl::Buffer::Impl>::delete_obj();
+template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
+
+}
#endif // __cplusplus
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other GpuMaterials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
+#define __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
+
+#ifdef __cplusplus
+
+#include "opencv2/core/core.hpp"
+
+namespace cv
+{
+//! Smart pointer for OpenGL buffer memory with reference counting.
+class CV_EXPORTS GlBuffer
+{
+public:
+ enum Usage
+ {
+ ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
+ TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
+ };
+
+ //! create empty buffer
+ explicit GlBuffer(Usage usage);
+
+ //! create buffer
+ GlBuffer(int rows, int cols, int type, Usage usage);
+ GlBuffer(Size size, int type, Usage usage);
+
+ //! copy from host/device memory
+ GlBuffer(InputArray mat, Usage usage);
+
+ void create(int rows, int cols, int type, Usage usage);
+ void create(Size size, int type, Usage usage);
+ void create(int rows, int cols, int type);
+ void create(Size size, int type);
+
+ void release();
+
+ //! copy from host/device memory
+ void copyFrom(InputArray mat);
+
+ void bind() const;
+ void unbind() const;
+
+ //! map to host memory
+ Mat mapHost();
+ void unmapHost();
+
+ //! map to device memory
+ gpu::GpuMat mapDevice();
+ void unmapDevice();
+
+ inline int rows() const { return rows_; }
+ inline int cols() const { return cols_; }
+ inline Size size() const { return Size(cols_, rows_); }
+ inline bool empty() const { return rows_ == 0 || cols_ == 0; }
+
+ inline int type() const { return type_; }
+ inline int depth() const { return CV_MAT_DEPTH(type_); }
+ inline int channels() const { return CV_MAT_CN(type_); }
+ inline int elemSize() const { return CV_ELEM_SIZE(type_); }
+ inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
+
+ inline Usage usage() const { return usage_; }
+
+ class Impl;
+private:
+ int rows_;
+ int cols_;
+ int type_;
+ Usage usage_;
+
+ Ptr<Impl> impl_;
+};
+
+template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
+
+//! Smart pointer for OpenGL 2d texture memory with reference counting.
+class CV_EXPORTS GlTexture
+{
+public:
+ //! create empty texture
+ GlTexture();
+
+ //! create texture
+ GlTexture(int rows, int cols, int type);
+ GlTexture(Size size, int type);
+
+ //! copy from host/device memory
+ explicit GlTexture(InputArray mat, bool bgra = true);
+
+ void create(int rows, int cols, int type);
+ void create(Size size, int type);
+ void release();
+
+ //! copy from host/device memory
+ void copyFrom(InputArray mat, bool bgra = true);
+
+ void bind() const;
+ void unbind() const;
+
+ inline int rows() const { return rows_; }
+ inline int cols() const { return cols_; }
+ inline Size size() const { return Size(cols_, rows_); }
+ inline bool empty() const { return rows_ == 0 || cols_ == 0; }
+
+ inline int type() const { return type_; }
+ inline int depth() const { return CV_MAT_DEPTH(type_); }
+ inline int channels() const { return CV_MAT_CN(type_); }
+ inline int elemSize() const { return CV_ELEM_SIZE(type_); }
+ inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
+
+ class Impl;
+private:
+ int rows_;
+ int cols_;
+ int type_;
+
+ Ptr<Impl> impl_;
+ GlBuffer buf_;
+};
+
+template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
+
+//! OpenGL Arrays
+class CV_EXPORTS GlArrays
+{
+public:
+ inline GlArrays()
+ : vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
+ {
+ }
+
+ void setVertexArray(InputArray vertex);
+ inline void resetVertexArray() { vertex_.release(); }
+
+ void setColorArray(InputArray color, bool bgra = true);
+ inline void resetColorArray() { color_.release(); }
+
+ void setNormalArray(InputArray normal);
+ inline void resetNormalArray() { normal_.release(); }
+
+ void setTexCoordArray(InputArray texCoord);
+ inline void resetTexCoordArray() { texCoord_.release(); }
+
+ void bind() const;
+ void unbind() const;
+
+ inline int rows() const { return vertex_.rows(); }
+ inline int cols() const { return vertex_.cols(); }
+ inline Size size() const { return vertex_.size(); }
+ inline bool empty() const { return vertex_.empty(); }
+
+private:
+ GlBuffer vertex_;
+ GlBuffer color_;
+ bool bgra_;
+ GlBuffer normal_;
+ GlBuffer texCoord_;
+};
+
+//! OpenGL Font
+class CV_EXPORTS GlFont
+{
+public:
+ enum Weight
+ {
+ WEIGHT_LIGHT = 300,
+ WEIGHT_NORMAL = 400,
+ WEIGHT_SEMIBOLD = 600,
+ WEIGHT_BOLD = 700,
+ WEIGHT_BLACK = 900
+ };
+
+ enum Style
+ {
+ STYLE_NORMAL = 0,
+ STYLE_ITALIC = 1,
+ STYLE_UNDERLINE = 2
+ };
+
+ static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
+
+ void draw(const char* str, int len) const;
+
+ inline const std::string& family() const { return family_; }
+ inline int height() const { return height_; }
+ inline Weight weight() const { return weight_; }
+ inline Style style() const { return style_; }
+
+private:
+ GlFont(const std::string& family, int height, Weight weight, Style style);
+
+ std::string family_;
+ int height_;
+ Weight weight_;
+ Style style_;
+
+ unsigned int base_;
+
+ GlFont(const GlFont&);
+ GlFont& operator =(const GlFont&);
+};
+
+//! render functions
+
+//! render texture rectangle in window
+CV_EXPORTS void render(const GlTexture& tex,
+ Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
+ Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
+
+//! render mode
+namespace RenderMode {
+ enum {
+ POINTS = 0x0000,
+ LINES = 0x0001,
+ LINE_LOOP = 0x0002,
+ LINE_STRIP = 0x0003,
+ TRIANGLES = 0x0004,
+ TRIANGLE_STRIP = 0x0005,
+ TRIANGLE_FAN = 0x0006,
+ QUADS = 0x0007,
+ QUAD_STRIP = 0x0008,
+ POLYGON = 0x0009
+ };
+}
+
+//! render OpenGL arrays
+CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
+
+CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
+
+//! OpenGL camera
+class CV_EXPORTS GlCamera
+{
+public:
+ GlCamera();
+
+ void lookAt(Point3d eye, Point3d center, Point3d up);
+ void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
+
+ void setScale(Point3d scale);
+
+ void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
+ void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
+ void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
+
+ void setupProjectionMatrix() const;
+ void setupModelViewMatrix() const;
+
+private:
+ Point3d eye_;
+ Point3d center_;
+ Point3d up_;
+
+ Point3d pos_;
+ double yaw_;
+ double pitch_;
+ double roll_;
+
+ bool useLookAtParams_;
+
+ Point3d scale_;
+
+ Mat projectionMatrix_;
+
+ double fov_;
+ double aspect_;
+
+ double left_;
+ double right_;
+ double bottom_;
+ double top_;
+
+ double zNear_;
+ double zFar_;
+
+ bool perspectiveProjection_;
+};
+
+inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
+inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
+inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
+inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
+
+} // namespace cv
+
+#endif // __cplusplus
+
+#endif // __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
#include "precomp.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/core/opengl_interop.hpp"
+#include "opencv2/core/opengl_interop_deprecated.hpp"
/****************************************************************************************\
* [scaled] Identity matrix initialization *
_InputArray::_InputArray(const vector<Mat>& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {}
_InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {}
_InputArray::_InputArray(const MatExpr& expr) : flags(FIXED_TYPE + FIXED_SIZE + EXPR), obj((void*)&expr) {}
-_InputArray::_InputArray(const GlBuffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {}
-_InputArray::_InputArray(const GlTexture& tex) : flags(OPENGL_TEXTURE), obj((void*)&tex) {}
+// < Deprecated
+_InputArray::_InputArray(const GlBuffer&) : flags(0), obj(0) {}
+_InputArray::_InputArray(const GlTexture&) : flags(0), obj(0) {}
+// >
_InputArray::_InputArray(const gpu::GpuMat& d_mat) : flags(GPU_MAT), obj((void*)&d_mat) {}
+_InputArray::_InputArray(const ogl::Buffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {}
+_InputArray::_InputArray(const ogl::Texture2D& tex) : flags(OPENGL_TEXTURE), obj((void*)&tex) {}
Mat _InputArray::getMat(int i) const
{
GlBuffer _InputArray::getGlBuffer() const
{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+ return GlBuffer(GlBuffer::ARRAY_BUFFER);
+}
+
+GlTexture _InputArray::getGlTexture() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+ return GlTexture();
+}
+
+gpu::GpuMat _InputArray::getGpuMat() const
+{
int k = kind();
- CV_Assert(k == OPENGL_BUFFER);
- //if( k == OPENGL_BUFFER )
- {
- const GlBuffer* buf = (const GlBuffer*)obj;
- return *buf;
- }
+ CV_Assert(k == GPU_MAT);
+
+ const gpu::GpuMat* d_mat = (const gpu::GpuMat*)obj;
+ return *d_mat;
}
-GlTexture _InputArray::getGlTexture() const
+ogl::Buffer _InputArray::getOGlBuffer() const
{
int k = kind();
- CV_Assert(k == OPENGL_TEXTURE);
- //if( k == OPENGL_TEXTURE )
- {
- const GlTexture* tex = (const GlTexture*)obj;
- return *tex;
- }
+ CV_Assert(k == OPENGL_BUFFER);
+
+ const ogl::Buffer* gl_buf = (const ogl::Buffer*)obj;
+ return *gl_buf;
}
-gpu::GpuMat _InputArray::getGpuMat() const
+ogl::Texture2D _InputArray::getOGlTexture2D() const
{
int k = kind();
- CV_Assert(k == GPU_MAT);
- //if( k == GPU_MAT )
- {
- const gpu::GpuMat* d_mat = (const gpu::GpuMat*)obj;
- return *d_mat;
- }
+ CV_Assert(k == OPENGL_TEXTURE);
+
+ const ogl::Texture2D* gl_tex = (const ogl::Texture2D*)obj;
+ return *gl_tex;
}
int _InputArray::kind() const
if( k == OPENGL_BUFFER )
{
CV_Assert( i < 0 );
- const GlBuffer* buf = (const GlBuffer*)obj;
+ const ogl::Buffer* buf = (const ogl::Buffer*)obj;
return buf->size();
}
if( k == OPENGL_TEXTURE )
{
CV_Assert( i < 0 );
- const GlTexture* tex = (const GlTexture*)obj;
+ const ogl::Texture2D* tex = (const ogl::Texture2D*)obj;
return tex->size();
}
}
if( k == OPENGL_BUFFER )
- return ((const GlBuffer*)obj)->type();
+ return ((const ogl::Buffer*)obj)->type();
CV_Assert( k == GPU_MAT );
//if( k == GPU_MAT )
}
if( k == OPENGL_BUFFER )
- return ((const GlBuffer*)obj)->empty();
+ return ((const ogl::Buffer*)obj)->empty();
if( k == OPENGL_TEXTURE )
- return ((const GlTexture*)obj)->empty();
+ return ((const ogl::Texture2D*)obj)->empty();
CV_Assert( k == GPU_MAT );
//if( k == GPU_MAT )
_OutputArray::_OutputArray(Mat& m) : _InputArray(m) {}
_OutputArray::_OutputArray(vector<Mat>& vec) : _InputArray(vec) {}
_OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {}
-_OutputArray::_OutputArray(GlBuffer& buf) : _InputArray(buf) {}
-_OutputArray::_OutputArray(GlTexture& tex) : _InputArray(tex) {}
+_OutputArray::_OutputArray(ogl::Buffer& buf) : _InputArray(buf) {}
+_OutputArray::_OutputArray(ogl::Texture2D& tex) : _InputArray(tex) {}
_OutputArray::_OutputArray(const Mat& m) : _InputArray(m) {flags |= FIXED_SIZE|FIXED_TYPE;}
_OutputArray::_OutputArray(const vector<Mat>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;}
_OutputArray::_OutputArray(const gpu::GpuMat& d_mat) : _InputArray(d_mat) {flags |= FIXED_SIZE|FIXED_TYPE;}
-_OutputArray::_OutputArray(const GlBuffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;}
-_OutputArray::_OutputArray(const GlTexture& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;}
+_OutputArray::_OutputArray(const ogl::Buffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;}
+_OutputArray::_OutputArray(const ogl::Texture2D& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;}
bool _OutputArray::fixedSize() const
}
if( k == OPENGL_BUFFER && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{
- CV_Assert(!fixedSize() || ((GlBuffer*)obj)->size() == _sz);
- CV_Assert(!fixedType() || ((GlBuffer*)obj)->type() == mtype);
- ((GlBuffer*)obj)->create(_sz, mtype);
+ CV_Assert(!fixedSize() || ((ogl::Buffer*)obj)->size() == _sz);
+ CV_Assert(!fixedType() || ((ogl::Buffer*)obj)->type() == mtype);
+ ((ogl::Buffer*)obj)->create(_sz, mtype);
return;
}
int sizes[] = {_sz.height, _sz.width};
}
if( k == OPENGL_BUFFER && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{
- CV_Assert(!fixedSize() || ((GlBuffer*)obj)->size() == Size(cols, rows));
- CV_Assert(!fixedType() || ((GlBuffer*)obj)->type() == mtype);
- ((GlBuffer*)obj)->create(rows, cols, mtype);
+ CV_Assert(!fixedSize() || ((ogl::Buffer*)obj)->size() == Size(cols, rows));
+ CV_Assert(!fixedType() || ((ogl::Buffer*)obj)->type() == mtype);
+ ((ogl::Buffer*)obj)->create(rows, cols, mtype);
return;
}
int sizes[] = {rows, cols};
if( k == OPENGL_BUFFER )
{
- ((GlBuffer*)obj)->release();
+ ((ogl::Buffer*)obj)->release();
return;
}
if( k == OPENGL_TEXTURE )
{
- ((GlTexture*)obj)->release();
+ ((ogl::Texture2D*)obj)->release();
return;
}
return *(gpu::GpuMat*)obj;
}
-GlBuffer& _OutputArray::getGlBufferRef() const
+ogl::Buffer& _OutputArray::getOGlBufferRef() const
{
int k = kind();
CV_Assert( k == OPENGL_BUFFER );
- return *(GlBuffer*)obj;
+ return *(ogl::Buffer*)obj;
}
-GlTexture& _OutputArray::getGlTextureRef() const
+ogl::Texture2D& _OutputArray::getOGlTexture2DRef() const
{
int k = kind();
CV_Assert( k == OPENGL_TEXTURE );
- return *(GlTexture*)obj;
+ return *(ogl::Texture2D*)obj;
}
static _OutputArray _none;
#endif
}
-bool cv::checkGlError(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;
#endif
////////////////////////////////////////////////////////////////////////
-// GlBuffer
+// ogl::Buffer
#ifndef HAVE_OPENGL
-class cv::GlBuffer::Impl
+class cv::ogl::Buffer::Impl
{
};
#else
-class cv::GlBuffer::Impl
+class cv::ogl::Buffer::Impl
{
public:
static const Ptr<Impl>& empty();
#endif
};
-const Ptr<cv::GlBuffer::Impl>& cv::GlBuffer::Impl::empty()
+const Ptr<cv::ogl::Buffer::Impl>& cv::ogl::Buffer::Impl::empty()
{
static Ptr<Impl> p(new Impl);
return p;
}
-cv::GlBuffer::Impl::Impl() : bufId_(0), autoRelease_(true)
+cv::ogl::Buffer::Impl::Impl() : bufId_(0), autoRelease_(true)
{
}
-cv::GlBuffer::Impl::Impl(GLuint abufId, bool autoRelease) : bufId_(abufId), autoRelease_(autoRelease)
+cv::ogl::Buffer::Impl::Impl(GLuint abufId, bool autoRelease) : bufId_(abufId), autoRelease_(autoRelease)
{
}
-cv::GlBuffer::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();
CV_CheckGlError();
}
-cv::GlBuffer::Impl::~Impl()
+cv::ogl::Buffer::Impl::~Impl()
{
if (autoRelease_ && bufId_)
gl::DeleteBuffers(1, &bufId_);
}
-void cv::GlBuffer::Impl::bind(GLenum target) const
+void cv::ogl::Buffer::Impl::bind(GLenum target) const
{
gl::BindBuffer(target, bufId_);
CV_CheckGlError();
}
-void cv::GlBuffer::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();
CV_CheckGlError();
}
-void cv::GlBuffer::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();
CV_CheckGlError();
}
-void cv::GlBuffer::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();
CV_CheckGlError();
}
-void* cv::GlBuffer::Impl::mapHost(GLenum access)
+void* cv::ogl::Buffer::Impl::mapHost(GLenum access)
{
gl::BindBuffer(gl::COPY_READ_BUFFER, bufId_);
CV_CheckGlError();
return data;
}
-void cv::GlBuffer::Impl::unmapHost()
+void cv::ogl::Buffer::Impl::unmapHost()
{
gl::UnmapBuffer(gl::COPY_READ_BUFFER);
}
#ifdef HAVE_CUDA
- void cv::GlBuffer::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::GlBuffer::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::GlBuffer::Impl::mapDevice(cudaStream_t stream)
+ void* cv::ogl::Buffer::Impl::mapDevice(cudaStream_t stream)
{
cudaResource_.registerBuffer(bufId_);
return cudaResource_.map(stream);
}
- void cv::GlBuffer::Impl::unmapDevice(cudaStream_t stream)
+ void cv::ogl::Buffer::Impl::unmapDevice(cudaStream_t stream)
{
cudaResource_.unmap(stream);
}
#endif // HAVE_OPENGL
-cv::GlBuffer::GlBuffer() : rows_(0), cols_(0), type_(0)
+cv::ogl::Buffer::Buffer() : rows_(0), cols_(0), type_(0)
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-cv::GlBuffer::GlBuffer(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;
#endif
}
-cv::GlBuffer::GlBuffer(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;
#endif
}
-cv::GlBuffer::GlBuffer(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::GlBuffer::GlBuffer(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::GlBuffer::GlBuffer(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;
#endif
}
-void cv::GlBuffer::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;
#endif
}
-void cv::GlBuffer::release()
+void cv::ogl::Buffer::release()
{
#ifdef HAVE_OPENGL
if (*impl_.refcount == 1)
#endif
}
-void cv::GlBuffer::setAutoRelease(bool flag)
+void cv::ogl::Buffer::setAutoRelease(bool flag)
{
#ifndef HAVE_OPENGL
(void) flag;
#endif
}
-void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
+void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease)
{
#ifndef HAVE_OPENGL
(void) arr;
if (kind == _InputArray::OPENGL_TEXTURE)
{
- GlTexture tex = arr.getGlTexture();
+ ogl::Texture2D tex = arr.getOGlTexture2D();
tex.copyTo(*this);
setAutoRelease(autoRelease);
return;
{
case _InputArray::OPENGL_BUFFER:
{
- GlBuffer buf = arr.getGlBuffer();
+ ogl::Buffer buf = arr.getOGlBuffer();
impl_->copyFrom(buf.bufId(), asize.area() * CV_ELEM_SIZE(atype));
break;
}
#endif
}
-void cv::GlBuffer::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;
{
case _InputArray::OPENGL_BUFFER:
{
- arr.getGlBufferRef().copyFrom(*this, target, autoRelease);
+ arr.getOGlBufferRef().copyFrom(*this, target, autoRelease);
break;
}
case _InputArray::OPENGL_TEXTURE:
{
- arr.getGlTextureRef().copyFrom(*this, autoRelease);
+ arr.getOGlTexture2DRef().copyFrom(*this, autoRelease);
break;
}
#endif
}
-GlBuffer cv::GlBuffer::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 GlBuffer();
+ return cv::ogl::Buffer();
#else
- GlBuffer buf;
+ ogl::Buffer buf;
buf.copyFrom(*this, target, autoRelease);
return buf;
#endif
}
-void cv::GlBuffer::bind(Target target) const
+void cv::ogl::Buffer::bind(Target target) const
{
#ifndef HAVE_OPENGL
(void) target;
#endif
}
-void cv::GlBuffer::unbind(Target target)
+void cv::ogl::Buffer::unbind(Target target)
{
#ifndef HAVE_OPENGL
(void) target;
#endif
}
-Mat cv::GlBuffer::mapHost(Access access)
+Mat cv::ogl::Buffer::mapHost(Access access)
{
#ifndef HAVE_OPENGL
(void) access;
#endif
}
-void cv::GlBuffer::unmapHost()
+void cv::ogl::Buffer::unmapHost()
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-GpuMat cv::GlBuffer::mapDevice()
+GpuMat cv::ogl::Buffer::mapDevice()
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-void cv::GlBuffer::unmapDevice()
+void cv::ogl::Buffer::unmapDevice()
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-unsigned int cv::GlBuffer::bufId() const
+unsigned int cv::ogl::Buffer::bufId() const
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-template <> void cv::Ptr<cv::GlBuffer::Impl>::delete_obj()
+template <> void cv::Ptr<cv::ogl::Buffer::Impl>::delete_obj()
{
if (obj) delete obj;
}
//////////////////////////////////////////////////////////////////////////////////////////
-// GlTexture
+// ogl::Texture
#ifndef HAVE_OPENGL
-class cv::GlTexture::Impl
+class cv::ogl::Texture2D::Impl
{
};
#else
-class cv::GlTexture::Impl
+class cv::ogl::Texture2D::Impl
{
public:
static const Ptr<Impl> empty();
bool autoRelease_;
};
-const Ptr<cv::GlTexture::Impl> cv::GlTexture::Impl::empty()
+const Ptr<cv::ogl::Texture2D::Impl> cv::ogl::Texture2D::Impl::empty()
{
static Ptr<Impl> p(new Impl);
return p;
}
-cv::GlTexture::Impl::Impl() : texId_(0), autoRelease_(true)
+cv::ogl::Texture2D::Impl::Impl() : texId_(0), autoRelease_(true)
{
}
-cv::GlTexture::Impl::Impl(GLuint atexId, bool autoRelease) : texId_(atexId), autoRelease_(autoRelease)
+cv::ogl::Texture2D::Impl::Impl(GLuint atexId, bool autoRelease) : texId_(atexId), autoRelease_(autoRelease)
{
}
-cv::GlTexture::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();
CV_CheckGlError();
}
-cv::GlTexture::Impl::~Impl()
+cv::ogl::Texture2D::Impl::~Impl()
{
if (autoRelease_ && texId_)
gl::DeleteTextures(1, &texId_);
}
-void cv::GlTexture::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();
CV_CheckGlError();
}
-void cv::GlTexture::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();
CV_CheckGlError();
}
-void cv::GlTexture::Impl::bind() const
+void cv::ogl::Texture2D::Impl::bind() const
{
gl::BindTexture(gl::TEXTURE_2D, texId_);
CV_CheckGlError();
#endif // HAVE_OPENGL
-cv::GlTexture::GlTexture() : rows_(0), cols_(0), format_(NONE)
+cv::ogl::Texture2D::Texture2D() : rows_(0), cols_(0), format_(NONE)
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-cv::GlTexture::GlTexture(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;
#endif
}
-cv::GlTexture::GlTexture(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;
#endif
}
-cv::GlTexture::GlTexture(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::GlTexture::GlTexture(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::GlTexture::GlTexture(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;
{
case _InputArray::OPENGL_BUFFER:
{
- GlBuffer buf = arr.getGlBuffer();
- buf.bind(GlBuffer::PIXEL_UNPACK_BUFFER);
+ ogl::Buffer buf = arr.getOGlBuffer();
+ buf.bind(ogl::Buffer::PIXEL_UNPACK_BUFFER);
impl_ = new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], 0, autoRelease);
- GlBuffer::unbind(GlBuffer::PIXEL_UNPACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER);
break;
}
throw_nocuda();
#else
GpuMat dmat = arr.getGpuMat();
- GlBuffer buf(dmat, GlBuffer::PIXEL_UNPACK_BUFFER);
- buf.bind(GlBuffer::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);
- GlBuffer::unbind(GlBuffer::PIXEL_UNPACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER);
#endif
break;
{
Mat mat = arr.getMat();
CV_Assert( mat.isContinuous() );
- GlBuffer::unbind(GlBuffer::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;
}
#endif
}
-void cv::GlTexture::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;
#else
if (rows_ != arows || cols_ != acols || format_ != aformat)
{
- GlBuffer::unbind(GlBuffer::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;
#endif
}
-void cv::GlTexture::release()
+void cv::ogl::Texture2D::release()
{
#ifdef HAVE_OPENGL
if (*impl_.refcount == 1)
#endif
}
-void cv::GlTexture::setAutoRelease(bool flag)
+void cv::ogl::Texture2D::setAutoRelease(bool flag)
{
#ifndef HAVE_OPENGL
(void) flag;
#endif
}
-void cv::GlTexture::copyFrom(InputArray arr, bool autoRelease)
+void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease)
{
#ifndef HAVE_OPENGL
(void) arr;
{
case _InputArray::OPENGL_BUFFER:
{
- GlBuffer buf = arr.getGlBuffer();
- buf.bind(GlBuffer::PIXEL_UNPACK_BUFFER);
+ ogl::Buffer buf = arr.getOGlBuffer();
+ buf.bind(ogl::Buffer::PIXEL_UNPACK_BUFFER);
impl_->copyFrom(asize.width, asize.height, srcFormats[cn], gl_types[depth], 0);
- GlBuffer::unbind(GlBuffer::PIXEL_UNPACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER);
break;
}
throw_nocuda();
#else
GpuMat dmat = arr.getGpuMat();
- GlBuffer buf(dmat, GlBuffer::PIXEL_UNPACK_BUFFER);
- buf.bind(GlBuffer::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);
- GlBuffer::unbind(GlBuffer::PIXEL_UNPACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER);
#endif
break;
{
Mat mat = arr.getMat();
CV_Assert( mat.isContinuous() );
- GlBuffer::unbind(GlBuffer::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::GlTexture::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;
{
case _InputArray::OPENGL_BUFFER:
{
- GlBuffer& buf = arr.getGlBufferRef();
- buf.create(rows_, cols_, CV_MAKE_TYPE(ddepth, cn), GlBuffer::PIXEL_PACK_BUFFER, autoRelease);
- buf.bind(GlBuffer::PIXEL_PACK_BUFFER);
+ ogl::Buffer& buf = arr.getOGlBufferRef();
+ 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);
- GlBuffer::unbind(GlBuffer::PIXEL_PACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_PACK_BUFFER);
break;
}
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
throw_nocuda();
#else
- GlBuffer buf(rows_, cols_, CV_MAKE_TYPE(ddepth, cn), GlBuffer::PIXEL_PACK_BUFFER);
- buf.bind(GlBuffer::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);
- GlBuffer::unbind(GlBuffer::PIXEL_PACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_PACK_BUFFER);
buf.copyTo(arr);
#endif
arr.create(rows_, cols_, CV_MAKE_TYPE(ddepth, cn));
Mat mat = arr.getMat();
CV_Assert( mat.isContinuous() );
- GlBuffer::unbind(GlBuffer::PIXEL_PACK_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::PIXEL_PACK_BUFFER);
impl_->copyTo(dstFormat, gl_types[ddepth], mat.data);
}
}
#endif
}
-void cv::GlTexture::bind() const
+void cv::ogl::Texture2D::bind() const
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-unsigned int cv::GlTexture::texId() const
+unsigned int cv::ogl::Texture2D::texId() const
{
#ifndef HAVE_OPENGL
throw_nogl();
#endif
}
-template <> void cv::Ptr<cv::GlTexture::Impl>::delete_obj()
+template <> void cv::Ptr<cv::ogl::Texture2D::Impl>::delete_obj()
{
if (obj) delete obj;
}
////////////////////////////////////////////////////////////////////////
-// GlArrays
+// ogl::Arrays
-cv::GlArrays::GlArrays() : size_(0)
+cv::ogl::Arrays::Arrays() : size_(0)
{
}
-void cv::GlArrays::setVertexArray(InputArray vertex)
+void cv::ogl::Arrays::setVertexArray(InputArray vertex)
{
const int cn = vertex.channels();
const int depth = vertex.depth();
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.getOGlBuffer();
else
vertex_.copyFrom(vertex);
size_ = vertex_.size().area();
}
-void cv::GlArrays::resetVertexArray()
+void cv::ogl::Arrays::resetVertexArray()
{
vertex_.release();
size_ = 0;
}
-void cv::GlArrays::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.getOGlBuffer();
else
color_.copyFrom(color);
}
-void cv::GlArrays::resetColorArray()
+void cv::ogl::Arrays::resetColorArray()
{
color_.release();
}
-void cv::GlArrays::setNormalArray(InputArray normal)
+void cv::ogl::Arrays::setNormalArray(InputArray normal)
{
const int cn = normal.channels();
const int depth = normal.depth();
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.getOGlBuffer();
else
normal_.copyFrom(normal);
}
-void cv::GlArrays::resetNormalArray()
+void cv::ogl::Arrays::resetNormalArray()
{
normal_.release();
}
-void cv::GlArrays::setTexCoordArray(InputArray texCoord)
+void cv::ogl::Arrays::setTexCoordArray(InputArray texCoord)
{
const int cn = texCoord.channels();
const int depth = texCoord.depth();
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.getOGlBuffer();
else
texCoord_.copyFrom(texCoord);
}
-void cv::GlArrays::resetTexCoordArray()
+void cv::ogl::Arrays::resetTexCoordArray()
{
texCoord_.release();
}
-void cv::GlArrays::release()
+void cv::ogl::Arrays::release()
{
resetVertexArray();
resetColorArray();
resetTexCoordArray();
}
-void cv::GlArrays::setAutoRelease(bool flag)
+void cv::ogl::Arrays::setAutoRelease(bool flag)
{
vertex_.setAutoRelease(flag);
color_.setAutoRelease(flag);
texCoord_.setAutoRelease(flag);
}
-void cv::GlArrays::bind() const
+void cv::ogl::Arrays::bind() const
{
#ifndef HAVE_OPENGL
throw_nogl();
gl::EnableClientState(gl::TEXTURE_COORD_ARRAY);
CV_CheckGlError();
- texCoord_.bind(GlBuffer::ARRAY_BUFFER);
+ texCoord_.bind(ogl::Buffer::ARRAY_BUFFER);
gl::TexCoordPointer(texCoord_.channels(), gl_types[texCoord_.depth()], 0, 0);
CV_CheckGlError();
gl::EnableClientState(gl::NORMAL_ARRAY);
CV_CheckGlError();
- normal_.bind(GlBuffer::ARRAY_BUFFER);
+ normal_.bind(ogl::Buffer::ARRAY_BUFFER);
gl::NormalPointer(gl_types[normal_.depth()], 0, 0);
CV_CheckGlError();
gl::EnableClientState(gl::COLOR_ARRAY);
CV_CheckGlError();
- color_.bind(GlBuffer::ARRAY_BUFFER);
+ color_.bind(ogl::Buffer::ARRAY_BUFFER);
const int cn = color_.channels();
gl::EnableClientState(gl::VERTEX_ARRAY);
CV_CheckGlError();
- vertex_.bind(GlBuffer::ARRAY_BUFFER);
+ vertex_.bind(ogl::Buffer::ARRAY_BUFFER);
gl::VertexPointer(vertex_.channels(), gl_types[vertex_.depth()], 0, 0);
CV_CheckGlError();
}
- GlBuffer::unbind(GlBuffer::ARRAY_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::ARRAY_BUFFER);
#endif
}
////////////////////////////////////////////////////////////////////////
// Rendering
-void cv::render(const GlTexture& 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;
texRect.x + texRect.width, texRect.y
};
- GlBuffer::unbind(GlBuffer::ARRAY_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::ARRAY_BUFFER);
gl::EnableClientState(gl::TEXTURE_COORD_ARRAY);
CV_CheckGlError();
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 GlArrays& arr, int mode, Scalar color)
+void cv::ogl::render(const ogl::Arrays& arr, int mode, Scalar color)
{
#ifndef HAVE_OPENGL
(void) arr;
#endif
}
-void cv::render(const GlArrays& 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;
{
case _InputArray::OPENGL_BUFFER :
{
- GlBuffer buf = indices.getGlBuffer();
+ ogl::Buffer buf = indices.getOGlBuffer();
const int depth = buf.depth();
else
type = gl::UNSIGNED_INT;
- buf.bind(GlBuffer::ELEMENT_ARRAY_BUFFER);
+ buf.bind(ogl::Buffer::ELEMENT_ARRAY_BUFFER);
gl::DrawElements(mode, buf.size().area(), type, 0);
- GlBuffer::unbind(GlBuffer::ELEMENT_ARRAY_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::ELEMENT_ARRAY_BUFFER);
break;
}
else
type = gl::UNSIGNED_INT;
- GlBuffer::unbind(GlBuffer::ELEMENT_ARRAY_BUFFER);
+ ogl::Buffer::unbind(ogl::Buffer::ELEMENT_ARRAY_BUFFER);
gl::DrawElements(mode, mat.size().area(), type, mat.data);
}
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of the copyright holders may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#include "precomp.hpp"
+#include "opencv2/core/opengl_interop_deprecated.hpp"
+#include "opencv2/core/gpumat.hpp"
+
+using namespace std;
+using namespace cv;
+using namespace cv::gpu;
+
+CvOpenGlFuncTab::~CvOpenGlFuncTab()
+{
+}
+
+void icvSetOpenGlFuncTab(const CvOpenGlFuncTab*)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+////////////////////////////////////////////////////////////////////////
+// GlBuffer
+
+class cv::GlBuffer::Impl
+{
+};
+
+cv::GlBuffer::GlBuffer(Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+cv::GlBuffer::GlBuffer(int, int, int, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+cv::GlBuffer::GlBuffer(Size, int, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+cv::GlBuffer::GlBuffer(InputArray, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlBuffer::create(int, int, int, Usage)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlBuffer::release()
+{
+}
+
+void cv::GlBuffer::copyFrom(InputArray)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlBuffer::bind() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlBuffer::unbind() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+Mat cv::GlBuffer::mapHost()
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+ return Mat();
+}
+
+void cv::GlBuffer::unmapHost()
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+GpuMat cv::GlBuffer::mapDevice()
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+ return GpuMat();
+}
+
+void cv::GlBuffer::unmapDevice()
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+template <> void cv::Ptr<cv::GlBuffer::Impl>::delete_obj()
+{
+ if (obj) delete obj;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// GlTexture
+
+class cv::GlTexture::Impl
+{
+};
+
+cv::GlTexture::GlTexture() : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+cv::GlTexture::GlTexture(int, int, int) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+cv::GlTexture::GlTexture(Size, int) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+cv::GlTexture::GlTexture(InputArray, bool) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlTexture::create(int, int, int)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlTexture::release()
+{
+}
+
+void cv::GlTexture::copyFrom(InputArray, bool)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlTexture::bind() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlTexture::unbind() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+template <> void cv::Ptr<cv::GlTexture::Impl>::delete_obj()
+{
+ if (obj) delete obj;
+}
+
+////////////////////////////////////////////////////////////////////////
+// GlArrays
+
+void cv::GlArrays::setVertexArray(InputArray)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlArrays::setColorArray(InputArray, bool)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlArrays::setNormalArray(InputArray)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlArrays::setTexCoordArray(InputArray)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlArrays::bind() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlArrays::unbind() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+////////////////////////////////////////////////////////////////////////
+// GlFont
+
+cv::GlFont::GlFont(const string& _family, int _height, Weight _weight, Style _style)
+ : family_(_family), height_(_height), weight_(_weight), style_(_style), base_(0)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlFont::draw(const char*, int) const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+Ptr<GlFont> cv::GlFont::get(const std::string&, int, Weight, Style)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+ return Ptr<GlFont>();
+}
+
+////////////////////////////////////////////////////////////////////////
+// Rendering
+
+void cv::render(const GlTexture&, Rect_<double>, Rect_<double>)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::render(const GlArrays&, int, Scalar)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::render(const string&, const Ptr<GlFont>&, Scalar, Point2d)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+////////////////////////////////////////////////////////////////////////
+// GlCamera
+
+cv::GlCamera::GlCamera() :
+ eye_(0.0, 0.0, -5.0), center_(0.0, 0.0, 0.0), up_(0.0, 1.0, 0.0),
+ pos_(0.0, 0.0, -5.0), yaw_(0.0), pitch_(0.0), roll_(0.0),
+ useLookAtParams_(false),
+
+ scale_(1.0, 1.0, 1.0),
+
+ projectionMatrix_(),
+ fov_(45.0), aspect_(0.0),
+ left_(0.0), right_(1.0), bottom_(1.0), top_(0.0),
+ zNear_(-1.0), zFar_(1.0),
+ perspectiveProjection_(false)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::lookAt(Point3d, Point3d, Point3d)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setCameraPos(Point3d, double, double, double)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setScale(Point3d)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setProjectionMatrix(const Mat&, bool)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setPerspectiveProjection(double, double, double, double)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setOrthoProjection(double, double, double, double, double, double)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setupProjectionMatrix() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::GlCamera::setupModelViewMatrix() const
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+////////////////////////////////////////////////////////////////////////
+// Error handling
+
+bool icvCheckGlError(const char*, const int, const char*)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+ return false;
+}
#if defined(HAVE_CUDA) && defined(HAVE_OPENGL)
/////////////////////////////////////////////
-// GlBuffer
+// Buffer
-PARAM_TEST_CASE(GlBuffer, cv::Size, MatType)
+PARAM_TEST_CASE(Buffer, cv::Size, MatType)
{
static void SetUpTestCase()
{
}
};
-GPU_TEST_P(GlBuffer, Constructor1)
+GPU_TEST_P(Buffer, Constructor1)
{
- cv::GlBuffer buf(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(size.height, size.width, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
}
-GPU_TEST_P(GlBuffer, Constructor2)
+GPU_TEST_P(Buffer, Constructor2)
{
- cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(size, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
}
-GPU_TEST_P(GlBuffer, ConstructorFromMat)
+GPU_TEST_P(Buffer, ConstructorFromMat)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, ConstructorFromGpuMat)
+GPU_TEST_P(Buffer, ConstructorFromGpuMat)
{
cv::Mat gold = randomMat(size, type);
cv::gpu::GpuMat d_gold(gold);
- cv::GlBuffer buf(d_gold, cv::GlBuffer::ARRAY_BUFFER);
+ cv::ogl::Buffer buf(d_gold, cv::ogl::Buffer::ARRAY_BUFFER);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, ConstructorFromGlBuffer)
+GPU_TEST_P(Buffer, ConstructorFromBuffer)
{
- cv::GlBuffer buf_gold(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf_gold(size, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
- cv::GlBuffer buf(buf_gold);
+ cv::ogl::Buffer buf(buf_gold);
EXPECT_EQ(buf_gold.bufId(), buf.bufId());
EXPECT_EQ(buf_gold.rows(), buf.rows());
EXPECT_EQ(buf_gold.type(), buf.type());
}
-GPU_TEST_P(GlBuffer, ConstructorFromGlTexture)
+GPU_TEST_P(Buffer, ConstructorFromTexture2D)
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
return;
cv::Mat gold = randomMat(size, type, 0, 1.0);
- cv::GlTexture tex_gold(gold, true);
+ cv::ogl::Texture2D tex_gold(gold, true);
- cv::GlBuffer buf(tex_gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
+ cv::ogl::Buffer buf(tex_gold, cv::ogl::Buffer::PIXEL_PACK_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
}
-GPU_TEST_P(GlBuffer, Create)
+GPU_TEST_P(Buffer, Create)
{
- cv::GlBuffer buf;
- buf.create(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf;
+ buf.create(size.height, size.width, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
}
-GPU_TEST_P(GlBuffer, CopyFromMat)
+GPU_TEST_P(Buffer, CopyFromMat)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf;
- buf.copyFrom(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf;
+ buf.copyFrom(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, CopyFromGpuMat)
+GPU_TEST_P(Buffer, CopyFromGpuMat)
{
cv::Mat gold = randomMat(size, type);
cv::gpu::GpuMat d_gold(gold);
- cv::GlBuffer buf;
- buf.copyFrom(d_gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf;
+ buf.copyFrom(d_gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, CopyFromGlBuffer)
+GPU_TEST_P(Buffer, CopyFromBuffer)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf_gold(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf_gold(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
- cv::GlBuffer buf;
- buf.copyFrom(buf_gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf;
+ buf.copyFrom(buf_gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
EXPECT_NE(buf_gold.bufId(), buf.bufId());
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, CopyFromGlTexture)
+GPU_TEST_P(Buffer, CopyFromTexture2D)
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
return;
cv::Mat gold = randomMat(size, type, 0, 1.0);
- cv::GlTexture tex_gold(gold, true);
+ cv::ogl::Texture2D tex_gold(gold, true);
- cv::GlBuffer buf;
- buf.copyFrom(tex_gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf;
+ buf.copyFrom(tex_gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
}
-GPU_TEST_P(GlBuffer, CopyToGpuMat)
+GPU_TEST_P(Buffer, CopyToGpuMat)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
cv::gpu::GpuMat dst;
buf.copyTo(dst);
EXPECT_MAT_NEAR(gold, dst, 0);
}
-GPU_TEST_P(GlBuffer, CopyToGlBuffer)
+GPU_TEST_P(Buffer, CopyToBuffer)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
- cv::GlBuffer dst;
- buf.copyTo(dst, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer dst;
+ buf.copyTo(dst, cv::ogl::Buffer::ARRAY_BUFFER, true);
EXPECT_NE(buf.bufId(), dst.bufId());
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, CopyToGlTexture)
+GPU_TEST_P(Buffer, CopyToTexture2D)
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
cv::Mat gold = randomMat(size, type, 0, 1.0);
- cv::GlBuffer buf(gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::PIXEL_PACK_BUFFER, true);
- cv::GlTexture tex;
- buf.copyTo(tex, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
+ cv::ogl::Texture2D tex;
+ buf.copyTo(tex, cv::ogl::Buffer::PIXEL_PACK_BUFFER, true);
cv::Mat texData;
tex.copyTo(texData);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlBuffer, Clone)
+GPU_TEST_P(Buffer, Clone)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
- cv::GlBuffer dst = buf.clone(cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer dst = buf.clone(cv::ogl::Buffer::ARRAY_BUFFER, true);
EXPECT_NE(buf.bufId(), dst.bufId());
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, MapHostRead)
+GPU_TEST_P(Buffer, MapHostRead)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
- cv::Mat dst = buf.mapHost(cv::GlBuffer::READ_ONLY);
+ cv::Mat dst = buf.mapHost(cv::ogl::Buffer::READ_ONLY);
EXPECT_MAT_NEAR(gold, dst, 0);
buf.unmapHost();
}
-GPU_TEST_P(GlBuffer, MapHostWrite)
+GPU_TEST_P(Buffer, MapHostWrite)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(size, type, cv::ogl::Buffer::ARRAY_BUFFER, true);
- cv::Mat dst = buf.mapHost(cv::GlBuffer::WRITE_ONLY);
+ cv::Mat dst = buf.mapHost(cv::ogl::Buffer::WRITE_ONLY);
gold.copyTo(dst);
buf.unmapHost();
dst.release();
EXPECT_MAT_NEAR(gold, bufData, 0);
}
-GPU_TEST_P(GlBuffer, MapDevice)
+GPU_TEST_P(Buffer, MapDevice)
{
cv::Mat gold = randomMat(size, type);
- cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
+ cv::ogl::Buffer buf(gold, cv::ogl::Buffer::ARRAY_BUFFER, true);
cv::gpu::GpuMat dst = buf.mapDevice();
buf.unmapDevice();
}
-INSTANTIATE_TEST_CASE_P(OpenGL, GlBuffer, testing::Combine(DIFFERENT_SIZES, ALL_TYPES));
+INSTANTIATE_TEST_CASE_P(OpenGL, Buffer, testing::Combine(DIFFERENT_SIZES, ALL_TYPES));
/////////////////////////////////////////////
-// GlTexture
+// Texture2D
-PARAM_TEST_CASE(GlTexture, cv::Size, MatType)
+PARAM_TEST_CASE(Texture2D, cv::Size, MatType)
{
static void SetUpTestCase()
{
int type;
int depth;
int cn;
- cv::GlTexture::Format format;
+ cv::ogl::Texture2D::Format format;
virtual void SetUp()
{
depth = CV_MAT_DEPTH(type);
cn = CV_MAT_CN(type);
- format = cn == 1 ? cv::GlTexture::DEPTH_COMPONENT : cn == 3 ? cv::GlTexture::RGB : cn == 4 ? cv::GlTexture::RGBA : cv::GlTexture::NONE;
+ format = cn == 1 ? cv::ogl::Texture2D::DEPTH_COMPONENT : cn == 3 ? cv::ogl::Texture2D::RGB : cn == 4 ? cv::ogl::Texture2D::RGBA : cv::ogl::Texture2D::NONE;
}
};
-GPU_TEST_P(GlTexture, Constructor1)
+GPU_TEST_P(Texture2D, Constructor1)
{
- cv::GlTexture tex(size.height, size.width, format, true);
+ cv::ogl::Texture2D tex(size.height, size.width, format, true);
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
}
-GPU_TEST_P(GlTexture, Constructor2)
+GPU_TEST_P(Texture2D, Constructor2)
{
- cv::GlTexture tex(size, format, true);
+ cv::ogl::Texture2D tex(size, format, true);
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
}
-GPU_TEST_P(GlTexture, ConstructorFromMat)
+GPU_TEST_P(Texture2D, ConstructorFromMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
- cv::GlTexture tex(gold, true);
+ cv::ogl::Texture2D tex(gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlTexture, ConstructorFromGpuMat)
+GPU_TEST_P(Texture2D, ConstructorFromGpuMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::gpu::GpuMat d_gold(gold);
- cv::GlTexture tex(d_gold, true);
+ cv::ogl::Texture2D tex(d_gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlTexture, ConstructorFromGlBuffer)
+GPU_TEST_P(Texture2D, ConstructorFromBuffer)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
- cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
+ cv::ogl::Buffer buf_gold(gold, cv::ogl::Buffer::PIXEL_UNPACK_BUFFER, true);
- cv::GlTexture tex(buf_gold, true);
+ cv::ogl::Texture2D tex(buf_gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlTexture, ConstructorFromGlTexture)
+GPU_TEST_P(Texture2D, ConstructorFromTexture2D)
{
- cv::GlTexture tex_gold(size, format, true);
- cv::GlTexture tex(tex_gold);
+ cv::ogl::Texture2D tex_gold(size, format, true);
+ cv::ogl::Texture2D tex(tex_gold);
EXPECT_EQ(tex_gold.texId(), tex.texId());
EXPECT_EQ(tex_gold.rows(), tex.rows());
EXPECT_EQ(tex_gold.format(), tex.format());
}
-GPU_TEST_P(GlTexture, Create)
+GPU_TEST_P(Texture2D, Create)
{
- cv::GlTexture tex;
+ cv::ogl::Texture2D tex;
tex.create(size.height, size.width, format, true);
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(format, tex.format());
}
-GPU_TEST_P(GlTexture, CopyFromMat)
+GPU_TEST_P(Texture2D, CopyFromMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
- cv::GlTexture tex;
+ cv::ogl::Texture2D tex;
tex.copyFrom(gold, true);
cv::Mat texData;
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlTexture, CopyFromGpuMat)
+GPU_TEST_P(Texture2D, CopyFromGpuMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::gpu::GpuMat d_gold(gold);
- cv::GlTexture tex;
+ cv::ogl::Texture2D tex;
tex.copyFrom(d_gold, true);
cv::Mat texData;
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlTexture, CopyFromGlBuffer)
+GPU_TEST_P(Texture2D, CopyFromBuffer)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
- cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
+ cv::ogl::Buffer buf_gold(gold, cv::ogl::Buffer::PIXEL_UNPACK_BUFFER, true);
- cv::GlTexture tex;
+ cv::ogl::Texture2D tex;
tex.copyFrom(buf_gold, true);
cv::Mat texData;
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
-GPU_TEST_P(GlTexture, CopyToGpuMat)
+GPU_TEST_P(Texture2D, CopyToGpuMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
- cv::GlTexture tex(gold, true);
+ cv::ogl::Texture2D tex(gold, true);
cv::gpu::GpuMat dst;
tex.copyTo(dst, depth);
EXPECT_MAT_NEAR(gold, dst, 1e-2);
}
-GPU_TEST_P(GlTexture, CopyToGlBuffer)
+GPU_TEST_P(Texture2D, CopyToBuffer)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
- cv::GlTexture tex(gold, true);
+ cv::ogl::Texture2D tex(gold, true);
- cv::GlBuffer dst;
+ cv::ogl::Buffer dst;
tex.copyTo(dst, depth, true);
cv::Mat bufData;
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
}
-INSTANTIATE_TEST_CASE_P(OpenGL, GlTexture, testing::Combine(DIFFERENT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
+INSTANTIATE_TEST_CASE_P(OpenGL, Texture2D, testing::Combine(DIFFERENT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)));
#endif
// OpenGL support
-typedef void (CV_CDECL *OpenGlDrawCallback)(void* userdata);
+typedef void (*OpenGlDrawCallback)(void* userdata);
CV_EXPORTS void setOpenGlDrawCallback(const string& winname, OpenGlDrawCallback onOpenGlDraw, void* userdata = 0);
CV_EXPORTS void setOpenGlContext(const string& winname);
CV_EXPORTS void updateWindow(const string& winname);
+// < Deperecated
+CV_EXPORTS void pointCloudShow(const string& winname, const GlCamera& camera, const GlArrays& arr);
+CV_EXPORTS void pointCloudShow(const string& winname, const GlCamera& camera, InputArray points, InputArray colors = noArray());
+// >
+
//Only for Qt
CV_EXPORTS CvFont fontQt(const string& nameFont, int pointSize=-1,
#ifdef HAVE_OPENGL
namespace
{
- std::map<std::string, cv::GlTexture> wndTexs;
- std::map<std::string, cv::GlTexture> ownWndTexs;
- std::map<std::string, cv::GlBuffer> ownWndBufs;
+ std::map<std::string, cv::ogl::Texture2D> wndTexs;
+ std::map<std::string, cv::ogl::Texture2D> ownWndTexs;
+ std::map<std::string, cv::ogl::Buffer> ownWndBufs;
- void CV_CDECL glDrawTextureCallback(void* userdata)
+ void glDrawTextureCallback(void* userdata)
{
- cv::GlTexture* texObj = static_cast<cv::GlTexture*>(userdata);
+ cv::ogl::Texture2D* texObj = static_cast<cv::ogl::Texture2D*>(userdata);
- cv::render(*texObj);
+ cv::ogl::render(*texObj);
}
}
#endif // HAVE_OPENGL
if (_img.kind() == _InputArray::OPENGL_TEXTURE)
{
- cv::GlTexture& tex = wndTexs[winname];
+ cv::ogl::Texture2D& tex = wndTexs[winname];
- tex = _img.getGlTexture();
+ tex = _img.getOGlTexture2D();
tex.setAutoRelease(false);
}
else
{
- cv::GlTexture& tex = ownWndTexs[winname];
+ cv::ogl::Texture2D& tex = ownWndTexs[winname];
if (_img.kind() == _InputArray::GPU_MAT)
{
- cv::GlBuffer& buf = ownWndBufs[winname];
+ cv::ogl::Buffer& buf = ownWndBufs[winname];
buf.copyFrom(_img);
buf.setAutoRelease(false);
#endif
}
+void cv::pointCloudShow(const string&, const GlCamera&, const GlArrays&)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
+void cv::pointCloudShow(const string&, const GlCamera&, InputArray, InputArray)
+{
+ CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
+}
+
// Without OpenGL
#ifndef HAVE_OPENGL
struct DrawData
{
- GlArrays arr;
- GlTexture tex;
- GlBuffer indices;
+ ogl::Arrays arr;
+ ogl::Texture2D tex;
+ ogl::Buffer indices;
};
-void CV_CDECL draw(void* userdata);
+void draw(void* userdata);
-void CV_CDECL draw(void* userdata)
+void draw(void* userdata)
{
- static double angle = 0.0;
-
DrawData* data = static_cast<DrawData*>(userdata);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(45.0, (double)win_width / win_height, 0.1, 100.0);
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
- glRotated(angle, 0, 1, 0);
-
- glEnable(GL_TEXTURE_2D);
- data->tex.bind();
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glDisable(GL_CULL_FACE);
-
- render(data->arr, data->indices, RenderMode::TRIANGLES);
+ glRotated(0.6, 0, 1, 0);
- angle += 0.3;
+ ogl::render(data->arr, data->indices, ogl::TRIANGLES);
}
int main(int argc, char* argv[])
data.indices.copyFrom(indices);
data.tex.copyFrom(img);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluPerspective(45.0, (double)win_width / win_height, 0.1, 100.0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0);
+
+ glEnable(GL_TEXTURE_2D);
+ data.tex.bind();
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ glDisable(GL_CULL_FACE);
+
setOpenGlDrawCallback("OpenGL", draw, &data);
for (;;)
{
updateWindow("OpenGL");
- int key = waitKey(10);
+ int key = waitKey(40);
if ((key & 0xff) == 27)
break;
}
return 0;
}
-#endif
\ No newline at end of file
+#endif