I wrote a little program to render a mandelbrot fractal
If I leave the locking/unlocking of the backbuffer out, I get weird black vertical (and sometimes horizontal) lines. Does al_draw_pixel not work properly on video bitmaps? Not that I would normally try to draw individual pixels on a bitmap in video memory (especially not millions of them), but I am a little curious as to why.
I can't reproduce it here. But the code has some problems:
- you lock with WRITEONLY but don't draw all the pixels
- al_draw_pixel is not supposed to be used when the bitmap is locked. Use al_put_pixel instead, or direct memory access.
- al_draw_pixel takes float parameters. You are drawing to the top-level of the pixel instead of at the pixel centre, which sometimes makes a difference.
Forgive my ignorance, but I thought that al_clear_to_color would ensure that all pixels are drawn? Yeah, put_pixel is probably better in this situation, didn't know there were two functions for drawing pixels.
And I didn't even know al_lock_bitmap had a return value. Makes sense now that I think about it. Thanks!
I thought that al_clear_to_color would ensure that all pixels are drawn?
It does, but then with the al_lock_bitmap call you promised to clobber all the pixels again, by passing the WRITEONLY flag. If you wished to leave some of the pixels as they were, you would need to use the READWRITE flag.