How do I perform resampling for anti-aliasing using dFdx() and dFdy() functions? [duplicate]

  antialiasing, c++, glsl, opengl, texture-mapping

I have a main.cpp, a fragment shader, and a vertex shader. The fragment shader takes 2 images as input as well as a Maya object. My fragment shader.glsl code is below for reference:

#version 410

// Inputs from application.
// Generally, "in" like the eye and normal vectors for things that change frequently,
// and "uniform" for things that change less often (think scene versus vertices).  
in vec3 position_eye, normal_eye;
uniform mat4 view_mat;

// This light setup would usually be passed in from the application.
vec3 light_position_world  = vec3 (10.0, 25.0, 10.0);
vec3 Ls = vec3 (1.0, 1.0, 1.0);    // neutral, full specular color of light
vec3 Ld = vec3 (0.8, 0.8, 0.8);    // neutral, lessened diffuse light color of light
vec3 La = vec3 (0.12, 0.12, 0.12); // ambient color of light - just a bit more than dk gray bg

// Surface reflectance properties for Phong or Blinn-Phong shading models below.
vec3 Ks = vec3 (1.0, 1.0, 1.0);    // fully reflect specular light
vec3 Kd = vec3 (0.32, 0.18, 0.5);  // purple diffuse surface reflectance
vec3 Ka = vec3 (1.0, 1.0, 1.0);    // fully reflect ambient light
float specular_exponent = 400.0;   // specular 'power' -- controls "roll-off"

// These come from the VAO for texture coordinates.
in vec2 texture_coords;

// And from the uniform outputs for the textures setup in main.cpp.
uniform sampler2D texture00;
uniform sampler2D texture01;

out vec4 fragment_color;           // color of surface to draw

void main () 
    // Ambient intensity
    vec3 Ia = La * Ka;

    // These next few lines sample the current texture coord (s, t) in texture00 and 01 and mix.
    vec4 texel_a = texture (texture00, fract(texture_coords*2.0));
    vec4 texel_b = texture (texture01, fract(texture_coords*2.0));
    //vec4 mixed   = mix (texel_a, texel_b, texture_coords.x);
    vec4 mixed   = mix (texel_a, texel_b, texture_coords.x);
    Kd.x = mixed.x;
    Kd.y = mixed.y;
    Kd.z = mixed.z; 

    // Transform light position to view space.
    // Vectors here are appended with _eye as a reminder once in view space versus world space.
    vec3 light_position_eye = vec3 (view_mat * vec4 (light_position_world, 1.0));
    vec3 distance_to_light_eye = light_position_eye - position_eye;
    vec3 direction_to_light_eye = normalize (distance_to_light_eye);

    // Diffuse intensity
    float dot_prod = dot (direction_to_light_eye, normal_eye);
    dot_prod = max (dot_prod, 0.0);
    vec3 Id = Ld * Kd * dot_prod; // final diffuse intensity

    // Specular is view dependent; get vector toward camera.
    vec3 surface_to_viewer_eye = normalize (-position_eye);

    // Blinn
    vec3 half_way_eye = normalize (surface_to_viewer_eye + direction_to_light_eye);
    float dot_prod_specular = max (dot (half_way_eye, normal_eye), 0.0);
    float specular_factor = pow (dot_prod_specular, specular_exponent);

    // Specular intensity
    vec3 Is = Ls * Ks * specular_factor; // final specular intensity

    // final color
    fragment_color = vec4 (Is + Id + Ia, 1.0);

I am being asked to modify this code using the dFdx() and dFdy() functions to make the code perform resampling for anti-aliasing but I am lost on where I should implement the functions in my code. Also, I am unclear on what these functions purposes are. Can someone walk me through this?

Source: Windows Questions C++