File: Framebuffer.hpp

package info (click to toggle)
openlayer 2.1-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,368 kB
  • ctags: 2,295
  • sloc: ansic: 10,432; cpp: 9,890; xml: 109; makefile: 89; sh: 36
file content (126 lines) | stat: -rw-r--r-- 3,812 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef OL_FRAMEBUFFER_HPP
#define OL_FRAMEBUFFER_HPP
#include "Includes.hpp"
#include "GlDriver.hpp"
#include "Declspec.hpp"
#include <vector>
#include <map>


namespace ol {



class OL_LIB_DECLSPEC FrameBuffer {
public:
   virtual ~FrameBuffer();

   virtual const char *GetName() = 0;
   virtual bool Initialize() = 0;
   virtual void BindToTexture( const OlTextureInfo &texture ) = 0;
   virtual void Release() = 0;
   virtual void Destroy( OlTextureInfo &texture ) = 0;
   virtual void DestroySurfaces() = 0;
   virtual void RefreshSurface() = 0;
   virtual void ReadPixels( int x, int y, int width, int height, GLenum textureFormat, unsigned char *pixelData ) = 0;
   virtual void CopyTexSubImage( int x, int y, int width, int height, int yOffset ) = 0;

   static FrameBuffer &GetInstance();
   static void Register( FrameBuffer *buffer );
   static void DestroyFramebuffers();

private:
   static void InitFramebuf();

   static std::vector< FrameBuffer *> possibleFramebufs;

   static FrameBuffer *frameBuffer;
};



class OL_LIB_DECLSPEC BackbufFramebuf : public FrameBuffer {
public:
   BackbufFramebuf()
      : boundTexture(0) {}
	virtual ~BackbufFramebuf(){}
   virtual const char *GetName();
   virtual bool Initialize();
   virtual void BindToTexture( const OlTextureInfo &texture );
   virtual void Release();
   virtual void Destroy( OlTextureInfo &texture );
   virtual void DestroySurfaces();


   virtual void RefreshSurface();
   virtual void ReadPixels( int x, int y, int width, int height, GLenum textureFormat, unsigned char *pixelData );
   virtual void CopyTexSubImage( int x, int y, int width, int height, int yOffset );

private:
   const OlTextureInfo *boundTexture;
};



class OL_LIB_DECLSPEC OlFramebufferObjExt : public FrameBuffer {
public:
   OlFramebufferObjExt()
      : boundTexture( 0 ) {}

   virtual ~OlFramebufferObjExt();

   virtual const char *GetName();
   virtual bool Initialize();
   virtual void BindToTexture( const OlTextureInfo &texture );
   virtual void Release();
   virtual void Destroy( OlTextureInfo &texture );
   virtual void DestroySurfaces();
   virtual void RefreshSurface();
   virtual void ReadPixels( int x, int y, int width, int height, GLenum textureFormat, unsigned char *pixelData );
   virtual void CopyTexSubImage( int x, int y, int width, int height, int yOffset );

private:

   #ifdef GL_EXT_framebuffer_object
      #ifdef _WIN32
         #ifndef PFNGLGENFRAMEBUFFERSEXTPROC
            typedef void (APIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC)
                                 (GLsizei n, GLuint *renderbuffers);
         #endif

         #ifndef PFNGLFRAMEBUFFERTEXTURE2DEXTPROC
            typedef void (APIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)
                                (GLenum target, GLenum attachment,
                                 GLenum textarget, GLuint texture,
                                 GLenum level);
         #endif

         #ifndef PFNGLBINDFRAMEBUFFEREXTPROC
            typedef void (APIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC)
                                 (GLenum target, GLuint renderbuffer);
         #endif

         #ifndef PFNGLDELETERENDERBUFFERSEXTPROC
            typedef void (APIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC)
                                 (GLsizei n, const GLuint *renderbuffers);
         #endif

         PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
         PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
         PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
         PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
      #endif // _WIN32
   #endif // GL_EXT_framebuffer_object

   //static const int INTERNAL_FORMAT;
   std::map< GLuint, GLuint > bufferMap;
   const OlTextureInfo *boundTexture;
};


}



#endif // OL_FRAMEBUFFER_HPP