1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Started introducing an extra layer of indirection so as to be able to bind the texture builder to the same flush and submit patern as the array builder.

This commit is contained in:
Thomas Harte 2016-12-03 20:47:19 -05:00
parent cb3c837e30
commit 0edc043378
2 changed files with 14 additions and 16 deletions

View File

@ -315,8 +315,8 @@ void CRT::output_level(unsigned int number_of_cycles)
Scan scan {
.type = Scan::Type::Level,
.number_of_cycles = number_of_cycles,
.tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(),
.tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position()
// .tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(),
// .tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position()
};
output_scan(&scan);
}
@ -349,8 +349,8 @@ void CRT::output_data(unsigned int number_of_cycles, unsigned int source_divider
Scan scan {
.type = Scan::Type::Data,
.number_of_cycles = number_of_cycles,
.tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(),
.tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position(),
// .tex_x = openGL_output_builder_.texture_builder.get_last_write_x_position(),
// .tex_y = openGL_output_builder_.texture_builder.get_last_write_y_position(),
.source_divider = source_divider
};
output_scan(&scan);

View File

@ -40,12 +40,6 @@ class TextureBuilder {
/// and indicates that its actual final size was @c actual_length.
void reduce_previous_allocation_to(size_t actual_length);
/// @returns the start column for the most recent allocated write area.
uint16_t get_last_write_x_position();
/// @returns the row of the most recent allocated write area.
uint16_t get_last_write_y_position();
/// @returns @c true if all future calls to @c allocate_write_area will fail on account of the input texture
/// being full; @c false if calls may succeed.
bool is_full();
@ -53,13 +47,13 @@ class TextureBuilder {
/// Updates the currently-bound texture with all new data provided since the last @c submit.
void submit();
struct WriteArea {
uint16_t x, y;
size_t length;
};
void flush(std::function<void(const std::vector<WriteArea> &write_areas, size_t count)>);
private:
// where pixel data will be put to the next time a write is requested
uint16_t next_write_x_position_, next_write_y_position_;
// the most recent position returned for pixel data writing
uint16_t write_x_position_, write_y_position_;
// details of the most recent allocation
size_t write_target_pointer_;
size_t last_allocation_amount_;
@ -70,6 +64,10 @@ class TextureBuilder {
// the buffer
std::vector<uint8_t> image_;
GLuint texture_name_;
std::vector<WriteArea> write_areas_;
size_t number_of_write_areas_;
uint16_t write_areas_start_x_, write_areas_start_y_;
};
}