If you want rendering to leave the green and blue components in the framebuffer unchanged, use glColorMask(). It’s not possible to achieve the same result using a fragment shader, as the fragment shader can’t control which components are written, and can’t read from the framebuffer directly (although you could make a copy of the framebuffer as a texture and have the fragment shader read from that).
I’m sorry, I’m sure I’m missing something. I used color masking this allow only my fragment shader to update red color wich is what I want but glDrawArray can’t set Green and Blue from my color buffer when I do that.
glColorPointer(3, GL_FLOAT, 0, color_buffer_);
glVertexPointer(3,GL_FLOAT, 0, faces_);// Vertex Pointer to triangle array
glNormalPointer(GL_FLOAT, 0, normale_); // Normal pointer to normal array
glDrawArrays(GL_TRIANGLES, 0, totalconnectedtriangles_);
How can i specify color masking for olny my fragment shader attached ?
OK, at some point in your render loop, you bind the program for use (with glUseProgram). Following this call, you make some rendering calls. And during those rendering calls, you want to write only to the red color. At some later point in your render loop, you bind a different program. Then you make other rendering calls. And during those calls, you want to write to all color channels.
So you do that. When you bind the program that you only want to write to the red color channel, you set the color mask to write only red. When you bind a different program, you change the color mask back.