Jump to content
  • Advertisement
Sign in to follow this  
Drag0n

OpenGL OpenGL and double?

This topic is 4883 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

Hi, I've been using OpenGL for some time now. I like the API, it's clean, it's complete and very well designed. However, I've always wondered: Why are lighting and material calculations only possible with floats, respective GLfloats? Just wondering. Everything I do is double-based (for accuracy). Converting to float isn't hard for sure, but why is it neccessary? ;) Cheers, Drag0n

Share this post


Link to post
Share on other sites
Advertisement
probably be cause no graphics card natively supports operations on doubles, they all use floating point value internally (as does the GLSL)

Share this post


Link to post
Share on other sites
You don't need a precision like double for, say materials. I don't think you would see the difference.
Also, if I'm correct, floats are faster than doubles in general.

Share this post


Link to post
Share on other sites
_the_phantom_: If I recall correctly, the values are converted to 80 bit extended precision internally in the GPU. But I might be wrong.

WanMaster: Sure, I don't need the extra precision (at least not for materials and lighting). But there are double-variants of virtually all OpenGL functions, why not for materials and lighting? ;)

Cheers,
Drag0n

Share this post


Link to post
Share on other sites
Well, for glInterleavedArrays there aro no double formats too... while it's possible to use glVertexd instead of glVertexf... mah... Because of this I decided to use floats instead of doubles :P

Share this post


Link to post
Share on other sites
Quote:
Original post by BladeWise
Well, for glInterleavedArrays there aro no double formats too... while it's possible to use glVertexd instead of glVertexf... mah... Because of this I decided to use floats instead of doubles :P


I'm starting to think, maybe it'll be my decision, too... ;)

Cheers,
Drag0n

Share this post


Link to post
Share on other sites
Quote:
Original post by Drag0n

WanMaster: Sure, I don't need the extra precision (at least not for materials and lighting). But there are double-variants of virtually all OpenGL functions, why not for materials and lighting? ;)

Drag0n


WanMaster, there are double-variants of virtually all OpenGL functions to simplify using your data structures. This is so that you do not have to explicitly convert your data structures. There are lots of situations where you need double precision, for example, game physics, and it is convenient that values from that can be used directly. However the above posts are correct that no video cards support double precision, and therefore several OpenGL commands will not accept doubles...basically anything that involves more than one data element (textures, vertex arrays).

So why no doubles for materials...they could be converted to floats internally...But the thing is you probably don't calculate material properties dynamically. You load them as part of your model...so it kind of makes sense that you'd start out with floats and never need to use doubles.

All philosophical though... :-)

Share this post


Link to post
Share on other sites
Quote:
Original post by renderer
All philosophical though... :-)


But right you are! ;) Didn't even think about that before, I probably don't really need to constantly convert floating point numbers around. Materials are pretty much constant I would think, and the lights that I can attach to my (double-based) "Movable" won't break the performance...

Cheers,
Drag0n

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!