1 #include <bz/renderer/renderer_internal.h>
3 #include <bz/gfx/gfx_internal.h>
4 #include <bz/math/math.h>
5 #include <bz/memory/arena.h>
6 #include <bz/renderer/render_pass_internal.h>
7 #include <playdate/entrypoint.h>
9 struct BZRendererPass
{
14 /*static SDL_Window *window;
15 static SDL_Renderer *renderer;
16 static SDL_Texture *renderTexture;
17 static SDL_Texture *renderTextureIntermediate;
18 static size_t intermediateWidth, intermediateHeight;
19 static int outputWidth, outputHeight;*/
20 //static SDL_Surface *windowSurface;
21 //static SDL_Surface *drawSurface;
23 //const static size_t kMaxRenderPasses = 8;
24 //static size_t numRenderPasses = 0;
25 #define kMaxRenderPasses 1 // FIXME
26 static BZRendererPass rendererPasses
[kMaxRenderPasses
];
28 #define GAME_WIDTH 200 // 256 //128 //320 //128 // 400 // 128
29 #define GAME_HEIGHT 120 // 128 //128 //180 //128 // 240 // 128
31 //#define RENDERER_WIDTH 256 //128 //320 //128 // 400 // 128
32 //#define RENDERER_HEIGHT 128 //128 //180 //128 // 240 // 128
34 #define RENDERER_WIDTH 400 // 1280
35 #define RENDERER_HEIGHT 240 // 720
37 #define SCREEN_WIDTH 400 * 1 // 1280
38 #define SCREEN_HEIGHT 240 * 1 // 720
40 //#define SCREEN_SCALE 4
42 void bzRendererInit() {//const BZRendererConfiguration *configuration, const char *title) {
44 for (size_t i
= 0; i
< kMaxRenderPasses
; ++i
) {
45 rendererPasses
[i
].pass
= NULL
;
49 bzGfxPrepareCanvasBuffer(kBZSystemMemoryArena
, GAME_WIDTH
, GAME_HEIGHT
);
52 void bzRendererTeardown() {
55 BZRendererPassID
bzRendererRegisterPass(BZRenderPassID renderPass
) {
56 for (size_t i
= 0; i
< kMaxRenderPasses
; ++i
) {
57 if (rendererPasses
[i
].pass
== NULL
) {
58 rendererPasses
[i
].pass
= renderPass
;
59 return &rendererPasses
[i
];
65 void bzRendererUnregisterPass(BZRendererPassID rendererPass
) {
66 rendererPass
->pass
= NULL
;
69 void bzRendererBlit() {
70 uint8_t *pixels
= playdate
->graphics
->getFrame();
71 for (size_t i
= 0; i
< kMaxRenderPasses
; ++i
) {
72 BZRenderPass
*renderPass
= rendererPasses
[i
].pass
;
73 if (renderPass
!= NULL
) {
74 if (renderPass
->softwareHook
!= NULL
) {
75 renderPass
->softwareHook((uint32_t *)pixels
/*drawSurface->pixels*/, 2, 2);
81 void bzRendererVBlank() {
82 playdate
->system
->drawFPS(0,0);
83 playdate
->graphics
->markUpdatedRows(0, 240); // FIXME