Skip to content

Smoothing and additive blending #1546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sebleedelisle opened this issue Sep 6, 2012 · 4 comments
Open

Smoothing and additive blending #1546

sebleedelisle opened this issue Sep 6, 2012 · 4 comments

Comments

@sebleedelisle
Copy link
Contributor

Hi guys!

I'm not sure why but as soon as you enable smoothing, additive blending is disabled. In fact I think someone on the team is also unsure - see the comment "why do we need this?" in libs/openFrameworks/gl/ofGLRenderer.cpp :)

//----------------------------------------------------------
void ofGLRenderer::startSmoothing(){
    #ifndef TARGET_OPENGLES
        glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT);
    #endif

    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    glEnable(GL_LINE_SMOOTH);

    //why do we need this?
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

I commented it out and it seemed to work OK, but I'm sure there are other repercussions. But it would be nice to have smoothing and blendmodes.

cheers
Seb

@thiagohersan
Copy link
Contributor

I think I read somewhere that you need GL_BLEND enabled in order for GL_LINE_SMOOTH to work.

But I am also having some problems with this. And was going to suggest some kind of internal state-keeping for the blend mode, instead of using pushAttrib/popAttrib.

Do we lose efficiency? Having to check if some kind of blending is already enabled, instead of pushing/popping attribs every time?

@ofTheo
Copy link
Member

ofTheo commented Sep 10, 2012

@sebleedelisle you're right this is a bug of sorts.
we should check if blending is currently enabled and if so, not set a different blend mode.

we can do this if blending is set through the ofEnableBlendMode method. If you are using OpenGL directly then it won't work and you might still have an issue.

An easier way to solve your problem, is just to do ofEnableSmoothing() at the beginning of your app and then do your additive blending calls any point after that.

@bakercp
Copy link
Member

bakercp commented Nov 14, 2012

@obviousjim @ofTheo could this be related to this #1623 ?

@armadillu
Copy link
Contributor

Yep I just wasted quite a few hours on this; if ofEnableSmoothing() has been called at any time, every draw call (to ofMesh, etc) re-sets the blending mode. This is particularly painful if you are doing pingpong shaders as every fbo->draw() re-enables the blending and gives very bizarre results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants