KGLLib
rendertarget.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KGLLIB_RENDERTARGET_H
00019 #define KGLLIB_RENDERTARGET_H
00020
00021 #include "kgllib.h"
00022
00023 #include <QtCore/QSize>
00024
00025 namespace KGLLib
00026 {
00027
00028 class Texture;
00029
00030 class KGLLIB_EXTRAS_EXPORT RenderTarget
00031 {
00032 public:
00037 explicit RenderTarget(Texture* color);
00046 RenderTarget(int width, int height, bool hasDepth = false, GLint textureFormat = GL_RGBA);
00052
00053
00054 virtual ~RenderTarget();
00055
00056 bool enable();
00057 bool disable();
00058
00059 Texture* texture() const { return mColorTexture; }
00060 int width() const;
00061 int height() const;
00062 QSize size() const;
00063
00064 bool isValid() const { return mValid; }
00065
00066 static bool isSupported();
00067
00068 protected:
00069 Texture* createColorTexture(int w, int h, GLint textureFormat = GL_RGBA);
00070 Texture* createDepthTexture(int w, int h);
00071 GLuint createDepthBuffer(int w, int h);
00072
00073 void attachColorTexture(Texture* tex);
00074 void attachDepthTexture(Texture* tex);
00075 void attachDepthBuffer(GLuint buffer);
00076
00077 bool startInit();
00078 void endInit();
00079
00080 private:
00081 bool mValid;
00082 bool mOwnColorTexture;
00083 Texture* mColorTexture;
00084
00085
00086 GLuint mFramebuffer;
00087 GLuint mDepthBuffer;
00088 };
00089
00090 }
00091
00092 #endif