simulate DirectX texture op: D3DTOP_MULTIPLYADD

Do anyone know how to implement or simulate one of Direct3D’s texture operation: D3DTOP_MULTIPLYADD using opengl fixed function?

D3DTOP_MULTIPLYADD from MSDN:
Performs a multiply-accumulate operation. It takes the last two arguments, multiplies them together, and adds them to the remaining input/source argument, and places that into the result.

SRGBA = Arg1 + Arg2 * Arg3

To simulate D3DTOP_MULTIPLYADD using fixed function is not easy, maybe impossible. I was missing this to some time ago, too.

However, there are two ways:

  1. Do you really need D3DTOP_MULTIPLYADD? What ever you are trying to do, maybe it is possible to do that without D3DTOP_MULTIPLYADD?

  2. When using shaders this would be an single line of code. If shaders are an option…