Fastest Method To Modify Pixels In SDL2 Texture?

Fastest Method To Modify Pixels In SDL2 Texture?

Hi,

We are working on a Wolfenstein 3D styled game SDL2 game now.
What would be the best and fastest method to modify pixels in an SDL2 texture?
We want to draw the 3d game off screen to an SDL2 texture and then render that SDL2 texture once to the screen.
Any advice would be appreciated!

You can download a clean and stable version of our work in progress game below:
http://16bitsoft.com/files/ThreeDimensional/Alpha/3D-WinLinux-Alpha02.zip
(game is 100% open-source cross-platform and has been tested on both Windows and Linux)

Thanks in advance!------------------------
JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com

I’ve had success using SDL_LockTexture and SDL_UpdateTexture for software
rendering. According to the wiki, SDL_LockTexture is faster but there are a
few anecdotes online where SDL_UpdateTexture has been faster. In the case
of SDL_UpdateTexture, I’m creating an RGBA/ABGR8888 pixel array with
Uint8_T *pixels = new [width * height *4]; Using SDL_LockTexture, it may be
possible to use SDL to allocate the memory
Uint8_T *pixels = SDL_LockTexture(tex);
//Modify pixels
pixels = NULL;
SDL_UnlockTexture(tex);On May 25, 2015 4:41 PM, “JeZ-l-Lee” wrote:

Fastest Method To Modify Pixels In SDL2 Texture?

Hi,

We are working on a Wolfenstein 3D styled game SDL2 game now.
What would be the best and fastest method to modify pixels in an SDL2
texture?
We want to draw the 3d game off screen to an SDL2 texture and then render
that SDL2 texture once to the screen.
Any advice would be appreciated!

You can download a clean and stable version of our work in progress game
below:
http://16bitsoft.com/files/ThreeDimensional/Alpha/3D-WinLinux-Alpha02.zip
(game is 100% open-source cross-platform and has been tested on both
Windows and Linux)

Thanks in advance!


JeZxLee
JessePalser GMail com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Maybe you can avoid modifying individual pixels altogether and avoid
the CPU in your path? By your description, at the core, it sounds
simply like a render-to-texture scenario.

I think the trick is getting the 3D scene to render to an SDL_texture
so you can just call SDL_RenderCopy on it for the final screen draw. I
haven’t looked into how to do that, but I think this technique is what
you are kind of after.
https://wiki.libsdl.org/SDL_GL_BindTexture

-EricOn 5/25/15, JeZ-l-Lee wrote:

Fastest Method To Modify Pixels In SDL2 Texture?

Hi,

We are working on a Wolfenstein 3D styled game SDL2 game now.
What would be the best and fastest method to modify pixels in an SDL2
texture?
We want to draw the 3d game off screen to an SDL2 texture and then render
that SDL2 texture once to the screen.
Any advice would be appreciated!


Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

We want to draw the 3d game off screen to an SDL2 texture and then
render that SDL2 texture once to the screen.
Any advice would be appreciated!

Just to be clear: if you want to render individual pixels, render them
to a memory buffer and upload them all to the texture when you’re ready
to put them to the screen, once, at the end of the frame.

(You can get away with doing this if you SDL_LockTexture() once at the
start of the frame, do whatever you want to the pixels, and Unlock right
before SDL_RenderCopy’ing the texture to the screen, but that’s because
streaming SDL_Textures keep a copy of themselves in RAM to make this
scenario faster.)

–ryan.