Jump to content
  • Advertisement
Sign in to follow this  
hannibar

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!