harsha

08-30-2013, 05:34 AM

Searched a lot but not getting now :(

I am passing GLushort half_float values to shader as :

const GLushort iValueSize[4] = {0x3C00, 0x7BFF, 0x0400, 0x8000};

glEnableVertexAttribArray(0);

glVertexAttribPointer(0, 1, GL_HALF_FLOAT, GL_FALSE, 0, iValueSize)

Vertex Shader as follows:

precision mediump float;

in mediump vec4 TestVector; // have bound loaction 0

out vec4 FragColor;

void main(void)

{

vec4 RefValue;

bool bCorrect = true;

RefValue.x = uintBitsToFloat(uint(0x3C00));

RefValue.y = uintBitsToFloat(uint(0x7BFF));

RefValue.z = uintBitsToFloat(uint(0x0400));

RefValue.w = uintBitsToFloat(uint(0x8000));

// if(TestVector.x==1.0) //passes

if(TestVector == RefValue) // failes

bCorrect = true;

if (bCorrect)

FragColor = vec4(0.0, 1.0, 0.0, 1.0); // Green (correct)

else

FragColor = vec4(1.0, 0.0, 0.0, 1.0); // Red (incorrect)

}

The rendered color is always RED.

Did lot of debugging but no getting why it is failing.

Is it valid to get float value from uint using uintBitsToFloat(uint(0x3C00)) ?

Thanks.

I am passing GLushort half_float values to shader as :

const GLushort iValueSize[4] = {0x3C00, 0x7BFF, 0x0400, 0x8000};

glEnableVertexAttribArray(0);

glVertexAttribPointer(0, 1, GL_HALF_FLOAT, GL_FALSE, 0, iValueSize)

Vertex Shader as follows:

precision mediump float;

in mediump vec4 TestVector; // have bound loaction 0

out vec4 FragColor;

void main(void)

{

vec4 RefValue;

bool bCorrect = true;

RefValue.x = uintBitsToFloat(uint(0x3C00));

RefValue.y = uintBitsToFloat(uint(0x7BFF));

RefValue.z = uintBitsToFloat(uint(0x0400));

RefValue.w = uintBitsToFloat(uint(0x8000));

// if(TestVector.x==1.0) //passes

if(TestVector == RefValue) // failes

bCorrect = true;

if (bCorrect)

FragColor = vec4(0.0, 1.0, 0.0, 1.0); // Green (correct)

else

FragColor = vec4(1.0, 0.0, 0.0, 1.0); // Red (incorrect)

}

The rendered color is always RED.

Did lot of debugging but no getting why it is failing.

Is it valid to get float value from uint using uintBitsToFloat(uint(0x3C00)) ?

Thanks.