I’m using visual c++ in a console project and using opengl. What kind of datatype should I be using for my vectors and whatnot? I have been making my own data types because I didn’t think it was built in to opengl… but maybe it is… I don’t want to start writing methods for cross-products and whatnot if that’s already done for me in OpenGl… this is an example of what im talking about:
GL is neither a type library nor a vector math library. All GL datatypes can be found in gh.h if you would care to look at it. If you want to submit data to OpenGL you have to use either vertex arrays or vertex specification operations. This way it is completely up to you how you define your data, GL doesn’t care.
And this is hardly an advanced topic, please post things like that in the beginners one.
Most, if not all, OpenGL implementations use 32 bit floats internally. For performance reasons you should prefer floats over doubles in your data structures if the precision is sufficient for your purpose.
Storing your data as floats breaks down if you need to use the utility routines, gluProject and gluUnproject. These assume that you have doubles and would therefore need to convert often. For this reason, I tend toward doubles instead of floats. I’ve never heard of double to float conversion being the bottleneck in a program.
Ah that would explain it, I thought I was missing part of the installation. Thanks for the help… I would move this but it doesn’t allow me, sorry for posting in the wrong section.
Also… I couldn’t help but notice
yes, you can specify vertex data using doubles, nobody’s saying you can’t. But consider that most implementations don’t support doubles in hardware, so when you submit an array of double precision vertices, it’s possible the driver will have to convert them to floats each time you submit them, but also keep a copy of the original floats in case you want to read them back. You’ve lost memory and upload performance, and gained nothing at all.
Originally posted by RigidBody: but if you use a display list, each vertex will be converted only once, correct?
It is likely that only one coversion will take place however this is not guaranteed and the driver may choose to do the conversion each time the list is called.