adding rendering
This commit is contained in:
@@ -24,7 +24,7 @@ extern "C" {
|
|||||||
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
|
#define NULL_CELL (struct tart_cell){{0,0,0},{0,0,0},0,0,0}
|
||||||
#define TART_CELL_DATA_SIZE 16 // todo add number
|
#define TART_CELL_DATA_SIZE 16 // todo add number
|
||||||
#else
|
#else
|
||||||
#define NULL_CELL (struct tart_cell){0,0,0,0,0}
|
#define NULL_CELL (struct tart_cell){0,0,0,0}
|
||||||
#define TART_CELL_DATA_SIZE 16
|
#define TART_CELL_DATA_SIZE 16
|
||||||
#endif
|
#endif
|
||||||
#define TART_OK 0
|
#define TART_OK 0
|
||||||
@@ -99,7 +99,6 @@ struct tart_cell {
|
|||||||
struct tart_rgb background;
|
struct tart_rgb background;
|
||||||
tart_byte style;
|
tart_byte style;
|
||||||
char display;
|
char display;
|
||||||
char* compiled;
|
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
struct tart_cell {
|
struct tart_cell {
|
||||||
@@ -107,7 +106,6 @@ struct tart_cell {
|
|||||||
tart_byte background;
|
tart_byte background;
|
||||||
tart_byte style;
|
tart_byte style;
|
||||||
char display;
|
char display;
|
||||||
char* compiled;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -133,8 +131,6 @@ struct tart_buffer {
|
|||||||
struct tart_vec2 size;
|
struct tart_vec2 size;
|
||||||
struct tart_vec2 position;
|
struct tart_vec2 position;
|
||||||
struct tart_cell* cells;
|
struct tart_cell* cells;
|
||||||
char* data;
|
|
||||||
int data_count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Tart Window
|
/* Tart Window
|
||||||
@@ -145,6 +141,8 @@ struct tart_window {
|
|||||||
struct tart_buffer buffers[0xFF+1];
|
struct tart_buffer buffers[0xFF+1];
|
||||||
tart_byte buffer_count;
|
tart_byte buffer_count;
|
||||||
struct tart_vec2 size;
|
struct tart_vec2 size;
|
||||||
|
char* data;
|
||||||
|
int data_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tart_window tart_create_window();
|
struct tart_window tart_create_window();
|
||||||
@@ -165,6 +163,10 @@ struct tart_buffer* tart_get_buffer(struct tart_window*, tart_byte);
|
|||||||
struct tart_cell* tart_get_cell(struct tart_buffer*, int);
|
struct tart_cell* tart_get_cell(struct tart_buffer*, int);
|
||||||
struct tart_cell tart_set_cell(struct tart_buffer*, struct tart_cell,int);
|
struct tart_cell tart_set_cell(struct tart_buffer*, struct tart_cell,int);
|
||||||
|
|
||||||
|
tart_byte tart_draw_window(struct tart_window*, char*);
|
||||||
|
|
||||||
|
tart_byte tart_add_cells_to_buffer(struct tart_buffer*, struct tart_cell*);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
struct tart_cell tart_test() {
|
struct tart_cell tart_test() {
|
||||||
#ifdef TART_RGB_COLORS
|
#ifdef TART_RGB_COLORS
|
||||||
return (struct tart_cell){{0,0,0}, {0,0,0}, 0, 't',0};
|
return (struct tart_cell){{0,0,0}, {0,0,0}, 0, '&',0};
|
||||||
#else
|
#else
|
||||||
return (struct tart_cell){0,0,0,0,0};
|
return (struct tart_cell){196,105,0,'&'};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
struct tart_window tart_create_window() {
|
struct tart_window tart_create_window() {
|
||||||
@@ -17,17 +17,22 @@ struct tart_window tart_create_window() {
|
|||||||
for(int i = 0; i < 0xFF; i++) {
|
for(int i = 0; i < 0xFF; i++) {
|
||||||
window.buffers[i] = tart_create_buffer(0, (struct tart_vec2){0,0},(struct tart_vec2){0,0});
|
window.buffers[i] = tart_create_buffer(0, (struct tart_vec2){0,0},(struct tart_vec2){0,0});
|
||||||
}
|
}
|
||||||
|
char* data = (char*)malloc((size.x*size.y) * (sizeof(char) * TART_CELL_DATA_SIZE));
|
||||||
window.size = term_current_size();
|
window.size = term_current_size();
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
||||||
unsigned int cell_count = size.x * size.y;
|
unsigned int cell_count = size.x * size.y;
|
||||||
|
|
||||||
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
|
struct tart_cell* cells = (struct tart_cell*)malloc((size.x * size.y) * sizeof(struct tart_cell));
|
||||||
struct tart_cell cell = NULL_CELL;
|
|
||||||
char* data = (char*)malloc((size.x*size.y) * (sizeof(char) * TART_CELL_DATA_SIZE));
|
for (int i = 0;i < cell_count;i++) {
|
||||||
|
cells[i] = NULL_CELL;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
|
unsigned int data_count = (size.x*size.y) * TART_CELL_DATA_SIZE;
|
||||||
struct tart_buffer buf = {cell_count,0,id,size,position,cells, data, data_count}; // -NOTE- dose not set the layer
|
struct tart_buffer buf = {cell_count,0,id,size,position,cells}; // -NOTE- dose not set the layer
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#ifdef TART_RGB_COLORS
|
#ifdef TART_RGB_COLORS
|
||||||
@@ -39,7 +44,7 @@ struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb
|
|||||||
|
|
||||||
struct tart_cell tart_create_cell(char display, tart_byte style,
|
struct tart_cell tart_create_cell(char display, tart_byte style,
|
||||||
tart_byte foreground, tart_byte background) {
|
tart_byte foreground, tart_byte background) {
|
||||||
return (struct tart_cell){foreground,background,style,display,0};
|
return (struct tart_cell){foreground,background,style,display};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
||||||
@@ -72,3 +77,27 @@ struct tart_cell tart_set_cell(struct tart_buffer* buffer, struct tart_cell cell
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tart_byte tart_draw_window(struct tart_window * window, char* rend_buffer) {
|
||||||
|
int p = 0;
|
||||||
|
int i = 0;
|
||||||
|
for (int b = 0;b < 0xFF; b++) {
|
||||||
|
for (int y = 0; y < window->size.y; y++) {
|
||||||
|
for (int x = 0; x < window->size.x; x++) {
|
||||||
|
for (int p = 0; p < TART_CELL_DATA_SIZE;p++) {
|
||||||
|
// add data to window c buffer.
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add cursor move command.
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf(window->data);
|
||||||
|
return TART_OK;
|
||||||
|
};
|
||||||
|
|
||||||
|
tart_byte tart_add_cells_to_buffer(struct tart_buffer* buffer, struct tart_cell* cells) {
|
||||||
|
|
||||||
|
return TART_OK;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user