Thomas Kostas
Thomas Kostas

Reputation: 455

fragment shader and glDrawArrays

is it possible to use fragment shader to set one color channel of a rendering and

glColorPointer(...);
glDrawArray();

to set the 2 others colors channels. If yes how can I do that ?

Upvotes: 0

Views: 589

Answers (1)

ratchet freak
ratchet freak

Reputation: 48196

If you are stepping to the programmable pipeline then I also suggest stepping away from glColorPointer glVertexPointer and the matrix stack and instead use glVertexAttribPointer and pass the transformation matrices as uniforms.

In the fragment shader you would do

gl_FragColor = vec4(channel1, channels2_3.xy, 1);

Where channel1 and channel2_3 can come from either a uniform or a attribute passed from the vertex shader.

Upvotes: 3

Related Questions