jmasterx
jmasterx

Reputation: 54133

Subtractive blending with OpenGL?

I would like to for example draw shapes A, B, C then set the blender, then draw shape D and everywhere where shape D is, the scene shows my background color of (1,1,1,0). Thanks

Upvotes: 1

Views: 1145

Answers (3)

Calvin1602
Calvin1602

Reputation: 9547

Much simpler than other answers :

  • Display shapes A, B and C the normal way
  • glDisable(GL_DEPTH_TEST);
  • glDisable(GL_ALPHA_TEST);
  • glDisable(GL_BLEND);
  • Display shape D with color (1,1,1,0)

and you're done.

Upvotes: 0

Dr. Snoopy
Dr. Snoopy

Reputation: 56377

glBlendEquation can do it.

Upvotes: -1

Jerry Coffin
Jerry Coffin

Reputation: 490398

I'm not aware of that being possible directly. There are a few possibilities to get the same effect though. The cleanest would probably be to start by filling the stencil buffer with 1's, then drawing shape D into the stencil buffer with 0's, then draw everything else (with the stencil buffer enabled, of course).

Upvotes: 4

Related Questions