Re: FxPlug / OpenGL Smooth Line Artifact
site_archiver@lists.apple.com Delivered-To: pro-apps-dev@lists.apple.com On Oct 17, 2008, at 5:10 PM, George King wrote: Thanks, George King glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); Darrin -- Darrin Cardani dcardani@apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/site_archiver%40lists.ap... I am seeing an odd artifact in my FxPlug OpenGL context when I draw a white line on a white background using GL_LINE_SMOOTH. In my test app that uses an NSOpenGL context (with no multisampling), i get pure white. However, when I run the same code in my FxPlug, I get dark artifacts where the line is blending. It looks as though the smooth line rasterizer is fading the color to black as the alpha fades to zero. As an example, take a white line with a small positive slope (almost horizontal). If I disable GL_BLEND, then I see two series of horizontal gradients in a staircase pattern, fading white to black and black to white. If I enable GL_BLEND, then the alpha for each gradient goes to zero as the color goes to black, leaving semi-transparent dark spots for every pixel of vertical rise. I hope that makes some sense! Attached are a few screen shots which should make the problem apparent. Note that this is not affected by glBlendColor, or the GL_TEXTURE_ENV_COLOR; changing either of those does not alter the black coloring. The problem occurs with and without texturing. Below is example code that can be pasted directly into the default FxFilter Xcode project. Insert it just before the glPopAttrib() call. You should also change *canRenderSoftware to NO to force OpenGL use. I'm hoping that I'm just missing some gl state call, but I've been scouring the red book all day to no avail. Let me know if I should post this to the OpenGL list too; I thought I'd ask here first since it works in regular contexts. I think the above is your problem. Since colors in OpenGL are already premultiplied, I think you want to use: Otherwise, you're applying the source alpha twice to the line color. I've always found this really confusing, too, fwiw. This email sent to site_archiver@lists.apple.com
participants (1)
-
Darrin Cardani