Comments (3)
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.
-
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?
-
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?
-
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?
-
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.
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).
- SDL2 supports a variety of formats. An overview about the different supported formats can be found at http://wiki.libsdl.org/SDL_PixelFormatEnum
- 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.
- I do not understand the question
- 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.
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)
- pysdl2 gfx not working in termux HOT 4
- Problem with SDL_GL_GetProcAddress() HOT 5
- Render._get_render_drivers() not working correctly
- Units test fail on big-endian architecture HOT 13
- Unit test expects SDL version to stay 2.0.x forever HOT 4
- Handling Resize of Images / Resize of Window with SpriteFactory/Renderer HOT 3
- SDL_TICKS_PASSED doesn't handle wraparound HOT 1
- Unable to set framerate with using the FPSManager HOT 2
- ValueError: NULL pointer access while running the test suite HOT 16
- test_Mix_MusicDuration failure: assert 0.2 < 0.1501... HOT 1
- Unit tests fail with SDL git main (2.25.x)
- How to convert SDL_Surface to pygame.Surface? HOT 3
- Accessing the original ctypes function pointers broke again HOT 2
- Incorrect use of SDL_GetError() to check whether calls failed HOT 6
- TTF_WRAPPED_ALIGN_* is not defined bug HOT 1
- How to delete UserWarning: Using SDL2 binaries from pysdl2-dll 2.28.0 HOT 6
- Window icon and title are not set properly HOT 5
- SDL_gfx: Circle radius greater than 1023 results in deformation HOT 1
- Events (keyboard kew presses) missing when running app in Debian minimum (console only, no X window manager) HOT 6
- SDL_CreateRGBSurfaceWithFormatFrom silently failing when passed a sub-array of a `bytes` object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from py-sdl2.