 |
» |
|
|
 |
Query Data Values |  |
Attributes are stored within IVL in the machine type that is used during
processing. Some state attributes are stored as floats, some as integers, some
as boolean values, etc. With some IVL routines, applications can specify a
state attribute as either a float or an integer (for example,
glColorTableParameterfvEXT and glColorTableParameterivEXT). In such
cases, IVL converts and stores the passed value in the machine type that is
used during processing.
It is considered good programming practice to query data values using the
routine that corresponds to the data type of the value being queried. For
instance, if you know you are querying an integer value, use the
glGetIntegerv routine. Where necessary, the glGet routines will
convert the requested value to the machine type specified by the routine. If
the requested state attribute has a different type than is requested, it will
be converted as follows:
If a boolean value is to be returned, floating point and integer values
are converted to GL_FALSE if and only if they have a value of zero.
Otherwise, they are converted to GL_TRUE.
If an integer is to be returned and the requested state attribute is a
boolean, the returned value will be either GL_TRUE or
GL_FALSE.
If an integer is to be returned and the attribute is a floating point
value, it will be rounded to the nearest integer unless it is a color (RGBA)
value. In this case, the individual components will be mapped from their
permissible floating point range of [-1.0, 1.0] to the full range of
allowable integer values (-1.0 maps to the largest representable
negative integer, 0.0 maps to 0, 1.0 maps to the largest representable
positive integer).
If a float or a double is to be returned, boolean state attributes are
returned as GL_TRUE or GL_FALSE and integer values are
coerced to floating point values.
See the glGet reference page
for a list of values that can be queried.
Image Data Formatting |  |
If you are calling
glDrawPixels with 12-bit
image data stored as 16-bit values, you might be tempted to think that you
only need to load a look-up table that contains 4096 entries. However, IVL has
no way of knowing that only 12 bits out of the 16 are significant. If you
create a look-up table with 4096 entries, IVL will (conceptually, at least)
map each incoming 16-bit value to a float in the range [0,1]. The resulting
value will then be multiplied by 4095 in order to compute the look-up table
index. Thus, your incoming 12-bit input values will all be mapped into the
first 256 entries of your color table.
One way to compensate for this effect would be to shift all your 12-bit values
up by four bits. Then your 4096-entry color table would provide the expected
results. Alternatively, you can load a full 64K-entry look-up table. If you go
this route, you need to provide all 64K values, but you may only need to
recompute the first 4096 entries, since the others might never be used. In
practice you would be well-advised to load additional entries in the table
since bicubic resampling in the
image transformation stage might generate values that overflow 12 bits.
RGBA Data Format |  |
Remember that GL_RGBA formatted data is stored in the following order:
red, green, blue, then alpha. A common mistake is to format the data as alpha,
red, green, then blue, which is incorrect.
|