55 fMSCoverageSamples (0),
76 static const std::string eh(
"TGLFBO::Init ");
79 if (!GLEW_EXT_framebuffer_object)
81 throw std::runtime_error(eh +
"GL_EXT_framebuffer_object extension required for FBO.");
91 if (nw != w || nh != h)
100 if (ms_samples > 0 && ! GLEW_EXT_framebuffer_multisample)
104 Info(eh.c_str(),
"GL implementation does not support multi-sampling for FBOs.");
118 glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &maxSize);
119 if (w > maxSize || h > maxSize)
121 throw std::runtime_error(eh +
Form(
"maximum size supported by GL implementation is %d.", maxSize));
128 if (GLEW_NV_framebuffer_multisample_coverage)
131 glGetIntegerv(GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV, &n_modes);
132 GLint *modes =
new GLint[2*n_modes];
133 glGetIntegerv(GL_MULTISAMPLE_COVERAGE_MODES_NV, modes);
135 for (
int i = 0; i < n_modes; ++i)
151 Info(eh.c_str(),
"InitStandard (no multi-sampling).");
156 GLenum
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
158 glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
159 glBindTexture (GL_TEXTURE_2D, 0);
163 case GL_FRAMEBUFFER_COMPLETE_EXT:
165 printf(
"%sConstructed TGLFBO ... all fine.\n", eh.c_str());
167 case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
169 throw std::runtime_error(eh +
"Constructed TGLFBO not supported, choose different formats.");
173 throw std::runtime_error(eh +
"Constructed TGLFBO is not complete, unexpected error.");
220 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT,
fFrameBuffer);
221 glBlitFramebufferEXT(0, 0,
fW,
fH, 0, 0,
fW,
fH, GL_COLOR_BUFFER_BIT, GL_NEAREST);
224 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
232 glPushAttrib(GL_TEXTURE_BIT);
234 glEnable(GL_TEXTURE_2D);
238 glMatrixMode(GL_TEXTURE);
241 glMatrixMode(GL_MODELVIEW);
252 glMatrixMode(GL_TEXTURE);
254 glMatrixMode(GL_MODELVIEW);
264 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT,
fFrameBuffer);
303 glGenRenderbuffersEXT(1, &
id);
304 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,
id);
311 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT,
fMSSamples, format,
fW,
fH);
315 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format,
fW,
fH);
318 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, type, GL_RENDERBUFFER_EXT,
id);
330 glGenTextures(1, &
id);
332 glBindTexture(GL_TEXTURE_2D,
id);
333 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
334 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
335 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
336 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
337 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
fW,
fH, 0, GL_RGBA,
338 GL_UNSIGNED_BYTE,
NULL);
340 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
341 GL_TEXTURE_2D,
id, 0);
static void SetRescaleToPow2(Bool_t r)
Set state of fgRescaleToPow2 static member.
UInt_t CreateAndAttachRenderBuffer(Int_t format, Int_t type)
UInt_t CreateAndAttachColorTexture()
Initialize color-texture and attach it to current FB.
void Unbind()
Unbind the frame-buffer object.
void Bind()
Bind the frame-buffer object.
virtual ~TGLFBO()
Destructor.
Double_t Log2(Double_t x)
void Release()
Release the allocated GL resources.
static std::string format(double x, double y, int digits, int width)
static Bool_t GetRescaleToPow2()
Return state of fgRescaleToPow2 static member.
void Info(const char *location, const char *msgfmt,...)
void Init(int w, int h, int ms_samples=0)
Acquire GL resources for given width, height and number of multi-sampling samples.
char * Form(const char *fmt,...)
static Bool_t fgMultiSampleNAWarned
void BindTexture()
Bind texture.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
void UnbindTexture()
Unbind texture.
static Bool_t fgRescaleToPow2
Int_t CeilNint(Double_t x)