Overlay API
kjhermans opened this issue · 4 comments
Hi,
I'd like to add an overlay API. Something that you can have a callback for, like the display() and update() functions, and that allows you to overlay pixels on the rendered 3D view. This, so you can have crosses through the middle, inventory sidebars, indication of available lives / heart points / whatever. I've created this, and have a diff for, this API in Linux. I'm not that well versed in the Windows API. Suggestions? Or is this already possible, and have I just overlooked it?
Thanks,
KJ
Hi! The way I do it is just have a function before the vid_blit() call every frame. At that point your 3D world should have been rendered to the pixel buffer so you can just render the overlays right on top of the scene. I'm not too sure why the OS would matter here unless you're using OS specific drawing?
I use the vid_blit() function call from the display() callback. In that scope, I have no 'handles' on anything I can draw on, just the PL_* functions. Which PL_ function do I use to address the screen buffer? Or is the screen buffer always the same global pointer somewhere?
Yes the screen buffer is a global pointer located here: https://github.com/LMP88959/PL3D-KC/blob/main/pl.h#L172C1-L173C29
You can simply write to it. Its dimensions are PL_hres x PL_vres and you can set a pixel at (x,y) using this:
PL_video_buffer[x + y * PL_hres] = 0xff00ff; /* packed RGB */
Ok. Hadn't found that. Thanks!