peng3d/resource.py
def addFromTex(self,name,img,category):
        """
        Adds a new texture from the given image.
        
        ``img`` may be any object that supports Pyglet-style copying in form of the ``blit_to_texture()`` method.
        
        This can be used to add textures that come from non-file sources, e.g. Render-to-texture.
        """
        texreg = self.categoriesTexBin[category].add(img)
        #texreg = texreg.get_transform(True,True) # Mirrors the image due to how pyglets coordinate system works
        # Strange behaviour, sometimes needed and sometimes not
        
        self.categories[category][name]=texreg
        target = texreg.target
        texid = texreg.id
        texcoords = texreg.tex_coords
        
        # Prevents texture bleeding with texture sizes that are powers of 2, else weird lines may appear at certain angles.
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)
        glGenerateMipmap(GL_TEXTURE_2D)
        
        out = target,texid,texcoords
        self.categoriesTexCache[category][name]=out
        return out
def addFromTex(self,name,img,category):
        """
        Adds a new texture from the given image.
        
        ``img`` may be any object that supports Pyglet-style copying in form of the ``blit_to_texture()`` method.
        
        This can be used to add textures that come from non-file sources, e.g. Render-to-texture.
        """
        texreg = self.categoriesTexBin[category].add(img)
        #texreg = texreg.get_transform(True,True) # Mirrors the image due to how pyglets coordinate system works
        # Strange behaviour, sometimes needed and sometimes not
        
        self.categories[category][name]=texreg
        target = texreg.target
        texid = texreg.id
        texcoords = texreg.tex_coords
        
        # Prevents texture bleeding with texture sizes that are powers of 2, else weird lines may appear at certain angles.
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR)
        glGenerateMipmap(GL_TEXTURE_2D)
        
        out = target,texid,texcoords
        self.categoriesTexCache[category][name]=out
        return out
def addFromTex ( self , name , img , category ) : texreg = self . categoriesTexBin [ category ] . add ( img ) #texreg = texreg.get_transform(True,True) # Mirrors the image due to how pyglets coordinate system works # Strange behaviour, sometimes needed and sometimes not self . categories [ category ] [ name ] = texreg target = texreg . target texid = texreg . id texcoords = texreg . tex_coords # Prevents texture bleeding with texture sizes that are powers of 2, else weird lines may appear at certain angles. glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_REPEAT ) glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_REPEAT ) glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_NEAREST ) glTexParameteri ( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_NEAREST_MIPMAP_LINEAR ) glGenerateMipmap ( GL_TEXTURE_2D ) out = target , texid , texcoords self . categoriesTexCache [ category ] [ name ] = out return out
Adds a new texture from the given image.
        
        ``img`` may be any object that supports Pyglet-style copying in form of the ``blit_to_texture()`` method.
        
        This can be used to add textures that come from non-file sources, e.g. Render-to-texture.
Adds a new texture from the given image . img may be any object that supports Pyglet - style copying in form of the blit_to_texture () method . This can be used to add textures that come from non - file sources e . g . Render - to - texture .