[SDL] Best way to implement a simple "Framebuffer"
nils.stec
nils-stec at spectra-light.de
Mon Sep 26 09:42:36 PDT 2011
Changing the update routine to this (swapped x/y and removed the calculating of the address) got me about 50fps on my Phenom, not bad, but should be more ;)
Code:
addr = 0x200;
for(y = 0; y < 32; y++) {
for(x = 0; x < 32; x++) {
set_px(x,y, get6502memory(addr));
addr++;
}
}
Accessing the memory via get6502memory is necessary, because of portability and for the use in other planned emus/changing the output interface. if i access the memory directly by it's pointer it makes ~~ +20fps.
Next step should be the use of a lookup table for colors, but this gets me a weird gfx output....:
this is what it looks like with my switch/case:
[Image: http://s2.postimage.org/2kfveu1wk/gfx_switchcase.jpg ] (http://postimage.org/image/2kfveu1wk/)
And this is with the lookup table (code following):
The skier starts to skiing and goes upwards instead of downwards. it seems the y coordinates is "negative", i don't understand, i simply changed from boxRGBA to boxColor. The wrong colors can be, i think i have some mistakes inside the lut...
[Image: http://s2.postimage.org/kaj2klw38/gfx_colorlut.png ] (http://www.postimage.org/)
After i get this working i will change the code to use a 32x32 surface and use rotozoom to zoom it by factor 8.
No pixel sizes are hardcode, i think, everything should be done with #defines, i want to compile it for my mobile later, so everything needs to be portable ;)[/img]
------------------------
If you're interested in Embedded Linux and Microcontrollers have a look at my (german) page:
http://krumeltee.wordpress.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20110926/75a3e3f0/attachment.htm>
More information about the SDL
mailing list