Fiext tart.h from some errors. Added all functions from tart.h and added testing.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
project(Tart VERSION 0.1)
|
||||
# CPP
|
||||
set( CMAKE_CXX_STANDARD 11)
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
#set( CMAKE_CXX_STANDARD 11)
|
||||
#set( CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# C
|
||||
set( CMAKE_C_STANDARD 11)
|
||||
set( CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#ifndef TART_H
|
||||
#define TART_H
|
||||
// #========================================================================#
|
||||
// | PreacherDHM:TART
|
||||
// |
|
||||
@@ -19,15 +21,20 @@ struct tart_vec2 {
|
||||
short x,y;
|
||||
};
|
||||
|
||||
struct tart_rgb {
|
||||
tart_byte r,g,b;
|
||||
};
|
||||
|
||||
/* Tart Cell
|
||||
*
|
||||
* This holds a rgb for the foreground and the background.
|
||||
* Includeing the display character.
|
||||
*
|
||||
*/
|
||||
|
||||
struct tart_cell {
|
||||
tart_byte fr,fg,fb;
|
||||
tart_byte br,bg,bb;
|
||||
struct tart_rgb foreground;
|
||||
struct tart_rgb background;
|
||||
tart_byte style;
|
||||
char display;
|
||||
};
|
||||
@@ -38,44 +45,41 @@ struct tart_cell {
|
||||
* Allso containes the size of the buffer.
|
||||
*
|
||||
* ........................width...............
|
||||
* ..........<-------------------------------->
|
||||
*
|
||||
* ........^ @################################@
|
||||
*
|
||||
* ........| #................................#
|
||||
*
|
||||
* ........| #................................#
|
||||
*
|
||||
* height--| #..........buffer................#
|
||||
*
|
||||
* ........| #................................#
|
||||
*
|
||||
* ........| #................................#
|
||||
*
|
||||
* ........V @################################@
|
||||
* ..........<-------------------------------->.
|
||||
* ........^ @################################@.
|
||||
* ........| #................................#.
|
||||
* ........| #................................#.
|
||||
* height--| #.............Buffer.............#.
|
||||
* ........| #................................#.
|
||||
* ........| #................................#.
|
||||
* ........V @################################@.
|
||||
*/
|
||||
struct tart_buffer {
|
||||
int cell_count;
|
||||
unsigned int cell_count;
|
||||
tart_byte layer;
|
||||
tart_vec2 size;
|
||||
tart_vec2 position;
|
||||
tart_id id;
|
||||
struct cell* cells;
|
||||
struct tart_vec2 size;
|
||||
struct tart_vec2 position;
|
||||
struct tart_cell* cells;
|
||||
};
|
||||
|
||||
struct tart_render_manager {
|
||||
struct tart_buffer buffers[sizeof(tart_byte)];
|
||||
/* Tart Window
|
||||
*
|
||||
* The tart window will have the window size and all of the buffers.
|
||||
**/
|
||||
struct tart_window {
|
||||
struct tart_buffer buffers[0xFF+1];
|
||||
tart_byte buffer_count;
|
||||
};
|
||||
|
||||
tart_buffer tart_create_buffer(tart_id, struct tart_vec2, struct tart_vect2);
|
||||
tart_cell tart_create_cell(char, tart_byte, tart_byte, tart_byte, tart_byte, tart_byte, tart_byte);
|
||||
tart_byte tart_add_buffer(struct tart_render_manager*, struct tart_buffer);
|
||||
tart_byte tart_set_buffer(struct tart_render_manager*, struct tart_buffer, tart_byte);
|
||||
struct tart_buffer tart_create_buffer(tart_id, struct tart_vec2, struct tart_vec2);
|
||||
struct tart_cell tart_create_cell(char, tart_byte, struct tart_rgb, struct tart_rgb);
|
||||
tart_byte tart_add_buffer(struct tart_window*, struct tart_buffer);
|
||||
tart_byte tart_set_buffer(struct tart_window*, struct tart_buffer, tart_byte);
|
||||
|
||||
tart_buffer& tart_get_buffer(struct tart_render_manager*, tart_byte);
|
||||
|
||||
tart_cell& tart_get_cell(struct tart_buffer*, int);
|
||||
tart_cell tart_set_cell(struct tart_buffer*, tart_cell,int);
|
||||
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_set_cell(struct tart_buffer*, struct tart_cell*,int);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
project(TartLib VERSION 0.1)
|
||||
set(Lib_SOURCES
|
||||
tart.cpp
|
||||
tart.c
|
||||
)
|
||||
add_library(${PROJECT_NAME} STATIC ${LIB_SOURCES})
|
||||
add_library(${PROJECT_NAME} STATIC tart.c)
|
||||
target_include_directories(${PROJECT_NAME} BEFORE PUBLIC "../includes/")
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "tart.h"
|
||||
#include <malloc.h>
|
||||
|
||||
struct tart_buffer tart_create_buffer(tart_id id, struct tart_vec2 size, struct tart_vec2 position) {
|
||||
int cell_count = position.x * position.y;
|
||||
struct tart_cell* cells = malloc(sizeof(struct tart_cell[cell_count]));
|
||||
struct tart_buffer buf = {cell_count,0,id,size,position,0};
|
||||
return buf;
|
||||
}
|
||||
struct tart_cell tart_create_cell(char display, tart_byte style, struct tart_rgb foreground, struct tart_rgb background) {
|
||||
return (struct tart_cell){foreground, background, style, display};
|
||||
}
|
||||
tart_byte tart_add_buffer(struct tart_window* window, struct tart_buffer buffer) {
|
||||
if(window->buffer_count < 0xFF) {
|
||||
window->buffers[window->buffer_count] = buffer;
|
||||
window->buffer_count++;
|
||||
return window->buffer_count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
tart_byte tart_set_buffer(struct tart_window* window, struct tart_buffer buffer, tart_byte layer) {
|
||||
if(layer <= 0xFF) {
|
||||
window->buffers[layer] = buffer;
|
||||
return layer;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct tart_buffer* tart_get_buffer(struct tart_window* window, tart_byte layer) {
|
||||
return &window->buffers[layer];
|
||||
}
|
||||
|
||||
struct tart_cell* tart_get_cell(struct tart_buffer* buffer, int idx) {
|
||||
return &buffer->cells[idx];
|
||||
}
|
||||
struct tart_cell* tart_set_cell(struct tart_buffer* buffer, struct tart_cell* cell,int idx) {
|
||||
if(buffer->cell_count >= idx) {
|
||||
buffer->cells[idx] = *cell;
|
||||
return cell;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ project(TartTest)
|
||||
set( SOURCES
|
||||
main.cpp
|
||||
)
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
target_include_directory(${PROJECT_NAME} Pickler)
|
||||
add_executable(${PROJECT_NAME} ${SOURCES} )
|
||||
target_link_libraries(${PROJECT_NAME} PickleLib TartLib)
|
||||
|
||||
add_test(${PROJECT_NAME} "${CMAKE_SOURCE_DIR}/bin/testing.exe")
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "test_tart.h"
|
||||
#include <Pickler.h>
|
||||
int main (int argc, char *argv[]) {
|
||||
|
||||
INSTALLSHELF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
2
testing/test_tart.h
Normal file
2
testing/test_tart.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <tart.h>
|
||||
#include <Pickler.h>
|
||||
Reference in New Issue
Block a user