Please do not reply to this email: if you want to comment on the bug, go to
the URL shown below and enter yourcomments there.
https://bugs.freedesktop.org/show_bug.cgi?id=4991
Summary: glReadPixels with 16 bits per channel - truncation error
Product: Mesa
Version: CVS
Platform: PC
OS/Version: Windows 2000
Status: NEW
Severity: minor
Priority: P4
Component: Mesa core
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
While using glReadPixels at 16 bits per channel we discovered that pixel values
are often decremented by 1 when read from the frame buffer. This was found to
be because the read routines called a generic function to read a row of pixels.
The data was converted to float values using the macro CHAN_TO_FLOAT defined in
colormac.h. These values were subsequently converted back to unsigned short
using the macro FLOAT_TO_USHORT defined in macros.h.
So, for a pixel value of 2, the first conversion gave a float value of 3.0518E-
5. On using the second macro the first stage is a multiplication of the stored
value by 65535 to give a value of about 1.999997. This is then truncated to
give a result of 1.
I corrected the problem for my own use by redefining this macro as below.
#define FLOAT_TO_USHORT(X) ((GLushort) (GLint) ((X) * 65535.0F + 1.0E-6F))
This then gives the correct values.
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev