04-30-2024, 01:16 PM
(This post was last modified: 05-02-2024, 05:48 PM by a740g.
Edit Reason: Fix typos
)
I’ve been toying with the idea of rendering graphics to SCREEN 0 for a while and have figured out quite a few things on how to accomplish this at a reasonably good speed. However, one of those experiments turned out to be the most fun of all. So much so that I decided to convert it into a tiny library and share it here. You can use this to give your programs a retro artistic look.
The library has just two functions: AAFB_Render and AAFB_SetupScreen0.
The AAFB_Render function is used to render any graphics image onto a SCREEN 0 image. It takes two parameters: srcImage and dstImage. The srcImage parameter is the handle of the graphics image to be rendered, and the dstImage parameter is the handle of the destination SCREEN 0 image where the ASCII art image will be rendered onto. dstImage can be 0 (i.e. the real SCREEN). srcImage and dstImage must have the same dimensions.
The AAFB_SetupScreen0 is just a convenience function that quickly sets up SCREEN 0 with optimal settings.
QB64-PE 3.12 is required. To use an older compiler, remove the "$INCLUDEONCE" lines from AAFB.bi and AAFB.bas.
There are some demos included in the Demo folder.
RokCoder's Galaga running on top of AAFB.
FishTank demo running on top of AAFB.
Limitations:
The library has just two functions: AAFB_Render and AAFB_SetupScreen0.
The AAFB_Render function is used to render any graphics image onto a SCREEN 0 image. It takes two parameters: srcImage and dstImage. The srcImage parameter is the handle of the graphics image to be rendered, and the dstImage parameter is the handle of the destination SCREEN 0 image where the ASCII art image will be rendered onto. dstImage can be 0 (i.e. the real SCREEN). srcImage and dstImage must have the same dimensions.
Code: (Select All)
SUB AAFB_Render (BYVAL srcImage AS LONG, BYVAL dstImage AS LONG)
The AAFB_SetupScreen0 is just a convenience function that quickly sets up SCREEN 0 with optimal settings.
Code: (Select All)
SUB AAFB_SetupScreen0 (screenWidth AS _UNSIGNED INTEGER, screenHeight AS _UNSIGNED INTEGER)
QB64-PE 3.12 is required. To use an older compiler, remove the "$INCLUDEONCE" lines from AAFB.bi and AAFB.bas.
There are some demos included in the Demo folder.
RokCoder's Galaga running on top of AAFB.
FishTank demo running on top of AAFB.
Limitations:
- There is no built-in scaling. However, this can be easily done with _PUTIMAGE
- Although it is quite fast, the rendering is done on the CPU and hence may not be suitable for high-resolution rendering (e.g. WIDTH 1920, 1080). However, lots of performance can be gained if you compile with the QB64-PE optimization option enabled.
- It does not render to the console / terminal. There are other of libraries that do that. However, they are limited to a reduced set of ASCII characters. AAFB uses all 256 ASCII characters.