Skip to content

Commit d7a3e75

Browse files
committed
ofFbo missing eventutils
1 parent d14688f commit d7a3e75

1 file changed

Lines changed: 30 additions & 29 deletions

File tree

libs/openFrameworks/gl/ofFbo.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <dlfcn.h>
1818
#endif
1919
#ifdef TARGET_ANDROID
20+
#include "ofEventUtils.h"
2021
#include "ofxAndroidUtils.h"
2122
#endif
2223

@@ -35,7 +36,7 @@ using std::vector;
3536

3637
#if defined(TARGET_OPENGLES) & !defined(TARGET_EMSCRIPTEN)
3738
bool ofFbo::bglFunctionsInitialized=false;
38-
39+
3940
typedef void (* glGenFramebuffersType) (GLsizei n, GLuint* framebuffers);
4041
glGenFramebuffersType glGenFramebuffersFunc;
4142
#define glGenFramebuffers glGenFramebuffersFunc
@@ -496,7 +497,7 @@ void ofFbo::destroy() {
496497
//--------------------------------------------------------------
497498
bool ofFbo::checkGLSupport() {
498499
#ifndef TARGET_OPENGLES
499-
500+
500501
if (!ofIsGLProgrammableRenderer()){
501502
if(ofGLCheckExtension("GL_EXT_framebuffer_object")){
502503
ofLogVerbose("ofFbo") << "GL frame buffer object supported";
@@ -535,7 +536,7 @@ void ofFbo::allocate(int width, int height, int internalformat, int numSamples)
535536
settings.height = height;
536537
settings.internalformat = internalformat;
537538
settings.numSamples = numSamples;
538-
539+
539540
#ifdef TARGET_OPENGLES
540541
settings.useDepth = false;
541542
settings.useStencil = false;
@@ -544,10 +545,10 @@ void ofFbo::allocate(int width, int height, int internalformat, int numSamples)
544545
#else
545546
settings.useDepth = true;
546547
settings.useStencil = true;
547-
//we do this as the fbo and the settings object it contains could be created before the user had the chance to disable or enable arb rect.
548-
settings.textureTarget = ofGetUsingArbTex() ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D;
549-
#endif
550-
548+
//we do this as the fbo and the settings object it contains could be created before the user had the chance to disable or enable arb rect.
549+
settings.textureTarget = ofGetUsingArbTex() ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D;
550+
#endif
551+
551552
allocate(settings);
552553
}
553554

@@ -577,7 +578,7 @@ void ofFbo::allocate(ofFboSettings _settings) {
577578
_settings.numSamples = 0;
578579
}
579580

580-
//currently depth only works if stencil is enabled.
581+
//currently depth only works if stencil is enabled.
581582
// http://forum.openframeworks.cc/index.php/topic,6837.0.html
582583
#ifdef TARGET_OPENGLES
583584
if(_settings.useDepth){
@@ -588,7 +589,7 @@ void ofFbo::allocate(ofFboSettings _settings) {
588589
ofLogWarning("ofFbo") << "allocate(): depthStencilAsTexture is not available for iOS";
589590
}
590591
#endif
591-
592+
592593
GLenum depthAttachment = GL_DEPTH_ATTACHMENT;
593594

594595
if( _settings.useDepth && _settings.useStencil ){
@@ -620,8 +621,8 @@ void ofFbo::allocate(ofFboSettings _settings) {
620621
GLint previousFboId = 0;
621622

622623
// note that we are using a glGetInteger method here, which may stall the pipeline.
623-
// in the allocate() method, this is not that tragic since this will not be called
624-
// within the draw() loop. Here, we need not optimise for performance, but for
624+
// in the allocate() method, this is not that tragic since this will not be called
625+
// within the draw() loop. Here, we need not optimise for performance, but for
625626
// simplicity and readability .
626627

627628
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFboId);
@@ -656,7 +657,7 @@ void ofFbo::allocate(ofFboSettings _settings) {
656657
#endif
657658
}
658659
}
659-
660+
660661
settings.useDepth = _settings.useDepth;
661662
settings.useStencil = _settings.useStencil;
662663
settings.depthStencilInternalFormat = _settings.depthStencilInternalFormat;
@@ -696,7 +697,7 @@ void ofFbo::allocate(ofFboSettings _settings) {
696697
#endif
697698
}
698699
settings.internalformat = _settings.internalformat;
699-
700+
700701
dirty.resize(_settings.colorFormats.size(), true); // we start with all color buffers dirty.
701702

702703
// if textures are attached to a different fbo (e.g. if using MSAA) check it's status
@@ -711,10 +712,10 @@ void ofFbo::allocate(ofFboSettings _settings) {
711712
glBindFramebuffer(GL_FRAMEBUFFER, previousFboId);
712713

713714
/* UNCOMMENT OUTSIDE OF DOING RELEASES
714-
715+
715716
// this should never happen
716717
if(settings != _settings) ofLogWarning("ofFbo") << "allocation not complete, passed settings not equal to created ones, this is an internal OF bug";
717-
718+
718719
*/
719720
#ifdef TARGET_ANDROID
720721
ofAddListener(ofxAndroidEvents().reloadGL,this,&ofFbo::reloadFbo);
@@ -757,7 +758,7 @@ GLuint ofFbo::createAndAttachRenderbuffer(GLenum internalFormat, GLenum attachme
757758

758759
//----------------------------------------------------------
759760
void ofFbo::createAndAttachTexture(GLenum internalFormat, GLenum attachmentPoint) {
760-
761+
761762
ofTextureData texData;
762763

763764
texData.textureTarget = settings.textureTarget;
@@ -784,21 +785,21 @@ void ofFbo::attachTexture(ofTexture & tex, GLenum internalFormat, GLenum attachm
784785
GLint temp;
785786
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &temp);
786787
glBindFramebuffer(GL_FRAMEBUFFER, fboTextures);
787-
788+
788789
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachmentPoint, tex.texData.textureTarget, tex.texData.textureID, 0);
789790
if(attachmentPoint >= textures.size()) {
790791
textures.resize(attachmentPoint+1);
791792
}
792793
textures[attachmentPoint] = tex;
793-
794+
794795
settings.colorFormats.resize(attachmentPoint + 1);
795796
settings.colorFormats[attachmentPoint] = internalFormat;
796797
settings.numColorbuffers = settings.colorFormats.size();
797-
798+
798799
// if MSAA, bind main fbo and attach renderbuffer
799800
if(settings.numSamples) {
800801
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
801-
802+
802803
GLuint colorBuffer = createAndAttachRenderbuffer(internalFormat, GL_COLOR_ATTACHMENT0 + attachmentPoint);
803804
colorBuffers.push_back(colorBuffer);
804805
retainRB(colorBuffer);
@@ -817,7 +818,7 @@ void ofFbo::createAndAttachDepthStencilTexture(GLenum target, GLint internalform
817818
depthBufferTex.texData.bFlipTexture = false;
818819
depthBufferTex.texData.width = settings.width;
819820
depthBufferTex.texData.height = settings.height;
820-
821+
821822
depthBufferTex.allocate(depthBufferTex.texData,transferFormat,transferType);
822823

823824
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, target, depthBufferTex.texData.textureID, 0);
@@ -832,7 +833,7 @@ void ofFbo::createAndAttachDepthStencilTexture(GLenum target, GLint internalform
832833
depthBufferTex.texData.bFlipTexture = false;
833834
depthBufferTex.texData.width = settings.width;
834835
depthBufferTex.texData.height = settings.height;
835-
836+
836837
depthBufferTex.allocate(depthBufferTex.texData);
837838

838839
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, target, depthBufferTex.texData.textureID, 0);
@@ -922,10 +923,10 @@ void ofFbo::flagDirty() const{
922923
//
923924
// All currently active draw buffers need to be flagged dirty
924925
//
925-
// If a draw buffer has been activated and then de-activated, it has been
926-
// flagged dirty at activation, so we can be sure all buffers which have
926+
// If a draw buffer has been activated and then de-activated, it has been
927+
// flagged dirty at activation, so we can be sure all buffers which have
927928
// been rendered to are flagged dirty.
928-
//
929+
//
929930
int numBuffersToFlag = std::min(dirty.size(), activeDrawBuffers.size());
930931
for(int i=0; i < numBuffersToFlag; i++){
931932
dirty[i] = true;
@@ -1020,7 +1021,7 @@ ofTexture& ofFbo::getTexture(){
10201021
//----------------------------------------------------------
10211022
ofTexture& ofFbo::getTexture(int attachmentPoint) {
10221023
updateTexture(attachmentPoint);
1023-
1024+
10241025
return textures[attachmentPoint];
10251026
}
10261027

@@ -1111,7 +1112,7 @@ void ofFbo::updateTexture(int attachmentPoint) {
11111112
if(!bIsAllocated) return;
11121113
#ifndef TARGET_OPENGLES
11131114
if(fbo != fboTextures && dirty[attachmentPoint]) {
1114-
1115+
11151116
// if fbo != fboTextures, we are dealing with an MSAA enabled FBO.
11161117
// and we need to blit one fbo into another to see get the texture
11171118
// content
@@ -1125,11 +1126,11 @@ void ofFbo::updateTexture(int attachmentPoint) {
11251126
if(renderer){
11261127
GLint readBuffer;
11271128
glGetIntegerv(GL_READ_BUFFER, &readBuffer);
1128-
1129+
11291130
renderer->bindForBlitting(*this,*this,attachmentPoint);
11301131
glBlitFramebuffer(0, 0, settings.width, settings.height, 0, 0, settings.width, settings.height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
11311132
renderer->unbind(*this);
1132-
1133+
11331134
glReadBuffer(readBuffer);
11341135
}
11351136

0 commit comments

Comments
 (0)