SpaceCadetPinball/SpaceCadetPinball/render.h

67 lines
1.8 KiB
C
Raw Normal View History

2020-11-06 14:56:32 +01:00
#pragma once
2020-11-08 16:37:59 +01:00
#include "gdrv.h"
#include "maths.h"
#include "zdrv.h"
enum class VisualTypes : char
2020-11-08 16:37:59 +01:00
{
Background = 0,
2020-11-08 16:37:59 +01:00
Sprite = 1,
Ball = 2
};
struct render_sprite
2020-11-08 16:37:59 +01:00
{
rectangle_type BmpRect{};
2020-11-15 15:39:00 +01:00
gdrv_bitmap8* Bmp;
2020-11-08 16:37:59 +01:00
zmap_header_type* ZMap;
bool DeleteFlag;
VisualTypes VisualType;
uint16_t Depth;
rectangle_type DirtyRectPrev{};
2020-11-08 16:37:59 +01:00
int ZMapOffestY;
int ZMapOffestX;
rectangle_type DirtyRect{};
std::vector<render_sprite*>* OccludedSprites;
rectangle_type BoundingRect{};
bool DirtyFlag{};
render_sprite(VisualTypes visualType, gdrv_bitmap8* bmp, zmap_header_type* zMap,
int xPosition, int yPosition, rectangle_type* boundingRect);
~render_sprite();
void set(gdrv_bitmap8* bmp, zmap_header_type* zMap, int xPos, int yPos);
void set_bitmap(gdrv_bitmap8* bmp);
void ball_set(gdrv_bitmap8* bmp, float depth, int xPos, int yPos);
2020-11-08 16:37:59 +01:00
};
2020-11-15 15:39:00 +01:00
2020-11-06 14:56:32 +01:00
class render
{
public:
static gdrv_bitmap8 *vscreen, *background_bitmap;
static SDL_Rect DestinationRect;
2020-11-08 16:37:59 +01:00
static void init(gdrv_bitmap8* bmp, int width, int height);
2020-11-15 15:39:00 +01:00
static void uninit();
static void recreate_screen_texture();
2020-11-06 14:56:32 +01:00
static void update();
static void AddSprite(render_sprite& sprite);
static void RemoveSprite(render_sprite& sprite);
static void set_background_zmap(zmap_header_type* zMap, int offsetX, int offsetY);
static void shift(int offsetX, int offsetY);
static void build_occlude_list();
static void SpriteViewer(bool* show);
static void PresentVScreen();
private:
static std::vector<render_sprite*> sprite_list, ball_list;
static zmap_header_type* background_zmap;
static int zmap_offsetX, zmap_offsetY, offset_x, offset_y;
static rectangle_type vscreen_rect;
static gdrv_bitmap8 *ball_bitmap[20];
static zmap_header_type* zscreen;
static void repaint(const render_sprite& sprite);
2020-11-15 15:39:00 +01:00
static void paint_balls();
static void unpaint_balls();
2020-11-06 14:56:32 +01:00
};