View Full Version : Use fragment shader to set olny one color channel instead of 3

11-10-2015, 01:16 AM

I would like to set colors firstly with my color_buffer_

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_);

and then my fragment shader only to change the red value of my texture

#version 410
layout(location = 0) out vec3 color_out;
precision highp float;

void main()
float z = 0.3f;
color_out = vec3(z, green_value_from_color_pointer(NO CHANGE) , blue_value_from_color_pointer(NO CHANGE))

Actually my fragment shader is able to set all the colors but I want to set only the red one.
Any help will appreciated if you have an idea :)

EDIT: please mod delete this thread I post it in the right section now :)

11-10-2015, 01:46 AM
Take look at glColorMask...