|
69 | 69 |
|
70 | 70 | from pyrr.utils import parameters_as_numpy_arrays
|
71 | 71 |
|
| 72 | +from pygly.gl import _generate_enum_map |
| 73 | + |
72 | 74 |
|
73 | 75 | def parse_shader_error( error ):
|
74 | 76 | """Parses a single GLSL error and extracts the line number
|
@@ -242,21 +244,6 @@ def attribute_for_name( handle, name ):
|
242 | 244 | return None
|
243 | 245 |
|
244 | 246 |
|
245 |
| -def _generate_enum_map( enum_names ): |
246 |
| - """Convert dicts of format {'GL_ENUM_NAME': value, ...} |
247 |
| - to { GL_ENUM_NAME : value, ...} |
248 |
| -
|
249 |
| - Used to ignore NameErrors that would otherwise result from incomplete |
250 |
| - OpenGL implementations. |
251 |
| - """ |
252 |
| - map = {} |
253 |
| - for (key, value) in enum_names.items(): |
254 |
| - try: |
255 |
| - map[ getattr(GL, key) ] = value |
256 |
| - except AttributeError: |
257 |
| - pass |
258 |
| - return map |
259 |
| - |
260 | 247 | #: processes our enumeration to string map and stores the result
|
261 | 248 | _enum_string_map = _generate_enum_map(
|
262 | 249 | {
|
@@ -470,7 +457,10 @@ def _print_shader_errors( self, buffer ):
|
470 | 457 | print( "\tCode: %s" % lines[ line - 1 ] )
|
471 | 458 |
|
472 | 459 | def __str__( self ):
|
473 |
| - string = "Shader:\t%s" % ( enum_to_string( self.type ) ) |
| 460 | + string = "%s(type=%s)" % ( |
| 461 | + self.__class__.__name__, |
| 462 | + enum_to_string( self.type ) |
| 463 | + ) |
474 | 464 | return string
|
475 | 465 |
|
476 | 466 |
|
@@ -670,14 +660,10 @@ def __getitem__(self, name):
|
670 | 660 | raise KeyError( name )
|
671 | 661 |
|
672 | 662 | def __str__( self ):
|
673 |
| - string = \ |
674 |
| - "ShaderProgram:\n" \ |
675 |
| - "Linked:\t%s\n" \ |
676 |
| - "%s\n" \ |
677 |
| - "%s" % ( |
678 |
| - str(self.linked), |
679 |
| - str(self.attributes), |
680 |
| - str(self.uniforms) |
| 663 | + string = "%s(uniforms=[%s], attributes=[%s])" % ( |
| 664 | + self.__class__.__name__, |
| 665 | + str( self.uniforms ), |
| 666 | + str( self.attributes ) |
681 | 667 | )
|
682 | 668 | return string
|
683 | 669 |
|
@@ -805,10 +791,13 @@ def __setitem__( self, name, value ):
|
805 | 791 | self[ name ].value = value
|
806 | 792 |
|
807 | 793 | def __str__( self ):
|
808 |
| - string = "Uniforms:\n" |
| 794 | + string = "%s(" % (self.__class__.__name__) |
| 795 | + |
809 | 796 | for uniform in self:
|
810 |
| - string += str(uniform) + "\n" |
811 |
| - return string[:-1] |
| 797 | + string += str(uniform) + ", " |
| 798 | + string = string[:-2] + ")" |
| 799 | + |
| 800 | + return string |
812 | 801 |
|
813 | 802 |
|
814 | 803 | class Uniform( object ):
|
@@ -948,7 +937,7 @@ def value( self, *args ):
|
948 | 937 | def __str__( self ):
|
949 | 938 | """Returns a human readable string representing the Uniform.
|
950 | 939 | """
|
951 |
| - return "%s:\t%s\t%s\t%d" % ( |
| 940 | + return "%s(name=%s, type=%s, location=%d)" % ( |
952 | 941 | self.__class__.__name__,
|
953 | 942 | self.name,
|
954 | 943 | enum_to_string( self.type ),
|
@@ -1280,10 +1269,12 @@ def __setitem__( self, name, value ):
|
1280 | 1269 | self[ name ].location = value
|
1281 | 1270 |
|
1282 | 1271 | def __str__( self ):
|
1283 |
| - string = "Attributes:\n" |
| 1272 | + string = "%s(" % (self.__class__.__name__) |
| 1273 | + |
1284 | 1274 | for attribute in self:
|
1285 |
| - string += str(attribute) + "\n" |
1286 |
| - return string[:-1] |
| 1275 | + string += str(attribute) + ", " |
| 1276 | + |
| 1277 | + return string[:-2] + ")" |
1287 | 1278 |
|
1288 | 1279 |
|
1289 | 1280 | class Attribute( object ):
|
@@ -1338,7 +1329,7 @@ def location( self, location ):
|
1338 | 1329 | def __str__( self ):
|
1339 | 1330 | """Returns a human readable string representing the Attribute.
|
1340 | 1331 | """
|
1341 |
| - return "%s:\t%s\t%s\t%d" % ( |
| 1332 | + return "%s(name=%s, type=%s, location=%d)" % ( |
1342 | 1333 | self.__class__.__name__,
|
1343 | 1334 | self.name,
|
1344 | 1335 | enum_to_string( self.type ),
|
|
0 commit comments