Giter VIP home page Giter VIP logo

Comments (6)

marcusva avatar marcusva commented on June 3, 2024

Original comment by Marcus von Appen (Bitbucket: marcusva, GitHub: marcusva):


  • fixed issue #36 and #39: the different render classes of sdl2.ext.sprite were renamed
    • the sdl2.ext.RenderContext class was renamed to sdl2.ext.Renderer to be
      consistent with with SDL2's naming scheme
    • sdl2.ext.SpriteRenderer was renamed to sdl2.ext.SpriteRenderSystem
    • sdl2.ext.SoftwareSpriteRenderer was renamed to sdl2.ext.SoftwareSpriteRenderSystem
    • sdl2.ext.TextureSpriteRenderer was renamed to sdl2.ext.TextureSpriteRenderSystem

from py-sdl2.

marcusva avatar marcusva commented on June 3, 2024

Original comment by Marcus von Appen (Bitbucket: marcusva, GitHub: marcusva):


Correct. You won't need an explicit TextureSpriteRenderer, though, since the RenderContext implicitly creates one, which is accessible via context.renderer on demand.

from py-sdl2.

marcusva avatar marcusva commented on June 3, 2024

Original comment by harradrush (Bitbucket: harradrush, GitHub: Unknown):


Oh, thanks. So, should I use something like that in such cases?

#!python

context = sdl2ext.RenderContext(window)
renderer = sdl2ext.TextureSpriteRenderer(context)
spriteFactory = sdl2ext.SpriteFactory(sprite_type=sdl2ext.TEXTURE, renderer=context)

from py-sdl2.

marcusva avatar marcusva commented on June 3, 2024

Original comment by Marcus von Appen (Bitbucket: marcusva, GitHub: marcusva):


The SpriteFactory requires a SDL_Renderer or RenderContext as argument to its renderer flag.

The TextureSpriteRenderer and SoftwareSpriterRenderer classes are not suitable for that, since they actually provide high-level functionality on top of the factory and renderers.

I should rename those to be more clear about that.

from py-sdl2.

marcusva avatar marcusva commented on June 3, 2024

Original comment by harradrush (Bitbucket: harradrush, GitHub: Unknown):


#!python

import sdl2.ext as sdl2ext

sdl2ext.init()

window = sdl2ext.Window('', size=(640, 480))
window.show()

renderer = sdl2ext.TextureSpriteRenderer(window)
#renderer.renderer = renderer.sdlrenderer #this is workaround I use
spriteFactory = sdl2ext.SpriteFactory(sprite_type=sdl2ext.TEXTURE, renderer=renderer)

sprite = spriteFactory.from_color(sdl2ext.convert_to_color((255, 0, 0, 0)), (32, 32))
renderer.render(sprite)

sdl2ext.TestEventProcessor().run(window)
sdl2ext.quit()

This code gives an error:

  File "D:\programming\PyCharm\virtualenv\Python_2.7.6_with_libs\lib\site-packages\sdl2\ext\sprite.py", line 465, in from_color
    return self.from_surface(sf, True)
  File "D:\programming\PyCharm\virtualenv\Python_2.7.6_with_libs\lib\site-packages\sdl2\ext\sprite.py", line 415, in from_surface
    texture = render.SDL_CreateTextureFromSurface(renderer.renderer,
AttributeError: 'TextureSpriteRenderer' object has no attribute 'renderer'

With workaround it works with no problem.

from py-sdl2.

marcusva avatar marcusva commented on June 3, 2024

Original comment by Marcus von Appen (Bitbucket: marcusva, GitHub: marcusva):


In which aspect is it incompatible with the SpriteFactory? Can you provide an example?

from py-sdl2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.