#version 400
//#version 330 core

varying vec2 texCoord;
//varying vec4 vColor;
uniform sampler2D colorMap;
uniform int abc;

/*
void main (void)
{
	gl_FragColor = texture2D(colorMap, texCoord);
}
*/
//uniform mat4 depthMVP;

void main (void)
{
//    gl_FragColor = vec4(vec3(gl_FragCoord.w),1.0f);
/*
    float depth=gl_FragCoord.w;
    double x2=depth*(65536*65536);
    double r2=floor(x2/(65536*256)); x2=x2-r2*(65536*256);
    double g2=floor(x2/(256*256)); x2=x2-g2*(256*256);
    double b2=floor(x2/(256)); x2=x2-b2*(256);
    double a2=x2;
    float r1=float(r2/256.0f);
    float g1=float(g2/256.0f);
    float b1=float(b2/256.0f);
    float a1=float(a2/256.0f);

    gl_FragColor = vec4(r1,g1,b1,1.0f);
*/
    float depth=gl_FragCoord.w;
    double x2=depth*256*256;
    double r2=floor(x2/double(256.0)); x2=x2-r2*double(256.0);
    double g2=x2;
    float r1=float(r2/256.0f);
    float g1=float(g2/256.0f);

    gl_FragColor = vec4(r1,g1,0.0f,1.0f);
}

/*
// Ouput data
//layout (location = 0) out float fragmentdepth;
out float fragmentdepth;

void main(){
    // Not really needed, OpenGL does it anyway
    fragmentdepth = gl_FragCoord.z;

    gl_FragColor = vec4(gl_FragCoord.z,gl_FragCoord.z,gl_FragCoord.z,1.0f);//texture2D(colorMap, texCoord);
}
*/
