예제 #1
0
//--------------------------------------------------------------
void ofShader::end()  const{
	ofGetGLRenderer()->unbind(*this);
}
예제 #2
0
//----------------------------------------
void ofDisableSeparateSpecularLight(){
    ofGetGLRenderer()->disableSeparateSpecularLight();
}
예제 #3
0
//----------------------------------------------------------
void ofTexture::unbind(int textureLocation) const{
	ofGetGLRenderer()->unbind(*this,textureLocation);
}
예제 #4
0
//----------------------------------------
void ofLight::setAmbientColor(const ofFloatColor& c) {
	data->ambientColor = c;
	ofGetGLRenderer()->setLightAmbientColor(data->glIndex, c);
}
예제 #5
0
//----------------------------------------
void ofLight::setSpecularColor(const ofFloatColor& c) {
	data->specularColor = c;
	ofGetGLRenderer()->setLightSpecularColor(data->glIndex, c);
}
예제 #6
0
//----------------------------------------
void ofLight::setSpotlightCutOff( float spotCutOff ) {
    data->spotCutOff = CLAMP(spotCutOff, 0, 90);
    ofGetGLRenderer()->setLightSpotlightCutOff(data->glIndex, spotCutOff);
}
예제 #7
0
//----------------------------------------
void ofLight::setSpotConcentration( float exponent ) {
    data->exponent = CLAMP(exponent, 0, 128);
	ofGetGLRenderer()->setLightSpotConcentration(data->glIndex, exponent);
}
예제 #8
0
//------------------------------------
void ofVideoPlayer::unbind() const{
	shared_ptr<ofBaseGLRenderer> renderer = ofGetGLRenderer();
	if(renderer){
		renderer->unbind(*this);
	}
}
예제 #9
0
//----------------------------------------
void ofSetSmoothLighting(bool b) {
	ofGetGLRenderer()->setSmoothLighting(b);
}
예제 #10
0
//--------------------------------------------------------------
void ofVbo::drawInstanced(int drawMode, int first, int total, int primCount) const{
	ofGetGLRenderer()->drawInstanced(*this,drawMode,first,total,primCount);
}
예제 #11
0
//--------------------------------------------------------------
void ofVbo::drawElementsInstanced(int drawMode, int amt, int primCount) const{
	ofGetGLRenderer()->drawElementsInstanced(*this,drawMode,amt,primCount);
}
예제 #12
0
//--------------------------------------------------------------
void ofVbo::drawElements(int drawMode, int amt, int offsetelements) const{
	ofGetGLRenderer()->drawElements(*this,drawMode,amt,offsetelements);
}
예제 #13
0
//--------------------------------------------------------------
void ofVbo::draw(int drawMode, int first, int total) const{
	ofGetGLRenderer()->draw(*this,drawMode,first,total);
}
예제 #14
0
void ofTexture::disableTextureTarget(int textureLocation) const{
	if(ofGetGLRenderer()) ofGetGLRenderer()->disableTextureTarget(texData.textureTarget, textureLocation);
}
예제 #15
0
//--------------------------------------------------------------
void ofFbo::allocate(Settings _settings) {
	if(!checkGLSupport()) return;

	clear();
	auto renderer = _settings.renderer.lock();
	if(renderer){
		settings.renderer = renderer;
	}else{
		settings.renderer = ofGetGLRenderer();
	}

	// check that passed values are correct
	if(_settings.width <= 0 || _settings.height <= 0){
		ofLogError("ofFbo") << "width and height have to be more than 0";
	}
	if(_settings.numSamples > maxSamples() && maxSamples() > -1) {
		ofLogWarning("ofFbo") << "allocate(): clamping numSamples " << _settings.numSamples << " to maxSamples " << maxSamples() << " for frame buffer object" << fbo;
		_settings.numSamples = maxSamples();
	}

	if(_settings.depthStencilAsTexture && _settings.numSamples){
		ofLogWarning("ofFbo") << "allocate(): multisampling not supported with depthStencilAsTexture, setting 0 samples for frame buffer object " << fbo;
		_settings.numSamples = 0;
	}

	//currently depth only works if stencil is enabled. 
	// http://forum.openframeworks.cc/index.php/topic,6837.0.html
#ifdef TARGET_OPENGLES
	if(_settings.useDepth){
	  	_settings.useStencil = true;
	}
    if( _settings.depthStencilAsTexture ){
        _settings.depthStencilAsTexture = false;
        ofLogWarning("ofFbo") << "allocate(): depthStencilAsTexture is not available for iOS";
    }
#endif
    
	GLenum depthAttachment = GL_DEPTH_ATTACHMENT;

	if( _settings.useDepth && _settings.useStencil ){
		_settings.depthStencilInternalFormat = GL_DEPTH_STENCIL;
		#ifdef TARGET_OPENGLES
			depthAttachment = GL_DEPTH_ATTACHMENT;
		#else
			depthAttachment = GL_DEPTH_STENCIL_ATTACHMENT;
		#endif
	}else if(_settings.useDepth){
		depthAttachment = GL_DEPTH_ATTACHMENT;
	}else if(_settings.useStencil){
		depthAttachment = GL_STENCIL_ATTACHMENT;
		_settings.depthStencilInternalFormat = GL_STENCIL_INDEX;
	}

	// set needed values for allocation on instance settings
	// the rest will be set by the corresponding methods during allocation
	settings.width = _settings.width;
	settings.height = _settings.height;
	settings.numSamples = _settings.numSamples;

	// create main fbo
	// this is the main one we bind for drawing into
	// all the renderbuffers are attached to this (whether MSAA is enabled or not)
	glGenFramebuffers(1, &fbo);
	retainFB(fbo);

	GLint previousFboId = 0;

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

	glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFboId);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);

	//- USE REGULAR RENDER BUFFER
	if(!_settings.depthStencilAsTexture){
		if(_settings.useDepth && _settings.useStencil){
			stencilBuffer = depthBuffer = createAndAttachRenderbuffer(_settings.depthStencilInternalFormat, depthAttachment);
			retainRB(stencilBuffer);
			retainRB(depthBuffer);
		}else if(_settings.useDepth){
			depthBuffer = createAndAttachRenderbuffer(_settings.depthStencilInternalFormat, depthAttachment);
			retainRB(depthBuffer);
		}else if(_settings.useStencil){
			stencilBuffer = createAndAttachRenderbuffer(_settings.depthStencilInternalFormat, depthAttachment);
			retainRB(stencilBuffer);
		}
	//- INSTEAD USE TEXTURE
	}else{
		if(_settings.useDepth || _settings.useStencil){
			createAndAttachDepthStencilTexture(_settings.textureTarget,_settings.depthStencilInternalFormat,depthAttachment);
			#ifdef TARGET_OPENGLES
				// if there's depth and stencil the texture should be attached as
				// depth and stencil attachments
				// http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt
				if(_settings.useDepth && _settings.useStencil){
					glFramebufferTexture2D(GL_FRAMEBUFFER,
										   GL_STENCIL_ATTACHMENT,
										   GL_TEXTURE_2D, depthBufferTex.texData.textureID, 0);
				}
			#endif
		}
	}
    
    settings.useDepth = _settings.useDepth;
    settings.useStencil = _settings.useStencil;
    settings.depthStencilInternalFormat = _settings.depthStencilInternalFormat;
    settings.depthStencilAsTexture = _settings.depthStencilAsTexture;
    settings.textureTarget = _settings.textureTarget;
    settings.wrapModeHorizontal = _settings.wrapModeHorizontal;
    settings.wrapModeVertical = _settings.wrapModeVertical;
    settings.maxFilter = _settings.maxFilter;
    settings.minFilter = _settings.minFilter;

	// if we want MSAA, create a new fbo for textures
	#ifndef TARGET_OPENGLES
		if(_settings.numSamples){
			glGenFramebuffers(1, &fboTextures);
			retainFB(fboTextures);
		}else{
			fboTextures = fbo;
		}
	#else
		fboTextures = fbo;
		if(_settings.numSamples){
			ofLogWarning("ofFbo") << "allocate(): multisampling not supported in OpenGL ES";
		}
	#endif

	// now create all textures and color buffers
	if(_settings.colorFormats.size() > 0) {
		for(int i=0; i<(int)_settings.colorFormats.size(); i++) createAndAttachTexture(_settings.colorFormats[i], i);
	} else if(_settings.numColorbuffers > 0) {
		for(int i=0; i<_settings.numColorbuffers; i++) createAndAttachTexture(_settings.internalformat, i);
		_settings.colorFormats = settings.colorFormats;
	} else {
		ofLogWarning("ofFbo") << "allocate(): no color buffers specified for frame buffer object " << fbo;
	}
	settings.internalformat = _settings.internalformat;
	
	dirty.resize(_settings.colorFormats.size(), true); // we start with all color buffers dirty.

	// if textures are attached to a different fbo (e.g. if using MSAA) check it's status
	if(fbo != fboTextures) {
		glBindFramebuffer(GL_FRAMEBUFFER, fboTextures);
	}

	// check everything is ok with this fbo
	bIsAllocated = checkStatus();

	// restore previous framebuffer id
	glBindFramebuffer(GL_FRAMEBUFFER, previousFboId);

    /* UNCOMMENT OUTSIDE OF DOING RELEASES
	
    // this should never happen
	if(settings != _settings) ofLogWarning("ofFbo") << "allocation not complete, passed settings not equal to created ones, this is an internal OF bug";
    
    */
#ifdef TARGET_ANDROID
	ofAddListener(ofxAndroidEvents().reloadGL,this,&ofFbo::reloadFbo);
#endif
}
예제 #16
0
//----------------------------------------
void ofSetGlobalAmbientColor(const ofFloatColor& c) {
	ofGetGLRenderer()->setGlobalAmbientColor(c);
	globalAmbient = c;
}
예제 #17
0
//----------------------------------------
void ofLight::disable() {
	data->isEnabled = false;
	ofGetGLRenderer()->disableLight(data->glIndex);
}
예제 #18
0
void ofGrabScreen(ofPixels & p, int x, int y, int w, int h){
	std::shared_ptr<ofBaseGLRenderer> renderer = ofGetGLRenderer();
	if(renderer){
		renderer->saveScreen(x,y,w,h,p);
	}
}
예제 #19
0
//----------------------------------------
void ofEnableLighting() {
	ofGetGLRenderer()->enableLighting();
}
예제 #20
0
void ofMaterial::begin() const{
	if(ofGetGLRenderer()){
		ofGetGLRenderer()->bind(*this);
	}
}
예제 #21
0
//----------------------------------------
void ofDisableLighting() {
	ofGetGLRenderer()->disableLighting();
}
예제 #22
0
void ofMaterial::end() const{
	if(ofGetGLRenderer()){
		ofGetGLRenderer()->unbind(*this);
	}
}
예제 #23
0
//----------------------------------------
void ofLight::setDiffuseColor(const ofFloatColor& c) {
	data->diffuseColor = c;
	ofGetGLRenderer()->setLightDiffuseColor(data->glIndex, c);
}
예제 #24
0
void ofTexture::disableTextureTarget(){
	if(ofGetGLRenderer()) ofGetGLRenderer()->disableTextureTarget(texData.textureTarget);
}
예제 #25
0
//----------------------------------------
void ofEnableSeparateSpecularLight(){
	ofGetGLRenderer()->enableSeparateSpecularLight();
}
예제 #26
0
//--------------------------------------------------------------
void ofShader::begin()  const{
	ofGetGLRenderer()->bind(*this);
}
예제 #27
0
//----------------------------------------
bool ofGetLightingEnabled() {
	return ofGetGLRenderer()->getLightingEnabled();
}
예제 #28
0
//----------------------------------------------------------
void ofTexture::drawSubsection(float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const{
	shared_ptr<ofBaseGLRenderer> renderer = ofGetGLRenderer();
	if(renderer){
		renderer->draw(*this,x,y,z,w,h,sx,sy,sw,sh);
	}
}