OpenGL Pixel Pollution

opengl

#1

Hey, I’m in a situation where I’m drawing into our plugin’s visualizer component by first drawing into an offscreen image and then drawing that image into the graphics context during paint. When OpenGL is enabled on our plugin we’re occasionally getting these weird side-glow issues, as if the image that I’m rendering into is getting pixels from outside it’s bounds from different parts of the interface. See the bottom right orange glow in the screenshot or the red in the second one.

You’ll notice that the side-glow is the color of other features on the interface (that I’m not actually drawing into the image manually). I’ve tracked this down to only happening when OpenGL is the rendering engine so it must be something there. Just wondering if anyone has seen stuff like this and if there’s a way to fix it? It would make some sense to me that since we’re drawing into the image by first getting its Graphics context, then that would be the same context as the rest of the interface (when using GL) and therefore maybe pixels are being contaminated.

For context, what we’re doing is drawing the waveform into an image normally, then drawing that image into a separate image that’s 1/8 the size, then drawing the small image stretched out to 8x its actual size. This is a hacky fast way to create a “glow” around the waveform.

for reference the code looks basically like this:

	blurImage.clear(blurImage.getBounds());
	Graphics blurGraphic(blurImage);

	//draw the level image squeezed into the blur image
	blurGraphic.drawImage(levelImage, 0, 0, blurImage.getWidth(), blurImage.getHeight(), 0, 0, levelImage.getWidth(), levelImage.getHeight(), false);

	//draw the small image stretched out onto the main graphic
	g.drawImage(blurImage, 0, 0, getWidth(), getHeight(), 0, 0, blurImage.getWidth(), blurImage.getHeight(), false);
	
	//draw the main image onto the main graphic
	g.drawImage(levelImage, 0, 0, getWidth(), getHeight(), 0, 0, getWidth(), getHeight(), false);

glowIssue2