예제 #1
0
파일: texture.py 프로젝트: vidriloco/pymt
 def has_bgr():
     if not Texture._has_bgr_tested:
         pymt_logger.warning('Texture: BGR/BGRA format is not supported by your graphic card')
         pymt_logger.warning('Texture: Software conversion will be done to RGB/RGBA')
         Texture._has_bgr = extensions.hasGLExtension('GL_EXT_bgra')
         Texture._has_bgr_tested = True
     return Texture._has_bgr
예제 #2
0
파일: texture.py 프로젝트: gavine199/pymt
 def has_bgr():
     if not Texture._has_bgr_tested:
         pymt_logger.warning('Texture: BGR/BGRA format is not supported by'
                             'your graphic card')
         pymt_logger.warning('Texture: Software conversion will be done to'
                             'RGB/RGBA')
         Texture._has_bgr = hasGLExtension('GL_EXT_bgra')
         Texture._has_bgr_tested = True
     return Texture._has_bgr
예제 #3
0
파일: texture.py 프로젝트: vidriloco/pymt
    def create(width, height, format=GL_RGBA, rectangle=False, mipmap=False):
        '''Create a texture based on size.'''
        target = GL_TEXTURE_2D
        if rectangle:
            if _is_pow2(width) and _is_pow2(height):
                rectangle = False
            elif GL_ARB_texture_rectangle:
                target = GL_TEXTURE_RECTANGLE_ARB
            elif GL_NV_texture_rectangle:
                target = GL_TEXTURE_RECTANGLE_NV
            else:
                pymt_logger.warning('Texture: Unable to create a rectangular texture, ' +
                                    'no GL support found.')
                rectangle = False

        if rectangle:
            texture_width = width
            texture_height = height
        else:
            texture_width = _nearest_pow2(width)
            texture_height = _nearest_pow2(height)

        id = glGenTextures(1)
        texture = Texture(texture_width, texture_height, target, id, mipmap=mipmap)

        texture.bind()
        texture.wrap        = GL_CLAMP_TO_EDGE
        if mipmap:
            texture.min_filter  = GL_LINEAR_MIPMAP_LINEAR
            #texture.mag_filter  = GL_LINEAR_MIPMAP_LINEAR
            glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE)
        else:
            texture.min_filter  = GL_LINEAR
            texture.mag_filter  = GL_LINEAR

        if not Texture.is_gl_format_supported(format):
            format = Texture.convert_gl_format(format)

        data = (GLubyte * texture_width * texture_height *
                Texture.gl_format_size(format))()
        glTexImage2D(target, 0, format, texture_width, texture_height, 0,
                     format, GL_UNSIGNED_BYTE, data)

        if rectangle:
            texture.tex_coords = \
                (0., 0., width, 0., width, height, 0., height)

        glFlush()

        if texture_width == width and texture_height == height:
            return texture

        return texture.get_region(0, 0, width, height)
예제 #4
0
파일: accelerate.py 프로젝트: patali/pymt
Accelerate module use cython, and is activated by default, if cython is
correctly installed. Please refer to http://www.cython.org/ about how
to install cython on your environment.

You can control the usage of accelerate module with env variable ::

    PYMT_USE_ACCELERATE

If the env is set to 0, the module will be deactivated.
'''

__all__ = ('accelerate', )

from pymt import options, pymt_logger

#: Accelerate module (None mean that the module is not available)
accelerate = None

# try to use cython is available
if options.get('use_accelerate'):
    try:
        import _accelerate as accelerate
        pymt_logger.info('Core: Using accelerate module')
    except ImportError, e:
        pymt_logger.warning('Core: Accelerate module not available <%s>' % e)
        pymt_logger.warning('Core: Execute "python setup.py build_ext --inplace"')
else:
    pymt_logger.info('Core: Accelerate module disabled by user')

예제 #5
0
Accelerate module use cython, and is activated by default, if cython is
correctly installed. Please refer to http://www.cython.org/ about how
to install cython on your environment.

You can control the usage of accelerate module with env variable ::

    PYMT_USE_ACCELERATE

If the env is set to 0, the module will be deactivated.
'''

__all__ = ('accelerate', )

from pymt import pymt_options, pymt_logger

#: Accelerate module (None mean that the module is not available)
accelerate = None

# try to use cython is available
if pymt_options.get('use_accelerate'):
    try:
        import pymt.c_ext.c_accelerate as accelerate
        pymt_logger.info('Core: Using accelerate module')
    except ImportError, e:
        pymt_logger.warning('Core: Accelerate module not available <%s>' % e)
        pymt_logger.warning('Core: Execute "python setup.py build_ext '
                            '--inplace"')
else:
    pymt_logger.info('Core: Accelerate module disabled by user')