Giter VIP home page Giter VIP logo

Comments (3)

marcusva avatar marcusva commented on June 2, 2024

Original comment by anatoly techtonik (Bitbucket: techtonik, GitHub: techtonik):


PySDL2 doesn't protect me from the complexity of SDL2 layer. =) I am looking to some intro / guideline about pixel manipulations with regard to helpers that PySDL2 provides.

  1. Thanks. This page helps. I'd still be interested to see some guidelines about how to use them. What are the most efficient pixel formats? How are they represented in SDL2? How they can be represented in Python? Where to set these pixel format? And how to convert my list of integers to pixel buffer? How to get that pixel buffer shown in window?

  2. There are PixelView and friends - http://pysdl2.readthedocs.org/en/latest/modules/sdl2ext_pixelaccess.html How are they different from continuous C memory buffer packed with raw pixel data? What is ctypes equivalent for these structures? Where memory buffer is locate - in CPU memory or in GPU memory? Can I edit CPU and GPU memory directly? Is it more efficient in Python than converting lists of ints?

  3. I want to have a pixel at 50,50. White. I figure out that white == (255,255,255), so what should I do to pixel = (50,50,(255,255,255) to make white dot appear on the screen? How processing will be different if I have a line of pixels?

  4. So, the ctypes is the only way to edit the memory directly? What about memoryview? How memory editing in Python is different from the same operation in C - is it optimized?

So basically I am looking for some guidelines how a pixel pipeline works in SDL2. Something like https://en.wikibooks.org/wiki/GLSL_Programming/OpenGL_ES_2.0_Pipeline or http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLES30PipelineMap.pdf with regard to SDL2 terms.

from py-sdl2.

marcusva avatar marcusva commented on June 2, 2024

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


I am not sure to what documentation you refer to, but PySDL2 does not protect you from messing with the bytes in system or video memory. You can gain read-write access to the pixel buffers of a texture or software surface via PySDL2 without any problems (and also without any safety net).

  1. SDL2 supports a variety of formats. An overview about the different supported formats can be found at http://wiki.libsdl.org/SDL_PixelFormatEnum
  2. PySDL2 provides a wrapper around the SDL2 internals. Hence there are no differences, since PySDL2 uses the C structures of SDL2 and just refers to the memory locations.
  3. I do not understand the question
  4. Are we talking about Python (the language) or PySDL2 here? The latter does not hide direct access to memory. Direct access is provided via ctypes.

from py-sdl2.

BigBMP avatar BigBMP commented on June 2, 2024

When using Software rendering "factory = sdl2.ext.SpriteFactory(sdl2.ext.SOFTWARE)" to creates a SpriteRenderSystem window "spriterenderer = factory.create_sprite_render_system(window)", how to you fill this window with a specific color?

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.