Public Group

# openGL problem with floats

This topic is 5400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a problem with openGL and the use of floats. Take a look at this piece of code for example
glColor3f(0.900, 0.550, 0.300);
MSVC6 gives these warnings : C:\Documents and Settings\Hans Packet\Mijn documenten\Mijn Spullen\Programmeren\Gui_Test\LijnTest\draw.cpp(11) : warning C4305: 'argument' : truncation from 'const double' to 'float' C:\Documents and Settings\Hans Packet\Mijn documenten\Mijn Spullen\Programmeren\Gui_Test\LijnTest\draw.cpp(11) : warning C4305: 'argument' : truncation from 'const double' to 'float' The numbers I use are floats. I don't know what causes the warnings. Although I know these are just warnings, and that I can just ignore them, I like a clean build without warnings. Thanks in advance

##### Share on other sites
That's because you're passing double arguments to a function that expects floats. It should be one of these:

glColor3d(0.900, 0.550, 0.300); // pass doubles to double function
glColor3f(0.900f, 0.550f, 0.300f); // pass floats to float function

-RC

• 21
• 16
• 9
• 17
• 13