Currently I am doing my rendering by using a 3D array window_width x window_height x rgb as a buffer, then looping through the buffer and plotting pixels on screen using SDL2 (SDL_RenderDrawPoint). I know this is horrible and stupidly slow but I am not well experienced in graphics techniques. What is the better way to do this?
You can use SDL_LockTexture and SDL_UnlockTexture for write only access to a texture created with the Create the buffer with SDL_CreateTexture (modify to you liking):
Lock with SDL_LockTexture:
Where Write your pixel data to Clean up with SDL_UnlockTexture:
Then you can RenderCopy this texture as normal:
This assumes the buffer is the same size as your window. Note you will have to modify this for your own use case. |
||||
|
SDL_Texture
s that you render usingSDL_RenderCopy
? Why do you need a buffer of these anyway? – congusbongus Jun 16 at 4:54