I am want to using blendmode like photoshop,and see https://www.slideshare.net/Mark_Kilgard/blend-modes-for-opengl, how to add extensions to cinder framework?
Thanks!
I am want to using blendmode like photoshop,and see https://www.slideshare.net/Mark_Kilgard/blend-modes-for-opengl, how to add extensions to cinder framework?
Thanks!
I use a fragment shader for this, here is an example
I bind two textures to this fragment shader and use a “iBlendMode” uniform variable to choose from the 25 blend modes.
Hi Gaoyu,
as you can see in the [cinder_root]/include/glload/_int_gl_exts.hpp file, the extension and its functions and enums are already defined. This file is automatically included for you, so you can readily use them in your application, as long as your GPU supports the extension. The extension requires a recent version of OpenGL, so you may be out of luck on the Mac OSX platform, but I can confirm that they are available on my Windows machine.
Note that the functions are glBlendParameteriNV
and glBlendBarrierNV
.
To check if the extension is available on your (target) machine, use the following code snippet:
if( ! ( gl::isExtensionAvailable( "gl_khr_blend_equation_advanced" ||
gl::isExtensionAvailable( "gl_nv_blend_equation_advanced" ) ) )
{
CI_LOG_E( "Oopsy, a required extension (blend_equation_advanced) is not
supported by this machine. Try installing the latest GPU driver." );
}
If the extension is not supported, the code provided by @brucelane should give you a pretty awesome solution to fall back on.
-Paul
@paul.houx
you are right. Thankyou.
I use
gl::enableBlending(true)
glBlendEquation(XX)
@paul.houx
how to cancel glBlendEquation ?
Not sure, I’ve never used it, but I would assume a call to gl::disableBlending()
or setting a different blend mode (e.g. gl::enableAlphaBlending()
, gl::enableAlphaBlendingPremult()
or gl::enableAdditiveBlending()
) would do the trick.
use glBlendEquation(GL_FUNC_ADD)