00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef RE_FrameBuffer_h
00038 #define RE_FrameBuffer_h
00039
00040 #include "RE_Render.h"
00041
00042 #include <UT/UT_PtrArray.h>
00043
00044 class re_FrameBufferAttachment;
00045
00046 enum RE_BufferAttachment
00047 {
00048 RE_COLOR_BUFFER,
00049 RE_DEPTH_BUFFER,
00050 RE_STENCIL_BUFFER
00051 };
00052
00053 class RE_API RE_FrameBuffer
00054 {
00055 public:
00056 RE_FrameBuffer();
00057 ~RE_FrameBuffer();
00058
00059 static bool isFrameBufferSupported();
00060 static int getNumColorAttachments();
00061
00062
00063
00064 bool attachTexture(RE_Render *r, GLuint textureid,
00065 RE_GPUType type, int vectorsize,
00066 int miplevel = 0,
00067 RE_BufferAttachment buf = RE_COLOR_BUFFER,
00068 int colorbufnum = 0);
00069
00070
00071
00072
00073
00074 GLuint createTexture(RE_Render *r, int w, int h,
00075 RE_GPUType type, int vectorsize,
00076 int miplevel = 0,
00077 RE_BufferAttachment buf = RE_COLOR_BUFFER,
00078 int colorbufnum = 0,
00079 bool rect = false);
00080
00081
00082
00083
00084
00085 GLuint createRenderBuffer(RE_Render *r, int w, int h,
00086 RE_GPUType type, int vectorsize,
00087 RE_BufferAttachment buf = RE_COLOR_BUFFER,
00088 int colorbufnum = 0);
00089
00090
00091
00092 void setResolution(int width, int height);
00093 int getWidth() const { return myWidth; }
00094 int getHeight() const { return myHeight; }
00095
00096
00097
00098 bool isValid(RE_Render *r);
00099
00100
00101
00102
00103
00104
00105 bool begin(RE_Render *r, RE_BufferAttachment buf = RE_COLOR_BUFFER,
00106 int colorbufnum = 0, bool initview = true);
00107 void end(RE_Render *r);
00108
00109 void drawToBuffer(RE_Render *r,
00110 RE_BufferAttachment buf = RE_COLOR_BUFFER,
00111 int colorbufnum = 0);
00112
00113
00114
00115
00116 void drawToBuffers(RE_Render *r, int num, int *bufferlist);
00117 static int getMaxDrawBuffers(RE_Render *r);
00118
00119
00120
00121
00122 bool readAsyncFromBuffers(RE_Render *r, int num, int *bufferlist);
00123
00124
00125
00126 bool readFromRenderBuffer(RE_Render *r, void *buffer,
00127 RE_BufferAttachment buf=RE_COLOR_BUFFER,
00128 int colorbufnum = 0);
00129
00130
00131
00132
00133 bool detach(RE_Render *r, RE_BufferAttachment buf=RE_COLOR_BUFFER,
00134 int colorbufnum = 0,
00135 bool freeme = false);
00136
00137 bool detachAndFree(RE_Render *r,
00138 RE_BufferAttachment buf=RE_COLOR_BUFFER,
00139 int colorbufnum = 0)
00140 { return detach( r, buf, colorbufnum ,true); }
00141
00142 private:
00143 bool privateReadFromBuffer(RE_Render *r,
00144 re_FrameBufferAttachment *attach,
00145 int glattachment,
00146 void *image_data);
00147
00148 enum RE_BufferBindMode
00149 {
00150 RE_BIND_NONE = 0,
00151 RE_BIND_READ = 1,
00152 RE_BIND_DRAW = 2,
00153 };
00154
00155 bool bindFrameBuffer(RE_Render *r,
00156 RE_BufferBindMode bindmode = RE_BIND_DRAW);
00157 void unbindFrameBuffer(RE_Render *r);
00158
00159 unsigned getGLBuffer() const;
00160
00161 GLuint myFrameBuffer;
00162 int myWidth;
00163 int myHeight;
00164 RE_RenderBuf myPrevRenderBuffer;
00165 bool myBegun;
00166 bool myRestoreView;
00167 RE_BufferBindMode myOpenMode;
00168 UT_PtrArray <re_FrameBufferAttachment *> myAttachments;
00169
00170 static int theARBExtension;
00171 };
00172
00173 #endif