def _has_uniform(self, name): #bruce 090309 """ @return: whether the specified uniform (input) shader variable has a location. @rtype: boolean @note: this can differ for different platforms based on the level of optimization done by their implementation of GLSL (if the uniform is allocated but not used by our shaders). @see: _uniform """ loc = glGetUniformLocationARB(self.progObj, name) return (loc != -1)
def _has_uniform(self, name): #bruce 090309 """ @return: whether the specified uniform (input) shader variable has a location. @rtype: boolean @note: this can differ for different platforms based on the level of optimization done by their implementation of GLSL (if the uniform is allocated but not used by our shaders). @see: _uniform """ loc = glGetUniformLocationARB(self.progObj, name) return (loc != -1)
def _uniform(self, name): #bruce 090302 renamed from self.uniform() """ Return location of a uniform (input) shader variable. If it's not found, return -1 and warn once per session for end users, or raise an AssertionError for developers. @see: _has_uniform """ loc = glGetUniformLocationARB(self.progObj, name) if loc == -1: # The glGetUniformLocationARB man page says: # "name must be an active uniform variable name in program that is # not a structure, an array of structures, or a subcomponent of a # vector or a matrix." # # It "returns -1 if the name does not correspond to an active # uniform variable in program". Then getUniform ignores it: "If # location is equal to -1, the data passed in will be silently # ignored and the specified uniform variable will not be changed." # # Lets not be so quiet. msg = "Invalid or unused uniform shader variable name '%s'." % name if EndUser.enableDeveloperFeatures(): # Developers want to know of a mismatch between their Python # and shader programs as soon as possible. Not doing so causes # logic errors, or at least incorrect assumptions, to silently # propagate through the code and makes debugging more difficult. assert 0, msg else: # End users on the other hand, may value program stability more. # Just print a warning if the program is released. Do it only # once per session, since this will be in the inner draw loop! global _warnedVars if name not in _warnedVars: print "Warning:", msg _warnedVars += [name] pass pass pass return loc
def _uniform(self, name): #bruce 090302 renamed from self.uniform() """ Return location of a uniform (input) shader variable. If it's not found, return -1 and warn once per session for end users, or raise an AssertionError for developers. @see: _has_uniform """ loc = glGetUniformLocationARB(self.progObj, name) if loc == -1: # The glGetUniformLocationARB man page says: # "name must be an active uniform variable name in program that is # not a structure, an array of structures, or a subcomponent of a # vector or a matrix." # # It "returns -1 if the name does not correspond to an active # uniform variable in program". Then getUniform ignores it: "If # location is equal to -1, the data passed in will be silently # ignored and the specified uniform variable will not be changed." # # Lets not be so quiet. msg = "Invalid or unused uniform shader variable name '%s'." % name if EndUser.enableDeveloperFeatures(): # Developers want to know of a mismatch between their Python # and shader programs as soon as possible. Not doing so causes # logic errors, or at least incorrect assumptions, to silently # propagate through the code and makes debugging more difficult. assert 0, msg else: # End users on the other hand, may value program stability more. # Just print a warning if the program is released. Do it only # once per session, since this will be in the inner draw loop! global _warnedVars if name not in _warnedVars: print "Warning:", msg _warnedVars += [name] pass pass pass return loc