Commit a938534a authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

restored binary compatibility

parent e06c3ec7
......@@ -90,10 +90,18 @@ class Mat;
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;
......@@ -1327,15 +1335,23 @@ public:
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;
......@@ -1387,8 +1403,8 @@ public:
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);
......@@ -1399,16 +1415,16 @@ public:
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;
......
......@@ -750,4 +750,35 @@ typedef struct CvBigFuncTable
(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__
......@@ -47,20 +47,20 @@
#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
......@@ -79,18 +79,18 @@ public:
};
//! 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);
......@@ -109,7 +109,7 @@ public:
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;
......@@ -147,10 +147,8 @@ private:
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
......@@ -162,18 +160,18 @@ public:
};
//! 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);
......@@ -212,13 +210,11 @@ private:
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();
......@@ -243,22 +239,21 @@ public:
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 {
enum {
POINTS = 0x0000,
LINES = 0x0001,
LINE_LOOP = 0x0002,
......@@ -269,19 +264,27 @@ namespace RenderMode {
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
......
......@@ -43,6 +43,7 @@
#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 *
......@@ -925,9 +926,13 @@ _InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {}
_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
{
......@@ -1069,26 +1074,14 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
GlBuffer _InputArray::getGlBuffer() const
{
int k = kind();
CV_Assert(k == OPENGL_BUFFER);
//if( k == OPENGL_BUFFER )
{
const GlBuffer* buf = (const GlBuffer*)obj;
return *buf;
}
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
return GlBuffer(GlBuffer::ARRAY_BUFFER);
}
GlTexture _InputArray::getGlTexture() const
{
int k = kind();
CV_Assert(k == OPENGL_TEXTURE);
//if( k == OPENGL_TEXTURE )
{
const GlTexture* tex = (const GlTexture*)obj;
return *tex;
}
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
return GlTexture();
}
gpu::GpuMat _InputArray::getGpuMat() const
......@@ -1096,11 +1089,29 @@ gpu::GpuMat _InputArray::getGpuMat() 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;
}
}
ogl::Buffer _InputArray::getOGlBuffer() const
{
int k = kind();
CV_Assert(k == OPENGL_BUFFER);
const ogl::Buffer* gl_buf = (const ogl::Buffer*)obj;
return *gl_buf;
}
ogl::Texture2D _InputArray::getOGlTexture2D() const
{
int k = kind();
CV_Assert(k == OPENGL_TEXTURE);
const ogl::Texture2D* gl_tex = (const ogl::Texture2D*)obj;
return *gl_tex;
}
int _InputArray::kind() const
......@@ -1167,14 +1178,14 @@ Size _InputArray::size(int i) 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();
}
......@@ -1235,7 +1246,7 @@ int _InputArray::type(int i) const
}
if( k == OPENGL_BUFFER )
return ((const GlBuffer*)obj)->type();
return ((const ogl::Buffer*)obj)->type();
CV_Assert( k == GPU_MAT );
//if( k == GPU_MAT )
......@@ -1287,10 +1298,10 @@ bool _InputArray::empty() const
}
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 )
......@@ -1305,14 +1316,14 @@ _OutputArray::~_OutputArray() {}
_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
......@@ -1344,9 +1355,9 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int
}
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};
......@@ -1372,9 +1383,9 @@ void _OutputArray::create(int rows, int cols, int mtype, int i, bool allowTransp
}
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};
......@@ -1598,13 +1609,13 @@ void _OutputArray::release() const
if( k == OPENGL_BUFFER )
{
((GlBuffer*)obj)->release();
((ogl::Buffer*)obj)->release();
return;
}
if( k == OPENGL_TEXTURE )
{
((GlTexture*)obj)->release();
((ogl::Texture2D*)obj)->release();
return;
}
......@@ -1673,18 +1684,18 @@ gpu::GpuMat& _OutputArray::getGpuMatRef() const
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;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -125,13 +125,18 @@ CV_EXPORTS_W void setTrackbarPos(const string& trackbarname, const string& winna
// 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,
......
......@@ -241,15 +241,15 @@ void cv::updateWindow(const string& windowName)
#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
......@@ -283,9 +283,9 @@ void cv::imshow( const string& winname, InputArray _img )
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);
......@@ -293,11 +293,11 @@ void cv::imshow( const string& winname, InputArray _img )
}
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);
......@@ -319,6 +319,16 @@ void cv::imshow( const string& winname, InputArray _img )
#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
......
......@@ -37,39 +37,20 @@ const int win_height = 640;
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[])
......@@ -106,12 +87,28 @@ 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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment