Compiling with double support

I noticed that 1.8 introduced the option of compiling panda using doubles internally (graphic drivers be damned :wink: ). I can’t seem to figure out how. Is there a flag for makepanda or is it only in ppremake? Thank you!

Edit: Also, does that compile bullet to use doubles or is that a separate system?

In makepanda, you’d use --override STDFLOAT_DOUBLE=1 on the command-line. Look in built/include/dtool_config.h after running the command to make sure that it did correctly write out the new setting.

Also make sure that you’ve removed the “built” subdirectory to make sure you’re doing a clean build.

Whether or not Bullet uses doubles is independent from Panda.

You can check PandaSystem.getGlobalPtr().hasSystem(‘stdfloat-double’) to prove that you’re running with doubles at runtime. Or just check that (LPoint3 == LPoint3d) is true and (LPoint3 == LPoint3f) is false.

David

No. You have to recompile Bullet yourself, and define BT_USE_DOUBLE_PRECISION.

Um… thinking about it you have to use this define both when compiling Bullet AND when compiling Panda3D Bullet modules.
I should add this in panda3d/src/bullet:/bullet_includes.h, something like

#ifdef STDFLOAT_DOUBLE
#define BT_USE_DOUBLE_PRECISION 1
#endif

I’m compiling on arch 64 using the panda3d-cvs AUR with the following flags: --everything --no-opencv --no-ffmpeg --no-fmod --override STDFLOAT_DOUBLE=1

The following error crops up:

[ 46%] Building C++ object built/tmp/p3glesgsg_glesgsg.o
In file included from panda/src/glstuff/glstuff_src.cxx:30:0,
                 from panda/src/glesgsg/glesgsg.cxx:20:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘virtual bool GLESGraphicsStateGuardian::prepare_lens()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:2081:57: error: ‘glLoadMatrixd’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘bool GLESGraphicsStateGuardian::update_standard_vertex_arrays(bool)’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:2676:42: error: ‘glColor4d’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:2693:44: error: ‘glColor4d’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘void GLESGraphicsStateGuardian::disable_standard_vertex_arrays()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:2847:38: error: ‘glColor4d’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘virtual void GLESGraphicsStateGuardian::end_draw_primitives()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:3394:63: error: ‘glLoadMatrixd’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘void GLESGraphicsStateGuardian::do_issue_transform()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:4479:51: error: ‘glLoadMatrixd’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘virtual void GLESGraphicsStateGuardian::begin_bind_lights()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:7113:58: error: ‘glLoadMatrixd’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘virtual void GLESGraphicsStateGuardian::begin_bind_clip_planes()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:7181:58: error: ‘glLoadMatrixd’ was not declared in this scope
panda/src/glstuff/glGraphicsStateGuardian_src.cxx: In member function ‘void GLESGraphicsStateGuardian::do_issue_tex_matrix()’:
panda/src/glstuff/glGraphicsStateGuardian_src.cxx:8105:68: error: ‘glLoadMatrixd’ was not declared in this scope
Storing dependency cache.
Elapsed Time: 18 min 53 sec
The following command returned a non-zero value: g++ -ftemplate-depth-30 -fPIC -c -o built/tmp/p3glesgsg_glesgsg.o -Ibuilt/tmp -Ibuilt/include -I/usr/include/python2.7 -I/usr/include/eigen3 -DMAKEPANDA= -Ipanda/src/glesgsg -Ipanda/src/glstuff -pthread -msse2 -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -DBUILDING_PANDAGLES panda/src/glesgsg/glesgsg.cxx
Build terminated.

When I remove the double override it compiles just fine.

Hmm, looks like OpenGL ES isn’t compatible with double support. This isn’t difficult to fix, but in the meantime, unless you actually need OpenGL ES, just add --no-gles and --no-gles2 to the makepanda line.

David

That would be inadvisable. If Bullet was installed correctly with the bullet.pc file in the right place, then makepanda will ask pkg-config for the correct cflags, which will include “-DBT_USE_DOUBLE_PRECISION” if Bullet was compiled with double precision.

Ok. I did an undo uf the last commit. I have not been aware of the bullet.pc files. Does this work on Windows too, or is it a Linux-only feature?

No, we don’t use pkg-config on Windows. It should probably be passed on the compiler command-line there (as a /D flag), though that does make it more difficult for a C++ program to link to libpandabullet. Hmm.