diff --git a/direct/src/gui/DirectScrolledList.py b/direct/src/gui/DirectScrolledList.py index 661b09f13d..ca7551d2c9 100644 --- a/direct/src/gui/DirectScrolledList.py +++ b/direct/src/gui/DirectScrolledList.py @@ -9,6 +9,12 @@ from direct.directnotify import DirectNotifyGlobal from direct.task.Task import Task from .DirectFrame import * from .DirectButton import * +import sys + +if sys.version_info >= (3,0): + stringType = str +else: + stringType = basestring class DirectScrolledListItem(DirectButton): @@ -61,7 +67,7 @@ class DirectScrolledList(DirectFrame): # so we can modify it without mangling the user's list if 'items' in kw: for item in kw['items']: - if type(item) != type(''): + if not isinstance(item, stringType): break else: # we get here if every item in 'items' is a string @@ -106,7 +112,7 @@ class DirectScrolledList(DirectFrame): DirectFrame, (self,), ) for item in self["items"]: - if item.__class__.__name__ != 'str': + if not isinstance(item, stringType): item.reparentTo(self.itemFrame) self.initialiseoptions(DirectScrolledList) @@ -124,7 +130,7 @@ class DirectScrolledList(DirectFrame): else: self.maxHeight = 0.0 for item in self["items"]: - if item.__class__.__name__ != 'str': + if not isinstance(item, stringType): self.maxHeight = max(self.maxHeight, item.getHeight()) def setScrollSpeed(self): @@ -172,7 +178,7 @@ class DirectScrolledList(DirectFrame): if len(self["items"]) == 0: return 0 - if type(self["items"][0]) == type(''): + if isinstance(self["items"][0], stringType): self.notify.warning("getItemIndexForItemID: cant find itemID for non-class list items!") return 0 @@ -238,7 +244,7 @@ class DirectScrolledList(DirectFrame): # Hide them all for item in self["items"]: - if item.__class__.__name__ != 'str': + if not isinstance(item, stringType): item.hide() # Then show the ones in range, and stack their positions @@ -248,7 +254,7 @@ class DirectScrolledList(DirectFrame): #print "stacking buttontext[", i,"]", self["items"][i]["text"] # If the item is a 'str', then it has not been created (scrolled list is 'as needed') # Therefore, use the the function given to make it or just make it a frame - if item.__class__.__name__ == 'str': + if isinstance(item, stringType): if self['itemMakeFunction']: # If there is a function to create the item item = self['itemMakeFunction'](item, i, self['itemMakeExtraArgs']) @@ -280,7 +286,7 @@ class DirectScrolledList(DirectFrame): # Therefore, use the the function given to make it or # just make it a frame #print "Making " + str(item) - if item.__class__.__name__ == 'str': + if isinstance(item, stringType): if self['itemMakeFunction']: # If there is a function to create the item item = self['itemMakeFunction'](item, i, self['itemMakeExtraArgs']) @@ -345,16 +351,16 @@ class DirectScrolledList(DirectFrame): Add this string and extraArg to the list """ assert self.notify.debugStateCall(self) - if type(item) != type(''): + if not isinstance(item, stringType): # cant add attribs to non-classes (like strings & ints) item.itemID = self.nextItemID self.nextItemID += 1 self['items'].append(item) - if type(item) != type(''): + if not isinstance(item, stringType): item.reparentTo(self.itemFrame) if refresh: self.refresh() - if type(item) != type(''): + if not isinstance(item, stringType): return item.itemID # to pass to scrollToItemID def removeItem(self, item, refresh=1): @@ -369,7 +375,7 @@ class DirectScrolledList(DirectFrame): if hasattr(self, "currentSelected") and self.currentSelected is item: del self.currentSelected self["items"].remove(item) - if type(item) != type(''): + if not isinstance(item, stringType): item.reparentTo(ShowBaseGlobal.hidden) self.refresh() return 1 @@ -387,7 +393,7 @@ class DirectScrolledList(DirectFrame): if (hasattr(item, 'destroy') and hasattr(item.destroy, '__call__')): item.destroy() self["items"].remove(item) - if type(item) != type(''): + if not isinstance(item, stringType): item.reparentTo(ShowBaseGlobal.hidden) self.refresh() return 1 @@ -409,7 +415,7 @@ class DirectScrolledList(DirectFrame): if hasattr(self, "currentSelected") and self.currentSelected is item: del self.currentSelected self["items"].remove(item) - if type(item) != type(''): + if not isinstance(item, stringType): #RAU possible leak here, let's try to do the right thing #item.reparentTo(ShowBaseGlobal.hidden) item.removeNode() @@ -434,7 +440,7 @@ class DirectScrolledList(DirectFrame): if (hasattr(item, 'destroy') and hasattr(item.destroy, '__call__')): item.destroy() self["items"].remove(item) - if type(item) != type(''): + if not isinstance(item, stringType): #RAU possible leak here, let's try to do the right thing #item.reparentTo(ShowBaseGlobal.hidden) item.removeNode() @@ -459,7 +465,7 @@ class DirectScrolledList(DirectFrame): def getSelectedText(self): assert self.notify.debugStateCall(self) - if self['items'][self.index].__class__.__name__ == 'str': + if isinstance(self['items'][self.index], stringType): return self['items'][self.index] else: return self['items'][self.index]['text'] diff --git a/makepanda/makepackage.py b/makepanda/makepackage.py index 560d1a2c55..44233fadf3 100755 --- a/makepanda/makepackage.py +++ b/makepanda/makepackage.py @@ -461,6 +461,11 @@ def MakeInstallerOSX(version, python_versions=[], **kwargs): oscmd("mkdir -p %s" % (dir)) WriteFile("%s/Panda3D.pth" % (dir), "/Developer/Panda3D") + # Also place it somewhere the Homebrew version of Python can find it. + dir = "dstroot/pybindings%s/usr/local/lib/python%s/site-packages" % (pyver, pyver) + oscmd("mkdir -p %s" % (dir)) + WriteFile("%s/Panda3D.pth" % (dir), "/Developer/Panda3D") + if not PkgSkip("FFMPEG"): oscmd("mkdir -p dstroot/ffmpeg/Developer/Panda3D/lib") oscmd("cp -R %s/lib/libp3ffmpeg.* dstroot/ffmpeg/Developer/Panda3D/lib/" % outputdir) diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 58866efef6..cdf68c3d1c 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -397,8 +397,9 @@ load_named_module(const string &name) { << "loading display module: " << dlname.to_os_specific() << std::endl; void *handle = load_dso(get_plugin_path().get_value(), dlname); if (handle == nullptr) { + std::string error = load_dso_error(); display_cat.warning() - << "Unable to load: " << load_dso_error() << std::endl; + << "Unable to load " << dlname.get_basename() << ": " << error << std::endl; return TypeHandle::none(); } diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 6e7fc565cc..8d90d1cd50 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -131,6 +131,7 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte // glVertexPointer). size_t nvarying = _shader->_var_spec.size(); _attributes.resize(nvarying); + _used_generic_attribs.clear(); for (size_t i = 0; i < nvarying; ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; @@ -332,6 +333,9 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte #endif _attributes[i] = loc; + if (loc >= 0) { + _used_generic_attribs.set_bit(loc); + } } _glgsg->report_my_gl_errors(); @@ -857,8 +861,6 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { int start, stride, num_values; size_t nvarying = _shader->_var_spec.size(); - GLuint max_p = 0; - for (size_t i = 0; i < nvarying; ++i) { const Shader::ShaderVarSpec &bind = _shader->_var_spec[i]; InternalName *name = bind._name; @@ -893,8 +895,6 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // limited in the options we can set. GLenum type = _glgsg->get_numeric_type(numeric_type); if (p >= 0) { - max_p = std::max(max_p, (GLuint)p + 1); - _glgsg->enable_vertex_attrib_array(p); if (numeric_type == GeomEnums::NT_packed_dabc) { @@ -1018,10 +1018,14 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { } } - // Disable attribute arrays we don't use. - GLint highest_p = _glgsg->_enabled_vertex_attrib_arrays.get_highest_on_bit() + 1; - for (GLint p = max_p; p < highest_p; ++p) { - _glgsg->disable_vertex_attrib_array(p); + // Disable enabled attribute arrays that we don't use. + BitMask32 disable = _glgsg->_enabled_vertex_attrib_arrays & ~_used_generic_attribs; + if (!disable.is_zero()) { + for (GLuint p = (GLuint)disable.get_lowest_on_bit(); p <= (GLuint)disable.get_highest_on_bit(); ++p) { + if (disable.get_bit(p)) { + _glgsg->disable_vertex_attrib_array(p); + } + } } } diff --git a/panda/src/glstuff/glCgShaderContext_src.h b/panda/src/glstuff/glCgShaderContext_src.h index 63338b3520..553cafe487 100644 --- a/panda/src/glstuff/glCgShaderContext_src.h +++ b/panda/src/glstuff/glCgShaderContext_src.h @@ -68,6 +68,7 @@ private: GLuint _glsl_program; pvector _attributes; + BitMask32 _used_generic_attribs; GLint _color_attrib_index; CGparameter _transform_table_param; CGparameter _slider_table_param; diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index 64acc8e42a..f17b43010d 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -123,9 +123,10 @@ load_audio_types() { << "loading audio type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { + std::string error = load_dso_error(); movies_cat.warning() << "Unable to load " << dlname.to_os_specific() - << ": " << load_dso_error() << endl; + << ": " << error << endl; } else if (movies_cat.is_debug()) { movies_cat.debug() << "done loading audio type module: " << name << endl; @@ -252,9 +253,10 @@ load_video_types() { << "loading video type module: " << name << endl; void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { + std::string error = load_dso_error(); movies_cat.warning() << "Unable to load " << dlname.to_os_specific() - << ": " << load_dso_error() << endl; + << ": " << error << endl; } else if (movies_cat.is_debug()) { movies_cat.debug() << "done loading video type module: " << name << endl; @@ -294,9 +296,10 @@ load_movie_library(const string &name) { void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == nullptr) { + std::string error = load_dso_error(); movies_cat.warning() << "Unable to load " << dlname.to_os_specific() - << ": " << load_dso_error() << endl; + << ": " << error << endl; } else if (movies_cat.is_debug()) { movies_cat.debug() << "done loading video type module: " << name << endl;