__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
"""Numbers passed as array handling code for PyOpenGL
"""
REGISTRY_NAME = 'numbers'
from OpenGL.raw.GL import _types
from OpenGL.raw.GL.VERSION import GL_1_1
from OpenGL.arrays import formathandler
import ctypes
from OpenGL._bytes import long, integer_types
n = c = None
class NumberHandler(formathandler.FormatHandler):
"""Allows the user to pass a bald Python float,int, etceteras as an array-of-1"""
HANDLED_TYPES = integer_types + (
float,
_types.GLdouble,
_types.GLfloat,
_types.GLint,
_types.GLshort,
_types.GLuint,
_types.GLulong,
_types.GLushort,
_types.GLclampf,
_types.GLclampd,
)
def from_param(self, value, typeCode=None):
"""If it's a ctypes value, pass on, otherwise do asArray"""
try:
return ctypes.byref(value)
except TypeError as err:
err.args += (
' If you have ERROR_ON_COPY enabled, remember to pass in an array to array-requiring functions.',
)
raise
dataPointer = from_param
def zeros(self, dims, typeCode=None):
"""Currently don't allow Number as output types!"""
raise NotImplementedError(
"""Number data-type not allowed as an output array format"""
)
def ones(self, dims, typeCode=None):
"""Currently don't allow Number as output types!"""
raise NotImplementedError(
"""Number data-type not allowed as an output array format"""
)
def arrayToGLType(self, value):
"""Given a value, guess OpenGL type of the corresponding pointer"""
if value.__class__ in TARGET_TYPES:
return TARGET_TYPES[value.__class__]
else:
guess = DEFAULT_TYPES.get(value.__class__)
if guess is not None:
return guess[1]
raise TypeError(
"""Can't guess array data-type for %r types""" % (type(value))
)
def arraySize(self, value, typeCode=None):
"""Given a data-value, calculate ravelled size for the array"""
return 1
def asArray(self, value, typeCode=None):
"""Convert given value to an array value of given typeCode"""
if value.__class__ in TARGET_TYPES:
return value
targetType = CONSTANT_TO_TYPE.get(typeCode)
if targetType is not None:
return targetType(value)
raise TypeError(
"""Don't know how to convert %r to an array type""" % (typeCode,)
)
def unitSize(self, value, typeCode=None):
"""Determine unit size of an array (if possible)"""
return 1 # there's only 1 possible value in the set...
def registerEquivalent(self, typ, base):
"""Register a sub-class for handling as the base-type"""
global TARGET_TYPE_TUPLE
for source in (DEFAULT_TYPES, TARGET_TYPES, BYTE_SIZES):
if base in source:
source[typ] = source[base]
if base in TARGET_TYPES:
TARGET_TYPE_TUPLE = TARGET_TYPE_TUPLE + (base,)
DEFAULT_TYPES = {
float: (_types.GLdouble, GL_1_1.GL_DOUBLE),
int: (_types.GLint, GL_1_1.GL_INT),
long: (_types.GLint, GL_1_1.GL_INT),
}
TARGET_TYPES = dict(
[(getattr(_types, n), c) for (n, c) in _types.ARRAY_TYPE_TO_CONSTANT]
)
TARGET_TYPE_TUPLE = tuple(
[getattr(_types, n) for (n, c) in _types.ARRAY_TYPE_TO_CONSTANT]
)
CONSTANT_TO_TYPE = dict(
[(c, getattr(_types, n)) for (n, c) in _types.ARRAY_TYPE_TO_CONSTANT]
)
BYTE_SIZES = dict(
[(c, ctypes.sizeof(getattr(_types, n))) for (n, c) in _types.ARRAY_TYPE_TO_CONSTANT]
)
try:
del n, c
except NameError as err:
pass
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 637 B | 0644 |
|
| _arrayconstants.py | File | 1.41 KB | 0644 |
|
| _buffers.py | File | 3.34 KB | 0644 |
|
| _strings.py | File | 2.25 KB | 0644 |
|
| arraydatatype.py | File | 13.64 KB | 0644 |
|
| arrayhelpers.py | File | 7 KB | 0644 |
|
| buffers.py | File | 4.29 KB | 0644 |
|
| ctypesarrays.py | File | 5.26 KB | 0644 |
|
| ctypesparameters.py | File | 5.42 KB | 0644 |
|
| ctypespointers.py | File | 3.36 KB | 0644 |
|
| formathandler.py | File | 3.78 KB | 0644 |
|
| lists.py | File | 7.66 KB | 0644 |
|
| nones.py | File | 2.42 KB | 0644 |
|
| numbers.py | File | 3.63 KB | 0644 |
|
| numpybuffers.py | File | 4.69 KB | 0644 |
|
| numpymodule.py | File | 10.4 KB | 0644 |
|
| strings.py | File | 3.58 KB | 0644 |
|
| vbo.py | File | 19.01 KB | 0644 |
|