individual pixel control

I am remaking a projects I did in 2000 reproducing steven wolfram's cellular automata. I had some success back in 2000. I used to acces each pixel via something like window.pixel(x,y) and change their colour according to the three pixels directly above... i.e. window.pixel(x,y-clientWidth) and window.pixel(x-1,y-clientWidth) and window.pixel(x+1,y-clientWidth) can anyone help with the code i need now, or direct me to a site? .. I use codeblock16.01 on windows7 where previously i used borland builder
Last edited on
What GUI tookit / framework are you using?
would that be SDL ? ... I am in the process of learning SDL .. I have installed and linked it all ok but am struggling to find tuts or even commands for individual pixel control via x,y coordinates.
SDL isn't designed for that, but it can be done without too much difficulty.

You can read how in the following tutorials:
http://lazyfoo.net/tutorials/SDL/

Specifically, you have to lock the texture, then you can access its Surface, which is the array of pixels.


Here's another take which is worth your time to read:
http://programmersranch.blogspot.com/2014/02/sdl2-pixel-drawing.html


Hope this helps.
thanks Douas ... I dont remember using SDL in the past ... I kinda wanted to do it raw in c++ but EVERYONE has said use SDL or openGL .. so i'll do the tuts you
recommend . I plan on using a hexagonal grid/frame and drawing snowflakes this time .. i've had some success on 3dsmax but i've run out of grids big enough ... gotta get down to the pixel.. thanks again.
You can always load the image data yourself, but you need some kind of library to display the images. SDL does both for you, so might as well use that. The SDL_Surface is a direct index into the image bitmap ("raw c++"), so it works out the same.

Good luck!
Topic archived. No new replies allowed.