Skip to content

Commit

Permalink
Comments for AbstractRenderer.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lpenguin authored Dec 9, 2021
1 parent 02e9378 commit 1e00bdd
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions lib/renderer/src/renderer/scene/AbstractRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,46 @@

namespace renderer::scene {
struct MapDescription {
int32_t width;
int32_t height;
uint8_t* material_begin_offsets;
int32_t width; // H_SIZE
int32_t height; // V_SIZE
uint8_t* material_begin_offsets; // Material offsets in the palette
uint8_t* material_end_offsets;
int32_t material_count;
int32_t material_count; // 8 for
};

// TODO: ugly definition
// HeightMap is basically struct { int32_t id; };
enum class _HeightMapT;
typedef ResourceId<_HeightMapT> HeightMap;
static_assert (sizeof (HeightMap) == sizeof (int32_t), "invalid HeightMap RID size");


// TODO: Rename it to the AbstractSceneRenderer?
class AbstractRenderer {
public:
// Creates HeightMap from description
virtual HeightMap map_create(const MapDescription& map_description) = 0;

// Destroys the HeightMap
virtual void map_destroy(HeightMap map) = 0;

// Gets width and height of the HeightMap
// nullptr-s are valid
virtual void map_query(HeightMap map, int32_t* width, int32_t* height) = 0;

// Updates a rectangular area the selected HeightMap with height data from *height* and meta data from *meta*
// The renderer must not keep the height and meta pointers since they will be deleted after the call
// TODO: the *height* parameter name is confusing
// TODO:
virtual void map_update_data(HeightMap map, const Rect& rect, uint8_t* height, uint8_t* meta) = 0;

// Updates a 256-color palette for the HeightMap.
// The renderer must not keep the palette pointer since if will be deleted after the call
virtual void map_update_palette(HeightMap map, uint32_t* palette, int32_t palette_size) = 0;

// Renders the scene into the viewport with size viewport_width*viewport_height and with camera position *camera_pos_XXX*
// TODO: need to discuss and refactor this function signature
virtual void render(int32_t viewport_width, int32_t viewport_height, int32_t camera_pos_x, int32_t camera_pos_y, int32_t camera_pos_z) = 0;

virtual ~AbstractRenderer() = default;
};
}
Expand Down

0 comments on commit 1e00bdd

Please sign in to comment.