ImageViewport.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * Copyright (c) 2007 The Zdeno Ash Miklas
  19. *
  20. * This source file is part of VideoTexture library
  21. *
  22. * Contributor(s):
  23. *
  24. * ***** END GPL LICENSE BLOCK *****
  25. */
  26. /** \file ImageViewport.h
  27. * \ingroup bgevideotex
  28. */
  29. #ifndef __IMAGEVIEWPORT_H__
  30. #define __IMAGEVIEWPORT_H__
  31. #include "Common.h"
  32. #include "ImageBase.h"
  33. #include "RAS_IOffScreen.h"
  34. /// class for viewport access
  35. class ImageViewport : public ImageBase
  36. {
  37. public:
  38. /// constructor
  39. ImageViewport (PyRASOffScreen *offscreen=NULL);
  40. /// destructor
  41. virtual ~ImageViewport (void);
  42. /// is whole buffer used
  43. bool getWhole (void) { return m_whole; }
  44. /// set whole buffer use
  45. void setWhole (bool whole);
  46. /// is alpha channel used
  47. bool getAlpha (void) { return m_alpha; }
  48. /// set whole buffer use
  49. void setAlpha (bool alpha) { m_alpha = alpha; }
  50. /// get capture size in viewport
  51. short * getCaptureSize (void) { return m_capSize; }
  52. /// set capture size in viewport
  53. void setCaptureSize (short size[2] = NULL);
  54. /// get position in viewport
  55. GLint * getPosition (void) { return m_position; }
  56. /// set position in viewport
  57. void setPosition (GLint pos[2] = NULL);
  58. /// capture image from viewport to user buffer
  59. virtual bool loadImage(unsigned int *buffer, unsigned int size, unsigned int format, double ts);
  60. protected:
  61. /// frame buffer rectangle
  62. GLint m_viewport[4];
  63. /// size of captured area
  64. short m_capSize[2];
  65. /// use whole viewport
  66. bool m_whole;
  67. /// use alpha channel
  68. bool m_alpha;
  69. /// position of capture rectangle in viewport
  70. GLint m_position[2];
  71. /// upper left point for capturing
  72. GLint m_upLeft[2];
  73. /// buffer to copy viewport
  74. BYTE * m_viewportImage;
  75. /// texture is initialized
  76. bool m_texInit;
  77. /// capture image from viewport
  78. virtual void calcImage (unsigned int texId, double ts) { calcViewport(texId, ts, GL_RGBA); }
  79. /// capture image from viewport
  80. virtual void calcViewport (unsigned int texId, double ts, unsigned int format);
  81. /// get viewport size
  82. GLint * getViewportSize (void) { return m_viewport + 2; }
  83. };
  84. PyObject *ImageViewport_getCaptureSize(PyImage *self, void *closure);
  85. int ImageViewport_setCaptureSize(PyImage *self, PyObject *value, void *closure);
  86. PyObject *ImageViewport_getWhole(PyImage *self, void *closure);
  87. int ImageViewport_setWhole(PyImage *self, PyObject *value, void *closure);
  88. PyObject *ImageViewport_getAlpha(PyImage *self, void *closure);
  89. int ImageViewport_setAlpha(PyImage *self, PyObject *value, void *closure);
  90. #endif