From 39264cbbbcd59a21aa2422c6e9ae8c262625eede Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 23 Jan 2001 00:15:20 +0000 Subject: [PATCH] *** empty log message *** --- dtool/pptempl/Global.msvc.pp | 26 +++++-- dtool/pptempl/Global.pp | 70 +++++++++---------- dtool/pptempl/Template.msvc.pp | 16 +++-- dtool/src/dtoolbase/dtoolbase_cc.h | 2 +- dtool/src/dtoolbase/dtoolsymbols.h | 2 +- panda/metalibs/panda/Sources.pp | 3 +- panda/metalibs/panda/panda.cxx | 26 +++++-- panda/metalibs/panda/panda.h | 14 ++++ panda/metalibs/pandadx/pandadx.cxx | 22 ++++-- panda/metalibs/pandadx/pandadx.h | 13 ++++ panda/metalibs/pandaegg/Sources.pp | 3 +- panda/metalibs/pandaegg/pandaegg.cxx | 24 +++++-- panda/metalibs/pandaegg/pandaegg.h | 14 ++++ panda/metalibs/pandagl/Sources.pp | 5 +- panda/metalibs/pandagl/pandagl.cxx | 28 ++++++-- panda/metalibs/pandagl/pandagl.h | 14 ++++ panda/src/builder/config_builder.cxx | 18 +++++ panda/src/builder/config_builder.h | 2 + panda/src/cull/cullTraverser.cxx | 2 +- panda/src/device/Sources.pp | 4 +- panda/src/device/config_device.cxx | 19 +++++ panda/src/device/config_device.h | 2 + panda/src/display/graphicsPipe.cxx | 27 +++++-- panda/src/display/graphicsPipe.h | 6 +- panda/src/display/graphicsStateGuardian.cxx | 22 +++++- panda/src/display/graphicsStateGuardian.h | 4 +- panda/src/display/graphicsWindow.cxx | 24 +++++-- panda/src/display/graphicsWindow.h | 6 +- panda/src/dxgsg/config_dxgsg.cxx | 23 ++++-- panda/src/dxgsg/config_dxgsg.h | 1 + panda/src/egg/config_egg.cxx | 31 ++++++-- panda/src/egg/config_egg.h | 2 + panda/src/egg2sg/config_egg2sg.cxx | 19 +++++ panda/src/egg2sg/config_egg2sg.h | 2 +- panda/src/express/Sources.pp | 1 + panda/src/framework/framework.cxx | 6 +- panda/src/glgsg/config_glgsg.cxx | 22 +++++- panda/src/glgsg/config_glgsg.h | 2 + panda/src/glutdisplay/config_glutdisplay.cxx | 4 +- panda/src/glxdisplay/config_glxdisplay.cxx | 4 +- panda/src/graph/config_graph.cxx | 62 ++++++++++------ panda/src/graph/config_graph.h | 2 + panda/src/graph/nodeRelation.cxx | 41 +++++++++-- panda/src/graph/nodeRelation.h | 7 +- panda/src/graph/wrt.I | 2 +- panda/src/pandabase/pandasymbols.h | 2 +- panda/src/pnmimage/config_pnmimage.cxx | 19 +++++ panda/src/pnmimage/config_pnmimage.h | 2 + panda/src/pnmimagetypes/Sources.pp | 3 + .../pnmimagetypes/config_pnmimagetypes.cxx | 20 ++++++ .../src/pnmimagetypes/config_pnmimagetypes.h | 2 + panda/src/ribdisplay/config_ribdisplay.cxx | 4 +- panda/src/ribgsg/config_ribgsg.cxx | 2 +- .../sgiglxdisplay/config_sgiglxdisplay.cxx | 2 +- panda/src/sgraph/Sources.pp | 3 +- panda/src/sgraph/config_sgraph.cxx | 22 ++++++ panda/src/sgraph/config_sgraph.h | 2 + panda/src/testbed/Sources.pp | 12 +++- panda/src/testbed/demo.cxx | 29 ++++++++ panda/src/wdxdisplay/Sources.pp | 2 +- panda/src/wdxdisplay/config_wdxdisplay.cxx | 23 +++++- panda/src/wdxdisplay/config_wdxdisplay.h | 1 + panda/src/wgldisplay/Sources.pp | 2 +- panda/src/wgldisplay/config_wgldisplay.cxx | 23 +++++- panda/src/wgldisplay/config_wgldisplay.h | 1 + 65 files changed, 675 insertions(+), 150 deletions(-) create mode 100644 panda/metalibs/panda/panda.h create mode 100644 panda/metalibs/pandadx/pandadx.h create mode 100644 panda/metalibs/pandaegg/pandaegg.h create mode 100644 panda/metalibs/pandagl/pandagl.h diff --git a/dtool/pptempl/Global.msvc.pp b/dtool/pptempl/Global.msvc.pp index 1fdf7f7c33..cb05af6e13 100644 --- a/dtool/pptempl/Global.msvc.pp +++ b/dtool/pptempl/Global.msvc.pp @@ -64,12 +64,23 @@ #endif #defer CFLAGS_SHARED +// Define LINK_ALL_STATIC to generate static libs instead of DLL's. +#if $[LINK_ALL_STATIC] + #define dlink_all_static LINK_ALL_STATIC + #define build_dlls + #define dlllib lib +#else + #define dlink_all_static + #define build_dlls yes + #define dlllib dll +#endif + #defer OPTFLAGS /O2 /Ob1 /Ogity /G6 -#defer CDEFINES_OPT1 _DEBUG -#defer CDEFINES_OPT2 _DEBUG -#defer CDEFINES_OPT3 -#defer CDEFINES_OPT4 NDEBUG +#defer CDEFINES_OPT1 _DEBUG $[dlink_all_static] +#defer CDEFINES_OPT2 _DEBUG $[dlink_all_static] +#defer CDEFINES_OPT3 $[dlink_all_static] +#defer CDEFINES_OPT4 NDEBUG $[dlink_all_static] #defer CFLAGS_OPT1 $[CDEFINES_OPT1:%=/D%] /MDd /Gi- /GZ /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" #defer CFLAGS_OPT2 $[CDEFINES_OPT2:%=/D%] /MDd /Gi- /Zi $[BROWSEINFO_FLAG] /Fd"$[osfilename $[target:%.obj=%.pdb]]" @@ -108,3 +119,10 @@ #defer LINK_BIN_C link /nologo $[LDFLAGS_OPT$[OPTIMIZE]] $[sources] $[decygwin %,/LIBPATH:"%",$[lpath]] $[patsubst %.lib,%.lib,%,lib%.lib,$[libs]] /OUT:"$[osfilename $[target]]" #defer LINK_BIN_C++ $[LINK_BIN_C] + +#if $[LINK_ALL_STATIC] + #defer SHARED_LIB_C $[STATIC_LIB_C] + #defer SHARED_LIB_C++ $[STATIC_LIB_C++] + #defer ODIR_SHARED $[ODIR_STATIC] +#endif + diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index 6857316aca..ef5d09ab6d 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -461,55 +461,55 @@ #defun get_lpath #define alt_lpath $[nspr_lpath] $[python_lpath] - #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs]],] + #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[crypto_lpath] #endif - #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],] + #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[zlib_lpath] #endif - #if $[ne $[USE_GL] $[components $[USE_GL],$[active_component_libs]],] + #if $[ne $[USE_GL] $[components $[USE_GL],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[gl_lpath] #endif - #if $[ne $[USE_GLX] $[components $[USE_GLX],$[active_component_libs]],] + #if $[ne $[USE_GLX] $[components $[USE_GLX],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[glx_lpath] #endif - #if $[ne $[USE_GLUT] $[components $[USE_GLUT],$[active_component_libs]],] + #if $[ne $[USE_GLUT] $[components $[USE_GLUT],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[glut_lpath] #endif - #if $[ne $[USE_DX] $[components $[USE_DX],$[active_component_libs]],] + #if $[ne $[USE_DX] $[components $[USE_DX],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[dx_lpath] #endif - #if $[ne $[USE_SOXST] $[components $[USE_SOXST],$[active_component_libs]],] + #if $[ne $[USE_SOXST] $[components $[USE_SOXST],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[soxst_lpath] #endif - #if $[ne $[USE_IPC] $[components $[USE_IPC],$[active_component_libs]],] + #if $[ne $[USE_IPC] $[components $[USE_IPC],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[ipc_lpath] #endif - #if $[ne $[USE_NET] $[components $[USE_NET],$[active_component_libs]],] + #if $[ne $[USE_NET] $[components $[USE_NET],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[net_lpath] #endif - #if $[ne $[USE_JPEG] $[components $[USE_JPEG],$[active_component_libs]],] + #if $[ne $[USE_JPEG] $[components $[USE_JPEG],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[jpeg_lpath] #endif - #if $[ne $[USE_TIFF] $[components $[USE_TIFF],$[active_component_libs]],] + #if $[ne $[USE_TIFF] $[components $[USE_TIFF],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[tiff_lpath] #endif - #if $[ne $[USE_FFTW] $[components $[USE_FFTW],$[active_component_libs]],] + #if $[ne $[USE_FFTW] $[components $[USE_FFTW],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[fftw_lpath] #endif - #if $[ne $[USE_VRPN] $[components $[USE_VRPN],$[active_component_libs]],] + #if $[ne $[USE_VRPN] $[components $[USE_VRPN],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[vrpn_lpath] #endif - #if $[ne $[USE_AUDIO] $[components $[USE_AUDIO],$[active_component_libs]],] + #if $[ne $[USE_AUDIO] $[components $[USE_AUDIO],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[audio_lpath] #endif - #if $[ne $[USE_MIKMOD] $[components $[USE_MIKMOD],$[active_component_libs]],] + #if $[ne $[USE_MIKMOD] $[components $[USE_MIKMOD],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[mikmod_lpath] #endif - #if $[ne $[USE_GTKMM] $[components $[USE_GTKMM],$[active_component_libs]],] + #if $[ne $[USE_GTKMM] $[components $[USE_GTKMM],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[gtkmm_lpath] #endif - #if $[ne $[USE_MAYA] $[components $[USE_MAYA],$[active_component_libs]],] + #if $[ne $[USE_MAYA] $[components $[USE_MAYA],$[active_component_libs] $[transitive_link]],] #set alt_lpath $[alt_lpath] $[maya_lpath] #endif @@ -524,59 +524,59 @@ #defun get_libs #define alt_libs $[nspr_libs] $[python_libs] - #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs]],] + #if $[ne $[USE_CRYPTO] $[components $[USE_CRYPTO],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[crypto_libs] #endif - #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs]],] + #if $[ne $[USE_ZLIB] $[components $[USE_ZLIB],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[zlib_libs] #endif - #if $[ne $[USE_GL] $[components $[USE_GL],$[active_component_libs]],] + #if $[ne $[USE_GL] $[components $[USE_GL],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[gl_libs] #endif - #if $[ne $[USE_GLX] $[components $[USE_GLX],$[active_component_libs]],] + #if $[ne $[USE_GLX] $[components $[USE_GLX],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[glx_libs] #endif - #if $[ne $[USE_GLUT] $[components $[USE_GLUT],$[active_component_libs]],] + #if $[ne $[USE_GLUT] $[components $[USE_GLUT],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[glut_libs] #endif - #if $[ne $[USE_DX] $[components $[USE_DX],$[active_component_libs]],] + #if $[ne $[USE_DX] $[components $[USE_DX],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[dx_libs] #endif - #if $[ne $[USE_SOXST] $[components $[USE_SOXST],$[active_component_libs]],] + #if $[ne $[USE_SOXST] $[components $[USE_SOXST],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[soxst_libs] #endif - #if $[ne $[USE_IPC] $[components $[USE_IPC],$[active_component_libs]],] + #if $[ne $[USE_IPC] $[components $[USE_IPC],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[ipc_libs] #endif - #if $[ne $[USE_NET] $[components $[USE_NET],$[active_component_libs]],] + #if $[ne $[USE_NET] $[components $[USE_NET],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[net_libs] #endif - #if $[ne $[USE_JPEG] $[components $[USE_JPEG],$[active_component_libs]],] + #if $[ne $[USE_JPEG] $[components $[USE_JPEG],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[jpeg_libs] #endif - #if $[ne $[USE_TIFF] $[components $[USE_TIFF],$[active_component_libs]],] + #if $[ne $[USE_TIFF] $[components $[USE_TIFF],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[tiff_libs] #endif - #if $[ne $[USE_FFTW] $[components $[USE_FFTW],$[active_component_libs]],] + #if $[ne $[USE_FFTW] $[components $[USE_FFTW],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[fftw_libs] #endif - #if $[ne $[USE_VRPN] $[components $[USE_VRPN],$[active_component_libs]],] + #if $[ne $[USE_VRPN] $[components $[USE_VRPN],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[vrpn_libs] #endif - #if $[ne $[USE_AUDIO] $[components $[USE_AUDIO],$[active_component_libs]],] + #if $[ne $[USE_AUDIO] $[components $[USE_AUDIO],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[audio_libs] #endif - #if $[ne $[USE_MIKMOD] $[components $[USE_MIKMOD],$[active_component_libs]],] + #if $[ne $[USE_MIKMOD] $[components $[USE_MIKMOD],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[mikmod_libs] #endif - #if $[ne $[USE_GTKMM] $[components $[USE_GTKMM],$[active_component_libs]],] + #if $[ne $[USE_GTKMM] $[components $[USE_GTKMM],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[gtkmm_libs] #endif - #if $[ne $[USE_MAYA] $[components $[USE_MAYA],$[active_component_libs]],] + #if $[ne $[USE_MAYA] $[components $[USE_MAYA],$[active_component_libs] $[transitive_link]],] #set alt_libs $[alt_libs] $[maya_libs] #endif #if $[UNIX_PLATFORM] - #set alt_libs $[alt_libs] $[UNIX_SYS_LIBS] $[components $[UNIX_SYS_LIBS],$[active_component_libs]] + #set alt_libs $[alt_libs] $[UNIX_SYS_LIBS] $[components $[UNIX_SYS_LIBS],$[active_component_libs] $[transitive_link]] #endif $[alt_libs] diff --git a/dtool/pptempl/Template.msvc.pp b/dtool/pptempl/Template.msvc.pp index c0abb1e022..070ea72877 100644 --- a/dtool/pptempl/Template.msvc.pp +++ b/dtool/pptempl/Template.msvc.pp @@ -74,7 +74,7 @@ // $[bin_targets] the list of binaries. $[test_bin_targets] is the // list of binaries that are to be built only when specifically asked // for. -#define lib_targets $[patsubst %,$[so_dir]\lib%$[dllext].dll,$[active_target(metalib_target noinst_lib_target)] $[real_lib_targets]] +#define lib_targets $[patsubst %,$[so_dir]\lib%$[dllext].$[dlllib],$[active_target(metalib_target noinst_lib_target)] $[real_lib_targets]] #define static_lib_targets $[active_target(static_lib_target ss_lib_target):%=$[st_dir]\lib%$[dllext].lib] #define bin_targets \ $[active_target(bin_target noinst_bin_target):%=$[st_dir]\%.exe] \ @@ -322,7 +322,7 @@ $[osfilename $[directory]] : $[components $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[RELDIR]\$[so_dir]\%.obj,%,,$[get_sources] $[get_igateoutput]]],$[active_component_libs]] #define varname $[subst -,_,lib$[TARGET]_so] $[varname] = $[osfilename $[sources]] - #define target $[so_dir]\lib$[TARGET]$[dllext].dll + #define target $[so_dir]\lib$[TARGET]$[dllext].$[dlllib] #define sources $($[varname]) #define flags $[get_cflags] $[C++FLAGS] $[CFLAGS_OPT$[OPTIMIZE]] $[CFLAGS_SHARED] $[building_var:%=/D%] $[target] : $[sources] "$[dtool_ver_dir]\version.rc" @@ -336,7 +336,9 @@ $[target] : $[sources] "$[dtool_ver_dir]\version.rc" $[SHARED_LIB_C] #endif +#if $[build_dlls] $[so_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].dll +#endif #endif @@ -344,7 +346,7 @@ $[so_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].dll // everything that goes along with it. #define installed_files \ $[if $[build_it], \ - $[install_lib_dir]\lib$[TARGET]$[dllext].dll \ + $[if $[build_dlls],$[install_lib_dir]\lib$[TARGET]$[dllext].dll] \ $[install_lib_dir]\lib$[TARGET]$[dllext].lib \ ] \ $[INSTALL_SCRIPTS:%=$[install_bin_dir]\%] \ @@ -360,10 +362,12 @@ uninstall-lib$[TARGET] : -del /f $[file] #end file +#if $[build_dlls] $[install_lib_dir]\lib$[TARGET]$[dllext].dll : $[so_dir]\lib$[TARGET]$[dllext].dll #define local lib$[TARGET]$[dllext].dll #define dest $[install_lib_dir] copy $[so_dir]\$[local] $[dest] +#endif $[install_lib_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].lib #define local lib$[TARGET]$[dllext].lib @@ -439,7 +443,7 @@ $[target] : $[source] #forscopes noinst_lib_target #define varname $[subst -,_,lib$[TARGET]_so] $[varname] = $[osfilename $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[so_dir]\%.obj,%,,$[get_sources]]]] -#define target $[so_dir]\lib$[TARGET]$[dllext].dll +#define target $[so_dir]\lib$[TARGET]$[dllext].$[dlllib] #define sources $($[varname]) $[target] : $[sources] #if $[filter %.cxx %.yxx %.lxx,$[get_sources]] @@ -448,7 +452,9 @@ $[target] : $[sources] $[SHARED_LIB_C] #endif +#if $[build_dlls] $[so_dir]\lib$[TARGET]$[dllext].lib : $[so_dir]\lib$[TARGET]$[dllext].dll +#endif #end noinst_lib_target @@ -541,6 +547,7 @@ $[varname] = $[osfilename $[unique $[patsubst %.cxx %.c %.yxx %.lxx,$[st_dir]\%. #define target $[st_dir]\$[TARGET].exe #define sources $($[varname]) #define ld $[get_ld] +#define transitive_link $[complete_local_libs] $[target] : $[sources] #if $[ld] // If there's a custom linker defined for the target, we have to use it. @@ -553,6 +560,7 @@ $[target] : $[sources] $[LINK_BIN_C] #endif #endif +#define transitive_link #define installed_files \ $[install_bin_dir]\$[TARGET].exe \ diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index bba2d942fd..8d9b21083a 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -54,7 +54,7 @@ using namespace std; #define INLINE inline #define TYPENAME typename -#ifdef WIN32_VC +#if defined(WIN32_VC) && !defined(LINK_ALL_STATIC) // This macro must be used to export an instantiated template class // from a DLL. If the template class name itself contains commas, it // may be necessary to first define a macro for the class name, to diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index 857267be88..15a35e0d4e 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -36,7 +36,7 @@ #define EXPCL_EMPTY -#if defined(WIN32_VC) && !defined(CPPPARSER) +#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) #ifdef BUILDING_DTOOL #define EXPCL_DTOOL __declspec(dllexport) diff --git a/panda/metalibs/panda/Sources.pp b/panda/metalibs/panda/Sources.pp index 0a1d8ee920..f3c7fd84f2 100644 --- a/panda/metalibs/panda/Sources.pp +++ b/panda/metalibs/panda/Sources.pp @@ -24,5 +24,6 @@ #begin metalib_target #define TARGET panda - #define SOURCES panda.cxx + #define SOURCES panda.cxx panda.h + #define INSTALL_HEADERS panda.h #end metalib_target diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 61f50efbdd..d028eff062 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -3,7 +3,25 @@ // //////////////////////////////////////////////////////////////////// -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libpanda.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libpanda. +#include "panda.h" + +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////// +// Function: init_libpanda +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpanda() { + init_libdevice(); + init_libgraph(); + init_libsgraph(); + init_libpnmimagetypes(); +} diff --git a/panda/metalibs/panda/panda.h b/panda/metalibs/panda/panda.h new file mode 100644 index 0000000000..50982cd81e --- /dev/null +++ b/panda/metalibs/panda/panda.h @@ -0,0 +1,14 @@ +// Filename: panda.h +// Created by: drose (2Jan01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDA_H +#define PANDA_H + +#include + +EXPCL_PANDA void init_libpanda(); + +#endif + diff --git a/panda/metalibs/pandadx/pandadx.cxx b/panda/metalibs/pandadx/pandadx.cxx index a3373b41b0..dc28e1c017 100644 --- a/panda/metalibs/pandadx/pandadx.cxx +++ b/panda/metalibs/pandadx/pandadx.cxx @@ -3,7 +3,21 @@ // //////////////////////////////////////////////////////////////////// -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libpandadx.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libpandadx. +#include "pandadx.h" + +#include +#include + +//////////////////////////////////////////////////////////////////// +// Function: init_libpandadx +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpandadx() { + init_libdxgsg(); + init_libwdxdisplay(); +} diff --git a/panda/metalibs/pandadx/pandadx.h b/panda/metalibs/pandadx/pandadx.h new file mode 100644 index 0000000000..527a4a19d2 --- /dev/null +++ b/panda/metalibs/pandadx/pandadx.h @@ -0,0 +1,13 @@ +// Filename: pandadx.h +// Created by: drose (2Jan01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDADX_H +#define PANDADX_H + +#include + +EXPCL_PANDADX void init_libpandadx(); + +#endif diff --git a/panda/metalibs/pandaegg/Sources.pp b/panda/metalibs/pandaegg/Sources.pp index 65ab060a2f..499efba5b7 100644 --- a/panda/metalibs/pandaegg/Sources.pp +++ b/panda/metalibs/pandaegg/Sources.pp @@ -16,5 +16,6 @@ #begin metalib_target #define TARGET pandaegg - #define SOURCES pandaegg.cxx + #define SOURCES pandaegg.cxx pandaegg.h + #define INSTALL_HEADERS pandaegg.h #end metalib_target diff --git a/panda/metalibs/pandaegg/pandaegg.cxx b/panda/metalibs/pandaegg/pandaegg.cxx index b326cc6e14..159e6b655f 100644 --- a/panda/metalibs/pandaegg/pandaegg.cxx +++ b/panda/metalibs/pandaegg/pandaegg.cxx @@ -3,7 +3,23 @@ // //////////////////////////////////////////////////////////////////// -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libpandaegg.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libpandaegg. +#include "pandaegg.h" + +#include +#include +#include + +//////////////////////////////////////////////////////////////////// +// Function: init_libpandaegg +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpandaegg() { + init_libegg(); + init_libbuilder(); + init_libegg2sg(); +} diff --git a/panda/metalibs/pandaegg/pandaegg.h b/panda/metalibs/pandaegg/pandaegg.h new file mode 100644 index 0000000000..80e2f09894 --- /dev/null +++ b/panda/metalibs/pandaegg/pandaegg.h @@ -0,0 +1,14 @@ +// Filename: pandaegg.h +// Created by: drose (2Jan01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDAEGG_H +#define PANDAEGG_H + +#include + +EXPCL_PANDAEGG void init_libpandaegg(); + +#endif + diff --git a/panda/metalibs/pandagl/Sources.pp b/panda/metalibs/pandagl/Sources.pp index 2093640166..2423501052 100644 --- a/panda/metalibs/pandagl/Sources.pp +++ b/panda/metalibs/pandagl/Sources.pp @@ -19,5 +19,8 @@ #begin metalib_target #define TARGET pandagl - #define SOURCES pandagl.cxx + #define SOURCES pandagl.cxx pandagl.h + + #define INSTALL_HEADERS pandagl.h + #end metalib_target diff --git a/panda/metalibs/pandagl/pandagl.cxx b/panda/metalibs/pandagl/pandagl.cxx index 6e2984ca1e..6e34261cb6 100644 --- a/panda/metalibs/pandagl/pandagl.cxx +++ b/panda/metalibs/pandagl/pandagl.cxx @@ -3,7 +3,27 @@ // //////////////////////////////////////////////////////////////////// -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libpandagl.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libpandagl. +#include "pandagl.h" + +#include + +#ifdef HAVE_WGL +#include +#endif + +//////////////////////////////////////////////////////////////////// +// Function: init_libpandagl +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpandagl() { + init_libglgsg(); + +#ifdef HAVE_WGL + init_libwgldisplay(); +#endif +} diff --git a/panda/metalibs/pandagl/pandagl.h b/panda/metalibs/pandagl/pandagl.h new file mode 100644 index 0000000000..20825ad14c --- /dev/null +++ b/panda/metalibs/pandagl/pandagl.h @@ -0,0 +1,14 @@ +// Filename: pandagl.h +// Created by: drose (2Jan01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef PANDAGL_H +#define PANDAGL_H + +#include + +EXPCL_PANDAGL void init_libpandagl(); + +#endif + diff --git a/panda/src/builder/config_builder.cxx b/panda/src/builder/config_builder.cxx index 8f05f58a4a..44d615c061 100644 --- a/panda/src/builder/config_builder.cxx +++ b/panda/src/builder/config_builder.cxx @@ -11,4 +11,22 @@ Configure(config_builder); NotifyCategoryDef(builder, ""); ConfigureFn(config_builder) { + init_libbuilder(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libbuilder +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libbuilder() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; } diff --git a/panda/src/builder/config_builder.h b/panda/src/builder/config_builder.h index 492da3a5fb..76fed3f2a0 100644 --- a/panda/src/builder/config_builder.h +++ b/panda/src/builder/config_builder.h @@ -11,4 +11,6 @@ NotifyCategoryDecl(builder, EXPCL_PANDAEGG, EXPTP_PANDAEGG); +extern EXPCL_PANDAEGG void init_libbuilder(); + #endif diff --git a/panda/src/cull/cullTraverser.cxx b/panda/src/cull/cullTraverser.cxx index eada5afd4c..9aa3f96f91 100644 --- a/panda/src/cull/cullTraverser.cxx +++ b/panda/src/cull/cullTraverser.cxx @@ -189,7 +189,7 @@ traverse(Node *root, _as_of = UpdateSeq::initial(); } } - _now = last_graph_update[_graph_type]; + _now = last_graph_update(_graph_type); _nested_count++; if (is_initial) { diff --git a/panda/src/device/Sources.pp b/panda/src/device/Sources.pp index 998bb4c674..e3caf8c72d 100644 --- a/panda/src/device/Sources.pp +++ b/panda/src/device/Sources.pp @@ -15,8 +15,8 @@ #define INSTALL_HEADERS \ adinputNode.h analogData.I analogData.h buttonData.I buttonData.h \ - clientBase.h dialData.I dialData.h mouse.h trackerData.I \ - trackerData.h trackerNode.h + clientBase.h config_device.h dialData.I dialData.h mouse.h \ + trackerData.I trackerData.h trackerNode.h #define IGATESCAN all diff --git a/panda/src/device/config_device.cxx b/panda/src/device/config_device.cxx index f3c06c0c17..bab3b9d59f 100644 --- a/panda/src/device/config_device.cxx +++ b/panda/src/device/config_device.cxx @@ -17,6 +17,25 @@ NotifyCategoryDef(device, ""); const bool asynchronous_clients = config_device.GetBool("asynchronous-clients", false); ConfigureFn(config_device) { + init_libdevice(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libdevice +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libdevice() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + MouseAndKeyboard::init_type(); TrackerNode::init_type(); ADInputNode::init_type(); diff --git a/panda/src/device/config_device.h b/panda/src/device/config_device.h index 5dd953b837..77061f7c5e 100644 --- a/panda/src/device/config_device.h +++ b/panda/src/device/config_device.h @@ -13,4 +13,6 @@ NotifyCategoryDecl(device, EXPCL_PANDA, EXPTP_PANDA); extern const bool asynchronous_clients; +extern EXPCL_PANDA void init_libdevice(); + #endif diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index d780f3f199..ff53d8053b 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -19,10 +19,9 @@ TypeHandle GraphicsPipe::_type_handle; TypeHandle GraphicsPipe::PipeSpec::_type_handle; -GraphicsPipe::PipeFactory GraphicsPipe::_factory; - // These static members are pointers rather than concrete objects so // we can guarantee order of creation at static init time. +GraphicsPipe::PipeFactory *GraphicsPipe::_factory = NULL; GraphicsPipe::Pipes *GraphicsPipe::_all_pipes = NULL; GraphicsPipe::PipeSpec::~PipeSpec(void) {} @@ -134,7 +133,7 @@ make_window() { FactoryParams params; params.add_param(new GraphicsWindow::WindowPipe(this)); - GraphicsWindow *win = GraphicsWindow::_factory. + GraphicsWindow *win = GraphicsWindow::get_factory(). make_instance(get_window_type(), params); nassertr(win != (GraphicsWindow *)NULL, NULL); @@ -157,7 +156,7 @@ make_window(const GraphicsWindow::Properties &props) { params.add_param(new GraphicsWindow::WindowPipe(this)); params.add_param(new GraphicsWindow::WindowProps(props)); - GraphicsWindow *win = GraphicsWindow::_factory. + GraphicsWindow *win = GraphicsWindow::get_factory(). make_instance(get_window_type(), params); nassertr(win != (GraphicsWindow *)NULL, NULL); @@ -294,7 +293,8 @@ add_window(GraphicsWindow *win) { } void GraphicsPipe::read_priorities(void) { - if (_factory.get_num_preferred() == 0) { + PipeFactory &factory = get_factory(); + if (factory.get_num_preferred() == 0) { Config::ConfigTable::Symbol::iterator i; for (i = preferred_pipe_begin(); i != preferred_pipe_end(); ++i) { ConfigString type_name = (*i).Val(); @@ -306,12 +306,27 @@ void GraphicsPipe::read_priorities(void) { } else { display_cat.debug() << "Specifying type " << type << " for pipe preference.\n"; - _factory.add_preferred(type); + factory.add_preferred(type); } } } } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsPipe::get_factory +// Access: Public, Static +// Description: Returns the factory object that can be used to +// register new kinds of GraphicsPipe objects that may +// be created. +//////////////////////////////////////////////////////////////////// +GraphicsPipe::PipeFactory &GraphicsPipe:: +get_factory() { + if (_factory == (PipeFactory *)NULL) { + _factory = new PipeFactory; + } + return (*_factory); +} + void GraphicsPipe::resolve_modules(void) { Config::ConfigTable::Symbol::iterator i; diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index 37bf955456..74658d2b73 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -88,8 +88,7 @@ public: static TypeHandle _type_handle; }; - static PipeFactory _factory; - + static PipeFactory &get_factory(); static void resolve_modules(void); private: @@ -108,7 +107,8 @@ private: typedef vector Pipes; Windows _windows; - + + static PipeFactory *_factory; static Pipes *_all_pipes; INLINE static Pipes &get_all_pipes(); diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index f032aee1b8..f4130b46b5 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -15,7 +15,7 @@ TypeHandle GraphicsStateGuardian::_type_handle; TypeHandle GraphicsStateGuardian::GsgWindow::_type_handle; -GraphicsStateGuardian::GsgFactory GraphicsStateGuardian::_factory; +GraphicsStateGuardian::GsgFactory *GraphicsStateGuardian::_factory = NULL; GraphicsStateGuardian::GsgWindow::~GsgWindow(void) {} @@ -414,9 +414,25 @@ unmark_prepared_texture(TextureContext *tc) { } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsStateGuardian::get_factory +// Access: Public, Static +// Description: Returns the factory object that can be used to +// register new kinds of GraphicsStateGuardian objects that may +// be created. +//////////////////////////////////////////////////////////////////// +GraphicsStateGuardian::GsgFactory &GraphicsStateGuardian:: +get_factory() { + if (_factory == (GsgFactory *)NULL) { + _factory = new GsgFactory; + } + return (*_factory); +} + void GraphicsStateGuardian::read_priorities(void) { - if (_factory.get_num_preferred() == 0) { + GsgFactory &factory = get_factory(); + if (factory.get_num_preferred() == 0) { Config::ConfigTable::Symbol::iterator i; for (i = preferred_gsg_begin(); i != preferred_gsg_end(); ++i) { ConfigString type_name = (*i).Val(); @@ -428,7 +444,7 @@ void GraphicsStateGuardian::read_priorities(void) } else { display_cat.debug() << "Specifying type " << type << " for GSG preference.\n"; - _factory.add_preferred(type); + factory.add_preferred(type); } } } diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 01c8a3498a..d6e8dc8054 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -182,11 +182,13 @@ public: INLINE GsgWindow(void) : GsgParam() {} }; - static GsgFactory _factory; + static GsgFactory &get_factory(); private: static void read_priorities(void); + static GsgFactory *_factory; + public: INLINE GraphicsWindow* get_window(void) const { return _win; } diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 29aba57c10..9d6918cefe 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -22,7 +22,7 @@ TypeHandle GraphicsWindow::_type_handle; TypeHandle GraphicsWindow::WindowProps::_type_handle; TypeHandle GraphicsWindow::WindowPipe::_type_handle; -GraphicsWindow::WindowFactory GraphicsWindow::_factory; +GraphicsWindow::WindowFactory *GraphicsWindow::_factory = NULL; PStatCollector GraphicsWindow::_app_pcollector = PStatCollector("App", RGBColorf(0,1,1)); @@ -497,14 +497,30 @@ make_gsg() { FactoryParams params; params.add_param(new GraphicsStateGuardian::GsgWindow(this)); - _gsg = GraphicsStateGuardian::_factory. + _gsg = GraphicsStateGuardian::get_factory(). make_instance(get_gsg_type(), params); nassertv(_gsg != (GraphicsStateGuardian *)NULL); } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsWindow::get_factory +// Access: Public, Static +// Description: Returns the factory object that can be used to +// register new kinds of GraphicsWindow objects that may +// be created. +//////////////////////////////////////////////////////////////////// +GraphicsWindow::WindowFactory &GraphicsWindow:: +get_factory() { + if (_factory == (WindowFactory *)NULL) { + _factory = new WindowFactory; + } + return (*_factory); +} + void GraphicsWindow::read_priorities(void) { - if (_factory.get_num_preferred() == 0) { + WindowFactory &factory = get_factory(); + if (factory.get_num_preferred() == 0) { Config::ConfigTable::Symbol::iterator i; for (i = preferred_window_begin(); i != preferred_window_end(); ++i) { ConfigString type_name = (*i).Val(); @@ -516,7 +532,7 @@ void GraphicsWindow::read_priorities(void) { } else { display_cat.debug() << "Specifying type " << type << " for window preference.\n"; - _factory.add_preferred(type); + factory.add_preferred(type); } } } diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 43bfbac9f1..b74d35c139 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -196,7 +196,7 @@ protected: private: typedef vector Channels; Channels _channels; - + public: // factory stuff @@ -237,7 +237,7 @@ public: INLINE WindowPipe(void) : WindowParam() {} }; - static WindowFactory _factory; + static WindowFactory &get_factory(); private: @@ -245,6 +245,8 @@ private: GraphicsWindow(const GraphicsWindow&); GraphicsWindow &operator=(const GraphicsWindow&); + + static WindowFactory *_factory; public: static TypeHandle get_class_type() { diff --git a/panda/src/dxgsg/config_dxgsg.cxx b/panda/src/dxgsg/config_dxgsg.cxx index c845e83b43..bbc6c76e23 100644 --- a/panda/src/dxgsg/config_dxgsg.cxx +++ b/panda/src/dxgsg/config_dxgsg.cxx @@ -57,6 +57,24 @@ parse_decal_type(const string &type) { } ConfigureFn(config_dxgsg) { + init_libdxgsg(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libdxgsg +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libdxgsg() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; string decal_type = config_dxgsg.GetString("dx-decal-type", ""); if (!decal_type.empty()) { @@ -67,10 +85,7 @@ ConfigureFn(config_dxgsg) { DXSavedFrameBuffer::init_type(); DXTextureContext::init_type(); - GraphicsStateGuardian::_factory.register_factory + GraphicsStateGuardian::get_factory().register_factory (DXGraphicsStateGuardian::get_class_type(), DXGraphicsStateGuardian::make_DXGraphicsStateGuardian); } - - - diff --git a/panda/src/dxgsg/config_dxgsg.h b/panda/src/dxgsg/config_dxgsg.h index 5680b97be8..66a60af03d 100644 --- a/panda/src/dxgsg/config_dxgsg.h +++ b/panda/src/dxgsg/config_dxgsg.h @@ -33,5 +33,6 @@ enum DXDecalType { }; extern DXDecalType dx_decal_type; +extern EXPCL_PANDADX void init_libdxgsg(); #endif diff --git a/panda/src/egg/config_egg.cxx b/panda/src/egg/config_egg.cxx index ab419bfcd5..9302d4c0f0 100644 --- a/panda/src/egg/config_egg.cxx +++ b/panda/src/egg/config_egg.cxx @@ -44,6 +44,31 @@ Configure(config_egg); NotifyCategoryDef(egg, ""); ConfigureFn(config_egg) { + init_libegg(); +} + +const DSearchPath & +get_egg_path() { + static DSearchPath *egg_path = NULL; + return get_config_path("egg-path", egg_path); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libegg +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libegg() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + EggRenderMode::init_type(); EggAnimData::init_type(); EggAttributes::init_type(); @@ -79,9 +104,3 @@ ConfigureFn(config_egg) { EggXfmAnimData::init_type(); EggXfmSAnim::init_type(); } - -const DSearchPath & -get_egg_path() { - static DSearchPath *egg_path = NULL; - return get_config_path("egg-path", egg_path); -} diff --git a/panda/src/egg/config_egg.h b/panda/src/egg/config_egg.h index cf5543445e..afd12afba0 100644 --- a/panda/src/egg/config_egg.h +++ b/panda/src/egg/config_egg.h @@ -15,4 +15,6 @@ NotifyCategoryDecl(egg, EXPCL_PANDAEGG, EXPTP_PANDAEGG); const DSearchPath &get_egg_path(); +extern EXPCL_PANDAEGG void init_libegg(); + #endif diff --git a/panda/src/egg2sg/config_egg2sg.cxx b/panda/src/egg2sg/config_egg2sg.cxx index 3537149610..8b8a220791 100644 --- a/panda/src/egg2sg/config_egg2sg.cxx +++ b/panda/src/egg2sg/config_egg2sg.cxx @@ -51,6 +51,25 @@ bool egg_keep_texture_pathnames = config_egg2sg.GetBool("egg-keep-texture-pathna CoordinateSystem egg_coordinate_system; ConfigureFn(config_egg2sg) { + init_libegg2sg(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libegg2sg +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libegg2sg() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + LoaderFileTypeEgg::init_type(); string csstr = config_egg2sg.GetString("egg-coordinate-system", "default"); diff --git a/panda/src/egg2sg/config_egg2sg.h b/panda/src/egg2sg/config_egg2sg.h index 342e279dfe..4f730191c0 100644 --- a/panda/src/egg2sg/config_egg2sg.h +++ b/panda/src/egg2sg/config_egg2sg.h @@ -41,6 +41,6 @@ extern EXPCL_PANDAEGG bool egg_flatten_siblings; extern EXPCL_PANDAEGG bool egg_show_collision_solids; extern EXPCL_PANDAEGG bool egg_keep_texture_pathnames; - +extern EXPCL_PANDAEGG void init_libegg2sg(); #endif diff --git a/panda/src/express/Sources.pp b/panda/src/express/Sources.pp index c7a4c1a99f..c617e4b49e 100644 --- a/panda/src/express/Sources.pp +++ b/panda/src/express/Sources.pp @@ -6,6 +6,7 @@ #define TARGET express #define USE_NSPR yes #define USE_CRYPTO yes + #define USE_NET yes #define SOURCES \ bigEndian.I bigEndian.cxx bigEndian.h buffer.I buffer.cxx buffer.h \ diff --git a/panda/src/framework/framework.cxx b/panda/src/framework/framework.cxx index 324ee9ba99..688eaffae8 100644 --- a/panda/src/framework/framework.cxx +++ b/panda/src/framework/framework.cxx @@ -926,10 +926,10 @@ int framework_main(int argc, char *argv[]) { GraphicsPipe::resolve_modules(); framework_cat.info() << "Known pipe types:" << endl; - GraphicsPipe::_factory.write_types(framework_cat.info(false), 2); + GraphicsPipe::get_factory().write_types(framework_cat.info(false), 2); // Create a window - main_pipe = GraphicsPipe::_factory. + main_pipe = GraphicsPipe::get_factory(). make_instance(InteractiveGraphicsPipe::get_class_type()); if (main_pipe == (GraphicsPipe*)0L) { @@ -942,7 +942,7 @@ int framework_main(int argc, char *argv[]) { << "Opened a '" << main_pipe->get_type().get_name() << "' interactive graphics pipe." << endl; - rib_pipe = GraphicsPipe::_factory. + rib_pipe = GraphicsPipe::get_factory(). make_instance(NoninteractiveGraphicsPipe::get_class_type()); if (rib_pipe == (GraphicsPipe*)0L) diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 3ad6a6514e..fe11d6316c 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -54,8 +54,26 @@ parse_decal_type(const string &type) { return GDT_offset; } - ConfigureFn(config_glgsg) { + init_libglgsg(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libglgsg +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libglgsg() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + string decal_type = config_glgsg.GetString("gl-decal-type", ""); if (!decal_type.empty()) { gl_decal_type = parse_decal_type(decal_type); @@ -65,7 +83,7 @@ ConfigureFn(config_glgsg) { GLSavedFrameBuffer::init_type(); GLTextureContext::init_type(); - GraphicsStateGuardian::_factory.register_factory + GraphicsStateGuardian::get_factory().register_factory (GLGraphicsStateGuardian::get_class_type(), GLGraphicsStateGuardian::make_GlGraphicsStateGuardian); } diff --git a/panda/src/glgsg/config_glgsg.h b/panda/src/glgsg/config_glgsg.h index 692f1a3584..a194ec4783 100644 --- a/panda/src/glgsg/config_glgsg.h +++ b/panda/src/glgsg/config_glgsg.h @@ -26,4 +26,6 @@ enum GLDecalType { }; extern GLDecalType gl_decal_type; +extern EXPCL_PANDAGL void init_libglgsg(); + #endif diff --git a/panda/src/glutdisplay/config_glutdisplay.cxx b/panda/src/glutdisplay/config_glutdisplay.cxx index 551d6b6c3a..eaed87b746 100644 --- a/panda/src/glutdisplay/config_glutdisplay.cxx +++ b/panda/src/glutdisplay/config_glutdisplay.cxx @@ -14,9 +14,9 @@ NotifyCategoryDef(glutdisplay, "display"); ConfigureFn(config_glutdisplay) { glutGraphicsPipe::init_type(); - GraphicsPipe::_factory.register_factory(glutGraphicsPipe::get_class_type(), + GraphicsPipe::get_factory().register_factory(glutGraphicsPipe::get_class_type(), glutGraphicsPipe::make_glutGraphicsPipe); glutGraphicsWindow::init_type(); - GraphicsWindow::_factory.register_factory(glutGraphicsWindow::get_class_type(), + GraphicsWindow::get_factory().register_factory(glutGraphicsWindow::get_class_type(), glutGraphicsWindow::make_GlutGraphicsWindow); } diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index 0d39404f2c..c9b8ad9b3f 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -15,10 +15,10 @@ NotifyCategoryDef(glxdisplay, "display"); ConfigureFn(config_glxdisplay) { glxGraphicsPipe::init_type(); - GraphicsPipe::_factory.register_factory(glxGraphicsPipe::get_class_type(), + GraphicsPipe::get_factory().register_factory(glxGraphicsPipe::get_class_type(), glxGraphicsPipe::make_glxGraphicsPipe); glxGraphicsWindow::init_type(); - GraphicsWindow::_factory.register_factory(glxGraphicsWindow::get_class_type(), + GraphicsWindow::get_factory().register_factory(glxGraphicsWindow::get_class_type(), glxGraphicsWindow::make_GlxGraphicsWindow); glxDisplay::init_type(); } diff --git a/panda/src/graph/config_graph.cxx b/panda/src/graph/config_graph.cxx index 0c8ba067d8..472aa4758b 100644 --- a/panda/src/graph/config_graph.cxx +++ b/panda/src/graph/config_graph.cxx @@ -23,26 +23,7 @@ NotifyCategoryDef(graph, ""); NotifyCategoryDef(wrt, graph_cat); ConfigureFn(config_graph) { - BoundedObject::init_type(); - NamedNode::init_type(); - Node::init_type(); - NodeRelation::init_type(); - NodeTransition::init_type(); - NodeAttribute::init_type(); - OnOffTransition::init_type(); - OnOffAttribute::init_type(); - MultiNodeTransition::init_type(); - MultiNodeAttribute::init_type(); - ImmediateTransition::init_type(); - ImmediateAttribute::init_type(); - - NodeRelation::register_with_factory(); - - //Registration of writeable object's creation - //functions with BamReader's factory - Node::register_with_read_factory(); - NamedNode::register_with_read_factory(); - NodeRelation::register_with_read_factory(); + init_libgraph(); } // Set this true if you want to cache some of the work of computing @@ -72,3 +53,44 @@ const bool paranoid_wrt = config_graph.GetBool("paranoid-wrt", false); // it cannot be turned on in NDEBUG mode. const bool paranoid_graph = config_graph.GetBool("paranoid-graph", false); + +//////////////////////////////////////////////////////////////////// +// Function: init_libgraph +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libgraph() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + + void init_last_graph_update(); + init_last_graph_update(); + + BoundedObject::init_type(); + NamedNode::init_type(); + Node::init_type(); + NodeRelation::init_type(); + NodeTransition::init_type(); + NodeAttribute::init_type(); + OnOffTransition::init_type(); + OnOffAttribute::init_type(); + MultiNodeTransition::init_type(); + MultiNodeAttribute::init_type(); + ImmediateTransition::init_type(); + ImmediateAttribute::init_type(); + + NodeRelation::register_with_factory(); + + //Registration of writeable object's creation + //functions with BamReader's factory + Node::register_with_read_factory(); + NamedNode::register_with_read_factory(); + NodeRelation::register_with_read_factory(); +} diff --git a/panda/src/graph/config_graph.h b/panda/src/graph/config_graph.h index 0d49f3a465..ab82fca1d2 100644 --- a/panda/src/graph/config_graph.h +++ b/panda/src/graph/config_graph.h @@ -18,4 +18,6 @@ extern const bool EXPCL_PANDA ambiguous_wrt_abort; extern const bool EXPCL_PANDA paranoid_wrt; extern const bool EXPCL_PANDA paranoid_graph; +extern EXPCL_PANDA void init_libgraph(); + #endif diff --git a/panda/src/graph/nodeRelation.cxx b/panda/src/graph/nodeRelation.cxx index 6fa5bead5c..2dbf7ab5a8 100644 --- a/panda/src/graph/nodeRelation.cxx +++ b/panda/src/graph/nodeRelation.cxx @@ -12,10 +12,39 @@ TypeHandle NodeRelation::_type_handle; -LastGraphUpdate last_graph_update; - Factory *NodeRelation::_factory = NULL; +typedef map LastGraphUpdate; +static LastGraphUpdate *last_graph_update_map = NULL; + +//////////////////////////////////////////////////////////////////// +// Function: last_graph_update +// Description: Returns a modifiable reference to the sequence number +// indicating the last update to the indicated type of +// graph. +//////////////////////////////////////////////////////////////////// +UpdateSeq & +last_graph_update(TypeHandle graph_type) { +#ifndef NDEBUG + static UpdateSeq initial; + nassertr(last_graph_update_map != (LastGraphUpdate *)NULL, initial); +#endif + return (*last_graph_update_map)[graph_type]; +} + +//////////////////////////////////////////////////////////////////// +// Function: init_last_graph_update +// Description: Initializes the last_graph_update map. This call +// must be made before last_graph_update() can be safely +// called. +//////////////////////////////////////////////////////////////////// +void +init_last_graph_update() { + if (last_graph_update_map == NULL) { + last_graph_update_map = new LastGraphUpdate; + } +} + // Following are a handful of local template functions that provide // support for manipulating the list of arcs on nodes. They are // template functions because they work as well on UpRelationArcs as @@ -472,7 +501,7 @@ attach() { // Blow out the cache and increment the current update sequence. _net_transitions.clear(); - _last_update = ++last_graph_update[_type]; + _last_update = ++last_graph_update(_type); /* // If we have just added a new parent arc to a node that previously @@ -532,7 +561,7 @@ detach() { // Blow out the cache and increment the current update sequence. _net_transitions.clear(); - _last_update = ++last_graph_update[_type]; + _last_update = ++last_graph_update(_type); /* // If we have just removed a parent arc from a node, leaving exactly @@ -576,7 +605,7 @@ detach_below() { // Blow out the cache and increment the current update sequence. _net_transitions.clear(); - _last_update = ++last_graph_update[_type]; + _last_update = ++last_graph_update(_type); return result; } @@ -598,7 +627,7 @@ changed_transition(TypeHandle trans_type) { if (_net_transitions != (NodeTransitionCache *)NULL) { _net_transitions->clear_transition(trans_type); } - _last_update = ++last_graph_update[get_type()]; + _last_update = ++last_graph_update(get_type()); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/graph/nodeRelation.h b/panda/src/graph/nodeRelation.h index 94f881df99..d9bb4a4a4b 100644 --- a/panda/src/graph/nodeRelation.h +++ b/panda/src/graph/nodeRelation.h @@ -26,12 +26,11 @@ class Node; -// This structure keeps a monotonically incrementing sequence number +// This function keeps a monotonically incrementing sequence number // for each change made to the graph, for the purpose of invalidating // wrt cache values. A different sequence number is kept for each -// type of graph, hence the map. -typedef map LastGraphUpdate; -extern LastGraphUpdate EXPCL_PANDA last_graph_update; +// type of graph, hence the parameter. +extern EXPCL_PANDA UpdateSeq &last_graph_update(TypeHandle graph_type); /////////////////////////////////////////////////////////////////// // Class : NodeRelation diff --git a/panda/src/graph/wrt.I b/panda/src/graph/wrt.I index a381372c93..94a52b5f97 100644 --- a/panda/src/graph/wrt.I +++ b/panda/src/graph/wrt.I @@ -394,7 +394,7 @@ cached_wrt_base(const Node *from, TransitionWrapper &result, TypeHandle graph_type) { - UpdateSeq now = last_graph_update[graph_type]; + UpdateSeq now = last_graph_update(graph_type); TransitionWrapper net_from_trans = TransitionWrapper::init_from(result); diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 40aad22785..d30589a65a 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -10,7 +10,7 @@ /* See dtoolsymbols.h for a rant on the purpose of this file. */ -#if defined(WIN32_VC) && !defined(CPPPARSER) +#if defined(WIN32_VC) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) #ifdef BUILDING_PANDA #define EXPCL_PANDA __declspec(dllexport) diff --git a/panda/src/pnmimage/config_pnmimage.cxx b/panda/src/pnmimage/config_pnmimage.cxx index 4a88eab3b9..dde7300fa3 100644 --- a/panda/src/pnmimage/config_pnmimage.cxx +++ b/panda/src/pnmimage/config_pnmimage.cxx @@ -12,5 +12,24 @@ Configure(config_pnmimage); NotifyCategoryDef(pnmimage, ""); ConfigureFn(config_pnmimage) { + init_libpnmimage(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libpnmimage +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpnmimage() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + PNMFileType::init_type(); } diff --git a/panda/src/pnmimage/config_pnmimage.h b/panda/src/pnmimage/config_pnmimage.h index e6ab45104b..ace60dfc4f 100644 --- a/panda/src/pnmimage/config_pnmimage.h +++ b/panda/src/pnmimage/config_pnmimage.h @@ -11,4 +11,6 @@ NotifyCategoryDecl(pnmimage, EXPCL_PANDA, EXPTP_PANDA); +extern EXPCL_PANDA void init_libpnmimage(); + #endif diff --git a/panda/src/pnmimagetypes/Sources.pp b/panda/src/pnmimagetypes/Sources.pp index 42cbf50b7e..b99905ba2b 100644 --- a/panda/src/pnmimagetypes/Sources.pp +++ b/panda/src/pnmimagetypes/Sources.pp @@ -22,5 +22,8 @@ #define IF_JPEG_SOURCES \ pnmFileTypeJPG.cxx pnmFileTypeJPGReader.cxx pnmFileTypeJPGWriter.cxx + #define INSTALL_HEADERS \ + config_pnmimagetypes.h + #end lib_target diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 5d4c03e4bf..2173a6f894 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -72,6 +72,26 @@ const int jpeg_scale_num = config_pnmimagetypes.GetInt("jpeg-scale-num", 1); const int jpeg_scale_denom = config_pnmimagetypes.GetInt("jpeg-scale-denom", 1); ConfigureFn(config_pnmimagetypes) { + init_libpnmimagetypes(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libpnmimagetypes +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpnmimagetypes() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + + init_libpnmimage(); PNMFileTypePNM::init_type(); PNMFileTypeSGI::init_type(); PNMFileTypeAlias::init_type(); diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.h b/panda/src/pnmimagetypes/config_pnmimagetypes.h index 40ce9b0631..ee7636ad2f 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.h +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.h @@ -41,4 +41,6 @@ extern IMGHeaderType img_header_type; extern const int img_xsize; extern const int img_ysize; +extern EXPCL_PANDA void init_libpnmimagetypes(); + #endif diff --git a/panda/src/ribdisplay/config_ribdisplay.cxx b/panda/src/ribdisplay/config_ribdisplay.cxx index 30082226b7..47583a4097 100644 --- a/panda/src/ribdisplay/config_ribdisplay.cxx +++ b/panda/src/ribdisplay/config_ribdisplay.cxx @@ -14,9 +14,9 @@ NotifyCategoryDef(ribdisplay, "display"); ConfigureFn(config_ribdisplay) { RIBGraphicsPipe::init_type(); - GraphicsPipe::_factory.register_factory(RIBGraphicsPipe::get_class_type(), + GraphicsPipe::get_factory().register_factory(RIBGraphicsPipe::get_class_type(), RIBGraphicsPipe::make_RIBGraphicsPipe); RIBGraphicsWindow::init_type(); - GraphicsWindow::_factory.register_factory(RIBGraphicsWindow::get_class_type(), + GraphicsWindow::get_factory().register_factory(RIBGraphicsWindow::get_class_type(), RIBGraphicsWindow::make_RibGraphicsWindow); } diff --git a/panda/src/ribgsg/config_ribgsg.cxx b/panda/src/ribgsg/config_ribgsg.cxx index 1ab61515f2..0459b05a4b 100644 --- a/panda/src/ribgsg/config_ribgsg.cxx +++ b/panda/src/ribgsg/config_ribgsg.cxx @@ -13,7 +13,7 @@ NotifyCategoryDef(ribgsg, ":display:gsg"); ConfigureFn(config_ribgsg) { RIBGraphicsStateGuardian::init_type(); - GraphicsStateGuardian::_factory. + GraphicsStateGuardian::get_factory(). register_factory(RIBGraphicsStateGuardian::get_class_type(), RIBGraphicsStateGuardian::make_RIBGraphicsStateGuardian); } diff --git a/panda/src/sgiglxdisplay/config_sgiglxdisplay.cxx b/panda/src/sgiglxdisplay/config_sgiglxdisplay.cxx index 8a323da3c0..d6a4b80fa2 100644 --- a/panda/src/sgiglxdisplay/config_sgiglxdisplay.cxx +++ b/panda/src/sgiglxdisplay/config_sgiglxdisplay.cxx @@ -13,6 +13,6 @@ NotifyCategoryDef(sgiglxdisplay, "display"); ConfigureFn(config_sgiglxdisplay) { SgiGlxGraphicsPipe::init_type(); - GraphicsPipe::_factory.register_factory(SgiGlxGraphicsPipe::get_class_type(), + GraphicsPipe::get_factory().register_factory(SgiGlxGraphicsPipe::get_class_type(), SgiGlxGraphicsPipe::make_sgiglxgraphicspipe); } diff --git a/panda/src/sgraph/Sources.pp b/panda/src/sgraph/Sources.pp index 50a8120b76..6c98345680 100644 --- a/panda/src/sgraph/Sources.pp +++ b/panda/src/sgraph/Sources.pp @@ -16,7 +16,8 @@ renderTraverser.I renderTraverser.cxx renderTraverser.h #define INSTALL_HEADERS \ - camera.I camera.h geomNode.I geomNode.h geomTransformer.I \ + camera.I camera.h config_sgraph.h \ + geomNode.I geomNode.h geomTransformer.I \ geomTransformer.h modelNode.I modelNode.h modelRoot.I \ modelRoot.h planeNode.I planeNode.h projectionNode.I \ projectionNode.h renderTraverser.I renderTraverser.h diff --git a/panda/src/sgraph/config_sgraph.cxx b/panda/src/sgraph/config_sgraph.cxx index d81d30c6f8..4e0c124891 100644 --- a/panda/src/sgraph/config_sgraph.cxx +++ b/panda/src/sgraph/config_sgraph.cxx @@ -13,11 +13,33 @@ #include "projectionNode.h" #include +#include Configure(config_sgraph); NotifyCategoryDef(sgraph, ""); ConfigureFn(config_sgraph) { + init_libsgraph(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libsgraph +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libsgraph() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + + init_libgraph(); + RenderTraverser::init_type(); GeomNode::init_type(); Camera::init_type(); diff --git a/panda/src/sgraph/config_sgraph.h b/panda/src/sgraph/config_sgraph.h index cf065da0c4..43f25dd03f 100644 --- a/panda/src/sgraph/config_sgraph.h +++ b/panda/src/sgraph/config_sgraph.h @@ -11,4 +11,6 @@ NotifyCategoryDecl(sgraph, EXPCL_PANDA, EXPTP_PANDA); +extern EXPCL_PANDA void init_libsgraph(); + #endif diff --git a/panda/src/testbed/Sources.pp b/panda/src/testbed/Sources.pp index fc63f5ded4..517a66d110 100644 --- a/panda/src/testbed/Sources.pp +++ b/panda/src/testbed/Sources.pp @@ -4,7 +4,17 @@ framework putil collide loader sgmanip chan text chancfg cull \ pnmimage pnmimagetypes event effects shader graph gobj display \ mathutil sgattrib putil express light dgraph device tform sgraph \ - linmath pstatclient sgraphutil + linmath pstatclient sgraphutil panda + +#if $[LINK_ALL_STATIC] + // If we're statically linking, we need to explicitly link with + // at least one graphics renderer. + #define LOCAL_LIBS pandagl pandadx $[LOCAL_LIBS] + + // And we might like to have the egg loader available. + #define LOCAL_LIBS pandaegg $[LOCAL_LIBS] +#endif + #define UNIX_SYS_LIBS m diff --git a/panda/src/testbed/demo.cxx b/panda/src/testbed/demo.cxx index 38a2614065..1d8a7be455 100644 --- a/panda/src/testbed/demo.cxx +++ b/panda/src/testbed/demo.cxx @@ -40,7 +40,19 @@ #include #include #include +#include +// If we're doing a static link, we should explicitly initialize some +// of our external libraries, or they may not get linked in. +#ifdef LINK_ALL_STATIC + #ifdef HAVE_GL + #include + #endif + #ifdef HAVE_DX + #include + #endif + #include +#endif //From framework extern PT(GeomNode) geomnode; @@ -578,6 +590,23 @@ void demo_keys(EventHandler&) { } int main(int argc, char *argv[]) { + // We call init_libpanda() to be paranoid. It's not supposed to be + // necessary, but it turns out that static init isn't dependable in + // all cases. + init_libpanda(); + + // If we're doing a static link, we should explicitly initialize some + // of our external libraries, or they may not get linked in. +#ifdef LINK_ALL_STATIC + #ifdef HAVE_GL + init_libpandagl(); + #endif + #ifdef HAVE_DX + init_libpandadx(); + #endif + init_libpandaegg(); +#endif + define_keys = &demo_keys; return framework_main(argc, argv); } diff --git a/panda/src/wdxdisplay/Sources.pp b/panda/src/wdxdisplay/Sources.pp index 30be08016e..8726235e19 100644 --- a/panda/src/wdxdisplay/Sources.pp +++ b/panda/src/wdxdisplay/Sources.pp @@ -14,7 +14,7 @@ wdxGraphicsPipe.h wdxGraphicsWindow.cxx wdxGraphicsWindow.h #define INSTALL_HEADERS \ - wdxGraphicsPipe.h wdxGraphicsWindow.h + config_wdxdisplay.h wdxGraphicsPipe.h wdxGraphicsWindow.h #end lib_target diff --git a/panda/src/wdxdisplay/config_wdxdisplay.cxx b/panda/src/wdxdisplay/config_wdxdisplay.cxx index b7ba1432f1..88e2042897 100644 --- a/panda/src/wdxdisplay/config_wdxdisplay.cxx +++ b/panda/src/wdxdisplay/config_wdxdisplay.cxx @@ -13,12 +13,31 @@ Configure(config_wdxdisplay); NotifyCategoryDef(wdxdisplay, "display"); ConfigureFn(config_wdxdisplay) { + init_libwdxdisplay(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libwdxdisplay +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libwdxdisplay() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + wdxGraphicsPipe::init_type(); - GraphicsPipe::_factory.register_factory( + GraphicsPipe::get_factory().register_factory( wdxGraphicsPipe::get_class_type(), wdxGraphicsPipe::make_wdxGraphicsPipe); wdxGraphicsWindow::init_type(); - GraphicsWindow::_factory.register_factory( + GraphicsWindow::get_factory().register_factory( wdxGraphicsWindow::get_class_type(), wdxGraphicsWindow::make_wdxGraphicsWindow); } diff --git a/panda/src/wdxdisplay/config_wdxdisplay.h b/panda/src/wdxdisplay/config_wdxdisplay.h index 25b2a7670d..9c23b7574e 100644 --- a/panda/src/wdxdisplay/config_wdxdisplay.h +++ b/panda/src/wdxdisplay/config_wdxdisplay.h @@ -11,5 +11,6 @@ NotifyCategoryDecl(wdxdisplay, EXPCL_PANDADX, EXPTP_PANDADX); +extern EXPCL_PANDADX void init_libwdxdisplay(); #endif /* __CONFIG_WDXDISPLAY_H__ */ diff --git a/panda/src/wgldisplay/Sources.pp b/panda/src/wgldisplay/Sources.pp index 163788d386..a942fb49c7 100644 --- a/panda/src/wgldisplay/Sources.pp +++ b/panda/src/wgldisplay/Sources.pp @@ -13,7 +13,7 @@ wglGraphicsPipe.h wglGraphicsWindow.cxx wglGraphicsWindow.h #define INSTALL_HEADERS \ - wglGraphicsPipe.h wglGraphicsWindow.h + config_wgldisplay.h wglGraphicsPipe.h wglGraphicsWindow.h #end lib_target diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index 67103c2356..68db469116 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -13,12 +13,31 @@ Configure(config_wgldisplay); NotifyCategoryDef(wgldisplay, "display"); ConfigureFn(config_wgldisplay) { + init_libwgldisplay(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libwgldisplay +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libwgldisplay() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + wglGraphicsPipe::init_type(); - GraphicsPipe::_factory.register_factory( + GraphicsPipe::get_factory().register_factory( wglGraphicsPipe::get_class_type(), wglGraphicsPipe::make_wglGraphicsPipe); wglGraphicsWindow::init_type(); - GraphicsWindow::_factory.register_factory( + GraphicsWindow::get_factory().register_factory( wglGraphicsWindow::get_class_type(), wglGraphicsWindow::make_wglGraphicsWindow); } diff --git a/panda/src/wgldisplay/config_wgldisplay.h b/panda/src/wgldisplay/config_wgldisplay.h index 38707e3b53..6fc5724f5f 100644 --- a/panda/src/wgldisplay/config_wgldisplay.h +++ b/panda/src/wgldisplay/config_wgldisplay.h @@ -11,5 +11,6 @@ NotifyCategoryDecl(wgldisplay, EXPCL_PANDAGL, EXPTP_PANDAGL); +extern EXPCL_PANDAGL void init_libwgldisplay(); #endif /* __CONFIG_WGLDISPLAY_H__ */