SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SENSGLTextureReader.h
Go to the documentation of this file.
1 #ifndef SENS_GL_TEXTURE_READER_H
2 #define SENS_GL_TEXTURE_READER_H
3 
4 #include <string>
5 #include <opencv2/core/core.hpp>
6 
7 //dont include opengl in the header so that opengl is not used if not needed
9 {
10 public:
11  //! ATTENTION: make sure this constructor is called from gl thread
12  SENSGLTextureReader(unsigned int textureId, bool isGlTextureExternal, int targetWidth, int targetHeight);
14  //! read gl texture from gpu. The transferred image will be filled. return false if it failed
15  //! in this case one can retrieve the last error
16  cv::Mat readImageFromGpu();
17  std::string getLastErrorMsg() const { return _lastErrorMsg; }
18 
19 private:
20  //! Checks if an OpenGL error occurred
21  static void getGLError(const char* file, int line, bool quit);
22  void initGl();
23 
24  std::string _lastErrorMsg;
25  //! id of externally generated texture
26  unsigned int _extTextureId;
27  bool _isGlTextureExternal = false;
30 
31  unsigned int _fbo = 0;
32  unsigned int _prog = 0;
33  unsigned int _VBO = 0;
34  unsigned int _VAO = 0;
35  unsigned int _EBO = 0;
36  unsigned int _targetTex = 0;
37 
38  //! vector for errors collected in getGLError
39  static std::vector<std::string> _errors;
40 };
41 
42 #endif
static void getGLError(const char *file, int line, bool quit)
Checks if an OpenGL error occurred.
SENSGLTextureReader(unsigned int textureId, bool isGlTextureExternal, int targetWidth, int targetHeight)
ATTENTION: make sure this constructor is called from gl thread.
std::string getLastErrorMsg() const
static std::vector< std::string > _errors
vector for errors collected in getGLError
unsigned int _extTextureId
id of externally generated texture