+#define use_fatal_failure
#define use_mathematics
+#define use_png_library
#include "xtandard.h"
#include "xector.h"
+#include "xormat.h"
#include "xarticle.h"
+#include "xhape.h"
+#include "xision.h"
-#include <raylib.h>
+static void print_shape (shape_node * sh) {
+ print ("shape data:\n");
+ print ("v = %i // %i\n", sh->vertex_count, sh->vertex_limit);
+ print ("i = %i // %i\n", sh->index_count, sh->index_limit);
+}
-int main (void) {
- particle_structure * particle = particle_initialize (1024);
+static void render_shape (vision_structure * vision, shape_node * sh) {
+ //~uint vc = sh->vertex_count;
+ //~uint ic = sh->index_count;
- InitWindow (800, 600, "Xarticle");
+ //~float va [100] = { 0 };
+ //~uint ia [100] = { 0 };
- Camera camera = { 0 };
- camera.position = (Vector3){ 0.0f, 2.0f, 4.0f }; // Camera position
- camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
- camera.fovy = 60.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
+ //~for (uint i = 0; i < vc; i += 5) {
+ //~va [i+0] = sh->vertex_array [i/5]->x;
+ //~va [i+1] = sh->vertex_array [i/5]->y;
+ //~va [i+2] = sh->vertex_array [i/5]->z;
+ //~va [i+3] = sh->unwrap_array [i/5]->x;
+ //~va [i+4] = sh->unwrap_array [i/5]->y;
+ //~}
+
+ //~for (uint i = 0; i < ic; i += 5) {
+ //~ia [i] = sh->index_array [i];
+ //~}
+
+ vision_render_base (vision, sh->vertex_count, sh->vertex_array, sh->index_count, sh->index_array, 0, 0xff7733ff);
+}
- SetTargetFPS(60);
+int main (void) {
+ //~vector_3 as = { +2,0,0 };
+ //~vector_3 bs = { -2,0,0 };
+ //~vector_3 cs = { 0,+2,0 };
+ //~vector_3 ds = { 0,-2,0 };
+ //~vector_3 es = { 0,0,+2 };
+ //~vector_3 fs = { 0,0,-2 };
+
+ shape_node * a = shape_tetrahedron_colour (+2,0,0, 1, 0xff7733ff);
+ shape_node * b = shape_tetrahedron_colour (-2,0,0, 1, 0xff7733ff);
+ shape_node * c = shape_tetrahedron_colour (0,+2,0, 1, 0xff7733ff);
+ shape_node * d = shape_tetrahedron_colour (0,-2,0, 1, 0xff7733ff);
+ shape_node * e = shape_tetrahedron_colour (0,0,+2, 1, 0xff7733ff);
+ shape_node * f = shape_tetrahedron_colour (0,0,-2, 1, 0xff7733ff);
+
+ //~print ("> v = %i // %i\n", a->vertex_count, a->vertex_limit);
+ //~print ("> i = %i // %i\n", a->index_count, a->index_limit);
+ print_shape (a);
+
+ vision_structure * vision = vision_initialize (60, 60, false, 6000, 3000, 256);
+ particle_structure * particle = particle_initialize (1024);
- Texture texture = LoadTexture ("xui/fullscreen_on.png");
+ uint i0 = vision_sprite_import (vision, "xui/goblin/end_turn_button.png");
+ uint i1 = vision_sprite_import (vision, "xui/goblin/separator_center.png");
+ uint i2 = vision_sprite_import (vision, "xui/goblin/separator_left.png");
+ uint i3 = vision_sprite_import (vision, "xui/goblin/separator_middle.png");
+ uint i4 = vision_sprite_import (vision, "xui/goblin/separator_right.png");
- while (! WindowShouldClose ()) {
- UpdateCamera(& camera, CAMERA_FIRST_PERSON);
+ vision_configure (vision, 800, 600, "Xube");
- BeginDrawing ();
+ while (vision->active == true) {
+ if (vision->signal [signal_q] == true) break;
- ClearBackground(RAYWHITE);
+ if (vision->signal [signal_i] == true) { vision_change_field_of_view (vision, + 0.1f); }
+ if (vision->signal [signal_o] == true) { vision_change_field_of_view (vision, - 0.1f); }
- BeginMode3D(camera);
+ if (vision->signal [signal_a] == true) { vision_change_translation (vision, + 0.1f, 0.0f, 0.0f); }
+ if (vision->signal [signal_d] == true) { vision_change_translation (vision, - 0.1f, 0.0f, 0.0f); }
+ if (vision->signal [signal_s] == true) { vision_change_translation (vision, 0.0f, 0.0f, + 0.1f); }
+ if (vision->signal [signal_w] == true) { vision_change_translation (vision, 0.0f, 0.0f, - 0.1f); }
- DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground
+ //~vision_change_rotation (vision, 0.0f, xxx);
- if (IsKeyPressed (KEY_ONE)) {
+ if (vision->signal [signal_1] == true) {
vector_3 p = {0,0,0};
vector_3 t = {0,0,0};
vector_3 s = {0.1f,0.1f,0.1f};
particle_append (particle, 0, 1.0f, 0, 0, & p, & t, & s);
}
- if (IsKeyPressed (KEY_TWO)) {
+ if (vision->signal [signal_2] == true) {
vector_3 p = {1,1,1};
particle_effect_splash (particle, 0, 2.0f, 0, 0, & p, 60, 0.03, 3);
}
- if (IsKeyPressed (KEY_THREE)) {
+ if (vision->signal [signal_3] == true) {
vector_3 p = {1,1,1};
particle_effect_evaporate (particle, 0, 2.0f, 0, 0, & p, 20, 0.001, 3);
}
- BeginBlendMode (BLEND_ALPHA_PREMULTIPLY);
+ render_shape (vision, a);
+ render_shape (vision, b);
+ render_shape (vision, c);
+ render_shape (vision, d);
+ render_shape (vision, e);
+ render_shape (vision, f);
+
+ //~float t0 [] = {1,0,0,0,0,1,0,1,0};
+ //~float t1 [] = {1,0,0,0,0,1,0,1,0};
+ //~float t2 [] = {1,0,0,0,0,1,0,1,0};
+ //~float t3 [] = {1,0,0,0,0,1,0,1,0};
+ //~float t4 [] = {1,0,0,0,0,1,0,1,0};
+ //~float t5 [] = {1,0,0,0,0,1,0,1,0};
+
+ //~vision_render_triangle (vision, t0, 0xff7733ff);
+ //~vision_render_triangle (vision, t1, 0xff7733ff);
+ //~vision_render_triangle (vision, t2, 0xff7733ff);
+ //~vision_render_triangle (vision, t3, 0xff7733ff);
+ //~vision_render_triangle (vision, t4, 0xff7733ff);
+ //~vision_render_triangle (vision, t5, 0xff7733ff);
+
+ //~for (uint i = 0; i < particle->count; ++i) {
+ //~Vector3 vector = {particle->position [i]->x, particle->position [i]->y, particle->position [i]->z};
+ //~DrawBillboard (camera, texture, vector, 1, RED);
+ //~}
+
+
+
+
+
+
+ //~float va [] = {
+ //~-1, -1, 0, 0, 1, 1, 1, 1, 1,
+ //~-1, +1, 0, 0, 0, 1, 1, 1, 1,
+ //~+1, +1, 0, 1, 0, 1, 1, 1, 1,
+ //~+1, -1, 0, 1, 1, 1, 1, 1, 1
+ //~};
+
+ //~uint ia [] = { 2, 1, 0, 3, 2, 1 };
+
+ //~vision_render_base (vision, sizeof(va)/4, va, sizeof(ia)/4, ia, 1, 0xff7733ff);
+
+
+
- for (uint i = 0; i < particle->count; ++i) {
- Vector3 vector = {particle->position [i]->x, particle->position [i]->y, particle->position [i]->z};
- DrawBillboard (camera, texture, vector, 1, RED);
- }
- EndBlendMode ();
- EndMode3D();
- DrawText (TextFormat ("count = %i", particle->count), 0, 0, 4, RED);
- EndDrawing ();
+ vision_synchronize (vision, 0xff);
particle_synchronize (particle, 60);
}
- CloseWindow ();
+ png_image_export ("meme.png", vision->spritesheet_data, 256, 256);
particle = particle_deinitialize (particle);
+ vision = vision_deinitialize (vision);
return (0);
}
#ifdef use_debug_printing
-static const char * operand_name [operand_count] = {
+static char * operand_name [operand_count] = {
"rel", "reg", "mem", "imm"
};
-static const char * operation_name [operation_count] = {
+static char * operation_name [operation_count] = {
"asmmem", "asmrel", "asmnum", "asmstr",
"add", "or", "adc", "sbb", "and", "sub", "xor", "cmp",
"inc", "dec", "not", "neg", "mul", "imul", "div", "idiv",
return (0x05 + 0x08 * code);
}
-static uint store_relative (const uint * array) {
- const uint relative = array [1];
+static uint store_relative (uint * array) {
+ uint relative = array [1];
#ifdef use_debug_printing
print ("/3asmrel/- %i", relative);
#endif
return 1;
}
-static uint store_memory (const uint * array) {
- const uint memory = array [1];
+static uint store_memory (uint * array) {
+ uint memory = array [1];
#ifdef use_debug_printing
print ("/3asmmem/- %i", memory);
#endif
return 1;
}
-static uint store_number (const uint * array) {
- const uint amount = array [1];
+static uint store_number (uint * array) {
+ uint amount = array [1];
#ifdef use_debug_printing
print ("/3asmnum/- %i", amount);
return amount + 1;
}
-static uint store_string (const uint * array) {
- const uint amount = array [1];
+static uint store_string (uint * array) {
+ uint amount = array [1];
#ifdef use_debug_printing
print ("/3asmstr/- %i", amount);
return amount + 1;
}
-static uint build_double (const uint * array) {
- const uint operation = array [0];
- const uint to = array [1];
- const uint destination = array [2];
- const uint from = array [3];
- const uint source = array [4];
+static uint build_double (uint * array) {
+ uint operation = array [0];
+ uint to = array [1];
+ uint destination = array [2];
+ uint from = array [3];
+ uint source = array [4];
#ifdef use_debug_printing
print ("/3%s/- /6%s/- %i /6%s/- %i", operation_name [operation], operand_name [to], destination, operand_name [from], source);
#endif
return 4;
}
-static uint build_single (const uint * array) {
- const uint operation = array [0];
- const uint to = array [1];
- const uint destination = array [2];
+static uint build_single (uint * array) {
+ uint operation = array [0];
+ uint to = array [1];
+ uint destination = array [2];
#ifdef use_debug_printing
print ("/3%s/- /6%s/- %i", operation_name [operation], operand_name [to], destination);
#endif
return 2;
}
-static uint build_shift (const uint * array) {
- const uint operation = array [0];
- const uint to = array [1];
- const uint destination = array [2];
- const uint offset = array [3];
+static uint build_shift (uint * array) {
+ uint operation = array [0];
+ uint to = array [1];
+ uint destination = array [2];
+ uint offset = array [3];
#ifdef use_debug_printing
print ("/3%s/- /6%s/- %i /cimm/- %i", operation_name [operation], operand_name [to], destination, offset);
#endif
return 3;
}
-static uint build_static_1 (const uint * array) {
- const uint operation = array [0];
+static uint build_static_1 (uint * array) {
+ uint operation = array [0];
#ifdef use_debug_printing
print ("/3%s/-", operation_name [operation]);
#endif
return 0;
}
-static uint build_jump_if (const uint * array) {
- const uint operation = array [0];
- const uint location = array [1];
+static uint build_jump_if (uint * array) {
+ uint operation = array [0];
+ uint location = array [1];
#ifdef use_debug_printing
print ("/3%s/- %i", operation_name [operation], location);
#endif
return 2;
}
-static uint build_jump (const uint * array) {
- const uint to = array [1];
- const uint destination = array [2];
+static uint build_jump (uint * array) {
+ uint to = array [1];
+ uint destination = array [2];
#ifdef use_debug_printing
print ("/3jmp/- /6%s/- %i", operand_name [to], destination);
#endif
return 2;
}
-static uint build_move (const uint * array) {
- const uint to = array [1];
- const uint destination = array [2];
- const uint from = array [3];
- const uint source = array [4];
+static uint build_move (uint * array) {
+ uint to = array [1];
+ uint destination = array [2];
+ uint from = array [3];
+ uint source = array [4];
#ifdef use_debug_printing
print ("/3mov/- /6%s/- %i /6%s/- %i", operand_name [to], destination, operand_name [from], source);
#endif
return 4;
}
-static uint build_call (const uint * array) {
- const uint from = array [1];
- const uint source = array [2];
+static uint build_call (uint * array) {
+ uint from = array [1];
+ uint source = array [2];
#ifdef use_debug_printing
print ("/3call/- /6%s/- %i", operand_name [from], source);
#endif
return 2;
}
-static uint (* build_instruction [operation_count]) (const uint * array) = {
+static uint (* build_instruction [operation_count]) (uint * array) = {
store_memory, // operation_memory : LABEL
store_relative, // operation_relative : "IMPLEMENTED"
store_number,
build_static_1, build_static_1, build_static_1, build_call, build_jump, build_move
};
-static void assemble (uint count, const uint * array, uint external_memory, uint internal_memory) {
+static void assemble (uint count, uint * array, uint external_memory, uint internal_memory) {
text_sector_byte = arena_add (external_memory * sizeof (* text_sector_byte));
data_sector_byte = arena_add (external_memory * sizeof (* text_sector_byte));
empty_store = arena_add (internal_memory * sizeof (* empty_store));
for (uint index = 0; index < count; ++index) {
- const uint size = text_sector_size;
+ uint size = text_sector_size;
uchar byte = 0;
#ifdef use_debug_nopping
#include <xolatile/xanguage/haskell.h>
#include <xolatile/xanguage/valgrind.h>
+static void (* language_highlighter [language_count]) (language_structure * language, syntax_structure * syntax) = {
+ language_highlight_common, language_highlight_ada, language_highlight_c, language_highlight_cpp,
+ language_highlight_d, language_highlight_eaxhla, language_highlight_flat, language_highlight_fortran,
+ language_highlight_pascal, language_highlight_python, language_highlight_go, language_highlight_lua,
+ language_highlight_bash, language_highlight_haskell, language_highlight_valgrind
+};
+
+static char * language_short_option [language_count] = {
+ "-X", "-A", "-C", "-S", "-D", "-E", "-T", "-F", "-P", "-Y", "-G", "-L", "-B", "-H", "-V"
+};
+
+static char * language_long_option [language_count] = {
+ "--common", "--ada", "--c", "--cpp", "--d", "--eaxhla", "--flat", "--fortran",
+ "--pascal", "--python", "--go", "--lua", "--bash", "--haskell", "--valgrind"
+};
+
+static char * language_identifier [language_count] = {
+ "Common", "Ada", "C", "C++", "D", "EAXHLA", "Flat", "Fortran",
+ "Pascal", "Python", "Go", "Lua", "Bash", "Haskell", "Valgrind"
+};
+
static language_structure * language_initialize (bool true_colour) {
language_structure * language = allocate (sizeof (* language));
return (deallocate (language));
}
-static void (* language_highlighter (language_enumeration language)) (language_structure * language, syntax_structure * syntax) {
- static const void (* highlighter [language_count]) (language_structure * language, syntax_structure * syntax) = {
- language_highlight_common, language_highlight_ada, language_highlight_c, language_highlight_cpp,
- language_highlight_d, language_highlight_eaxhla, language_highlight_flat, language_highlight_fortran,
- language_highlight_pascal, language_highlight_python, language_highlight_go, language_highlight_lua,
- language_highlight_bash, language_highlight_haskell, language_highlight_valgrind
- };
-
- fatal_failure (language >= language_count, "language_highlighter: Language index not in enumeration.");
-
- return (highlighter [language]);
-}
-
-static char * language_short_option (language_enumeration language) {
- static const char * short_option [language_count] = {
- "-X", "-A", "-C", "-S", "-D", "-E", "-T", "-F", "-P", "-Y", "-G", "-L", "-B", "-H", "-V"
- };
-
- fatal_failure (language >= language_count, "language_short_option: Language index not in enumeration.");
-
- return (short_option [language]);
-}
-
-static char * language_long_option (language_enumeration language) {
- static const char * long_option [language_count] = {
- "--common", "--ada", "--c", "--cpp", "--d", "--eaxhla", "--flat", "--fortran",
- "--pascal", "--python", "--go", "--lua", "--bash", "--haskell", "--valgrind"
- };
-
- fatal_failure (language >= language_count, "language_long_option: Language index not in enumeration.");
-
- return (long_option [language]);
-}
-
-static char * language_identifier (language_enumeration language) {
- static const char * identifier [language_count] = {
- "Common", "Ada", "C", "C++", "D", "EAXHLA", "Flat", "Fortran",
- "Pascal", "Python", "Go", "Lua", "Bash", "Haskell", "Valgrind"
- };
-
- fatal_failure (language >= language_count, "language_identifier: Language index not in enumeration.");
-
- return (identifier [language]);
-}
-
-static void language_conditionally_select (language_structure * language, syntax_structure * syntax, uint select) {
+static void language_conditionally_select (language_structure * language, syntax_structure * syntax, language_enumeration select) {
if (syntax->count == 0) {
if ((select == file_type_c_source) || (select == file_type_c_header)) {
language_highlight_c (language, syntax);
static void language_highlight_ada (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/&|()\" \t\r\n";
+ char * separators = ".,:;<=>+-*/&|()\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"abort", "else", "new", "return", "abs", "elsif", "not", "reverse",
"abstract", "end", "null", "accept", "entry", "select", "access", "of",
"separate", "aliased", "exit", "or", "some", "all", "others", "subtype",
static void language_highlight_bash (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"exit", "set", "elif", "done", "in", "then", "function", "fi",
"if", "else", "do", "while", "for"
};
static void language_highlight_cpp (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"alignas", "alignof", "and", "asm", "auto", "break", "case",
"catch", "class", "compl", "concept", "const", "consteval", "constexpr",
"constinit", "continue", "decltype", "default", "delete", "do", "else",
"volatile", "while", "xor", "final", "override", "import", "module"
};
- const char * types [] = {
+ char * types [] = {
"void", "bool", "off_t", "va_list", "float", "double", "float_t", "double_t",
"char", "short", "int", "long", "uchar", "ushort", "uint", "ulong",
"int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t",
"signed", "unsigned", "size_t", "ssize_t"
};
- const char * commons [] = {
+ char * commons [] = {
"std", "FILE", "DIR", "EOF", "va_arg", "va_start", "va_end", "va_copy"
};
static void language_highlight_c (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
"do", "while", "for", "continue", "switch", "case", "default", "break",
"enum", "union", "struct", "typedef", "goto", "return", "sizeof", "inline",
"restrict", "true", "false"
};
- const char * types [] = {
+ char * types [] = {
"void", "bool", "off_t", "va_list", "float", "double", "float_t", "double_t",
"char", "short", "int", "long", "uchar", "ushort", "uint", "ulong",
"int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t",
"signed", "unsigned", "size_t", "ssize_t"
};
- const char * commons [] = {
+ char * commons [] = {
"null", "NULL", "FILE", "DIR", "va_arg", "va_start", "va_end", "va_copy",
"alignas", "alignof", "offsetof", "typeof", "EOF", "ABS", "MIN", "MAX",
- "ARRAYSIZE", "SWAP", "UNUSED", "UNREACHABLE", "STRINGIFY", "CONCAT", "assert", "static_assert"
+ "ARRAYSIZE", "SWAP", "UNUSED", "UNREACHABLE", "STRINGIFY", "CONCAT", "assert", "static_assert",
+ "thread_local", "nullptr"
};
syntax_define (syntax, false, false, "/*", "*/", '\0', language->comment_colour, language->comment_effect);
static void language_highlight_common (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+*-/%!&~^?|()[]{}'\"@#$` \t\r\n";
+ char * separators = ".,:;<=>+*-/%!&~^?|()[]{}'\"@#$` \t\r\n";
syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect);
syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect);
static void language_highlight_d (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|@()[]{}'\"` \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|@()[]{}'\"` \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"abstract", "alias", "align", "asm", "assert", "auto", "body", "bool",
"break", "byte", "case", "cast", "catch", "cdouble", "cent", "cfloat",
"char", "class", "const", "continue", "creal", "dchar", "debug", "default",
"void", "wchar", "while", "foreach_reverse"
};
- const char * types [] = {
+ char * types [] = {
"byte", "ubyte", "short", "ushort", "int", "uint", "long", "ulong",
"cent", "ucent", "char", "wchar", "dchar", "float", "double", "real",
"ifloat", "idouble", "ireal", "cfloat", "cdouble", "creal", "void", "bool",
static void language_highlight_eaxhla (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,+-*/[]<>=; \t\r\n";
+ char * separators = ".,+-*/[]<>=; \t\r\n";
- const char * declarations [] = {
+ char * declarations [] = {
"program", "procedure", "machine", "library", "fast", "unix", "begin", "end",
"if", "then", "else", "repeat", "break", "continue", "until", "exit",
"fastcall", "shell", "alias", "macro", "scope", "unscope", "use", "include"
};
- const char * types [] = {
+ char * types [] = {
"s8", "s16", "s32", "s64", "u8", "u16", "u32", "u64",
"f32", "f64", "f80", "v0", "s128", "u128", "s256", "u256",
"s512", "u512"
};
- const char * instructions [] = {
+ char * instructions [] = {
"jnpe", "jpo", "jnpo", "jpe", "jnb", "jae", "jnbe", "ja",
"jna", "jbe", "jnae", "jb", "jnl", "jge", "jnle", "jg",
"jng", "jle", "jnge", "jl", "cmovng", "cmovle", "cmovnge", "cmovl",
"bswap", "bsf", "bsr", "loop", "loope", "loopne"
};
- const char * registers [] = {
+ char * registers [] = {
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
static void language_highlight_flat (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,+-=:;(){}[]%$<> \t\r\n";
+ char * separators = ".,+-=:;(){}[]%$<> \t\r\n";
- const char * declarations [] = {
+ char * declarations [] = {
"format", "executable", "readable", "writable", "segment", "sector", "entry", "macro",
"db", "dw", "dd", "dq", "rb", "rw", "rd", "rq"
};
- const char * instructions [] = {
+ char * instructions [] = {
"mov", "movabs", "movapd", "movaps", "movebe", "movsd", "movsx", "movzx",
"movsxd", "movd", "movq", "movs", "movsb", "movsw", "movsd", "movsq",
"cmovmp", "cmovrcxz", "cmovc", "cmovnc", "cmove", "cmovne", "cmovz", "cmovnz",
"rep", "repe", "repz", "repne", "repnz", "loop", "loope", "loopne"
};
- const char * registers [] = {
+ char * registers [] = {
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi",
static void language_highlight_fortran (language_structure * language, syntax_structure * syntax) {
- const char * separators = ",:<=>+-*/&()[]\"\' \t\r\n";
+ char * separators = ",:<=>+-*/&()[]\"\' \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"allocatable", "allocate", "associate", "backspace", "block", "call", "case", "common",
"contains", "cycle", "data", "deallocate", "d0", "do", "else", "elseif",
"end", "enddo", "endfile", "endif", "entry", "equivalence", "exit", "external",
"then", "to", "type", "use", "where", "write"
};
- const char * types [] = {
+ char * types [] = {
"character", "integer", "logical", "real", "complex"
};
- const char * subkeywords [] = {
+ char * subkeywords [] = {
".and.", ".or.", ".not.", ".true.", ".false.", "in", "out", "len",
"dimension", "modulo", "advance"
};
static void language_highlight_go (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\"` \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\"` \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"break", "default", "func", "interface", "select", "case", "defer", "go",
"struct", "else", "goto", "package", "switch", "const", "var", "for",
"fallthrough", "if", "range", "type", "continue", "import", "return"
};
- const char * types [] = {
+ char * types [] = {
"map", "uint", "int", "uintptr", "uint8", "uint16", "uint32", "uint64",
"int8", "int16", "int32", "int64", "float32", "float64", "complex64", "complex128",
"byte", "rune", "string", "chan", "bool"
};
- const char * commons [] = {
+ char * commons [] = {
"true", "false", "nil", "err"
};
static void language_highlight_haskell (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!@#$&~^?|()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%!@#$&~^?|()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"case", "class", "data", "deriving", "do", "else", "if", "import",
"in", "infix", "infixl", "infixr", "instance", "let", "of", "module",
"newtype", "then", "type", "where"
};
- const char * types [] = {
+ char * types [] = {
"Int", "Integer", "String", "Char", "Float", "Boolean"
};
--- /dev/null
+static void language_highlight_holy_c (language_structure * language, syntax_structure * syntax) {
+ char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
+///////////// DOES NOT FUCKING WORK YET
+ char * keywords [] = {
+ "auto", "extern", "if", "else",
+ "do", "while", "for", "switch", "case", "default", "break",
+ "enum", "union", "struct", "typedef", "goto", "return", "sizeof", "inline",
+ "restrict", "true", "false"
+ };
+
+ char * types [] = {
+ "void", "bool", "off_t", "va_list", "float", "double", "float_t", "double_t",
+ "char", "short", "int", "long", "uchar", "ushort", "uint", "ulong",
+ "int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t", "uint32_t", "uint64_t",
+ "signed", "unsigned", "size_t", "ssize_t"
+ };
+
+ char * commons [] = {
+ "null", "NULL", "FILE", "DIR", "va_arg", "va_start", "va_end", "va_copy",
+ "alignas", "alignof", "offsetof", "typeof", "EOF", "ABS", "MIN", "MAX",
+ "ARRAYSIZE", "SWAP", "UNUSED", "UNREACHABLE", "STRINGIFY", "CONCAT", "assert", "static_assert",
+ "thread_local", "nullptr"
+ };
+
+ syntax_define (syntax, false, false, "/*", "*/", '\0', language->comment_colour, language->comment_effect);
+ syntax_define (syntax, false, false, "//", "\n", '\0', language->comment_colour, language->comment_effect);
+ syntax_define (syntax, false, false, "#", "\n", '\\', language->processor_colour, language->processor_effect);
+ syntax_define (syntax, false, false, "'", "'", '\\', language->character_colour, language->character_effect);
+ syntax_define (syntax, false, false, "\"", "\"", '\\', language->string_colour, language->string_effect);
+
+ for (ulong word = 0; word < array_length (keywords); ++word) {
+ syntax_define (syntax, false, true, keywords [word], separators, '\0', language->keyword_colour, language->keyword_effect);
+ }
+
+ for (ulong word = 0; word < array_length (types); ++word) {
+ syntax_define (syntax, false, true, types [word], separators, '\0', language->type_colour, language->type_effect);
+ }
+
+ for (ulong word = 0; word < array_length (commons); ++word) {
+ syntax_define (syntax, false, true, commons [word], separators, '\0', language->extension_colour, language->extension_effect);
+ }
+
+ syntax_define (syntax, true, false, "()[]{}", "", '\0', language->bracket_colour, language->bracket_effect);
+ syntax_define (syntax, true, false, ".,:;<=>+*-/%!&~^?|", "", '\0', language->operator_colour, language->operator_effect);
+
+ syntax_define (syntax, true, true, "0123456789", separators, '\0', language->number_colour, language->number_effect);
+ syntax_define (syntax, true, true, "abcdefghijklmnopqrstuvwxyz", separators, '\0', language->lowercase_colour, language->lowercase_effect);
+ syntax_define (syntax, true, true, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", separators, '\0', language->uppercase_colour, language->uppercase_effect);
+ syntax_define (syntax, true, true, "_", separators, '\0', language->underscore_colour, language->underscore_effect);
+}
static void language_highlight_lua (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%~^#|()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%~^#|()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"and", "break", "do", "else", "elseif", "end", "false", "for",
"function", "if", "in", "local", "nil", "not", "or", "until",
"repeat", "return", "then", "true", "while"
};
- const char * types [] = {
+ char * types [] = {
"boolean", "number", "string", "userdata", "function", "thread", "table"
};
- const char * commons [] = {
+ char * commons [] = {
"require", "print", "seek", "dofile", "loadfile", "assert", "rawset", "rawget",
"setfenv", "pairs", "ipairs", "tonumber", "tostring", "foreach", "setn", "getn",
"insert", "concat", "sort", "remove", "abs", "ceil", "floor", "log10",
static void language_highlight_pascal (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/&@#$%^()[] \t\r\n";
+ char * separators = ".,:;<=>+-*/&@#$%^()[] \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"absolute", "and", "array", "asm", "begin", "case", "const", "constructor",
"destructor", "div", "do", "downto", "else", "end", "file", "for",
"function", "goto", "if", "in", "inherited", "inline", "interface", "xor",
static void language_highlight_python (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"and", "as", "assert", "break", "class", "continue", "def", "del",
"elif", "else", "except", "False", "finally", "for", "from", "global",
"if", "import", "in", "is", "labmda", "None", "nonlocal", "not",
"yield", "async", "await"
};
- const char * subkeywords [] = {
+ char * subkeywords [] = {
"abs", "all", "any", "apply", "ascii", "basestring", "bin", "bool",
"breakpoint", "buffer", "bytearray", "bytes", "callable", "chr", "classmethod", "cmp",
"coerce", "compile", "complex", "copyright", "credits", "delattr", "dict", "dir",
static void language_highlight_valgrind (language_structure * language, syntax_structure * syntax) {
- const char * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n";
+ char * separators = ".,:;<=>+-*/%!&~^?|@#$()[]{}'\" \t\r\n";
- const char * titles [] = {
+ char * titles [] = {
//~"exit", "set", "elif", "done", "in", "then", "function", "fi",
"HEAP", "LEAK", "ERROR", "SUMMARY"
};
cross_configure (cross, 640, 480, "Xaptor - File Manager");
while (cross->active == true) {
- const uint offset = 48;
+ uint offset = 48;
cross_synchronize (cross, 0x00000000);
uint height = 0;
uint * buffer = null;
- const uint current = raptor->font_count;
+ uint current = raptor->font_count;
++raptor->font_count;
return (current);
}
-static uint raptor_sprite_import (raptor_structure * raptor, const char * path) {
+static uint raptor_sprite_import (raptor_structure * raptor, char * path) {
uint width = 0;
uint height = 0;
uint * data = null;
return (raptor_sprite_raw_import (raptor, data, width, height));
}
-static uint raptor_font_import (raptor_structure * raptor, const char * path, char begin, char end, uint colour) {
+static uint raptor_font_import (raptor_structure * raptor, char * path, char begin, char end, uint colour) {
uint width = 0;
uint height = 0;
uint result = 0;
return (result);
}
-static uint raptor_sprite_width (const raptor_structure * raptor, uint sprite) {
+static uint raptor_sprite_width (raptor_structure * raptor, uint sprite) {
return (raptor->sprite_width [sprite]);
}
-static uint raptor_sprite_height (const raptor_structure * raptor, uint sprite) {
+static uint raptor_sprite_height (raptor_structure * raptor, uint sprite) {
return (raptor->sprite_height [sprite]);
}
if ((character < raptor->font_begin [font]) || (character > raptor->font_end [font])) {
return (0);
} else {
- const uint index = raptor->font_index [font] [character - raptor->font_begin [font]];
+ uint index = raptor->font_index [font] [character - raptor->font_begin [font]];
return ((uint) (scale * (float) raptor->sprite_width [index]));
}
if ((character < raptor->font_begin [font]) || (character > raptor->font_end [font])) {
return (0);
} else {
- const uint index = raptor->font_index [font] [character - raptor->font_begin [font]];
+ uint index = raptor->font_index [font] [character - raptor->font_begin [font]];
return ((uint) (scale * (float) raptor->sprite_height [index]));
}
}
-static uint raptor_string_width (raptor_structure * raptor, const char * string, uint font, float scale) {
+static uint raptor_string_width (raptor_structure * raptor, char * string, uint font, float scale) {
uint width = 0;
uint match = 0;
return (maximum (width, match));
}
-static uint raptor_string_height (raptor_structure * raptor, const char * string, uint font, float scale) {
+static uint raptor_string_height (raptor_structure * raptor, char * string, uint font, float scale) {
uint height = raptor_character_height (raptor, ' ', font, scale);
if ((string == null) || (string [0] == '\0')) {
return (height);
}
-static uint raptor_center_x (const raptor_structure * raptor, uint size) {
+static uint raptor_center_x (raptor_structure * raptor, uint size) {
return ((raptor->window_width - size) / 2);
}
-static uint raptor_center_y (const raptor_structure * raptor, uint size) {
+static uint raptor_center_y (raptor_structure * raptor, uint size) {
return ((raptor->window_height - size) / 2);
}
-static bool raptor_cursor_inside (const raptor_structure * raptor, int x, int y, uint width, uint height) {
+static bool raptor_cursor_inside (raptor_structure * raptor, int x, int y, uint width, uint height) {
return ((raptor->cursor_x > x)
&& (raptor->cursor_y > y)
&& (raptor->cursor_x < x + (int) width)
&& (raptor->cursor_y < y + (int) height));
}
-static bool raptor_cursor_left_click (const raptor_structure * raptor, int x, int y, uint width, uint height) {
+static bool raptor_cursor_left_click (raptor_structure * raptor, int x, int y, uint width, uint height) {
if (raptor->cursor [cursor_left] == true) {
return (raptor_cursor_inside (raptor, x, y, width, height) == true);
}
return (false);
}
-static bool raptor_cursor_right_click (const raptor_structure * raptor, int x, int y, uint width, uint height) {
+static bool raptor_cursor_right_click (raptor_structure * raptor, int x, int y, uint width, uint height) {
if (raptor->cursor [cursor_right] == true) {
return (raptor_cursor_inside (raptor, x, y, width, height));
}
return (false);
}
-static void raptor_configure (raptor_structure * raptor, uint window_width, uint window_height, const char * window_title) {
- const ulong font_bitmap [2 * 95] = {
+static void raptor_configure (raptor_structure * raptor, uint window_width, uint window_height, char * window_title) {
+ ulong font_bitmap [2 * 95] = {
0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000,
0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000,
0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000,
(void) lower_right;
uint interpolate_pixels (uint pixel, uint modifier) {
- const uint r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff;
- const uint g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff;
- const uint b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff;
- const uint a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff;
+ uint r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff;
+ uint g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff;
+ uint b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff;
+ uint a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff;
return ((r << 24) | (g << 16) | (b << 8) | a);
}
if (horizontal + x >= raptor->window_width) break;
if (horizontal + u >= raptor->sprite_width [sprite]) break;
- const uint pixel = raptor->sprite_data [sprite] [(vertical + v) * raptor->sprite_width [sprite] + horizontal + u];
- const uint at = (y + vertical) * raptor->window_width + (x + horizontal);
+ uint pixel = raptor->sprite_data [sprite] [(vertical + v) * raptor->sprite_width [sprite] + horizontal + u];
+ uint at = (y + vertical) * raptor->window_width + (x + horizontal);
raptor->framebuffer [at] = (((pixel & 0xff000000) >> 24) > 0x77)
? interpolate_pixels (pixel, upper_left)
}
static void raptor_render_sprite (raptor_structure * raptor, uint sprite, int x, int y) {
- const uint width = raptor->sprite_width [sprite];
- const uint height = raptor->sprite_height [sprite];
+ uint width = raptor->sprite_width [sprite];
+ uint height = raptor->sprite_height [sprite];
raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, 1.0f, 1.0f, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu);
}
static void raptor_render_sprite_scale (raptor_structure * raptor, uint sprite, int x, int y, float scale_x, float scale_y) {
- const uint width = raptor->sprite_width [sprite];
- const uint height = raptor->sprite_height [sprite];
+ uint width = raptor->sprite_width [sprite];
+ uint height = raptor->sprite_height [sprite];
raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, scale_x, scale_y, 0, 0, 0xffffffffu, 0xffffffffu, 0xffffffffu,
0xffffffffu);
}
static void raptor_render_sprite_colour (raptor_structure * raptor, uint sprite, uint colour, int x, int y) {
- const uint width = raptor->sprite_width [sprite];
- const uint height = raptor->sprite_height [sprite];
+ uint width = raptor->sprite_width [sprite];
+ uint height = raptor->sprite_height [sprite];
raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, 1.0f, 1.0f, 0, 0, colour, colour, colour, colour);
}
}
static void raptor_render_sprite_flip (raptor_structure * raptor, uint sprite, int x, int y, int flip_x, int flip_y) {
- const uint width = raptor->sprite_width [sprite];
- const uint height = raptor->sprite_height [sprite];
+ uint width = raptor->sprite_width [sprite];
+ uint height = raptor->sprite_height [sprite];
raptor_render_base (raptor, sprite, x, y, 0, 0, width, height, 1.0f, 1.0f, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu,
0xffffffffu);
}
static void raptor_render_sprite_animate (raptor_structure * raptor, uint sprite, int x, int y, uint frames, uint state, uint states) {
- const uint width = raptor->sprite_width [sprite] / states;
- const uint height = raptor->sprite_height [sprite] / frames;
+ uint width = raptor->sprite_width [sprite] / states;
+ uint height = raptor->sprite_height [sprite] / frames;
- const uint u = width * (state % states);
- const uint v = height * (raptor->animation_tick % frames);
+ uint u = width * (state % states);
+ uint v = height * (raptor->animation_tick % frames);
raptor_render_sprite_crop (raptor, sprite, x, y, u, v, width, height);
}
static void raptor_render_character (raptor_structure * raptor, char character, uint font, int x, int y, float scale, uint colour) {
if ((character < raptor->font_begin [font]) || (character > raptor->font_end [font])) return;
- const uint index = raptor->font_index [font] [character - raptor->font_begin [font]];
+ uint index = raptor->font_index [font] [character - raptor->font_begin [font]];
- const uint width = raptor->sprite_width [index];
- const uint height = raptor->sprite_height [index];
+ uint width = raptor->sprite_width [index];
+ uint height = raptor->sprite_height [index];
raptor_render_base (raptor, index, x, y, 0, 0, width, height, scale, scale, 0, 0, colour, colour, colour, colour);
}
-static void raptor_render_string (raptor_structure * raptor, const char * string, uint font, int x, int y, float scale, uint colour) {
+static void raptor_render_string (raptor_structure * raptor, char * string, uint font, int x, int y, float scale, uint colour) {
int offset = x;
if (string == null) return;
}
static void raptor_synchronize (raptor_structure * raptor, uint clear_colour) {
- const uint signal_code [signal_count] = {
+ uint signal_code [signal_count] = {
0,
38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33,
24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14,
#include <xolatile/xanguage.h>
#include <xolatile/xormat/png.h>
-static const uint background = 0xff181818;
-static const uint foreground = 0xffcccccc;
-static const uint font_width = 8;
-static const uint font_height = 16;
-static const uint tab_width = 8;
-static const uint render_border = 10;
+static uint background = 0xff181818;
+static uint foreground = 0xffcccccc;
+static uint font_width = 8;
+static uint font_height = 16;
+static uint tab_width = 8;
+static uint render_border = 10;
static uint * render_image = null;
static uint render_width = 0;
print ("\t/6$ xarbon file.ext/- /0---/- Language is automatically detected in this case.\n\n");
print ("Supported languages:\n\n");
- for (uint index = 0; index < language_count; ++index) {
+ for (language_enumeration index = 0; index < language_count; ++index) {
char align [32] = "";
print ("\t/B/4%s/- /4%s/- /0---/- %s syntax highlighting\n",
- language_short_option (index),
- string_align_left (string_copy (align, language_long_option (index)), 9, ' '),
- language_identifier (index));
+ language_short_option [index],
+ string_align_left (string_copy (align, language_long_option [index]), 9, ' '),
+ language_identifier [index]);
}
}
print ("\tVersion: /40 (Zero)/-\n");
}
-static uint fetch_width (const char * data) {
+static uint fetch_width (char * data) {
uint image_width = 0;
uint count = 0;
return (image_width - 1);
}
-static uint fetch_height (const char * data) {
+static uint fetch_height (char * data) {
uint image_height = 0;
uint count = 0;
}
static void render_character (char character, uint * x, uint * y, uint colour) {
- const ulong glyphmap [192] = {
+ ulong glyphmap [192] = {
0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000,
0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000,
0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000,
* y += font_height;
* x = render_border;
- render_string (format_to_string ((int) ++line_number, false, 10, (int) line_digits, ' '), line_digits, x, y, foreground);
+ render_string (format_to_string ((int) ++line_number, false, 10, (int) line_digits, ' '),
+ line_digits, x, y, foreground);
* x += font_width;
} else {
}
for (uint index = 0; index < language_count; ++index) {
- if (argument_compare (argv [argument], language_short_option (index), language_long_option (index)) == true) {
- (* (language_highlighter (index))) (language, syntax);
+ if (argument_compare (argv [argument], language_short_option [index], language_long_option [index]) == true) {
+ (* (language_highlighter [index])) (language, syntax);
select = index;
break;
}
return (deallocate (particle));
}
-static void particle_append (particle_structure * particle, uint sprite, float life, uint colour_in, uint colour_out, const vector_3 * position,
- const vector_3 * target, const vector_3 * speed) {
+static void particle_append (particle_structure * particle, uint sprite, float life, uint colour_in, uint colour_out, vector_3 * position,
+ vector_3 * target, vector_3 * speed) {
if (particle->count + 1 >= particle->limit) return;
++particle->count;
return (destination);
}
-static float matrix_2_determinant (const matrix_2 * matrix) {
- const float a = matrix [0] [0] * matrix [1] [1];
- const float b = matrix [0] [1] * matrix [1] [0];
+static float matrix_2_determinant (matrix_2 * matrix) {
+ float a = matrix [0] [0] * matrix [1] [1];
+ float b = matrix [0] [1] * matrix [1] [0];
return (a - b);
}
-static float matrix_3_determinant (const matrix_3 * matrix) {
- const matrix_2 matrix_a = { { matrix [1] [1], matrix [1] [2] },
+static float matrix_3_determinant (matrix_3 * matrix) {
+ matrix_2 matrix_a = { { matrix [1] [1], matrix [1] [2] },
{ matrix [2] [1], matrix [2] [2] } };
- const matrix_2 matrix_b = { { matrix [1] [0], matrix [1] [2] },
+ matrix_2 matrix_b = { { matrix [1] [0], matrix [1] [2] },
{ matrix [2] [0], matrix [2] [2] } };
- const matrix_2 matrix_c = { { matrix [1] [0], matrix [1] [1] },
+ matrix_2 matrix_c = { { matrix [1] [0], matrix [1] [1] },
{ matrix [2] [0], matrix [2] [1] } };
- const float a = matrix [0] [0] * matrix_2_determinant (& matrix_a);
- const float b = matrix [0] [1] * matrix_2_determinant (& matrix_b);
- const float c = matrix [0] [2] * matrix_2_determinant (& matrix_c);
+ float a = matrix [0] [0] * matrix_2_determinant (& matrix_a);
+ float b = matrix [0] [1] * matrix_2_determinant (& matrix_b);
+ float c = matrix [0] [2] * matrix_2_determinant (& matrix_c);
return (a - b + c);
}
-static float matrix_4_determinant (const matrix_4 * matrix) {
- const matrix_3 matrix_a = { { matrix [1] [1], matrix [1] [2], matrix [1] [3] },
+static float matrix_4_determinant (matrix_4 * matrix) {
+ matrix_3 matrix_a = { { matrix [1] [1], matrix [1] [2], matrix [1] [3] },
{ matrix [2] [1], matrix [2] [2], matrix [2] [3] },
{ matrix [3] [1], matrix [3] [2], matrix [3] [3] } };
- const matrix_3 matrix_b = { { matrix [1] [0], matrix [1] [2], matrix [1] [3] },
+ matrix_3 matrix_b = { { matrix [1] [0], matrix [1] [2], matrix [1] [3] },
{ matrix [2] [0], matrix [2] [2], matrix [2] [3] },
{ matrix [3] [0], matrix [3] [2], matrix [3] [3] } };
- const matrix_3 matrix_c = { { matrix [1] [0], matrix [1] [1], matrix [1] [3] },
+ matrix_3 matrix_c = { { matrix [1] [0], matrix [1] [1], matrix [1] [3] },
{ matrix [2] [0], matrix [2] [1], matrix [2] [3] },
{ matrix [3] [0], matrix [3] [1], matrix [3] [3] } };
- const matrix_3 matrix_d = { { matrix [1] [0], matrix [1] [1], matrix [1] [2] },
+ matrix_3 matrix_d = { { matrix [1] [0], matrix [1] [1], matrix [1] [2] },
{ matrix [2] [0], matrix [2] [1], matrix [2] [2] },
{ matrix [3] [0], matrix [3] [1], matrix [3] [2] } };
- const float a = matrix [0] [0] * matrix_3_determinant (& matrix_a);
- const float b = matrix [0] [1] * matrix_3_determinant (& matrix_b);
- const float c = matrix [0] [2] * matrix_3_determinant (& matrix_c);
- const float d = matrix [0] [3] * matrix_3_determinant (& matrix_d);
+ float a = matrix [0] [0] * matrix_3_determinant (& matrix_a);
+ float b = matrix [0] [1] * matrix_3_determinant (& matrix_b);
+ float c = matrix [0] [2] * matrix_3_determinant (& matrix_c);
+ float d = matrix [0] [3] * matrix_3_determinant (& matrix_d);
return (a - b + c - d);
}
-static matrix_2 * matrix_2_copy (matrix_2 * destination, const matrix_2 * source) {
+static matrix_2 * matrix_2_copy (matrix_2 * destination, matrix_2 * source) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
destination [row] [column] = source [row] [column];
return (destination);
}
-static matrix_3 * matrix_3_copy (matrix_3 * destination, const matrix_3 * source) {
+static matrix_3 * matrix_3_copy (matrix_3 * destination, matrix_3 * source) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
destination [row] [column] = source [row] [column];
return (destination);
}
-static matrix_4 * matrix_4_copy (matrix_4 * destination, const matrix_4 * source) {
+static matrix_4 * matrix_4_copy (matrix_4 * destination, matrix_4 * source) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
destination [row] [column] = source [row] [column];
return (destination);
}
-static matrix_2 * matrix_2_scale_to (matrix_2 * destination, const matrix_2 * source, float scale) {
+static matrix_2 * matrix_2_scale_to (matrix_2 * destination, matrix_2 * source, float scale) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
destination [row] [column] = source [row] [column] * scale;
return (destination);
}
-static matrix_3 * matrix_3_scale_to (matrix_3 * destination, const matrix_3 * source, float scale) {
+static matrix_3 * matrix_3_scale_to (matrix_3 * destination, matrix_3 * source, float scale) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
destination [row] [column] = source [row] [column] * scale;
return (destination);
}
-static matrix_4 * matrix_4_scale_to (matrix_4 * destination, const matrix_4 * source, float scale) {
+static matrix_4 * matrix_4_scale_to (matrix_4 * destination, matrix_4 * source, float scale) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
destination [row] [column] = source [row] [column] * scale;
return (destination);
}
-static matrix_2 * matrix_2_add (matrix_2 * destination, const matrix_2 * source) {
+static matrix_2 * matrix_2_add (matrix_2 * destination, matrix_2 * source) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
destination [row] [column] += source [row] [column];
return (destination);
}
-static matrix_3 * matrix_3_add (matrix_3 * destination, const matrix_3 * source) {
+static matrix_3 * matrix_3_add (matrix_3 * destination, matrix_3 * source) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
destination [row] [column] += source [row] [column];
return (destination);
}
-static matrix_4 * matrix_4_add (matrix_4 * destination, const matrix_4 * source) {
+static matrix_4 * matrix_4_add (matrix_4 * destination, matrix_4 * source) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
destination [row] [column] += source [row] [column];
return (destination);
}
-static matrix_2 * matrix_2_add_to (matrix_2 * destination, const matrix_2 * matrix_a, const matrix_2 * matrix_b) {
+static matrix_2 * matrix_2_add_to (matrix_2 * destination, matrix_2 * matrix_a, matrix_2 * matrix_b) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
destination [row] [column] = matrix_a [row] [column] + matrix_b [row] [column];
return (destination);
}
-static matrix_3 * matrix_3_add_to (matrix_3 * destination, const matrix_3 * matrix_a, const matrix_3 * matrix_b) {
+static matrix_3 * matrix_3_add_to (matrix_3 * destination, matrix_3 * matrix_a, matrix_3 * matrix_b) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
destination [row] [column] = matrix_a [row] [column] + matrix_b [row] [column];
return (destination);
}
-static matrix_4 * matrix_4_add_to (matrix_4 * destination, const matrix_4 * matrix_a, const matrix_4 * matrix_b) {
+static matrix_4 * matrix_4_add_to (matrix_4 * destination, matrix_4 * matrix_a, matrix_4 * matrix_b) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
destination [row] [column] = matrix_a [row] [column] + matrix_b [row] [column];
return (destination);
}
-static matrix_2 * matrix_2_subtract (matrix_2 * destination, const matrix_2 * source) {
+static matrix_2 * matrix_2_subtract (matrix_2 * destination, matrix_2 * source) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
destination [row] [column] -= source [row] [column];
return (destination);
}
-static matrix_3 * matrix_3_subtract (matrix_3 * destination, const matrix_3 * source) {
+static matrix_3 * matrix_3_subtract (matrix_3 * destination, matrix_3 * source) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
destination [row] [column] -= source [row] [column];
return (destination);
}
-static matrix_4 * matrix_4_subtract (matrix_4 * destination, const matrix_4 * source) {
+static matrix_4 * matrix_4_subtract (matrix_4 * destination, matrix_4 * source) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
destination [row] [column] -= source [row] [column];
return (destination);
}
-static matrix_2 * matrix_2_subtract_to (matrix_2 * destination, const matrix_2 * matrix_a, const matrix_2 * matrix_b) {
+static matrix_2 * matrix_2_subtract_to (matrix_2 * destination, matrix_2 * matrix_a, matrix_2 * matrix_b) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
destination [row] [column] = matrix_a [row] [column] - matrix_b [row] [column];
return (destination);
}
-static matrix_3 * matrix_3_subtract_to (matrix_3 * destination, const matrix_3 * matrix_a, const matrix_3 * matrix_b) {
+static matrix_3 * matrix_3_subtract_to (matrix_3 * destination, matrix_3 * matrix_a, matrix_3 * matrix_b) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
destination [row] [column] = matrix_a [row] [column] - matrix_b [row] [column];
return (destination);
}
-static matrix_4 * matrix_4_subtract_to (matrix_4 * destination, const matrix_4 * matrix_a, const matrix_4 * matrix_b) {
+static matrix_4 * matrix_4_subtract_to (matrix_4 * destination, matrix_4 * matrix_a, matrix_4 * matrix_b) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
destination [row] [column] = matrix_a [row] [column] - matrix_b [row] [column];
return (destination);
}
-static matrix_2 * matrix_2_multiply (matrix_2 * result, const matrix_2 * matrix_a, const matrix_2 * matrix_b) {
+static matrix_2 * matrix_2_multiply (matrix_2 * result, matrix_2 * matrix_a, matrix_2 * matrix_b) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
result [row] [column] = 0.0f;
return (result);
}
-static matrix_3 * matrix_3_multiply (matrix_3 * result, const matrix_3 * matrix_a, const matrix_3 * matrix_b) {
+static matrix_3 * matrix_3_multiply (matrix_3 * result, matrix_3 * matrix_a, matrix_3 * matrix_b) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
result [row] [column] = 0.0f;
return (result);
}
-static matrix_4 * matrix_4_multiply (matrix_4 * result, const matrix_4 * matrix_a, const matrix_4 * matrix_b) {
+static matrix_4 * matrix_4_multiply (matrix_4 * result, matrix_4 * matrix_a, matrix_4 * matrix_b) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
result [row] [column] = 0.0f;
return (result);
}
-static float matrix_2_trace (const matrix_2 * matrix) {
+static float matrix_2_trace (matrix_2 * matrix) {
return (matrix [0] [0] + matrix [1] [1]);
}
-static float matrix_3_trace (const matrix_3 * matrix) {
+static float matrix_3_trace (matrix_3 * matrix) {
return (matrix [0] [0] + matrix [1] [1] + matrix [2] [2]);
}
-static float matrix_4_trace (const matrix_4 * matrix) {
+static float matrix_4_trace (matrix_4 * matrix) {
return (matrix [0] [0] + matrix [1] [1] + matrix [2] [2] + matrix [3] [3]);
}
-static bool matrix_2_compare (const matrix_2 * matrix_a, const matrix_2 * matrix_b) {
+static bool matrix_2_compare (matrix_2 * matrix_a, matrix_2 * matrix_b) {
for (uint row = 0; row < 2; ++row) {
for (uint column = 0; column < 2; ++column) {
if (matrix_a [row] [column] != matrix_b [row] [column]) {
return (true);
}
-static bool matrix_3_compare (const matrix_3 * matrix_a, const matrix_3 * matrix_b) {
+static bool matrix_3_compare (matrix_3 * matrix_a, matrix_3 * matrix_b) {
for (uint row = 0; row < 3; ++row) {
for (uint column = 0; column < 3; ++column) {
if (matrix_a [row] [column] != matrix_b [row] [column]) {
return (true);
}
-static bool matrix_4_compare (const matrix_4 * matrix_a, const matrix_4 * matrix_b) {
+static bool matrix_4_compare (matrix_4 * matrix_a, matrix_4 * matrix_b) {
for (uint row = 0; row < 4; ++row) {
for (uint column = 0; column < 4; ++column) {
if (matrix_a [row] [column] != matrix_b [row] [column]) {
uint * index;
} script_information;
-static void script_warning (const script_structure * script, bool condition, const char * message) {
+static void script_warning (script_structure * script, bool condition, char * message) {
if (condition == true) {
print ("[/3Warning/-] %s: %i: %s\n", script->path, script->line, message);
}
}
-static void script_failure (const script_structure * script, bool condition, const char * message) {
+static void script_failure (script_structure * script, bool condition, char * message) {
if (condition == true) {
print ("[/1Failure/-] %s: %i: %s\n", script->path, script->line, message);
}
}
-static script_structure * script_open (const char * path) {
+static script_structure * script_open (char * path) {
script_structure * script = allocate (sizeof (* script));
script->path = string_duplicate (path);
return (deallocate (script));
}
-static bool script_compare (const script_structure * script, const char * string) {
+static bool script_compare (script_structure * script, char * string) {
return (string_compare_limit (string, script->last_string, script->last_length));
}
-static bool script_check (const script_information * information, uint index, const char * identifier) {
+static bool script_check (script_information * information, uint index, char * identifier) {
return (string_compare (identifier, information->identifier [index]));
}
-static char * script_export_string (const script_structure * script) {
+static char * script_export_string (script_structure * script) {
return (string_duplicate_limit (script->last_string, script->last_length));
}
-static uint script_export_number (const script_structure * script) {
+static uint script_export_number (script_structure * script) {
return (string_limit_to_number (script->last_string, script->last_length));
}
-static uint script_export_marker (const script_information * information, const script_structure * script) {
+static uint script_export_marker (script_information * information, script_structure * script) {
for (uint counter = 0; counter < information->counter; ++counter) {
if (script_compare (script, information->identifier [counter]) == true) {
return (information->index [counter]);
return (word);
}
-static char * script_expect_header (script_information * information, const script_structure * script, uint index, bool accept) {
+static char * script_expect_header (script_information * information, script_structure * script, uint index, bool accept) {
if (accept == true) {
++information->counter;
return (script_export_number (script));
}
-static uint script_expect_marker (const script_information * information, script_structure * script) {
+static uint script_expect_marker (script_information * information, script_structure * script) {
script_word_type word = script_unknown;
script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator.");
return (script_export_marker (information, script));
}
-static uint script_expect_number_or_marker (const script_information * information, script_structure * script) {
+static uint script_expect_number_or_marker (script_information * information, script_structure * script) {
script_word_type word = script_unknown;
script_failure (script, (word = script_parser (script)) != script_assign, "Expected '=', assignment operator.");
return (~ 0u);
}
-static uint * script_expect_ordered_array (const script_information * information, script_structure * script, uint * count) {
+static uint * script_expect_ordered_array (script_information * information, script_structure * script, uint * count) {
script_word_type word = script_unknown;
uint found = 0;
return (array);
}
-static uint * script_expect_unordered_array (const script_information * information, script_structure * script, uint count) {
+static uint * script_expect_unordered_array (script_information * information, script_structure * script, uint count) {
script_word_type word = script_unknown;
uint * array = allocate (count * sizeof (* array));
return (array);
}
-static script_information * script_initialize (const char * general_script_file_path) {
+static script_information * script_initialize (char * general_script_file_path) {
script_information * script = allocate (sizeof (* script));
script_word_type word = script_unknown;
return (deallocate (script));
}
-static uint script_indexer (script_information * information, const char * identifier) {
+static uint script_indexer (script_information * information, char * identifier) {
for (uint counter = 0; counter < information->counter; ++counter) {
if (string_compare (identifier, information->identifier [counter]) == true) {
return (information->index [counter]);
--- /dev/null
+/// _
+/// __ _____| |_ _ __ ___ ___
+/// \ \/ / __| __| '__/ _ \/ _ \
+/// > < (__| |_| | | __/ __/
+/// /_/\_\___|\__|_| \___|\___|
+///
+/// Copyright (c) 1997 - Ognjen 'xolatile' Milan Robovic
+///
+/// xolatile@chud.cyou - xctree - Whitespace insignificant INI/CFG-like script parser.
+///
+/// This program is free software, free as in freedom and as in free beer, you can redistribute it and/or modify it under the terms of the GNU
+/// General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version if you wish...
+///
+/// This program is distributed in the hope that it will be useful, but it is probably not, and without any warranty, without even the implied
+/// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License
+/// for more details, if you dare, it is a lot of text that nobody wants to read...
+
+typedef struct {
+ bool division;
+ float scale;
+ vector_3 * * vertex;
+ vector_3 * origin;
+ vector_3 * offset;
+
+ struct octree_node * children [8];
+} octree_node;
+
+typedef struct {
+ uint count;
+ uint limit;
+ octree_node * * array;
+} octree_structure;
return (destination);
}
-static float vector_2_length (const vector_2 * vector) {
- const float x = vector->x;
- const float y = vector->y;
+static float vector_2_length (vector_2 * vector) {
+ float x = vector->x;
+ float y = vector->y;
return (square_root (x * x + y * y));
}
-static float vector_3_length (const vector_3 * vector) {
- const float x = vector->x;
- const float y = vector->y;
- const float z = vector->z;
+static float vector_3_length (vector_3 * vector) {
+ float x = vector->x;
+ float y = vector->y;
+ float z = vector->z;
return (square_root (x * x + y * y + z * z));
}
-static float vector_4_length (const vector_4 * vector) {
- const float x = vector->x;
- const float y = vector->y;
- const float z = vector->z;
- const float w = vector->w;
+static float vector_4_length (vector_4 * vector) {
+ float x = vector->x;
+ float y = vector->y;
+ float z = vector->z;
+ float w = vector->w;
return (square_root (x * x + y * y + z * z + w * w));
}
static vector_2 * vector_2_normalize (vector_2 * destination) {
- const float length = vector_2_length (destination);
+ float length = vector_2_length (destination);
destination->x /= length;
destination->y /= length;
}
static vector_3 * vector_3_normalize (vector_3 * destination) {
- const float length = vector_3_length (destination);
+ float length = vector_3_length (destination);
destination->x /= length;
destination->y /= length;
}
static vector_4 * vector_4_normalize (vector_4 * destination) {
- const float length = vector_4_length (destination);
+ float length = vector_4_length (destination);
destination->x /= length;
destination->y /= length;
return (destination);
}
-static vector_2 * vector_2_normalize_to (vector_2 * destination, const vector_2 * source) {
- const float length = vector_2_length (source);
+static vector_2 * vector_2_normalize_to (vector_2 * destination, vector_2 * source) {
+ float length = vector_2_length (source);
destination->x = source->x / length;
destination->y = source->y / length;
return (destination);
}
-static vector_3 * vector_3_normalize_to (vector_3 * destination, const vector_3 * source) {
- const float length = vector_3_length (source);
+static vector_3 * vector_3_normalize_to (vector_3 * destination, vector_3 * source) {
+ float length = vector_3_length (source);
destination->x = source->x / length;
destination->y = source->y / length;
return (destination);
}
-static vector_4 * vector_4_normalize_to (vector_4 * destination, const vector_4 * source) {
- const float length = vector_4_length (source);
+static vector_4 * vector_4_normalize_to (vector_4 * destination, vector_4 * source) {
+ float length = vector_4_length (source);
destination->x = source->x / length;
destination->y = source->y / length;
return (destination);
}
-static vector_2 * vector_2_copy (vector_2 * destination, const vector_2 * source) {
+static vector_2 * vector_2_copy (vector_2 * destination, vector_2 * source) {
destination->x = source->x;
destination->y = source->y;
return (destination);
}
-static vector_3 * vector_3_copy (vector_3 * destination, const vector_3 * source) {
+static vector_3 * vector_3_copy (vector_3 * destination, vector_3 * source) {
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
return (destination);
}
-static vector_4 * vector_4_copy (vector_4 * destination, const vector_4 * source) {
+static vector_4 * vector_4_copy (vector_4 * destination, vector_4 * source) {
destination->x = source->x;
destination->y = source->y;
destination->z = source->z;
return (destination);
}
-static vector_2 * vector_2_scale_to (vector_2 * destination, const vector_2 * source, float scale) {
+static vector_2 * vector_2_scale_to (vector_2 * destination, vector_2 * source, float scale) {
destination->x = source->x * scale;
destination->y = source->y * scale;
return (destination);
}
-static vector_3 * vector_3_scale_to (vector_3 * destination, const vector_3 * source, float scale) {
+static vector_3 * vector_3_scale_to (vector_3 * destination, vector_3 * source, float scale) {
destination->x = source->x * scale;
destination->y = source->y * scale;
destination->z = source->z * scale;
return (destination);
}
-static vector_4 * vector_4_scale_to (vector_4 * destination, const vector_4 * source, float scale) {
+static vector_4 * vector_4_scale_to (vector_4 * destination, vector_4 * source, float scale) {
destination->x = source->x * scale;
destination->y = source->y * scale;
destination->z = source->z * scale;
return (destination);
}
-static vector_2 * vector_2_add (vector_2 * destination, const vector_2 * source) {
+static vector_2 * vector_2_add (vector_2 * destination, vector_2 * source) {
destination->x += source->x;
destination->y += source->y;
return (destination);
}
-static vector_3 * vector_3_add (vector_3 * destination, const vector_3 * source) {
+static vector_3 * vector_3_add (vector_3 * destination, vector_3 * source) {
destination->x += source->x;
destination->y += source->y;
destination->z += source->z;
return (destination);
}
-static vector_4 * vector_4_add (vector_4 * destination, const vector_4 * source) {
+static vector_4 * vector_4_add (vector_4 * destination, vector_4 * source) {
destination->x += source->x;
destination->y += source->y;
destination->z += source->z;
return (destination);
}
-static vector_2 * vector_2_add_to (vector_2 * destination, const vector_2 * vector_a, const vector_2 * vector_b) {
+static vector_2 * vector_2_add_to (vector_2 * destination, vector_2 * vector_a, vector_2 * vector_b) {
destination->x = vector_a->x + vector_b->x;
destination->y = vector_a->y + vector_b->y;
return (destination);
}
-static vector_3 * vector_3_add_to (vector_3 * destination, const vector_3 * vector_a, const vector_3 * vector_b) {
+static vector_3 * vector_3_add_to (vector_3 * destination, vector_3 * vector_a, vector_3 * vector_b) {
destination->x = vector_a->x + vector_b->x;
destination->y = vector_a->y + vector_b->y;
destination->z = vector_a->z + vector_b->z;
return (destination);
}
-static vector_4 * vector_4_add_to (vector_4 * destination, const vector_4 * vector_a, const vector_4 * vector_b) {
+static vector_4 * vector_4_add_to (vector_4 * destination, vector_4 * vector_a, vector_4 * vector_b) {
destination->x = vector_a->x + vector_b->x;
destination->y = vector_a->y + vector_b->y;
destination->z = vector_a->z + vector_b->z;
return (destination);
}
-static vector_2 * vector_2_subtract (vector_2 * destination, const vector_2 * source) {
+static vector_2 * vector_2_subtract (vector_2 * destination, vector_2 * source) {
destination->x -= source->x;
destination->y -= source->y;
return (destination);
}
-static vector_3 * vector_3_subtract (vector_3 * destination, const vector_3 * source) {
+static vector_3 * vector_3_subtract (vector_3 * destination, vector_3 * source) {
destination->x -= source->x;
destination->y -= source->y;
destination->z -= source->z;
return (destination);
}
-static vector_4 * vector_4_subtract (vector_4 * destination, const vector_4 * source) {
+static vector_4 * vector_4_subtract (vector_4 * destination, vector_4 * source) {
destination->x -= source->x;
destination->y -= source->y;
destination->z -= source->z;
return (destination);
}
-static vector_2 * vector_2_subtract_to (vector_2 * destination, const vector_2 * vector_a, const vector_2 * vector_b) {
+static vector_2 * vector_2_subtract_to (vector_2 * destination, vector_2 * vector_a, vector_2 * vector_b) {
destination->x = vector_a->x - vector_b->x;
destination->y = vector_a->y - vector_b->y;
return (destination);
}
-static vector_3 * vector_3_subtract_to (vector_3 * destination, const vector_3 * vector_a, const vector_3 * vector_b) {
+static vector_3 * vector_3_subtract_to (vector_3 * destination, vector_3 * vector_a, vector_3 * vector_b) {
destination->x = vector_a->x - vector_b->x;
destination->y = vector_a->y - vector_b->y;
destination->z = vector_a->z - vector_b->z;
return (destination);
}
-static vector_4 * vector_4_subtract_to (vector_4 * destination, const vector_4 * vector_a, const vector_4 * vector_b) {
+static vector_4 * vector_4_subtract_to (vector_4 * destination, vector_4 * vector_a, vector_4 * vector_b) {
destination->x = vector_a->x - vector_b->x;
destination->y = vector_a->y - vector_b->y;
destination->z = vector_a->z - vector_b->z;
return (destination);
}
-static bool vector_2_compare (const vector_2 * vector_a, const vector_2 * vector_b) {
+static bool vector_2_compare (vector_2 * vector_a, vector_2 * vector_b) {
if ((vector_a->x == vector_b->x) && (vector_a->y == vector_b->y)) {
return (true);
} else {
}
}
-static bool vector_3_compare (const vector_3 * vector_a, const vector_3 * vector_b) {
+static bool vector_3_compare (vector_3 * vector_a, vector_3 * vector_b) {
if ((vector_a->x == vector_b->x) && (vector_a->y == vector_b->y) && (vector_a->z == vector_b->z)) {
return (true);
} else {
}
}
-static bool vector_4_compare (const vector_4 * vector_a, const vector_4 * vector_b) {
+static bool vector_4_compare (vector_4 * vector_a, vector_4 * vector_b) {
if ((vector_a->x == vector_b->x) && (vector_a->y == vector_b->y) && (vector_a->z == vector_b->z) && (vector_a->w == vector_b->w)) {
return (true);
} else {
}
}
-static float vector_2_dot_product (const vector_2 * vector_a, const vector_2 * vector_b) {
+static float vector_2_dot_product (vector_2 * vector_a, vector_2 * vector_b) {
return (vector_a->x * vector_b->x + vector_a->y * vector_b->y);
}
-static float vector_3_dot_product (const vector_3 * vector_a, const vector_3 * vector_b) {
+static float vector_3_dot_product (vector_3 * vector_a, vector_3 * vector_b) {
return (vector_a->x * vector_b->x + vector_a->y * vector_b->y + vector_a->z * vector_b->z);
}
-static float vector_4_dot_product (const vector_4 * vector_a, const vector_4 * vector_b) {
+static float vector_4_dot_product (vector_4 * vector_a, vector_4 * vector_b) {
return (vector_a->x * vector_b->x + vector_a->y * vector_b->y + vector_a->z * vector_b->z + vector_a->w * vector_b->w);
}
-static float vector_2_cross_product (const vector_2 * vector_a, const vector_2 * vector_b) {
+static float vector_2_cross_product (vector_2 * vector_a, vector_2 * vector_b) {
return (vector_a->x * vector_b->y - vector_a->y * vector_b->x);
}
-static vector_3 * vector_3_cross_product (vector_3 * destination, const vector_3 * source) {
+static vector_3 * vector_3_cross_product (vector_3 * destination, vector_3 * source) {
destination->x = destination->y * source->z - destination->z * source->y;
destination->y = destination->z * source->x - destination->x * source->z;
destination->z = destination->x * source->y - destination->y * source->x;
}
static void terminal_render_toggle (terminal_structure * terminal, bool toggle, uint x, uint y) {
- const char marker = (toggle == true) ? '+' : '-';
- const char colour = (toggle == true) ? colour_green : colour_red;
+ char marker = (toggle == true) ? '+' : '-';
+ char colour = (toggle == true) ? colour_green : colour_red;
terminal_render_character (terminal, '[', colour_grey, effect_bold, x + 0, y);
terminal_render_character (terminal, marker, colour, effect_bold, x + 1, y);
}
}
-static void terminal_render_string (terminal_structure * terminal, const char * string, uint colour, uint effect, uint x, uint y) {
+static void terminal_render_string (terminal_structure * terminal, char * string, uint colour, uint effect, uint x, uint y) {
for (uint index = 0; string [index] != '\0'; ++index) {
terminal_render_character (terminal, string [index], colour, effect, x + index, y);
}
terminal_render_string (terminal, number_to_string (number), colour, effect, x, y);
}
-static void terminal_render_string_crop (terminal_structure * terminal, const char * string, uint colour, uint effect, uint x, uint y, uint crop) {
+static void terminal_render_string_crop (terminal_structure * terminal, char * string, uint colour, uint effect, uint x, uint y, uint crop) {
for (uint index = 0; (string [index] != '\0') && (index < crop); ++index) {
terminal_render_character (terminal, string [index], colour, effect, x + index, y);
}
}
}
-static void terminal_render_format (terminal_structure * terminal, const char * format, uint x, uint y, ...) {
+static void terminal_render_format (terminal_structure * terminal, char * format, uint x, uint y, ...) {
va_list list;
uint offset_x = 0;
char * * description;
} challenge_structure;
-static const char * special_name [special_count] = {
+static char * special_name [special_count] = {
"strength", "perception", "edurance", "charisma", "intelligence", "agility", "luck"
};
-static bool challenge_is_repeatable (const challenge_structure * challenges, uint index) {
+static bool challenge_is_repeatable (challenge_structure * challenges, uint index) {
return ((challenges->type [index] == special_strength + 1) ||
(challenges->type [index] == special_edurance + 1) ||
(challenges->type [index] == special_agility + 1));
}
-static bool challenge_is_available (const challenge_structure * challenges, uint index) {
+static bool challenge_is_available (challenge_structure * challenges, uint index) {
return ((challenges->completed [index] == 0) || (challenge_is_repeatable (challenges, index) == true));
}
-static bool challenge_is_completable (const uint * special, const challenge_structure * challenges, uint index) {
+static bool challenge_is_completable (uint * special, challenge_structure * challenges, uint index) {
if (challenge_is_available (challenges, index) == false) {
return (false);
}
return (true);
}
-static void render_challenge_list (terminal_structure * terminal, const uint * special, const challenge_structure * challenges, uint x, uint y) {
+static void render_challenge_list (terminal_structure * terminal, uint * special, challenge_structure * challenges, uint x, uint y) {
uint count = 0;
uint * array = allocate (challenges->count * sizeof (* array));
array = deallocate (array);
}
-static void render_special_attributes (terminal_structure * terminal, const uint * special, uint offset, uint selection) {
+static void render_special_attributes (terminal_structure * terminal, uint * special, uint offset, uint selection) {
for (uint index = 0; index < special_count; ++index) {
- const uint effect = (selection == index) ? effect_bold : effect_normal;
- const uint length = attribute_maximum + 3;
+ uint effect = (selection == index) ? effect_bold : effect_normal;
+ uint length = attribute_maximum + 3;
char name [32] = "";
uint selection = 0;
bool show_help = false;
- const char * main_messages [] = {
+ char * main_messages [] = {
"Press H or Tab to toggle help.",
"Press Q or Escape to use default settings.",
"Press S or Enter to save changes.",
"Choose your SPECIAL attributes:"
};
- const char * help_messages [] = {
+ char * help_messages [] = {
"Show help - H or Tab",
"Use default settings - Q or Escape",
"Save and quit - S or Enter",
if (show_help == true) {
for (uint index = 0; index < array_length (help_messages); ++index) {
- const uint offset = array_length (main_messages) + special_count + 2;
+ uint offset = array_length (main_messages) + special_count + 2;
terminal_render_string (terminal, help_messages [index], colour_white, effect_normal, 0, index + offset);
}
information = deallocate (information);
}
-static void export_user_configuration (const uint * special, const uint * daily_challenges, const bool * completition) {
+static void export_user_configuration (uint * special, uint * daily_challenges, bool * completition) {
char buffer [4096] = "";
for (uint index = 0; index < special_count; ++index) {
file = file_close (file);
}
-static uint generate_challenge (const uint * special, const challenge_structure * challenges) {
+static uint generate_challenge (uint * special, challenge_structure * challenges) {
uint index = urandomize (0, challenges->count - 1);
bool valid = false;
return (index);
}
-static void generate_challenges (const uint * special, const challenge_structure * challenges, uint * * daily_challenges, bool * * completition) {
+static void generate_challenges (uint * special, challenge_structure * challenges, uint * * daily_challenges, bool * * completition) {
(* daily_challenges) = allocate (challenges_per_day * sizeof (* * daily_challenges));
(* completition) = allocate (challenges_per_day * sizeof (* * completition));
}
}
-static void render_challenges (const uint * special, challenge_structure * challenges, uint * daily_challenges, bool * completition) {
+static void render_challenges (uint * special, challenge_structure * challenges, uint * daily_challenges, bool * completition) {
terminal_structure * terminal = terminal_initialize ();
uint selection = 0;
bool show_help = false;
bool show_list = false;
- const char * main_messages [] = {
+ char * main_messages [] = {
"Press H or Tab to toggle help.",
"Press Q or Escape to quit the program without saving changes.",
"Press S or Enter to save changes and quit the program.",
"Your daily challenges:"
};
- const char * help_messages [] = {
+ char * help_messages [] = {
"Show help - H or Tab",
"Quit - Q or Escape",
"Save and quit - S or Enter",
char * class = challenges->class [daily_challenges [index]];
char * description = challenges->description [daily_challenges [index]];
- const uint effect = (selection == index) ? effect_bold : effect_normal;
+ uint effect = (selection == index) ? effect_bold : effect_normal;
- const uint offset = array_length (main_messages) + 2;
+ uint offset = array_length (main_messages) + 2;
- const uint alignment = string_length (class) + 4;
+ uint alignment = string_length (class) + 4;
terminal_render_toggle (terminal, completition [index], 0, index + offset);
}
if (show_help == true) {
- const uint offset = array_length (main_messages) + challenges_per_day + 3;
+ uint offset = array_length (main_messages) + challenges_per_day + 3;
for (uint index = 0; index < array_length (help_messages); ++index) {
terminal_render_string (terminal, help_messages [index], colour_white, effect_normal, 0, index + offset);
--- /dev/null
+/// _
+/// __ _| |__ __ _ _ __ ___
+/// \ \/ / '_ \ / _` | '_ \ / _ \
+/// > <| | | | (_| | |_) | __/
+/// /_/\_\_| |_|\__,_| .__/ \___|
+/// |_|
+///
+/// Copyright (c) 1997 - Ognjen 'xolatile' Milan Robovic
+///
+/// xolatile@chud.cyou - xhape - Simplistic programmer art 3D model creator library.
+///
+/// This program is free software, free as in freedom and as in free beer, you can redistribute it and/or modify it under the terms of the GNU
+/// General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version if you wish...
+///
+/// This program is distributed in the hope that it will be useful, but it is probably not, and without any warranty, without even the implied
+/// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License
+/// for more details, if you dare, it is a lot of text that nobody wants to read...
+
+typedef struct {
+ uint vertex_count;
+ uint index_count;
+ uint vertex_limit;
+ uint index_limit;
+ float * vertex_array;
+ uint * index_array;
+} shape_node;
+
+static shape_node * shape_allocate (uint vertex_limit, uint index_limit) {
+ shape_node * shape = allocate (sizeof (* shape));
+
+ shape->vertex_limit = vertex_limit;
+ shape->index_limit = index_limit;
+
+ shape->vertex_array = allocate (vertex_limit * sizeof (* shape->vertex_array));
+ shape->index_array = allocate (index_limit * sizeof (* shape->index_array));
+
+ return (shape);
+}
+
+static shape_node * shape_deallocate (shape_node * shape) {
+ shape->vertex_array = deallocate (shape->vertex_array);
+ shape->index_array = deallocate (shape->index_array);
+
+ return (deallocate (shape));
+}
+
+static void shape_add_vertex_unwrap_colour (shape_node * shape, float x, float y, float z, float u, float v, uint colour) {
+ fatal_failure (shape->vertex_count + 9 > shape->vertex_limit, "shape_add_vertex");
+
+ if (shape->vertex_count + 9 > shape->vertex_limit) return;
+
+ shape->vertex_array [shape->vertex_count + 0] = x;
+ shape->vertex_array [shape->vertex_count + 1] = y;
+ shape->vertex_array [shape->vertex_count + 2] = z;
+ shape->vertex_array [shape->vertex_count + 3] = u;
+ shape->vertex_array [shape->vertex_count + 4] = v;
+ shape->vertex_array [shape->vertex_count + 5] = normal_r (colour);
+ shape->vertex_array [shape->vertex_count + 6] = normal_g (colour);
+ shape->vertex_array [shape->vertex_count + 7] = normal_b (colour);
+ shape->vertex_array [shape->vertex_count + 8] = normal_a (colour);
+
+ shape->vertex_count += 9;
+}
+
+static void shape_add_index (shape_node * shape, uint a, uint b, uint c) {
+ fatal_failure (shape->index_count + 3 > shape->index_limit, "shape_add_index");
+
+ if (shape->index_count + 3 > shape->index_limit) return;
+
+ shape->index_array [shape->index_count + 0] = a;
+ shape->index_array [shape->index_count + 1] = b;
+ shape->index_array [shape->index_count + 2] = c;
+
+ shape->index_count += 3;
+}
+
+//~static shape_node * shape_tetrahedron_unwrap (float x, float y, float z, float scale) {
+//~static shape_node * shape_tetrahedron_unwrap_colour (float x, float y, float z, float scale, uint colour) {
+static shape_node * shape_tetrahedron_colour (float x, float y, float z, float scale, uint colour) {
+ shape_node * shape = shape_allocate (4 * 9, 4 * 3);
+
+ float vertices [12] = {
+ x + scale, y + scale, z + scale,
+ x - scale, y - scale, z + scale,
+ x - scale, y + scale, z - scale,
+ x + scale, y - scale, z - scale
+ };
+
+ for (uint vertex = 0; vertex < 4; ++vertex) {
+ float x = vertices [3 * vertex + 0];
+ float y = vertices [3 * vertex + 1];
+ float z = vertices [3 * vertex + 2];
+ float u = (binary_sign (vertex >> 0) + 1.0f) / 2.0f;
+ float v = (binary_sign (vertex >> 1) + 1.0f) / 2.0f;
+
+ shape_add_vertex_unwrap_colour (shape, x, y, z, u, v, colour);
+ }
+
+ shape_add_index (shape, 0, 1, 2);
+ shape_add_index (shape, 0, 3, 1);
+ shape_add_index (shape, 0, 2, 3);
+ shape_add_index (shape, 1, 3, 2);
+
+ return (shape);
+}
+
+//~static shape_node * shape_square (vector_3 * origin, float scale, uint colour) {
+ //~shape_node * shape = shape_allocate (4, 2 * 3);
+
+ //~shape_set_origin (shape, origin);
+
+ //~float central = square_root (2.0f) * scale / 2.0f;
+
+ //~vector_4 normal_colour = {
+ //~normal_r (colour),
+ //~normal_b (colour),
+ //~normal_g (colour),
+ //~normal_a (colour)
+ //~};
+
+ //~for (uint vertex = 0; vertex < 4; ++vertex) {
+ //~vector_3 point = {
+ //~origin->x + binary_sign (vertex >> 0) * central,
+ //~origin->y + binary_sign (vertex >> 1) * central,
+ //~origin->z
+ //~};
+
+ //~vector_2 unwrap = {
+ //~(binary_sign (vertex >> 0) + 1.0f) / 2.0f,
+ //~(binary_sign (vertex >> 1) + 1.0f) / 2.0f
+ //~};
+
+ //~shape_add_vertex (shape, & point, & unwrap, & normal_colour);
+ //~}
+
+ //~shape_add_index (shape, 0, 1, 2);
+ //~shape_add_index (shape, 1, 3, 2);
+
+ //~return (shape);
+//~}
+
+//~static shape_node * shape_cube (vector_3 * origin, float scale, uint colour) {
+ //~shape_node * shape = shape_allocate (8, 12 * 3);
+
+ //~shape_set_origin (shape, origin);
+
+ //~float central = square_root (3.0f) * scale / 2.0f;
+
+ //~vector_4 normal_colour = {
+ //~normal_r (colour),
+ //~normal_b (colour),
+ //~normal_g (colour),
+ //~normal_a (colour)
+ //~};
+
+ //~for (uint vertex = 0; vertex < 8; ++vertex) {
+ //~vector_3 point = {
+ //~origin->x + binary_sign (vertex >> 0) * central,
+ //~origin->y + binary_sign (vertex >> 1) * central,
+ //~origin->z + binary_sign (vertex >> 2) * central
+ //~};
+
+ //~vector_2 unwrap = {
+ //~0.0f,
+ //~0.0f
+ //~};
+
+ //~shape_add_vertex (shape, & point, & unwrap, & normal_colour);
+ //~}
+
+ //~shape_add_index (shape, 0, 1, 2);
+ //~shape_add_index (shape, 1, 3, 2);
+
+ //~return (shape);
+//~}
static int build_static_1 (int * array) {
int operation = array [0];
- const unsigned char data [] = {
+ unsigned char data [] = {
0x90, 0xc3, 0xcb, 0xc9, 0x9d, 0x9c
};
static int build_static_2 (int * array) {
int operation = array [0];
- const unsigned short data [] = {
+ unsigned short data [] = {
0x050f, 0xa20f, 0xd0d9, 0xe0d9, 0xe1d9, 0xe4d9, 0xe5d9, 0xe8d9,
0xe9d9, 0xead9, 0xebd9, 0xecd9, 0xedd9, 0xeed9, 0xf0d9, 0xf1d9,
0xf2d9, 0xf3d9, 0xf4d9, 0xf5d9, 0xf6d9, 0xf7d9, 0xf8d9, 0xf9d9,
print ("\t/6$ xighlight file.ext/- /0---/- Language is automatically detected in this case.\n\n");
print ("Supported languages:\n\n");
- for (uint index = 0; index < language_count; ++index) {
+ for (language_enumeration index = 0; index < language_count; ++index) {
char align [32] = "";
print ("\t/B/4%s/- /4%s/- /0---/- %s syntax highlighting\n",
- language_short_option (index),
- string_align_left (string_copy (align, language_long_option (index)), 9, ' '),
- language_identifier (index));
+ language_short_option [index],
+ string_align_left (string_copy (align, language_long_option [index]), 9, ' '),
+ language_identifier [index]);
}
}
}
for (uint index = 0; index < language_count; ++index) {
- if (argument_compare (argv [argument], language_short_option (index), language_long_option (index)) == true) {
- (* (language_highlighter (index))) (language, syntax);
+ if (argument_compare (argv [argument], language_short_option [index], language_long_option [index]) == true) {
+ (* (language_highlighter [index])) (language, syntax);
select = index;
break;
}
--- /dev/null
+/// _ _
+/// __ _(_)___(_) ___ _ __
+/// \ \/ / / __| |/ _ \| '_ \
+/// > <| \__ \ | (_) | | | |
+/// /_/\_\_|___/_|\___/|_| |_|
+///
+/// Copyright (c) 1997 - Ognjen 'xolatile' Milan Robovic
+///
+/// xolatile@chud.cyou - xision - General 3D GLFW, OpenGL and OpenAL wrapper library.
+///
+/// This program is free software, free as in freedom and as in free beer, you can redistribute it and/or modify it under the terms of the GNU
+/// General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version if you wish...
+///
+/// This program is distributed in the hope that it will be useful, but it is probably not, and without any warranty, without even the implied
+/// warranty of merchantability or fitness for a particular purpose, because it is pointless. Please see the GNU (Geenoo) General Public License
+/// for more details, if you dare, it is a lot of text that nobody wants to read...
+
+#include <GLFW/glfw3.h>
+
+#define vision_font_width (8)
+#define vision_font_height (16)
+
+typedef struct {
+ GLFWwindow * window;
+
+ PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
+ PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
+ PFNGLGENBUFFERSPROC glGenBuffers;
+ PFNGLBINDBUFFERPROC glBindBuffer;
+ PFNGLCREATESHADERPROC glCreateShader;
+ PFNGLSHADERSOURCEPROC glShaderSource;
+ PFNGLCOMPILESHADERPROC glCompileShader;
+ PFNGLCREATEPROGRAMPROC glCreateProgram;
+ PFNGLATTACHSHADERPROC glAttachShader;
+ PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation;
+ PFNGLLINKPROGRAMPROC glLinkProgram;
+ PFNGLUSEPROGRAMPROC glUseProgram;
+ PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
+ PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
+ PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
+ PFNGLUNIFORM1IPROC glUniform1i;
+ PFNGLUNIFORM1FPROC glUniform1f;
+ PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
+ PFNGLDELETEBUFFERSPROC glDeleteBuffers;
+ PFNGLDELETESHADERPROC glDeleteShader;
+ PFNGLDELETEPROGRAMPROC glDeleteProgram;
+ PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
+ PFNGLBUFFERDATAPROC glBufferData;
+ PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
+
+ bool signal [signal_count];
+ bool cursor [cursor_count];
+ int cursor_x;
+ int cursor_y;
+
+ bool using_precomputed_spritesheet;
+ ulong spritesheet_size;
+ ulong vertex_limit;
+ ulong index_limit;
+ uint gameplay_framerate;
+ uint animation_framerate;
+ uint tab_width;
+ uint default_font;
+ bool active;
+ uint window_width;
+ uint window_height;
+ float pixel_width;
+ float pixel_height;
+ uint framerate;
+ ulong frame_time;
+ ulong frame_begin;
+ ulong frame_end;
+ uint global_tick;
+ uint gameplay_tick;
+ uint animation_tick;
+ bool freeze_cursor;
+ bool freeze_signal;
+ uint vertex_object;
+ uint vertex_buffer;
+ uint index_buffer;
+ uint vertex_shader;
+ uint fragment_shader;
+ uint shader_program;
+ uint spritesheet;
+ uint vertex_count;
+ uint index_count;
+ float * vertex_array;
+ uint * index_array;
+ uint sprite_count;
+ uint font_count;
+ uint * spritesheet_data;
+ uint * * sprite_data;
+ uint * sprite_width;
+ uint * sprite_height;
+ float * sprite_u;
+ float * sprite_v;
+ uint * * font_index;
+ uint * * font_width;
+ uint * * font_height;
+ char * font_begin;
+ char * font_end;
+ float projection_matrix [16];
+ float movement_matrix [16];
+ float rotation_matrix [16];
+ float aspect_ratio;
+ float field_of_view;
+ float far_plane;
+ float near_plane;
+ float camera_x;
+ float camera_y;
+ float sensitivity;
+} vision_structure;
+
+static uint vision_sprite_raw_import (vision_structure * vision, uint * data, uint width, uint height) {
+ fatal_failure (vision->active == true, "vision_sprite_raw_import: OpenGL renderer is already initialized.");
+ fatal_failure (data == null, "vision_sprite_raw_import: Data is null pointer.");
+ fatal_failure (width == 0, "vision_sprite_raw_import: Font image width is zero.");
+ fatal_failure (height == 0, "vision_sprite_raw_import: Font image height is zero.");
+
+ ++vision->sprite_count;
+
+ vision->sprite_data = reallocate (vision->sprite_data, vision->sprite_count * sizeof (* vision->sprite_data));
+ vision->sprite_width = reallocate (vision->sprite_width, vision->sprite_count * sizeof (* vision->sprite_width));
+ vision->sprite_height = reallocate (vision->sprite_height, vision->sprite_count * sizeof (* vision->sprite_height));
+ vision->sprite_u = reallocate (vision->sprite_u, vision->sprite_count * sizeof (* vision->sprite_u));
+ vision->sprite_v = reallocate (vision->sprite_v, vision->sprite_count * sizeof (* vision->sprite_v));
+
+ vision->sprite_data [vision->sprite_count - 1] = data;
+ vision->sprite_width [vision->sprite_count - 1] = width;
+ vision->sprite_height [vision->sprite_count - 1] = height;
+ vision->sprite_u [vision->sprite_count - 1] = 0;
+ vision->sprite_v [vision->sprite_count - 1] = 0;
+
+ return (vision->sprite_count - 1);
+}
+
+static uint vision_font_raw_import (vision_structure * vision, uint * data, uint image_width, char begin, char end, uint empty) {
+ uint pointer = 0;
+ uint width = 0;
+ uint height = 0;
+
+ fatal_failure (vision->active == true, "vision_font_raw_import: OpenGL renderer is already initialized.");
+ fatal_failure (data == null, "vision_font_raw_import: Data is null pointer.");
+ fatal_failure (image_width == 0, "vision_font_raw_import: Font image width is zero.");
+ fatal_failure (begin >= end, "vision_font_raw_import: Font character range is inverted.");
+
+ ++vision->font_count;
+
+ vision->font_index = reallocate (vision->font_index, vision->font_count * sizeof (* vision->font_index));
+ vision->font_width = reallocate (vision->font_width, vision->font_count * sizeof (* vision->font_width));
+ vision->font_height = reallocate (vision->font_height, vision->font_count * sizeof (* vision->font_height));
+ vision->font_begin = reallocate (vision->font_begin, vision->font_count * sizeof (* vision->font_begin));
+ vision->font_end = reallocate (vision->font_end, vision->font_count * sizeof (* vision->font_end));
+
+ vision->font_begin [vision->font_count - 1] = begin;
+ vision->font_end [vision->font_count - 1] = end;
+
+ vision->font_index [vision->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * vision->font_index));
+ vision->font_width [vision->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * vision->font_width));
+ vision->font_height [vision->font_count - 1] = allocate ((ulong) (end - begin + 1) * sizeof (* * vision->font_height));
+
+ for (char index = begin; index <= end; ++index) {
+ for ( ; data [pointer] == empty; ++pointer);
+ for (width = 0; data [pointer + width] != empty; ++width);
+ for (height = 0; data [pointer + height * image_width] != empty; ++height);
+
+ uint * buffer = allocate (width * height * sizeof (* buffer));
+
+ for (uint y = 0; y < height; ++y) {
+ for (uint x = 0; x < width; ++x) {
+ buffer [y * width + x] = data [pointer + (y * image_width) + x];
+ }
+ }
+
+ vision->font_index [vision->font_count - 1] [index - begin] = vision_sprite_raw_import (vision, buffer, width, height);
+ vision->font_width [vision->font_count - 1] [index - begin] = width;
+ vision->font_height [vision->font_count - 1] [index - begin] = height;
+
+ pointer += width;
+
+ for (; data [pointer] == empty; ++pointer);
+
+ if (pointer % image_width == 2) {
+ pointer += height * image_width;
+ }
+ }
+
+ return (vision->font_count - 1);
+}
+
+static uint vision_sprite_import (vision_structure * vision, char * path) {
+ uint width = 0;
+ uint height = 0;
+ uint * data = null;
+
+ data = format_image_import (path, & width, & height);
+
+ return (vision_sprite_raw_import (vision, data, width, height));
+}
+
+static uint vision_font_import (vision_structure * vision, char * path, char begin, char end, uint colour) {
+ uint width = 0;
+ uint height = 0;
+ uint result = 0;
+ uint * data = null;
+
+ data = format_image_import (path, & width, & height);
+
+ result = vision_font_raw_import (vision, data, width, begin, end, colour);
+
+ data = deallocate (data);
+
+ return (result);
+}
+
+static uint vision_sprite_width (vision_structure * vision, uint sprite) {
+ return (vision->sprite_width [sprite]);
+}
+
+static uint vision_sprite_height (vision_structure * vision, uint sprite) {
+ return (vision->sprite_height [sprite]);
+}
+
+static uint vision_center_x (vision_structure * vision, uint size) {
+ return ((vision->window_width - size) / 2);
+}
+
+static uint vision_center_y (vision_structure * vision, uint size) {
+ return ((vision->window_height - size) / 2);
+}
+
+static bool vision_cursor_inside (vision_structure * vision, int x, int y, uint width, uint height) {
+ return ((vision->cursor_x > x) &&
+ (vision->cursor_y > y) &&
+ (vision->cursor_x < x + (int) width) &&
+ (vision->cursor_y < y + (int) height));
+}
+
+static bool vision_cursor_left_click (vision_structure * vision, int x, int y, uint width, uint height) {
+ if (vision->cursor [cursor_left] == true) {
+ vision->freeze_cursor = true;
+
+ return (vision_cursor_inside (vision, x, y, width, height) == true);
+ }
+
+ return (false);
+}
+
+static bool vision_cursor_right_click (vision_structure * vision, int x, int y, uint width, uint height) {
+ if (vision->cursor [cursor_right]) {
+ vision->freeze_cursor = true;
+
+ return (vision_cursor_inside (vision, x, y, width, height));
+ }
+
+ return (false);
+}
+
+static void vision_import_spritesheet (vision_structure * vision, char * data_file) {
+ int file = file_open (data_file, file_flag_read);
+
+ fatal_failure (vision->active == true, "vision_import_spritesheet: OpenGL renderer is already initialized.");
+
+ file_read (file, & vision->spritesheet_size, sizeof (vision->spritesheet_size));
+
+ file_read (file, & vision->sprite_count, sizeof (vision->sprite_count));
+
+ vision->sprite_width = allocate (vision->sprite_count * sizeof (* vision->sprite_width));
+ vision->sprite_height = allocate (vision->sprite_count * sizeof (* vision->sprite_height));
+ vision->sprite_u = allocate (vision->sprite_count * sizeof (* vision->sprite_u));
+ vision->sprite_v = allocate (vision->sprite_count * sizeof (* vision->sprite_v));
+
+ file_read (file, vision->sprite_width, vision->sprite_count * sizeof (* vision->sprite_width));
+ file_read (file, vision->sprite_height, vision->sprite_count * sizeof (* vision->sprite_height));
+ file_read (file, vision->sprite_u, vision->sprite_count * sizeof (* vision->sprite_u));
+ file_read (file, vision->sprite_v, vision->sprite_count * sizeof (* vision->sprite_v));
+
+ file_read (file, & vision->font_count, sizeof (vision->font_count));
+
+ vision->font_index = allocate (vision->font_count * sizeof (* vision->font_index));
+ vision->font_width = allocate (vision->font_count * sizeof (* vision->font_width));
+ vision->font_height = allocate (vision->font_count * sizeof (* vision->font_height));
+ vision->font_begin = allocate (vision->font_count * sizeof (* vision->font_begin));
+ vision->font_end = allocate (vision->font_count * sizeof (* vision->font_end));
+
+ file_read (file, vision->font_begin, vision->font_count * sizeof (* vision->font_begin));
+ file_read (file, vision->font_end, vision->font_count * sizeof (* vision->font_end));
+
+ for (uint index = 0; index < vision->font_count; ++index) {
+ uint range = (uint) (vision->font_end [index] - vision->font_begin [index]) + 1;
+
+ vision->font_index [index] = allocate (range * sizeof (* * vision->font_index));
+ vision->font_width [index] = allocate (range * sizeof (* * vision->font_width));
+ vision->font_height [index] = allocate (range * sizeof (* * vision->font_height));
+
+ for (uint subindex = 0; subindex < range; ++subindex) {
+ file_read (file, & vision->font_index [index] [subindex], sizeof (* * vision->font_index));
+ file_read (file, & vision->font_width [index] [subindex], sizeof (* * vision->font_width));
+ file_read (file, & vision->font_height [index] [subindex], sizeof (* * vision->font_height));
+ }
+ }
+
+ file = file_close (file);
+
+ vision->sprite_count = 0;
+ vision->font_count = 0;
+}
+
+static void vision_export_spritesheet (vision_structure * vision, char * data_file) {
+ int file = file_open (data_file, file_flag_write | file_flag_create | file_flag_truncate);
+
+ fatal_failure (vision->spritesheet_data == null, "vision_export_spritesheet: OpenGL renderer can't access spritesheet data.");
+
+ file_write (file, & vision->spritesheet_size, sizeof (vision->spritesheet_size));
+
+ file_write (file, & vision->sprite_count, sizeof (vision->sprite_count));
+
+ file_write (file, vision->sprite_width, vision->sprite_count * sizeof (* vision->sprite_width));
+ file_write (file, vision->sprite_height, vision->sprite_count * sizeof (* vision->sprite_height));
+ file_write (file, vision->sprite_u, vision->sprite_count * sizeof (* vision->sprite_u));
+ file_write (file, vision->sprite_v, vision->sprite_count * sizeof (* vision->sprite_v));
+
+ file_write (file, & vision->font_count, sizeof (vision->font_count));
+
+ file_write (file, vision->font_begin, vision->font_count * sizeof (* vision->font_begin));
+ file_write (file, vision->font_end, vision->font_count * sizeof (* vision->font_end));
+
+ for (uint index = 0; index < vision->font_count; ++index) {
+ for (uint subindex = 0; subindex < (uint) (vision->font_end [index] - vision->font_begin [index]) + 1; ++subindex) {
+ file_write (file, & vision->font_index [index] [subindex], sizeof (* * vision->font_index));
+ file_write (file, & vision->font_width [index] [subindex], sizeof (* * vision->font_width));
+ file_write (file, & vision->font_height [index] [subindex], sizeof (* * vision->font_height));
+ }
+ }
+
+ file = file_close (file);
+
+ print ("/c Exported internal binary data of OpenGL spritesheet.");
+}
+
+static vision_structure * vision_initialize (uint gameplay_framerate, uint animation_framerate, bool use_precomputed_spritesheet,
+ uint vertex_limit, uint index_limit, uint spritesheet_side) {
+ vision_structure * vision = allocate (sizeof (* vision));
+
+ vision->using_precomputed_spritesheet = use_precomputed_spritesheet;
+
+ vision->spritesheet_size = spritesheet_side;
+ vision->gameplay_framerate = gameplay_framerate;
+ vision->animation_framerate = animation_framerate;
+ vision->vertex_limit = vertex_limit;
+ vision->index_limit = index_limit;
+ vision->tab_width = 4;
+ vision->default_font = ~0u;
+ vision->field_of_view = 2.0f;
+ vision->far_plane = 100.0f;
+ vision->near_plane = 0.1f;
+ vision->sensitivity = 0.1f;
+
+ if (use_precomputed_spritesheet == true) {
+ print ("[/0Comment/-] Importing spritesheet image and information...\n");
+
+ vision_import_spritesheet (vision, "binary/spritesheet.bin");
+ }
+
+ print ("[/2Success/-] Initialized OpenGL renderer.\n");
+
+ return (vision);
+}
+
+static vision_structure * vision_deinitialize (vision_structure * vision) {
+ vision->active = false;
+
+ for (uint index = 0; index < vision->font_count; ++index) {
+ vision->font_index [index] = deallocate (vision->font_index [index]);
+ vision->font_width [index] = deallocate (vision->font_width [index]);
+ vision->font_height [index] = deallocate (vision->font_height [index]);
+ }
+
+ vision->font_index = deallocate (vision->font_index);
+ vision->font_width = deallocate (vision->font_width);
+ vision->font_height = deallocate (vision->font_height);
+ vision->font_begin = deallocate (vision->font_begin);
+ vision->font_end = deallocate (vision->font_end);
+
+ vision->sprite_width = deallocate (vision->sprite_width);
+ vision->sprite_height = deallocate (vision->sprite_height);
+ vision->sprite_u = deallocate (vision->sprite_u);
+ vision->sprite_v = deallocate (vision->sprite_v);
+
+ if (vision->using_precomputed_spritesheet == false) {
+ vision->spritesheet_data = deallocate (vision->spritesheet_data);
+ }
+
+ vision->vertex_array = deallocate (vision->vertex_array);
+ vision->index_array = deallocate (vision->index_array);
+
+ glDeleteTextures (1, & vision->spritesheet);
+
+ vision->glDeleteProgram (vision->shader_program);
+ vision->glDeleteShader (vision->fragment_shader);
+ vision->glDeleteShader (vision->vertex_shader);
+
+ vision->glDeleteBuffers (1, & vision->index_buffer);
+ vision->glDeleteBuffers (1, & vision->vertex_buffer);
+ vision->glDeleteVertexArrays (1, & vision->vertex_object);
+
+ glfwDestroyWindow (vision->window);
+
+ glfwTerminate ();
+
+ print ("[/2Success/-] Deinitialized OpenGL renderer.\n");
+
+ return (deallocate (vision));
+}
+
+static void vision_configure (vision_structure * vision, uint window_width, uint window_height, char * window_title) {
+ ulong font_bitmap [190] = {
+ 0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000,
+ 0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000,
+ 0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000,
+ 0x0000201008080808, 0x0808102000000000, 0x000000000024187e, 0x1824000000000000, 0x000000000010107c, 0x1010000000000000,
+ 0x0000000000000000, 0x0000101020000000, 0x000000000000007e, 0x0000000000000000, 0x0000000000000000, 0x0000101000000000,
+ 0x0000040408081010, 0x2020404000000000, 0x00003c4242464a52, 0x6242423c00000000, 0x0000081828080808, 0x0808083e00000000,
+ 0x00003c4242020408, 0x1020407e00000000, 0x00003c4242021c02, 0x0242423c00000000, 0x000002060a122242, 0x7e02020200000000,
+ 0x00007e4040407c02, 0x0202423c00000000, 0x00001c2040407c42, 0x4242423c00000000, 0x00007e0202040408, 0x0810101000000000,
+ 0x00003c4242423c42, 0x4242423c00000000, 0x00003c424242423e, 0x0202043800000000, 0x0000000000101000, 0x0000101000000000,
+ 0x0000000000101000, 0x0000101020000000, 0x0000000408102040, 0x2010080400000000, 0x00000000007e0000, 0x7e00000000000000,
+ 0x0000004020100804, 0x0810204000000000, 0x00003c4242420408, 0x0800080800000000, 0x00007c829ea2a2a2, 0xa69a807e00000000,
+ 0x00003c424242427e, 0x4242424200000000, 0x00007c4242427c42, 0x4242427c00000000, 0x00003c4242404040, 0x4042423c00000000,
+ 0x0000784442424242, 0x4242447800000000, 0x00007e4040407840, 0x4040407e00000000, 0x00007e4040407840, 0x4040404000000000,
+ 0x00003c424240404e, 0x4242423c00000000, 0x0000424242427e42, 0x4242424200000000, 0x0000381010101010, 0x1010103800000000,
+ 0x00000e0404040404, 0x0444443800000000, 0x0000424448506060, 0x5048444200000000, 0x0000404040404040, 0x4040407e00000000,
+ 0x000082c6aa929282, 0x8282828200000000, 0x000042424262524a, 0x4642424200000000, 0x00003c4242424242, 0x4242423c00000000,
+ 0x00007c424242427c, 0x4040404000000000, 0x00003c4242424242, 0x42424a3c02000000, 0x00007c424242427c, 0x5048444200000000,
+ 0x00003c4240403c02, 0x0242423c00000000, 0x0000fe1010101010, 0x1010101000000000, 0x0000424242424242, 0x4242423c00000000,
+ 0x0000424242424224, 0x2424181800000000, 0x0000828282828292, 0x92aac68200000000, 0x0000424224241818, 0x2424424200000000,
+ 0x0000828244442810, 0x1010101000000000, 0x00007e0202040810, 0x2040407e00000000, 0x0000382020202020, 0x2020203800000000,
+ 0x0000404020201010, 0x0808040400000000, 0x0000380808080808, 0x0808083800000000, 0x0000102844000000, 0x0000000000000000,
+ 0x0000000000000000, 0x0000007e00000000, 0x1008000000000000, 0x0000000000000000, 0x00000000003c023e, 0x4242423e00000000,
+ 0x00004040407c4242, 0x4242427c00000000, 0x00000000003c4240, 0x4040423c00000000, 0x00000202023e4242, 0x4242423e00000000,
+ 0x00000000003c4242, 0x7e40403c00000000, 0x00000e10107c1010, 0x1010101000000000, 0x00000000003e4242, 0x4242423e02023c00,
+ 0x00004040407c4242, 0x4242424200000000, 0x0000101000301010, 0x1010103800000000, 0x00000404000c0404, 0x0404040444443800,
+ 0x0000404040424448, 0x7048444200000000, 0x0000301010101010, 0x1010103800000000, 0x0000000000fc9292, 0x9292929200000000,
+ 0x00000000007c4242, 0x4242424200000000, 0x00000000003c4242, 0x4242423c00000000, 0x00000000007c4242, 0x4242427c40404000,
+ 0x00000000003e4242, 0x4242423e02020200, 0x00000000005e6040, 0x4040404000000000, 0x00000000003e4040, 0x3c02027c00000000,
+ 0x00001010107c1010, 0x1010100e00000000, 0x0000000000424242, 0x4242423e00000000, 0x0000000000424242, 0x2424181800000000,
+ 0x0000000000828292, 0x9292927c00000000, 0x0000000000424224, 0x1824424200000000, 0x0000000000424242, 0x4242423e02023c00,
+ 0x00000000007e0408, 0x1020407e00000000, 0x00000c1010102010, 0x1010100c00000000, 0x0000101010101010, 0x1010101000000000,
+ 0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000
+ };
+
+ char * vertex_shader =
+ "#version 330 core\n"
+ "in vec3 vertex_xyz;\n"
+ "in vec2 vertex_uv;\n"
+ "in vec4 vertex_rgba;\n"
+ "out vec2 fragment_uv;\n"
+ "out vec4 fragment_rgba;\n"
+ "uniform mat4 projection_matrix;\n"
+ "uniform mat4 movement_matrix;\n"
+ "uniform mat4 rotation_matrix;\n"
+ "void main () {\n"
+ " gl_Position = movement_matrix * rotation_matrix * projection_matrix * vec4 (vertex_xyz, 1.0);\n"
+ " fragment_uv = vertex_uv;\n"
+ " fragment_rgba = vertex_rgba;\n"
+ "}\n";
+
+ char * fragment_shader =
+ "#version 330 core\n"
+ "uniform sampler2D texture_p;\n"
+ "in vec2 fragment_uv;\n"
+ "in vec4 fragment_rgba;\n"
+ "out vec4 data;\n"
+ "void main () {\n"
+ " data = texture (texture_p, fragment_uv) * fragment_rgba;\n"
+ "}\n";
+
+ uint * dumb_buffer = null;
+ uint * order = null;
+
+ uint xyz_attribute = 0;
+ uint uv_attribute = 0;
+ uint rgba_attribute = 0;
+
+ uint u = 0;
+ uint v = 0;
+
+ if (vision->using_precomputed_spritesheet == true) {
+ for (uint index = 0; index < 95; ++index) {
+ vision->font_index [vision->font_count] [index] = ++vision->sprite_count - 1;
+ }
+
+ ++vision->sprite_count;
+ ++vision->font_count;
+
+ goto ignore_import;
+ }
+
+ dumb_buffer = allocate (256 * sizeof (* dumb_buffer));
+
+ for (uint index = 0; index < 256; ++index) {
+ dumb_buffer [index] = 0xffffffff;
+ }
+
+ ++vision->font_count;
+
+ uint current = vision->font_count - 1;
+
+ vision->font_index = reallocate (vision->font_index, vision->font_count * sizeof (* vision->font_index));
+ vision->font_width = reallocate (vision->font_width, vision->font_count * sizeof (* vision->font_width));
+ vision->font_height = reallocate (vision->font_height, vision->font_count * sizeof (* vision->font_height));
+ vision->font_begin = reallocate (vision->font_begin, vision->font_count * sizeof (* vision->font_begin));
+ vision->font_end = reallocate (vision->font_end, vision->font_count * sizeof (* vision->font_end));
+
+ vision->font_begin [vision->font_count - 1] = ' ';
+ vision->font_end [vision->font_count - 1] = '~';
+
+ vision->font_index [vision->font_count - 1] = allocate (95 * sizeof (* * vision->font_index));
+ vision->font_width [vision->font_count - 1] = allocate (95 * sizeof (* * vision->font_width));
+ vision->font_height [vision->font_count - 1] = allocate (95 * sizeof (* * vision->font_height));
+
+ for (uint index = 0; index < 95; ++index) {
+ uint * buffer = allocate (vision_font_width * vision_font_height * sizeof (* buffer));
+
+ for (uint value = 0; value < 2; ++value) {
+ for (uint bit = 64; bit > 0; --bit) {
+ uint destination = ((value << 3) - ((bit - 1) >> 3) + 7) * vision_font_width - ((bit - 1) & 7) + 7;
+ uint source = (font_bitmap [2 * index + value] >> (bit - 1)) & 1;
+
+ buffer [destination] = (source) ? 0xffffffff : 0x00000000;
+ }
+ }
+
+ vision->font_index [current] [index] = vision_sprite_raw_import (vision, buffer, vision_font_width, vision_font_height);
+ vision->font_width [current] [index] = vision_font_width;
+ vision->font_height [current] [index] = vision_font_height;
+ }
+
+ vision_sprite_raw_import (vision, dumb_buffer, 16, 16);
+
+ vision->spritesheet_data = allocate (vision->spritesheet_size * vision->spritesheet_size * sizeof (* vision->spritesheet_data));
+
+ order = allocate (vision->sprite_count * sizeof (* order));
+
+ for (uint index = 0; index < vision->sprite_count; ++index) {
+ order [index] = index;
+ }
+
+ for (uint index = 0; index < vision->sprite_count; ++index) {
+ for (uint subindex = 0; subindex < vision->sprite_count; ++subindex) {
+ if (vision->sprite_height [order [index]] < vision->sprite_height [order [subindex]]) {
+ uint temporary = order [index];
+
+ order [index] = order [subindex];
+ order [subindex] = temporary;
+ }
+ }
+ }
+
+ for (uint index = 0; index < vision->sprite_count; ++index) {
+ if (u + vision->sprite_width [order [index]] >= vision->spritesheet_size) {
+ u *= 0;
+ v += vision->sprite_height [order [index]];
+ }
+
+ vision->sprite_u [order [index]] = (float) u / (float) vision->spritesheet_size;
+ vision->sprite_v [order [index]] = (float) v / (float) vision->spritesheet_size;
+
+ for (uint y = 0; y < vision->sprite_height [order [index]]; ++y) {
+ for (uint x = 0; x < vision->sprite_width [order [index]]; ++x) {
+ uint destination = (v + y) * vision->spritesheet_size + (u + x);
+ uint source = y * vision->sprite_width [order [index]] + x;
+
+ vision->spritesheet_data [destination] = vision->sprite_data [order [index]] [source];
+ }
+ }
+
+ u += vision->sprite_width [order [index]];
+
+ vision->sprite_data [order [index]] = deallocate (vision->sprite_data [order [index]]);
+ }
+
+ vision->sprite_data = deallocate (vision->sprite_data);
+ order = deallocate (order);
+
+ ignore_import:
+
+ vision->window_width = window_width;
+ vision->window_height = window_height;
+
+ vision->aspect_ratio = (float) window_height / (float) window_width;
+
+ vision->pixel_width = 2.0f / (float) window_width;
+ vision->pixel_height = 2.0f / (float) window_height;
+
+ glfwInit ();
+
+ glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 3);
+ glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+ glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, 1);
+
+ vision->window = glfwCreateWindow ((int) window_width, (int) window_height, window_title, null, null);
+
+ fatal_failure (vision->window == null, "Failed to create GLFW window.\n");
+
+ glfwSetWindowSizeLimits (vision->window, 320, 240, 1920, 1080);
+
+ //~glfwSetInputMode (vision->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
+ //~glfwSetInputMode (vision->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
+
+ glfwSetCursorPos (vision->window, (double) vision->window_width / 2.0, (double) vision->window_height / 2.0);
+
+ glfwMakeContextCurrent (vision->window);
+
+ vision->glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) glfwGetProcAddress ("glGenVertexArrays");
+ vision->glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) glfwGetProcAddress ("glBindVertexArray");
+ vision->glGenBuffers = (PFNGLGENBUFFERSPROC) glfwGetProcAddress ("glGenBuffers");
+ vision->glBindBuffer = (PFNGLBINDBUFFERPROC) glfwGetProcAddress ("glBindBuffer");
+ vision->glCreateShader = (PFNGLCREATESHADERPROC) glfwGetProcAddress ("glCreateShader");
+ vision->glShaderSource = (PFNGLSHADERSOURCEPROC) glfwGetProcAddress ("glShaderSource");
+ vision->glCompileShader = (PFNGLCOMPILESHADERPROC) glfwGetProcAddress ("glCompileShader");
+ vision->glCreateProgram = (PFNGLCREATEPROGRAMPROC) glfwGetProcAddress ("glCreateProgram");
+ vision->glAttachShader = (PFNGLATTACHSHADERPROC) glfwGetProcAddress ("glAttachShader");
+ vision->glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) glfwGetProcAddress ("glBindFragDataLocation");
+ vision->glLinkProgram = (PFNGLLINKPROGRAMPROC) glfwGetProcAddress ("glLinkProgram");
+ vision->glUseProgram = (PFNGLUSEPROGRAMPROC) glfwGetProcAddress ("glUseProgram");
+ vision->glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) glfwGetProcAddress ("glGetAttribLocation");
+ vision->glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) glfwGetProcAddress ("glEnableVertexAttribArray");
+ vision->glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) glfwGetProcAddress ("glVertexAttribPointer");
+ vision->glUniform1i = (PFNGLUNIFORM1IPROC) glfwGetProcAddress ("glUniform1i");
+ vision->glUniform1f = (PFNGLUNIFORM1FPROC) glfwGetProcAddress ("glUniform1f");
+ vision->glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) glfwGetProcAddress ("glDeleteVertexArrays");
+ vision->glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) glfwGetProcAddress ("glDeleteBuffers");
+ vision->glDeleteShader = (PFNGLDELETESHADERPROC) glfwGetProcAddress ("glDeleteShader");
+ vision->glDeleteProgram = (PFNGLDELETEPROGRAMPROC) glfwGetProcAddress ("glDeleteProgram");
+ vision->glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) glfwGetProcAddress ("glGetUniformLocation");
+ vision->glBufferData = (PFNGLBUFFERDATAPROC) glfwGetProcAddress ("glBufferData");
+ vision->glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) glfwGetProcAddress ("glUniformMatrix4fv");
+
+ glViewport (0, 0, (int) window_width, (int) window_height);
+
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDepthFunc (GL_LESS);
+
+ glEnable (GL_DEPTH_TEST);
+ glEnable (GL_CULL_FACE);
+ glEnable (GL_BLEND);
+
+ vision->glGenVertexArrays (1, & vision->vertex_object);
+ vision->glBindVertexArray (vision->vertex_object);
+
+ vision->glGenBuffers (1, & vision->vertex_buffer);
+ vision->glBindBuffer (GL_ARRAY_BUFFER, vision->vertex_buffer);
+
+ vision->glGenBuffers (1, & vision->index_buffer);
+ vision->glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, vision->index_buffer);
+
+ vision->vertex_shader = vision->glCreateShader (GL_VERTEX_SHADER);
+
+ vision->glShaderSource (vision->vertex_shader, 1, & vertex_shader, null);
+ vision->glCompileShader (vision->vertex_shader);
+
+ vision->fragment_shader = vision->glCreateShader (GL_FRAGMENT_SHADER);
+
+ vision->glShaderSource (vision->fragment_shader, 1, & fragment_shader, null);
+ vision->glCompileShader (vision->fragment_shader);
+
+ vision->shader_program = vision->glCreateProgram ();
+
+ vision->glAttachShader (vision->shader_program, vision->vertex_shader);
+ vision->glAttachShader (vision->shader_program, vision->fragment_shader);
+
+ vision->glBindFragDataLocation (vision->shader_program, 0, "data");
+
+ vision->glLinkProgram (vision->shader_program);
+ vision->glUseProgram (vision->shader_program);
+
+ xyz_attribute = (uint) vision->glGetAttribLocation (vision->shader_program, "vertex_xyz");
+
+ vision->glEnableVertexAttribArray (xyz_attribute);
+
+ vision->glVertexAttribPointer (xyz_attribute, 3, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (void *) 0);
+
+ uv_attribute = (uint) vision->glGetAttribLocation (vision->shader_program, "vertex_uv");
+
+ vision->glEnableVertexAttribArray (uv_attribute);
+
+ vision->glVertexAttribPointer (uv_attribute, 2, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (void *) (3 * sizeof (float)));
+
+ rgba_attribute = (uint) vision->glGetAttribLocation (vision->shader_program, "vertex_rgba");
+
+ vision->glEnableVertexAttribArray (rgba_attribute);
+
+ vision->glVertexAttribPointer (rgba_attribute, 4, GL_FLOAT, GL_FALSE, 9 * sizeof (float), (void *) (5 * sizeof (float)));
+
+ vision->vertex_array = allocate (vision->vertex_limit * sizeof (vision->vertex_array));
+ vision->index_array = allocate (vision->index_limit * sizeof (vision->index_array));
+
+ for (uint index = 0; index < 16; ++index) {
+ vision->projection_matrix [index] = 0.0f;
+ vision->movement_matrix [index] = 0.0f;
+ vision->rotation_matrix [index] = 0.0f;
+ }
+
+ vision->movement_matrix [0] = vision->movement_matrix [5] = vision->movement_matrix [10] = vision->movement_matrix [15] = 1.0f;
+ vision->rotation_matrix [0] = vision->rotation_matrix [5] = vision->rotation_matrix [10] = vision->rotation_matrix [15] = 1.0f;
+
+ vision->projection_matrix [ 0] = vision->aspect_ratio / tangent (vision->field_of_view / 2.0f);
+ vision->projection_matrix [ 5] = 1.0f / tangent (vision->field_of_view / 2.0f);
+ vision->projection_matrix [10] = vision->far_plane / (vision->far_plane - vision->near_plane);
+ vision->projection_matrix [11] = 1.0f;
+ vision->projection_matrix [14] = (- vision->far_plane * vision->near_plane) / (vision->far_plane - vision->near_plane);
+
+ vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "projection_matrix"), 1, GL_FALSE,
+ vision->projection_matrix);
+
+ vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "movement_matrix"), 1, GL_FALSE,
+ vision->movement_matrix);
+
+ vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "rotation_matrix"), 1, GL_FALSE,
+ vision->rotation_matrix);
+
+ glGenTextures (1, & vision->spritesheet);
+
+ glBindTexture (GL_TEXTURE_2D, vision->spritesheet);
+
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, vision->spritesheet_size, vision->spritesheet_size, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ vision->spritesheet_data);
+
+ vision->glUniform1i (vision->glGetUniformLocation (vision->shader_program, "texture_p"), 0);
+ //~vision->glUniform1f (vision->glGetUniformLocation (vision->shader_program, "aspect_ratio"), vision->aspect_ratio);
+
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ if (vision->using_precomputed_spritesheet == true) {
+ vision->spritesheet_data = deallocate (vision->spritesheet_data);
+ }
+
+ vision->active = true;
+
+ vision->frame_begin = nano_time ();
+
+ glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
+
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ print ("[/2Success/-] Configured OpenGL renderer.\n");
+}
+
+static void vision_synchronize (vision_structure * vision, uint colour) {
+ int signal_code [signal_count] = {
+ 0,
+ GLFW_KEY_A, GLFW_KEY_B, GLFW_KEY_C, GLFW_KEY_D,
+ GLFW_KEY_E, GLFW_KEY_F, GLFW_KEY_G, GLFW_KEY_H,
+ GLFW_KEY_I, GLFW_KEY_J, GLFW_KEY_K, GLFW_KEY_L,
+ GLFW_KEY_M, GLFW_KEY_N, GLFW_KEY_O, GLFW_KEY_P,
+ GLFW_KEY_Q, GLFW_KEY_R, GLFW_KEY_S, GLFW_KEY_T,
+ GLFW_KEY_U, GLFW_KEY_V, GLFW_KEY_W, GLFW_KEY_X,
+ GLFW_KEY_Y, GLFW_KEY_Z, GLFW_KEY_0, GLFW_KEY_1,
+ GLFW_KEY_2, GLFW_KEY_3, GLFW_KEY_4, GLFW_KEY_5,
+ GLFW_KEY_6, GLFW_KEY_7, GLFW_KEY_8, GLFW_KEY_9,
+ GLFW_KEY_ESCAPE, GLFW_KEY_TAB, GLFW_KEY_ENTER, GLFW_KEY_ENTER,
+ GLFW_KEY_SLASH, GLFW_KEY_BACKSLASH, GLFW_KEY_SEMICOLON, GLFW_KEY_GRAVE_ACCENT,
+ GLFW_KEY_SPACE, GLFW_KEY_BACKSPACE, GLFW_KEY_PERIOD, GLFW_KEY_COMMA,
+ GLFW_KEY_APOSTROPHE, GLFW_KEY_CAPS_LOCK, GLFW_KEY_MINUS, GLFW_KEY_EQUAL,
+ GLFW_KEY_LEFT_BRACKET, GLFW_KEY_RIGHT_BRACKET, GLFW_KEY_LEFT_CONTROL, GLFW_KEY_RIGHT_CONTROL,
+ GLFW_KEY_LEFT_SHIFT, GLFW_KEY_RIGHT_SHIFT, GLFW_KEY_LEFT_ALT, GLFW_KEY_RIGHT_ALT,
+ GLFW_KEY_F1, GLFW_KEY_F2, GLFW_KEY_F3, GLFW_KEY_F4,
+ GLFW_KEY_F5, GLFW_KEY_F6, GLFW_KEY_F7, GLFW_KEY_F8,
+ GLFW_KEY_F9, GLFW_KEY_F10, GLFW_KEY_F11, GLFW_KEY_F12,
+ GLFW_KEY_UP, GLFW_KEY_DOWN, GLFW_KEY_LEFT, GLFW_KEY_RIGHT,
+ GLFW_KEY_NUM_LOCK, GLFW_KEY_PAUSE, GLFW_KEY_INSERT, GLFW_KEY_HOME,
+ GLFW_KEY_PAGE_UP, GLFW_KEY_DELETE, GLFW_KEY_END, GLFW_KEY_PAGE_DOWN,
+ GLFW_KEY_KP_ADD, GLFW_KEY_KP_SUBTRACT, GLFW_KEY_KP_MULTIPLY, GLFW_KEY_KP_DIVIDE,
+ GLFW_KEY_KP_ENTER, GLFW_KEY_KP_DECIMAL, GLFW_KEY_KP_0, GLFW_KEY_KP_1,
+ GLFW_KEY_KP_2, GLFW_KEY_KP_3, GLFW_KEY_KP_4, GLFW_KEY_KP_5,
+ GLFW_KEY_KP_6, GLFW_KEY_KP_7, GLFW_KEY_KP_8, GLFW_KEY_KP_9
+ };
+
+ int new_window_width = 0;
+ int new_window_height = 0;
+
+ glClearColor (normal_r (colour), normal_g (colour), normal_b (colour), normal_a (colour));
+
+ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glfwPollEvents ();
+
+ glfwSetWindowShouldClose (vision->window, vision->active == false);
+
+ glfwGetWindowSize (vision->window, & new_window_width, & new_window_height);
+
+ if ((vision->window_width != (uint) new_window_width) || (vision->window_height != (uint) new_window_height)) {
+ if ((new_window_width <= 0) || (new_window_height <= 0)) return;
+
+ glViewport (0, 0, new_window_width, new_window_height);
+
+ vision->window_width = (uint) new_window_width;
+ vision->window_height = (uint) new_window_height;
+
+ vision->pixel_width = 2.0f / (float) new_window_width;
+ vision->pixel_height = 2.0f / (float) new_window_height;
+ }
+
+ vision->cursor [cursor_left] = (bool) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);
+ vision->cursor [cursor_middle] = (bool) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS);
+ vision->cursor [cursor_right] = (bool) (glfwGetMouseButton (vision->window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS);
+
+ glfwSetCursorPos (vision->window, (double) vision->window_width / 2.0, (double) vision->window_height / 2.0);
+
+ if (vision->freeze_cursor == false) {
+ double x = 0.0;
+ double y = 0.0;
+
+ glfwGetCursorPos (vision->window, & x, & y);
+
+ vision->cursor_x = (int) x;
+ vision->cursor_y = (int) y;
+
+ //~float offset_x = vision->camera_x - x;
+
+ //~for (uint index = 0; index < 16; ++index) {
+ //~vision->rotation_matrix [index] = 0.0f;
+ //~}
+
+ //~offset_x *= vision->sensitivity;
+
+ //~vision->rotation_matrix [0] = vision->rotation_matrix [5] = vision->rotation_matrix [10] = vision->rotation_matrix [15] = 1.0f;
+
+ //~vision->rotation_matrix [5] = vision->rotation_matrix [10] = cosine (offset_x);
+ //~vision->rotation_matrix [6] = vision->rotation_matrix [ 9] = sine (offset_x);
+
+ //~vision->rotation_matrix [6] *= - 1.0f;
+
+ //~vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "rotation_matrix"), 1, GL_FALSE,
+ //~vision->rotation_matrix);
+
+ //~vision->camera_x = x;
+ } else {
+ if ((vision->cursor [cursor_left] == false)
+ && (vision->cursor [cursor_middle] == false)
+ && (vision->cursor [cursor_right] == false)) {
+ vision->freeze_cursor = false;
+ }
+ }
+
+ if (vision->freeze_signal == false) {
+ for (uint index = 0; index < signal_count; ++index) {
+ vision->signal [index] = (bool) (glfwGetKey (vision->window, signal_code [index]) == GLFW_PRESS);
+ }
+ }
+
+ vision->glBufferData (GL_ARRAY_BUFFER, vision->vertex_count * 4, vision->vertex_array, GL_DYNAMIC_DRAW);
+ vision->glBufferData (GL_ELEMENT_ARRAY_BUFFER, vision->index_count * 4, vision->index_array, GL_DYNAMIC_DRAW);
+
+ vision->glBindBuffer (GL_ARRAY_BUFFER, vision->vertex_buffer);
+
+ glDrawElements (GL_TRIANGLES, (int) vision->index_count * 4, GL_UNSIGNED_INT, null);
+
+ glfwSwapBuffers (vision->window);
+
+ vision->vertex_count = 0;
+ vision->index_count = 0;
+
+ vision->frame_end = nano_time ();
+
+ vision->frame_time = vision->frame_end - vision->frame_begin;
+
+ if (vision->frame_time < 1000000000ul / vision->gameplay_framerate) {
+ nano_wait (1000000000ul / vision->gameplay_framerate - vision->frame_time);
+ }
+
+ if (vision->global_tick % vision->gameplay_framerate == 0) {
+ vision->framerate = (uint) (1000000000ul / vision->frame_time);
+ }
+
+ ++vision->global_tick;
+
+ vision->global_tick = vision->global_tick % (vision->gameplay_framerate * vision->animation_framerate);
+ vision->gameplay_tick = vision->global_tick % (vision->gameplay_framerate);
+ vision->animation_tick = vision->global_tick / (vision->gameplay_framerate / vision->animation_framerate);
+
+ vision->frame_begin = nano_time ();
+}
+
+static void vision_render_base (vision_structure * vision, uint vertex_count, float * vertex_array, uint index_count,
+ uint * index_array, uint sprite, uint colour) {
+ if (sprite >= vision->sprite_count) return;
+ if (vision->vertex_count + vertex_count >= vision->vertex_limit) return;
+ if (vision->index_count + index_count >= vision->index_limit) return;
+
+ float unwrap_x = (float) vision->sprite_u [sprite] / (float) vision->spritesheet_size;
+ float unwrap_y = (float) vision->sprite_v [sprite] / (float) vision->spritesheet_size;
+
+ float unwrap_width = (float) vision->sprite_width [sprite] / (float) vision->spritesheet_size;
+ float unwrap_height = (float) vision->sprite_height [sprite] / (float) vision->spritesheet_size;
+
+ //~for (uint vertex = 0; vertex < vertex_count; ++vertex) {
+ //~uint destination = 9 * vertex + vision->vertex_count;
+ //~uint source = 5 * vertex;
+
+ //~vision->vertex_array [destination + 0] = vertex_array [source + 0];
+ //~vision->vertex_array [destination + 1] = vertex_array [source + 1];
+ //~vision->vertex_array [destination + 2] = vertex_array [source + 2];
+ //~vision->vertex_array [destination + 3] = vertex_array [source + 3] * unwrap_width + unwrap_x;
+ //~vision->vertex_array [destination + 4] = vertex_array [source + 4] * unwrap_height + unwrap_y;
+ //~vision->vertex_array [destination + 5] = normal_r (colour);
+ //~vision->vertex_array [destination + 6] = normal_g (colour);
+ //~vision->vertex_array [destination + 7] = normal_b (colour);
+ //~vision->vertex_array [destination + 8] = normal_a (colour);
+ //~}
+
+ for (uint vertex = 0; vertex < vertex_count; ++vertex) {
+ vision->vertex_array [vision->vertex_count + vertex] = vertex_array [vertex];
+ }
+
+ //~vision->vertex_array [destination + 3] = vertex_array [source + 3] * unwrap_width + unwrap_x;
+ //~vision->vertex_array [destination + 4] = vertex_array [source + 4] * unwrap_height + unwrap_y;
+
+ for (uint index = 0; index < index_count; ++index) {
+ vision->index_array [vision->index_count + index] = index_array [index];
+ }
+
+ //~vision->vertex_count += 36 * vertex_count;
+ //~vision->index_count += 3 * index_count;
+ vision->vertex_count += vertex_count;
+ vision->index_count += index_count;
+}
+
+//~static void vision_render_triangle (vision_structure * vision, float * vertex_array, uint colour) {
+ //~if (vision->vertex_count + 3 * 36 >= vision->vertex_limit) return;
+ //~if (vision->index_count + 3 >= vision->index_limit) return;
+
+ //~for (uint vertex = 0; vertex < 3; ++vertex) {
+ //~uint destination = 9 * vertex + vision->vertex_count;
+ //~uint source = 5 * vertex;
+
+ //~vision->vertex_array [destination + 0] = vertex_array [source + 0];
+ //~vision->vertex_array [destination + 1] = vertex_array [source + 1];
+ //~vision->vertex_array [destination + 2] = vertex_array [source + 2];
+ //~vision->vertex_array [destination + 3] = (binary_sign (vertex >> 0) + 1.0f) / 2.0f;
+ //~vision->vertex_array [destination + 4] = (binary_sign (vertex >> 1) + 1.0f) / 2.0f;
+ //~vision->vertex_array [destination + 5] = normal_r (colour);
+ //~vision->vertex_array [destination + 6] = normal_g (colour);
+ //~vision->vertex_array [destination + 7] = normal_b (colour);
+ //~vision->vertex_array [destination + 8] = normal_a (colour);
+ //~}
+
+ //~for (uint index = 0; index < 3; ++index) {
+ //~vision->index_array [vision->index_count + index] = vision->vertex_array [vision->vertex_count / 9 + index];
+ //~}
+
+ //~vision->vertex_count += 108;
+ //~vision->index_count += 3;
+//~}
+
+static void vision_change_field_of_view (vision_structure * vision, float change) {
+ vision->field_of_view += change;
+
+ vision->projection_matrix [ 0] = vision->aspect_ratio / tangent (vision->field_of_view / 2.0f);
+ vision->projection_matrix [ 5] = 1.0f / tangent (vision->field_of_view / 2.0f);
+
+ vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "projection_matrix"), 1, GL_FALSE,
+ vision->projection_matrix);
+}
+
+static void vision_change_translation (vision_structure * vision, float x, float y, float z) {
+ vision->movement_matrix [ 3] += x;
+ vision->movement_matrix [ 7] += y;
+ vision->movement_matrix [11] += z;
+
+ vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "movement_matrix"), 1, GL_FALSE,
+ vision->movement_matrix);
+}
+
+static void vision_change_rotation (vision_structure * vision, float vertical, float horizontal) {
+ for (uint index = 0; index < 16; ++index) {
+ vision->rotation_matrix [index] = 0.0f;
+ }
+
+ vision->rotation_matrix [0] = vision->rotation_matrix [5] = vision->rotation_matrix [10] = vision->rotation_matrix [15] = 1.0f;
+
+ vision->rotation_matrix [5] = vision->rotation_matrix [10] = cosine (vertical);
+ vision->rotation_matrix [6] = vision->rotation_matrix [ 9] = sine (vertical);
+
+ vision->rotation_matrix [6] *= - 1.0f;
+
+ vision->glUniformMatrix4fv (vision->glGetUniformLocation (vision->shader_program, "rotation_matrix"), 1, GL_FALSE,
+ vision->rotation_matrix);
+}
+
+#undef vision_font_width
+#undef vision_font_height
char * font_end;
} common_structure;
-static uint common_center_x (const common_structure * common, uint size) {
+static uint common_center_x (common_structure * common, uint size) {
return ((common->window_width - size) / 2);
}
-static uint common_center_y (const common_structure * common, uint size) {
+static uint common_center_y (common_structure * common, uint size) {
return ((common->window_height - size) / 2);
}
-static bool common_cursor_inside (const common_structure * common, int x, int y, uint width, uint height) {
+static bool common_cursor_inside (common_structure * common, int x, int y, uint width, uint height) {
return ((common->cursor_x > x)
&& (common->cursor_y > y)
&& (common->cursor_x < x + (int) width)
return (common->font_count - 1);
}
-static uint common_sprite_import (common_structure * common, const char * path) {
+static uint common_sprite_import (common_structure * common, char * path) {
uint width = 0;
uint height = 0;
uint * data = null;
return (common_sprite_raw_import (common, data, width, height));
}
-static uint common_font_import (common_structure * common, const char * path, char begin, char end, uint colour) {
+static uint common_font_import (common_structure * common, char * path, char begin, char end, uint colour) {
uint width = 0;
uint height = 0;
uint result = 0;
return (result);
}
-static uint common_sprite_width (const common_structure * common, uint sprite) {
+static uint common_sprite_width (common_structure * common, uint sprite) {
return (common->sprite_width [sprite]);
}
-static uint common_sprite_height (const common_structure * common, uint sprite) {
+static uint common_sprite_height (common_structure * common, uint sprite) {
return (common->sprite_height [sprite]);
}
return (deallocate (common));
}
-static void common_configure (common_structure * common, uint width, uint height, const char * title, uint window_flags) {
- const ulong font_bitmap [190] = {
+static void common_configure (common_structure * common, uint width, uint height, char * title, uint window_flags) {
+ ulong font_bitmap [190] = {
0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000,
0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000,
0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000,
0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000
};
- const uint event_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
+ uint event_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
uint mask_window_flags [2] = { 0 };
}
static void common_synchronize (common_structure * common, uint colour) {
- const uint signal_code [signal_count] = {
+ uint signal_code [signal_count] = {
0,
38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33,
24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14,
/// COLOUR INTERPOLATION WITH RBGA-ABGR CONVERSION
uint interpolate_pixels (uint pixel, uint modifier) {
- const uint r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff;
- const uint g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff;
- const uint b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff;
- const uint a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff;
+ uint r = (((pixel & 0xff000000) >> 24) * ((modifier & 0x000000ff) >> 0)) / 0xff;
+ uint g = (((pixel & 0x00ff0000) >> 16) * ((modifier & 0x0000ff00) >> 8)) / 0xff;
+ uint b = (((pixel & 0x0000ff00) >> 8) * ((modifier & 0x00ff0000) >> 16)) / 0xff;
+ uint a = (((pixel & 0x000000ff) >> 0) * ((modifier & 0xff000000) >> 24)) / 0xff;
return ((r << 24) | (g << 16) | (b << 8) | a);
}
if (horizontal + x >= common->window_width) break;
if (horizontal + u >= common->sprite_width [sprite]) break;
- const uint pixel = common->sprite_data [sprite] [(vertical + v) * common->sprite_width [sprite] + horizontal + u];
- const uint at = (y + vertical) * common->window_width + (x + horizontal);
+ uint pixel = common->sprite_data [sprite] [(vertical + v) * common->sprite_width [sprite] + horizontal + u];
+ uint at = (y + vertical) * common->window_width + (x + horizontal);
common->framebuffer [at] = (((pixel & 0xff000000) >> 24) > 0x77) ? interpolate_pixels (pixel, upper_left) : common->framebuffer [at];
}
common_render_base (common, sprite, x, y, u, v, width, height, 1, 1, flip_x, flip_y, 0xffffffffu, 0xffffffffu, 0xffffffffu, 0xffffffffu);
}
-static uint common_render_string_width (common_structure * common, const char * string, uint font, float scale) {
+static uint common_render_string_width (common_structure * common, char * string, uint font, float scale) {
uint length = 0;
if (string == null) {
return (length);
}
-static void common_render_string (common_structure * common, const char * string, uint font, int x, int y, float scale, uint colour) {
+static void common_render_string (common_structure * common, char * string, uint font, int x, int y, float scale, uint colour) {
int offset = x;
if (string == null) return;
#include <xolatile/xormat/tga.h>
#endif
-static void * format_image_import (const char * path, uint * width, uint * height) {
+static void * format_image_import (char * path, uint * width, uint * height) {
uint * data = null;
-#ifdef use_png_library
- if (data == null) {
- char buffer [256] = "";
+//~#ifdef use_png_library
+ //~if (data == null) {
+ //~char buffer [256] = "";
- if (file_exists (string_concatenate (string_copy (buffer, path), ".png")) == true) {
- data = png_image_import (buffer, width, height);
- }
- }
-#endif
+ //~if (file_exists (string_concatenate (string_copy (buffer, path), ".png")) == true) {
+ //~data = png_image_import (buffer, width, height);
+ //~}
+ //~}
+//~#endif
-#ifdef use_jxl_library
- if (data == null) {
- char buffer [256] = "";
+//~#ifdef use_jxl_library
+ //~if (data == null) {
+ //~char buffer [256] = "";
- if (file_exists (string_concatenate (string_copy (buffer, path), ".jxl")) == true) {
- data = jxl_image_import (buffer, width, height);
- }
- }
-#endif
+ //~if (file_exists (string_concatenate (string_copy (buffer, path), ".jxl")) == true) {
+ //~data = jxl_image_import (buffer, width, height);
+ //~}
+ //~}
+//~#endif
-#ifdef use_jpg_library
- if (data == null) {
- char buffer [256] = "";
+//~#ifdef use_jpg_library
+ //~if (data == null) {
+ //~char buffer [256] = "";
- if (file_exists (string_concatenate (string_copy (buffer, path), ".jpg")) == true) {
- data = jpg_image_import (buffer, width, height);
- }
- }
-#endif
+ //~if (file_exists (string_concatenate (string_copy (buffer, path), ".jpg")) == true) {
+ //~data = jpg_image_import (buffer, width, height);
+ //~}
+ //~}
+//~#endif
-#ifdef use_tga_library
- if (data == null) {
- char buffer [256] = "";
+//~#ifdef use_tga_library
+ //~if (data == null) {
+ //~char buffer [256] = "";
- if (file_exists (string_concatenate (string_copy (buffer, path), ".tga")) == true) {
- data = tga_image_import (buffer, width, height);
- }
- }
-#endif
+ //~if (file_exists (string_concatenate (string_copy (buffer, path), ".tga")) == true) {
+ //~data = tga_image_import (buffer, width, height);
+ //~}
+ //~}
+//~#endif
if (data == null) {
switch (file_type (path)) {
#define use_jxl_library
#endif
-static void * jxl_image_import (const char * path, uint * width, uint * height) {
+static void * jxl_image_import (char * path, uint * width, uint * height) {
JxlDecoder * decoder = null;
JxlBasicInfo information = { 0 };
JxlPixelFormat format = { 4, JXL_TYPE_UINT8, JXL_NATIVE_ENDIAN, 0 };
--- /dev/null
+
+#ifndef use_ply_library
+#define use_ply_library
+#endif
+
+
#define use_png_library
#endif
-static void * png_image_import (const char * path, uint * width, uint * height) {
+static void * png_image_import (char * path, uint * width, uint * height) {
FILE * file;
uint * data;
uint index;
return (data);
}
-static void png_image_export (const char * path, uint * data, uint width, uint height) {
+static void png_image_export (char * path, uint * data, uint width, uint height) {
png_image image = { 0 };
fatal_failure (path == null, "png_image_export: File path is null pointer.");
return (opengl->font_count - 1);
}
-static uint opengl_sprite_import (opengl_structure * opengl, const char * path) {
+static uint opengl_sprite_import (opengl_structure * opengl, char * path) {
uint width = 0;
uint height = 0;
uint * data = null;
return (opengl_sprite_raw_import (opengl, data, width, height));
}
-static uint opengl_font_import (opengl_structure * opengl, const char * path, char begin, char end, uint colour) {
+static uint opengl_font_import (opengl_structure * opengl, char * path, char begin, char end, uint colour) {
uint width = 0;
uint height = 0;
uint result = 0;
return (false);
}
-static void opengl_import_spritesheet (opengl_structure * opengl, const char * data_file) {
+static void opengl_import_spritesheet (opengl_structure * opengl, char * data_file) {
int file = file_open (data_file, file_flag_read);
fatal_failure (opengl->active == true, "opengl_import_spritesheet: OpenGL renderer is already initialized.");
opengl->font_count = 0;
}
-static void opengl_export_spritesheet (opengl_structure * opengl, const char * data_file) {
+static void opengl_export_spritesheet (opengl_structure * opengl, char * data_file) {
int file = file_open (data_file, file_flag_write | file_flag_create | file_flag_truncate);
fatal_failure (opengl->spritesheet_data == null, "opengl_export_spritesheet: OpenGL renderer can't access spritesheet data.");
return (deallocate (opengl));
}
-static void opengl_configure (opengl_structure * opengl, uint window_width, uint window_height, const char * window_title) {
- const ulong font_bitmap [190] = {
+static void opengl_configure (opengl_structure * opengl, uint window_width, uint window_height, char * window_title) {
+ ulong font_bitmap [190] = {
0x0000000000000000, 0x0000000000000000, 0x0000101010101010, 0x1000101000000000, 0x0024242400000000, 0x0000000000000000,
0x00002424247e2424, 0x7e24242400000000, 0x0010107c9290907c, 0x1212927c10100000, 0x0000649468081010, 0x202c524c00000000,
0x000018242418304a, 0x4444443a00000000, 0x0010101000000000, 0x0000000000000000, 0x0000081020202020, 0x2020100800000000,
0x0000300808080408, 0x0808083000000000, 0x000000000062928c, 0x0000000000000000
};
- const char * vertex_shader =
+ char * vertex_shader =
"# version 330 core\n"
"in vec2 vertex_xy;\n"
"in vec2 vertex_uv;\n"
" fragment_rgba = vertex_rgba;\n"
"}\n";
- const char * fragment_shader =
+ char * fragment_shader =
"# version 330 core\n"
"uniform sampler2D texture_p;\n"
"in vec2 fragment_uv;\n"
++opengl->font_count;
- const uint current = opengl->font_count - 1;
+ uint current = opengl->font_count - 1;
opengl->font_index = reallocate (opengl->font_index, opengl->font_count * sizeof (* opengl->font_index));
opengl->font_width = reallocate (opengl->font_width, opengl->font_count * sizeof (* opengl->font_width));
}
static void opengl_synchronize (opengl_structure * opengl, uint colour) {
- const int signal_code [signal_count] = {
+ int signal_code [signal_count] = {
0,
GLFW_KEY_A, GLFW_KEY_B, GLFW_KEY_C, GLFW_KEY_D,
GLFW_KEY_E, GLFW_KEY_F, GLFW_KEY_G, GLFW_KEY_H,
opengl->vertex_array [opengl->vertex_count + 30] = normal_b (colour_lower_right);
opengl->vertex_array [opengl->vertex_count + 31] = normal_a (colour_lower_right);
- opengl->index_array [opengl->index_count + 0] = (opengl->vertex_count >> 3) + 2;
- opengl->index_array [opengl->index_count + 1] = (opengl->vertex_count >> 3) + 1;
- opengl->index_array [opengl->index_count + 2] = (opengl->vertex_count >> 3) + 0;
- opengl->index_array [opengl->index_count + 3] = (opengl->vertex_count >> 3) + 1;
- opengl->index_array [opengl->index_count + 4] = (opengl->vertex_count >> 3) + 2;
- opengl->index_array [opengl->index_count + 5] = (opengl->vertex_count >> 3) + 3;
+ opengl->index_array [opengl->index_count + 0] = (opengl->vertex_count / 8) + 2;
+ opengl->index_array [opengl->index_count + 1] = (opengl->vertex_count / 8) + 1;
+ opengl->index_array [opengl->index_count + 2] = (opengl->vertex_count / 8) + 0;
+ opengl->index_array [opengl->index_count + 3] = (opengl->vertex_count / 8) + 1;
+ opengl->index_array [opengl->index_count + 4] = (opengl->vertex_count / 8) + 2;
+ opengl->index_array [opengl->index_count + 5] = (opengl->vertex_count / 8) + 3;
opengl->vertex_count += 32;
opengl->index_count += 6;
if ((character < opengl->font_begin [font]) || (character > opengl->font_end [font])) {
return (0);
} else {
- const uint index = opengl->font_index [font] [character - opengl->font_begin [font]];
+ uint index = opengl->font_index [font] [character - opengl->font_begin [font]];
return ((uint) (scale * (float) opengl->sprite_width [index]));
}
if ((character < opengl->font_begin [font]) || (character > opengl->font_end [font])) {
return (0);
} else {
- const uint index = opengl->font_index [font] [character - opengl->font_begin [font]];
+ uint index = opengl->font_index [font] [character - opengl->font_begin [font]];
return ((uint) (scale * (float) opengl->sprite_height [index]));
}
}
-static uint opengl_render_string_width (opengl_structure * opengl, const char * string, uint font, float scale) {
+static uint opengl_render_string_width (opengl_structure * opengl, char * string, uint font, float scale) {
uint width = 0;
uint match = 0;
return (maximum (width, match));
}
-static uint opengl_render_string_height (opengl_structure * opengl, const char * string, uint font, float scale) {
+static uint opengl_render_string_height (opengl_structure * opengl, char * string, uint font, float scale) {
uint height = opengl_render_character_height (opengl, ' ', font, scale);
if ((string == null) || (string [0] == '\0')) {
font = opengl->font_count - 1;
}
- const uint index = opengl->font_index [font] [character - opengl->font_begin [font]];
- const uint width = opengl->sprite_width [index];
- const uint height = opengl->sprite_height [index];
+ uint index = opengl->font_index [font] [character - opengl->font_begin [font]];
+ uint width = opengl->sprite_width [index];
+ uint height = opengl->sprite_height [index];
opengl_render_base (opengl, index, x, y, 0, 0, width, height, scale, scale, 0, 0, colour_upper_left, colour_upper_right,
colour_lower_left, colour_lower_right);
opengl_render_character_base (opengl, character, font, x, y, scale, colour_left, colour_right, colour_left, colour_right);
}
-static void opengl_render_string_base (opengl_structure * opengl, const char * string, uint font, int x, int y, float scale,
+static void opengl_render_string_base (opengl_structure * opengl, char * string, uint font, int x, int y, float scale,
uint colour_upper_left, uint colour_upper_right, uint colour_lower_left, uint colour_lower_right) {
int offset = x;
}
}
-static void opengl_render_string (opengl_structure * opengl, const char * string, uint font, int x, int y, float scale, uint colour) {
+static void opengl_render_string (opengl_structure * opengl, char * string, uint font, int x, int y, float scale, uint colour) {
opengl_render_string_base (opengl, string, font, x, y, scale, colour, colour, colour, colour);
}
-static void opengl_render_string_vertical_gradient (opengl_structure * opengl, const char * string, uint font, int x, int y, float scale,
+static void opengl_render_string_vertical_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale,
uint colour_up, uint colour_down) {
opengl_render_string_base (opengl, string, font, x, y, scale, colour_up, colour_up, colour_down, colour_down);
}
-static void opengl_render_string_horizontal_gradient (opengl_structure * opengl, const char * string, uint font, int x, int y, float scale,
+static void opengl_render_string_horizontal_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale,
uint colour_left, uint colour_right) {
opengl_render_string_base (opengl, string, font, x, y, scale, colour_left, colour_right, colour_left, colour_right);
}
-static void opengl_render_string_full_vertical_gradient (opengl_structure * opengl, const char * string, uint font, int x, int y, float scale,
+static void opengl_render_string_full_vertical_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale,
uint colour_up, uint colour_down) {
int offset = x;
uint back = 0;
uint up = 0;
uint down = 0;
- const float interpolator = 1.0f / (float) string_full_height (string);
+ float interpolator = 1.0f / (float) string_full_height (string);
if (string == null) return;
}
}
-static void opengl_render_string_full_horizontal_gradient (opengl_structure * opengl, const char * string, uint font, int x, int y, float scale,
+static void opengl_render_string_full_horizontal_gradient (opengl_structure * opengl, char * string, uint font, int x, int y, float scale,
uint colour_left, uint colour_right) {
int offset = x;
uint back = 0;
uint left = 0;
uint right = 0;
- const float interpolator = 1.0f / (float) string_full_width (string, opengl->tab_width);
+ float interpolator = 1.0f / (float) string_full_width (string, opengl->tab_width);
if (string == null) return;
}
static float sphere_z (float distance, float horizontal, float vertical) {
- const float x_over_z = tangent (horizontal);
- const float y_over_z = tangent (vertical);
+ float x_over_z = tangent (horizontal);
+ float y_over_z = tangent (vertical);
return (distance * square_root (1.0f / (x_over_z * x_over_z + y_over_z * y_over_z + 1.0f)));
}
static void sphere_transpose_x (float * distance, float * horizontal, float x) {
- const float origin = (* distance) * (* distance);
- const float offset = x * x;
- const float square = origin + offset + 2 * x * (* distance) * cosine (* horizontal);
+ float origin = (* distance) * (* distance);
+ float offset = x * x;
+ float square = origin + offset + 2 * x * (* distance) * cosine (* horizontal);
* distance = square_root (square);
}
static void sphere_transpose_y (float * distance, float * vertical, float y) {
- const float origin = (* distance) * (* distance);
- const float offset = y * y;
+ float origin = (* distance) * (* distance);
+ float offset = y * y;
* distance = square_root (origin + offset + 2 * y * (* distance) * cosine (* vertical));
}
static void sphere_transpose_z (float * distance, float * horizontal, float * vertical, float z) {
- const float origin = (* distance) * (* distance);
- const float offset = z * z;
- const float side_a = secant (* vertical);
- const float side_b = tangent (* horizontal);
+ float origin = (* distance) * (* distance);
+ float offset = z * z;
+ float side_a = secant (* vertical);
+ float side_b = tangent (* horizontal);
* distance = square_root (origin + offset + 2 * z * (* distance) * square_root (1.0f / (side_a * side_a + sibe_b * side_b)));
}
return (data);
}
-static void sprite_export (const char * path, int width, int height, unsigned int * data) {
+static void sprite_export (char * path, int width, int height, unsigned int * data) {
int file, move;
file = file_open (path, file_flag_edit | file_flag_truncate | file_flag_create);
return ((void*) & arena->block_array [current]->buffer [arena->block_array [current]->count - size]);
}
-static char * arena_add_data (const void * data, ulong size) {
+static char * arena_add_data (void * data, ulong size) {
void * pointer = arena_add (size);
memory_copy (pointer, data, size);
return (pointer);
}
-static char * arena_add_file (const char * path, uint flag, bool null_terminate) {
+static char * arena_add_file (char * path, uint flag, bool null_terminate) {
int file = -1;
ulong size = 0;
char * data = null;
//~#include <xolatile/xtandard.h>
//~#include <xolatile/xrena.h>
-static int parse_comment (const char * buffer);
-static int parse_include (const char * buffer);
-static int parse_use (const char * buffer);
-static int parse_alias (const char * buffer);
-static int parse_macro (const char * buffer);
-static int parse_scope (const char * buffer);
-static int parse_unscope (const char * buffer);
-static int parse_default (const char * buffer);
-static void parse_buffer (const char * buffer, int limit);
+static int parse_comment (char * buffer);
+static int parse_include (char * buffer);
+static int parse_use (char * buffer);
+static int parse_alias (char * buffer);
+static int parse_macro (char * buffer);
+static int parse_scope (char * buffer);
+static int parse_unscope (char * buffer);
+static int parse_default (char * buffer);
+static void parse_buffer (char * buffer, int limit);
enum {
token_comment, token_include, token_use, token_alias, token_macro, token_scope, token_unscope, token_default
};
-static const char * token_key [token_default] = {
+static char * token_key [token_default] = {
"---", "include ", "use ", "alias ", "macro ", "scope ", "unscope "
};
-static int (* parse_key [token_default + 1]) (const char * buffer) = {
+static int (* parse_key [token_default + 1]) (char * buffer) = {
parse_comment, parse_include, parse_use, parse_alias, parse_macro, parse_scope, parse_unscope, parse_default
};
static int token_count = 0;
static struct {
- const char * data;
+ char * data;
int size;
int type;
} * token_array [token_limit],
* token_value [token_limit];
-static int parse_default (const char * buffer) {
+static int parse_default (char * buffer) {
int select;
for (select = 0; select < token_count; ++select) {
return (1);
}
-static int parse_comment (const char * buffer) {
+static int parse_comment (char * buffer) {
int offset;
for (offset = 3; buffer [offset] != '\0'; ++offset) {
return (offset + 1);
}
-static int parse_use (const char * buffer) {
+static int parse_use (char * buffer) {
int offset;
int length;
return (offset + length + 1);
}
-static int parse_include (const char * buffer) {
+static int parse_include (char * buffer) {
int length;
int offset;
char * data;
return (offset + length + 1);
}
-static int parse_alias (const char * buffer) {
+static int parse_alias (char * buffer) {
int offset;
int length;
return (offset + length + 1);
}
-static int parse_macro (const char * buffer) {
+static int parse_macro (char * buffer) {
int offset;
int length;
return (offset + length + 9 + 1);
}
-static int parse_scope (const char * buffer) {
+static int parse_scope (char * buffer) {
int offset;
int length;
int select;
return (offset + length + 1);
}
-static int parse_unscope (const char * buffer) {
+static int parse_unscope (char * buffer) {
int offset;
int length;
int select;
return (offset + length + 1);
}
-static void parse_buffer (const char * buffer, int limit) {
+static void parse_buffer (char * buffer, int limit) {
int offset;
int length;
int select;
}
static void echo_code (int character) {
- const char * code [] = {
+ char * code [] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
" "
}
static void echo_name (int character) {
- const char * name [] = {
+ char * name [] = {
"Null", "Start of heading", "Start of text", "End of text",
"End of transmission", "Enquiry", "Acknowledge", "Bell",
"Backspace", "Horizontal tab", "Line feed", "Vertical tab",
signal_count
} signal_enumeration;
-static const char * cursor_name [cursor_count] = {
+static char * cursor_name [cursor_count] = {
"---",
"Left button", "Middle button", "Right button",
"Scroll up", "Scroll down"
};
-static const char * signal_name [signal_count] = {
+static char * signal_name [signal_count] = {
"---",
"A", "B", "C", "D",
"E", "F", "G", "H",
read (standard_input, data, size);
}
-static void output (const void * data, ulong size) {
+static void output (void * data, ulong size) {
write (standard_output, data, size);
}
}
#ifdef use_fatal_failure
-static void fatal_failure (bool condition, const char * message) {
+static void fatal_failure (bool condition, char * message) {
if (condition == true) {
echo ("[\x1b[1;31m FATAL \x1b[0m] ");
#define fatal_failure(...)
#endif
-static void execute (const char * command) {
+static void execute (char * command) {
int status = 0;
system (command);
return (buffer);
}
-static bool character_compare_array (char character, const char * character_array) {
+static bool character_compare_array (char character, char * character_array) {
for (ulong index = 0; character_array [index] != '\0'; ++index) {
if (character == character_array [index]) {
return (true);
return (string);
}
-static ulong string_length (const char * string) {
+static ulong string_length (char * string) {
ulong length = 0;
fatal_failure (string == null, "string_length: String is null pointer.");
return (string_reverse_limit (string, string_length (string)));
}
-static bool string_compare_limit (const char * string_a, const char * string_b, ulong limit) {
+static bool string_compare_limit (char * string_a, char * string_b, ulong limit) {
fatal_failure (string_a == null, "string_compare_limit: First source string is null pointer.");
fatal_failure (string_b == null, "string_compare_limit: Second source string is null pointer.");
fatal_failure (limit <= 0, "string_compare_limit: Limit is equal or below zero.");
return (true);
}
-static bool string_compare (const char * string_a, const char * string_b) {
+static bool string_compare (char * string_a, char * string_b) {
return (string_compare_limit (string_a, string_b, string_length (string_a) + 1));
}
-static char * string_copy_limit (char * destination, const char * source, ulong limit) {
+static char * string_copy_limit (char * destination, char * source, ulong limit) {
fatal_failure (destination == null, "string_copy_limit: Destination string is null pointer.");
fatal_failure (source == null, "string_copy_limit: Source string is null pointer.");
fatal_failure (limit <= 0, "string_copy_limit: Limit is equal or below zero.");
return (destination);
}
-static char * string_copy (char * destination, const char * source) {
+static char * string_copy (char * destination, char * source) {
return (string_copy_limit (destination, source, string_length (source) + 1));
}
-static char * string_concatenate_limit (char * destination, const char * source, ulong limit) {
+static char * string_concatenate_limit (char * destination, char * source, ulong limit) {
ulong offset = string_length (destination);
fatal_failure (destination == null, "string_concatenate_limit: Destination string is null pointer.");
return (destination);
}
-static char * string_concatenate (char * destination, const char * source) {
+static char * string_concatenate (char * destination, char * source) {
return (string_concatenate_limit (destination, source, string_length (source) + 1));
}
-static char * string_duplicate (const char * string) {
+static char * string_duplicate (char * string) {
char * duplicate = null;
duplicate = allocate ((string_length (string) + 1) * sizeof (* duplicate));
return (duplicate);
}
-static char * string_duplicate_limit (const char * string, uint limit) {
+static char * string_duplicate_limit (char * string, uint limit) {
char * duplicate = null;
duplicate = allocate ((limit + 1) * sizeof (* duplicate));
}
}
-static int memory_compare (void * memory_0, const void * memory_1, ulong size) {
+static int memory_compare (void * memory_0, void * memory_1, ulong size) {
char * cast_0 = ( char *) memory_0;
- const char * cast_1 = (const char *) memory_1;
+ char * cast_1 = (char *) memory_1;
fatal_failure (memory_0 == null, "memory_compare: Memory is null pointer.");
fatal_failure (memory_1 == null, "memory_compare: Source is null pointer.");
return (true);
}
-static void memory_copy (void * destination, const void * source, ulong size) {
+static void memory_copy (void * destination, void * source, ulong size) {
char * cast_0 = ( char *) destination;
- const char * cast_1 = (const char *) source;
+ char * cast_1 = (char *) source;
fatal_failure (destination == null, "memory_copy: Destination is null pointer.");
fatal_failure (source == null, "memory_copy: Source is null pointer.");
}
}
-static int file_open (const char * path, int mode) {
+static int file_open (char * path, int mode) {
fatal_failure (path == null, "file_open: File path is null pointer.");
return (open (path, mode, 0777));
read (file, data, size);
}
-static void file_write (int file, const void * data, ulong size) {
+static void file_write (int file, void * data, ulong size) {
fatal_failure (file <= -1, "file_write: File descriptor is closed or invalid.");
fatal_failure (data == null, "file_write: Data is null pointer.");
fatal_failure (size == 0, "file_write: Size is zero.");
write (file, data, size);
}
-static void file_echo (int file, const char * data) {
+static void file_echo (int file, char * data) {
file_write (file, data, string_length (data));
}
return ((ulong) lseek (file, 0, whence));
}
-static ulong file_size (const char * path) {
+static ulong file_size (char * path) {
struct stat data = { 0 };
fatal_failure (path == null, "file_size: File path is null pointer.");
return ((ulong) data.st_size);
}
-static file_type_enumeration file_type (const char * path) {
- const char * extensions [file_type_count] = {
+static file_type_enumeration file_type (char * path) { /// SHIT BREAKS ON "./THIS/THAT.EXT"...
+ char * extensions [file_type_count] = {
".c", ".h", ".adb", ".ads", ".cpp", ".hpp", ".f90", ".mod",
".pas", ".d", ".go", ".jai", ".asm", ".eax", ".gas", ".fasm",
".hs", ".el", ".cfg", ".lua", ".sh", ".py", ".tcl", ".4th",
return (~ 0u);
}
-static bool file_exists (const char * path) {
+static bool file_exists (char * path) {
fatal_failure (path == null, "file_record: File path is null pointer.");
return ((access (path, F_OK) == 0) ? true : false);
}
-static void file_remove (const char * path) {
+static void file_remove (char * path) {
unlink (path);
}
-static void * file_record (const char * path) {
+static void * file_record (char * path) {
int file = -1;
ulong size = 0;
char * data = null;
return (data);
}
-static char * file_import (const char * path) {
+static char * file_import (char * path) {
int file = -1;
ulong size = 0;
char * data = null;
return (data);
}
-static void file_export (const char * path, const char * data) {
+static void file_export (char * path, char * data) {
int file = -1;
fatal_failure (path == null, "file_export: File path is null pointer.");
file = file_close (file);
}
-static void * folder_open (const char * path) {
+static void * folder_open (char * path) {
DIR * folder = null;
fatal_failure (path == null, "folder_open: Folder path is null pointer.");
return (null);
}
-static char * * folder_create_path_list (const char * folder, uint * path_count, bool sort) {
+static char * * folder_create_path_list (char * folder, uint * path_count, bool sort) {
void * handle = null;
char * * path_array = 0;
return (deallocate (path_array));
}
-static char * configuration_format (const char * path) {
+static char * configuration_format (char * path) {
static char buffer [512] = "";
string_copy (buffer, getenv ("HOME"));
return (buffer);
}
-static bool configuration_exists (const char * path) {
+static bool configuration_exists (char * path) {
return (file_exists (configuration_format (path)));
}
-static void configuration_remove (const char * path) {
+static void configuration_remove (char * path) {
file_remove (configuration_format (path));
}
-static char * configuration_import (const char * path) {
+static char * configuration_import (char * path) {
return (file_import (configuration_format (path)));
}
-static void configuration_export (const char * path, const char * data) {
+static void configuration_export (char * path, char * data) {
file_export (configuration_format (path), data);
}
-static bool argument_compare (const char * argument, const char * short_option, const char * long_option) {
+static bool argument_compare (char * argument, char * short_option, char * long_option) {
return ((string_compare (argument, short_option) == true) || (string_compare (argument, long_option) == true));
}
-static uint string_full_width (const char * string, uint tab_width) {
+static uint string_full_width (char * string, uint tab_width) {
uint width = 0;
uint count = 0;
return (width - 1);
}
-static uint string_full_height (const char * string) {
+static uint string_full_height (char * string) {
uint height = 0;
do {
return (height + 1);
}
-static uint string_limit_to_number (const char * string, uint limit) {
+static uint string_limit_to_number (char * string, uint limit) {
uint number = 0;
for (uint index = 0; (string [index] != '\0') && (index < limit); ++index) {
return (number);
}
-static uint string_to_number (const char * string) {
+static uint string_to_number (char * string) {
return (string_limit_to_number (string, string_length (string)));
}
return (string);
}
-static char * format (const char * base, ...) {
+static char * format (char * base, ...) {
static char string [1024];
va_list list;
return (string);
}
-static void print (const char * format, ...) {
+static void print (char * format, ...) {
va_list list;
va_start (list, format);
char * string = number_to_string (va_arg (list, int));
output (string, string_length (string));
} break;
+ case ('f'): {
+ float number = (float) va_arg (list, double);
+ char * upper = number_to_string ((int) number);
+ char * lower = number_to_string ((int) (number * 1000.0f) % 1000);
+ output (upper, string_length (upper));
+ output (".", 1);
+ output (lower, string_length (lower));
+ } break;
case ('t'): {
int toggle = (va_arg (list, int));
echo_colour ((toggle == true) ? colour_green : colour_red, effect_normal);
#define pi (3.14159265f)
-static float sign (float x) { return ((x > 0.0f) ? +1.0f : -1.0f); }
+static float sign (float x) { return ((x > 0.0f) ? + 1.0f : - 1.0f); }
+static float binary_sign (uint x) { return ((x > 0) ? + 1.0f : - 1.0f); }
static float square_root (float x) { return (sqrtf (x)); }
static float cube_root (float x) { return (cbrtf (x)); }
} ui_structure;
static ui_structure * ui_initialize (cross_structure * cross) {
- const char * subtype_file_name [ui_subcount] = {
+ char * subtype_file_name [ui_subcount] = {
"window_left", "window_right", "window_upper", "window_lower",
"window_upper_left", "window_upper_right", "window_lower_left", "window_lower_right",
"frame_left", "frame_right", "frame_upper", "frame_lower",
ui->monofont = cross_font_import (cross, configuration_format ("xui/monospace"), ' ', '~', 0xffeeee00u);
for (uint index = 0; index < ui_subcount; ++index) {
- const char * file_name = configuration_format (format ("xui/%s", subtype_file_name [index]));
+ char * file_name = configuration_format (format ("xui/%s", subtype_file_name [index]));
ui->sprite [index] = cross_sprite_import (cross, file_name);
return (deallocate (ui));
}
-static int ui_offset_x (const cross_structure * cross, const ui_structure * ui) {
+static int ui_offset_x (cross_structure * cross, ui_structure * ui) {
return (ui->camera_x - cross->window_width / 2);
}
-static int ui_offset_y (const cross_structure * cross, const ui_structure * ui) {
+static int ui_offset_y (cross_structure * cross, ui_structure * ui) {
return (ui->camera_y - cross->window_height / 2);
}
-static uint ui_side_panel (const ui_structure * ui) {
+static uint ui_side_panel (ui_structure * ui) {
return (ui->side_panel); /// MAKE IT WINDOW SIZE DEPENDENT?
}
static void ui_camera_left (ui_structure * ui) { ui->freeview = true; ui->camera_x -= ui->camera_speed; }
static void ui_camera_right (ui_structure * ui) { ui->freeview = true; ui->camera_x += ui->camera_speed; }
-static void ui_render (cross_structure * cross, const ui_structure * ui, ui_subtype index, int x, int y) {
+static void ui_render (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y) {
cross_render_sprite (cross, ui->sprite [index], x, y);
}
-static void ui_render_colour (cross_structure * cross, const ui_structure * ui, ui_subtype index, uint colour, int x, int y) {
+static void ui_render_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, uint colour, int x, int y) {
cross_render_sprite_colour (cross, ui->sprite [index], colour, x, y);
}
-static void ui_subrender (cross_structure * cross, const ui_structure * ui, ui_subtype index, int x, int y, uint u, uint v, uint width, uint height) {
+static void ui_subrender (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint u, uint v, uint width, uint height) {
cross_render_sprite_crop (cross, ui->sprite [index], x, y, u, v, width, height);
}
-static void ui_subrender_colour (cross_structure * cross, const ui_structure * ui, ui_subtype index, uint colour, int x, int y, uint u, uint v, uint width, uint height) {
+static void ui_subrender_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, uint colour, int x, int y, uint u, uint v, uint width, uint height) {
cross_render_sprite_crop_colour (cross, ui->sprite [index], colour, x, y, u, v, width, height);
}
-static void ui_render_horizontal (cross_structure * cross, const ui_structure * ui, ui_subtype index, int x, int y, uint width) {
- const int entire = (width / ui->width [index]) * ui->width [index];
+static void ui_render_horizontal (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint width) {
+ int entire = (width / ui->width [index]) * ui->width [index];
for (uint margin = 0; margin < width / ui->width [index]; ++margin) {
ui_render (cross, ui, index, x + margin * ui->width [index], y);
}
}
-static void ui_render_horizontal_colour (cross_structure * cross, const ui_structure * ui, ui_subtype index, uint colour, int x, int y, uint width) {
- const int entire = (width / ui->width [index]) * ui->width [index];
+static void ui_render_horizontal_colour (cross_structure * cross, ui_structure * ui, ui_subtype index, uint colour, int x, int y, uint width) {
+ int entire = (width / ui->width [index]) * ui->width [index];
for (uint margin = 0; margin < width / ui->width [index]; ++margin) {
ui_render_colour (cross, ui, index, colour, x + margin * ui->width [index], y);
}
}
-static void ui_render_vertical (cross_structure * cross, const ui_structure * ui, ui_subtype index, int x, int y, uint height) {
- const int entire = (height / ui->height [index]) * ui->height [index];
+static void ui_render_vertical (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint height) {
+ int entire = (height / ui->height [index]) * ui->height [index];
for (uint margin = 0; margin < height / ui->height [index]; ++margin) {
ui_render (cross, ui, index, x, y + margin * ui->height [index]);
}
}
-static void ui_render_background (cross_structure * cross, const ui_structure * ui, ui_subtype index, int x, int y, uint width, uint height) {
- const uint offset_x = (width / ui->width [index]) * ui->width [index];
- const uint offset_y = (height / ui->height [index]) * ui->height [index];
+static void ui_render_background (cross_structure * cross, ui_structure * ui, ui_subtype index, int x, int y, uint width, uint height) {
+ uint offset_x = (width / ui->width [index]) * ui->width [index];
+ uint offset_y = (height / ui->height [index]) * ui->height [index];
- const uint cutoff_x = width % ui->width [index];
- const uint cutoff_y = height % ui->height [index];
+ uint cutoff_x = width % ui->width [index];
+ uint cutoff_y = height % ui->height [index];
for (uint vertical = 0; vertical < height / ui->height [index]; ++vertical) {
for (uint horizontal = 0; horizontal < width / ui->width [index]; ++horizontal) {
cross_render_rectangle_vertical_gradient (cross, 0, cross->window_height / 2, cross->window_width, cross->window_height / 2, 0x00, 0xcc);
}
-static void ui_render_grid (cross_structure * cross, const ui_structure * ui, ui_type element, int x, int y, uint width, uint height, uint margin, bool background) {
- const uint upper_length = width - ui->width [element + 4] - ui->width [element + 5];
- const uint lower_length = width - ui->width [element + 6] - ui->width [element + 7];
- const uint left_length = height - ui->height [element + 4] - ui->height [element + 6];
- const uint right_length = height - ui->height [element + 5] - ui->height [element + 7];
+static void ui_render_grid (cross_structure * cross, ui_structure * ui, ui_type element, int x, int y, uint width, uint height, uint margin, bool background) {
+ uint upper_length = width - ui->width [element + 4] - ui->width [element + 5];
+ uint lower_length = width - ui->width [element + 6] - ui->width [element + 7];
+ uint left_length = height - ui->height [element + 4] - ui->height [element + 6];
+ uint right_length = height - ui->height [element + 5] - ui->height [element + 7];
- const int upper_offset_x = ui->width [element + 4];
- const int lower_offset_x = ui->width [element + 6];
- const int lower_offset_y = height - ui->height [element + 3];
+ int upper_offset_x = ui->width [element + 4];
+ int lower_offset_x = ui->width [element + 6];
+ int lower_offset_y = height - ui->height [element + 3];
- const int right_offset_x = width - ui->width [element + 1];
- const int left_offset_y = ui->height [element + 4];
- const int right_offset_y = ui->height [element + 5];
+ int right_offset_x = width - ui->width [element + 1];
+ int left_offset_y = ui->height [element + 4];
+ int right_offset_y = ui->height [element + 5];
- const int upper_right_offset_x = width - ui->width [element + 5];
- const int lower_right_offset_x = width - ui->width [element + 7];
- const int lower_left_offset_y = height - ui->height [element + 6];
- const int lower_right_offset_y = height - ui->height [element + 7];
+ int upper_right_offset_x = width - ui->width [element + 5];
+ int lower_right_offset_x = width - ui->width [element + 7];
+ int lower_left_offset_y = height - ui->height [element + 6];
+ int lower_right_offset_y = height - ui->height [element + 7];
if ((background == true) && (width > 2 * margin) && (height > 2 * margin)) {
ui_render_background (cross, ui, element + 8, x + margin, y + margin, width - 2 * margin, height - 2 * margin);
ui_render (cross, ui, element + 7, x + lower_right_offset_x, y + lower_right_offset_y);
}
-static void ui_render_window (cross_structure * cross, const ui_structure * ui, int x, int y, uint width, uint height) {
+static void ui_render_window (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) {
ui_render_grid (cross, ui, ui_window, x, y, width, height, 0, false);
}
-static void ui_render_frame (cross_structure * cross, const ui_structure * ui, int x, int y, uint width, uint height) {
+static void ui_render_frame (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) {
ui_render_grid (cross, ui, ui_frame, x, y, width, height, 0, false);
}
-static void ui_render_status (cross_structure * cross, const ui_structure * ui, int x, int y, uint width, uint height) {
+static void ui_render_status (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) {
ui_render_grid (cross, ui, ui_status, x, y, width, height, 16, true);
}
-static void ui_render_menu (cross_structure * cross, const ui_structure * ui, int x, int y, uint width, uint height) {
+static void ui_render_menu (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) {
ui_render_grid (cross, ui, ui_menu, x, y, width, height, 24, true);
}
-static void ui_render_button (cross_structure * cross, const ui_structure * ui, int x, int y, uint width, uint height) {
+static void ui_render_button (cross_structure * cross, ui_structure * ui, int x, int y, uint width, uint height) {
ui_render_grid (cross, ui, ui_button, x, y, width, height, 16, true);
}
-static void ui_render_separator (cross_structure * cross, const ui_structure * ui, int x, int y, uint width) {
- const uint margin = ui->width [ui_separator_left];
- const uint length = width - margin - ui->width [ui_separator_right];
+static void ui_render_separator (cross_structure * cross, ui_structure * ui, int x, int y, uint width) {
+ uint margin = ui->width [ui_separator_left];
+ uint length = width - margin - ui->width [ui_separator_right];
ui_render (cross, ui, ui_separator_left, x, y);
ui_render (cross, ui, ui_separator_center, x + (width - ui->width [ui_separator_center]) / 2, y);
}
-static void ui_render_title_bar (cross_structure * cross, const ui_structure * ui, const char * title, int x, int y, uint width) {
- const uint margin = ui->width [ui_title_bar_left];
- const uint length = width - margin - ui->width [ui_title_bar_right];
+static void ui_render_title_bar (cross_structure * cross, ui_structure * ui, char * title, int x, int y, uint width) {
+ uint margin = ui->width [ui_title_bar_left];
+ uint length = width - margin - ui->width [ui_title_bar_right];
ui_render (cross, ui, ui_title_bar_left, x, y);
cross_render_string (cross, title, ui->font, x + margin + 8, y + 8, 1, 0x112233ff);
}
-static void ui_render_icon_and_text (cross_structure * cross, const ui_structure * ui, const char * title, uint icon, int x, int y) {
+static void ui_render_icon_and_text (cross_structure * cross, ui_structure * ui, char * title, uint icon, int x, int y) {
cross_render_sprite (cross, icon, x, y);
cross_render_string (cross, title, ui->font, x - 2 + ui->icon_size, y + 2, 1, 0x112233ffu);
}
-static void ui_render_scroll_bar (cross_structure * cross, const ui_structure * ui, float slider, int x, int y, uint height) {
- const uint margin = ui->height [ui_scroll_bar_upper];
- const uint length = height - margin - ui->height [ui_scroll_bar_lower];
+static void ui_render_scroll_bar (cross_structure * cross, ui_structure * ui, float slider, int x, int y, uint height) {
+ uint margin = ui->height [ui_scroll_bar_upper];
+ uint length = height - margin - ui->height [ui_scroll_bar_lower];
ui_render (cross, ui, ui_scroll_bar_upper, x, y);
ui_render (cross, ui, ui_scroll_bar_slider, x, y + margin + (uint) (slider * (float) (length - ui->height [ui_scroll_bar_slider])));
}
-static void ui_render_fill_bar (cross_structure * cross, const ui_structure * ui, float fill, uint colour, int x, int y, uint width) {
- const uint margin = ui->width [ui_fill_bar_left];
- const uint length = width - margin - ui->width [ui_fill_bar_right];
+static void ui_render_fill_bar (cross_structure * cross, ui_structure * ui, float fill, uint colour, int x, int y, uint width) {
+ uint margin = ui->width [ui_fill_bar_left];
+ uint length = width - margin - ui->width [ui_fill_bar_right];
ui_render (cross, ui, ui_fill_bar_left, x, y);
ui_render_horizontal_colour (cross, ui, ui_fill_bar_base, colour, x + margin, y, (uint) (fill * (float) length));
}
-static void ui_render_icon (cross_structure * cross, const ui_structure * ui, uint icon, int x, int y) {
+static void ui_render_icon (cross_structure * cross, ui_structure * ui, uint icon, int x, int y) {
cross_render_sprite (cross, ui->sprite [ui_icon_frame], x, y);
if (icon != ui->ignore) {
}
}
-static void ui_render_overicon (cross_structure * cross, const ui_structure * ui, uint icon, int x, int y) {
+static void ui_render_overicon (cross_structure * cross, ui_structure * ui, uint icon, int x, int y) {
if (icon != ui->ignore) {
cross_render_sprite (cross, icon, x, y);
}
cross_render_sprite (cross, ui->sprite [ui_overicon_frame], x, y);
}
-static void ui_render_ubericon (cross_structure * cross, const ui_structure * ui, uint icon, int x, int y) {
+static void ui_render_ubericon (cross_structure * cross, ui_structure * ui, uint icon, int x, int y) {
cross_render_sprite (cross, ui->sprite [ui_ubericon_frame], x, y);
if (icon != ui->ignore) {
}
}
-static void ui_render_menu_full (cross_structure * cross, const ui_structure * ui, const char * title, int x, int y, uint width, uint height) {
- const uint margin = 24;
+static void ui_render_menu_full (cross_structure * cross, ui_structure * ui, char * title, int x, int y, uint width, uint height) {
+ uint margin = 24;
ui_screen_overlay (cross);
uint layout_height;
} vulkan_structure;
-static const char * vulkan_continue_execution [] = {
+static char * vulkan_continue_execution [] = {
"/s Commands successfully completed.\n",
"/w Fence or query hasn't yet completed.\n",
"/w Wait operation hasn't completed in the specified time.\n",
"/w Return array was too small for the result.\n"
};
-static const char * vulkan_break_execution [] = {
+static char * vulkan_break_execution [] = {
"/f Host memory allocation has failed.\n",
"/f Device memory allocation has failed.\n",
"/f Initialization of an object couldn't be completed.\n",
vulkan->transfer_buffer = VK_NULL_HANDLE;
}
-static void vulkan_create_window (vulkan_structure * vulkan, const char * application) {
+static void vulkan_create_window (vulkan_structure * vulkan, char * application) {
uint window_flags [2] = { 0 };
vulkan->time = tick_tock ();
print ("/c Time approximation: /6%i/-\n", tick_tock () - vulkan->time);
}
-static void vulkan_create_instance (vulkan_structure * vulkan, const char * application) {
+static void vulkan_create_instance (vulkan_structure * vulkan, char * application) {
uint current = 0;
uint general = 0;
uint * instance_extension_index = null;
VkExtensionProperties * instance_extension_array = null;
- const uint default_instance_layer_count = (uint) (vulkan->validation_layers == true);
- const uint default_instance_extension_count = 2;
+ uint default_instance_layer_count = (uint) (vulkan->validation_layers == true);
+ uint default_instance_extension_count = 2;
- const char * default_instance_layer_array [VK_MAX_EXTENSION_NAME_SIZE] = {
+ char * default_instance_layer_array [VK_MAX_EXTENSION_NAME_SIZE] = {
"VK_LAYER_KHRONOS_validation"
//~"VK_LAYER_LUNARG_parameter_validation",
//~"VK_LAYER_LUNARG_core_validation",
//~"VK_LAYER_LUNARG_standard_validation"
};
- const char * default_instance_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = {
+ char * default_instance_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = {
VK_KHR_SURFACE_EXTENSION_NAME,
VK_KHR_XCB_SURFACE_EXTENSION_NAME
};
VkPhysicalDevice * physical_device_array = null;
VkBool32 * support = null;
- const float queue_priorities [1] = { 1 };
+ float queue_priorities [1] = { 1 };
- const uint default_device_extension_count = 1;
+ uint default_device_extension_count = 1;
- const char * default_device_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = {
+ char * default_device_extension_array [VK_MAX_EXTENSION_NAME_SIZE] = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME
};
}
static void vulkan_create_vertex_shader (vulkan_structure * vulkan) {
- const uint vertex_shader_code [] = {
+ uint vertex_shader_code [] = {
0x07230203, 0x00010000, 0x000d000b, 0x00000028, 0x00000000, 0x00020011, 0x00000001, 0x0006000b,
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001,
0x000b000f, 0x00000000, 0x00000004, 0x6e69616d, 0x00000000, 0x0000000d, 0x00000012, 0x00000021,
}
static void vulkan_create_fragment_shader (vulkan_structure * vulkan) {
- const uint fragment_shader_code [] = {
+ uint fragment_shader_code [] = {
0x07230203, 0x00010000, 0x000d000b, 0x00000018, 0x00000000, 0x00020011, 0x00000001, 0x0006000b,
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000001,
0x0008000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000009, 0x00000011, 0x00000015,
order = deallocate (order);
}
-static void vulkan_configure (vulkan_structure * vulkan, int width, int height, const char * application) {
+static void vulkan_configure (vulkan_structure * vulkan, int width, int height, char * application) {
int index = 0;
uint * dumb_buffer = null;
vulkan_render_core (vulkan, vulkan->sprite_count - 1, x, y, 0, 0, 16, 16, (float) width / 16, (float) height / 16, 0, 0, colour_left, colour_right, colour_left, colour_right);
}
-static int vulkan_string_width (vulkan_structure * vulkan, const char * string, int font, float scale) {
+static int vulkan_string_width (vulkan_structure * vulkan, char * string, int font, float scale) {
int length = 0;
for (uint index = 0; string [index] != '\0'; ++index) {
return (length);
}
-static void vulkan_render_string (vulkan_structure * vulkan, const char * string, int font, int x, int y, uint colour) {
+static void vulkan_render_string (vulkan_structure * vulkan, char * string, int font, int x, int y, uint colour) {
int offset = x;
for (uint index = 0; string [index] != '\0'; ++index) {
}
}
-static void vulkan_render_string_scale (vulkan_structure * vulkan, const char * string, int font, int x, int y, float scale, uint colour) {
+static void vulkan_render_string_scale (vulkan_structure * vulkan, char * string, int font, int x, int y, float scale, uint colour) {
int offset = x;
for (uint index = 0; string [index] != '\0'; ++index) {
}
}
-static void vulkan_render_string_offset (vulkan_structure * vulkan, const char * string, uint length, uint font, uint offset, int * x, int * y, uint colour) {
+static void vulkan_render_string_offset (vulkan_structure * vulkan, char * string, uint length, uint font, uint offset, int * x, int * y, uint colour) {
for (uint index = 0; (string [index] != '\0') && (index < length); ++index) {
uint character = vulkan->font_index [font] [string [index] - vulkan->font_begin [font]];
}
}
-static void vulkan_render_string_gradient_v (vulkan_structure * vulkan, const char * string, int font, int x, int y, float scale, uint colour_up, uint colour_down) {
+static void vulkan_render_string_gradient_v (vulkan_structure * vulkan, char * string, int font, int x, int y, float scale, uint colour_up, uint colour_down) {
int offset = x;
for (uint index = 0; string [index] != '\0'; ++index) {
}
}
-static void vulkan_render_string_gradient_h (vulkan_structure * vulkan, const char * string, int font, int x, int y, float scale, uint colour_left, uint colour_right) {
+static void vulkan_render_string_gradient_h (vulkan_structure * vulkan, char * string, int font, int x, int y, float scale, uint colour_left, uint colour_right) {
int offset = x;
for (uint index = 0; string [index] != '\0'; ++index) {
}
static void vulkan_handle_events (vulkan_structure * vulkan) {
- static const int signal_code [signal_count] = {
+ static int signal_code [signal_count] = {
0,
38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33,
24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14,
xcb_flush (vulkan->connection);
} break;
/*case (XCB_CONFIGURE_NOTIFY): {
- const xcb_configure_notify_event_t * reconfigure = (const xcb_configure_notify_event_t *) generic_event;
+ xcb_configure_notify_event_t * reconfigure = (xcb_configure_notify_event_t *) generic_event;
if ((reconfigure->width != vulkan->width) || (reconfigure->height != vulkan->height)) {
vulkan->width = reconfigure->width;
vulkan->height = reconfigure->height;
void * ubo_void = null;
- const VkPipelineStageFlags wait_stages [1] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT} ;
+ VkPipelineStageFlags wait_stages [1] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT} ;
VkSubmitInfo submit_information = { 0 };
VkPresentInfoKHR present_information = { 0 };
dungeon_item_definition * item_array;
} * dungeon_structure;
-static uint dungeon_biome_define (dungeon_structure dungeon, const char * name, uint temperature, uint humidity) {
+static uint dungeon_biome_define (dungeon_structure dungeon, char * name, uint temperature, uint humidity) {
dungeon_biome_definition biome = arena_add (sizeof (* biome));
fatal_failure (dungeon == null, "biome_define: Dungeon is not configured.");
static uint dungeon_biome_temperature (dungeon_structure dungeon, uint index) { return (dungeon->biome_array [index]->temperature); }
static uint dungeon_biome_humidity (dungeon_structure dungeon, uint index) { return (dungeon->biome_array [index]->humidity); }
-static uint dungeon_landmark_define (dungeon_structure dungeon, const char * name, uint biome, bool clip) {
+static uint dungeon_landmark_define (dungeon_structure dungeon, char * name, uint biome, bool clip) {
dungeon_landmark_definition landmark = arena_add (sizeof (* landmark));
fatal_failure (dungeon == null, "landmark_define: Dungeon is not configured.");
static uint dungeon_landmark_biome (dungeon_structure dungeon, uint index) { return (dungeon->landmark_array [index]->biome); }
static bool dungeon_landmark_clip (dungeon_structure dungeon, uint index) { return (dungeon->landmark_array [index]->clip); }
-static uint dungeon_expertise_define (dungeon_structure dungeon, const char * name) {
+static uint dungeon_expertise_define (dungeon_structure dungeon, char * name) {
dungeon_expertise_definition expertise = arena_add (sizeof (* expertise));
fatal_failure (dungeon == null, "expertise_define: Dungeon is not configured.");
static char * dungeon_expertise_name (dungeon_structure dungeon, uint index) { return (dungeon->expertise_array [index]->name); }
-static uint dungeon_attribute_define (dungeon_structure dungeon, const char * name, uint base, uint limit) {
+static uint dungeon_attribute_define (dungeon_structure dungeon, char * name, uint base, uint limit) {
dungeon_attribute_definition attribute = arena_add (sizeof (* attribute));
fatal_failure (dungeon == null, "attribute_define: Dungeon is not configured.");
static uint dungeon_attribute_base (dungeon_structure dungeon, uint index) { return (dungeon->attribute_array [index]->base); }
static uint dungeon_attribute_limit (dungeon_structure dungeon, uint index) { return (dungeon->attribute_array [index]->limit); }
-static uint dungeon_skill_define (dungeon_structure dungeon, const char * name, uint base, uint limit) {
+static uint dungeon_skill_define (dungeon_structure dungeon, char * name, uint base, uint limit) {
dungeon_skill_definition skill = arena_add (sizeof (* skill));
fatal_failure (dungeon == null, "skill_define: Dungeon is not configured.");
static uint dungeon_skill_base (dungeon_structure dungeon, uint index) { return (dungeon->skill_array [index]->base); }
static uint dungeon_skill_limit (dungeon_structure dungeon, uint index) { return (dungeon->skill_array [index]->limit); }
-static uint dungeon_resource_define (dungeon_structure dungeon, const char * name, uint base, uint limit, uint value, uint trade) {
+static uint dungeon_resource_define (dungeon_structure dungeon, char * name, uint base, uint limit, uint value, uint trade) {
dungeon_resource_definition resource = arena_add (sizeof (* resource));
fatal_failure (dungeon == null, "resource_define: Dungeon is not configured.");
static uint dungeon_resource_value (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->value); }
static uint dungeon_resource_trade (dungeon_structure dungeon, uint index) { return (dungeon->resource_array [index]->trade); }
-static uint dungeon_item_slot_define (dungeon_structure dungeon, const char * name) {
+static uint dungeon_item_slot_define (dungeon_structure dungeon, char * name) {
dungeon_item_slot_definition item_slot = arena_add (sizeof (* item_slot));
fatal_failure (dungeon == null, "item_slot_define: Dungeon is not configured.");
static char * dungeon_item_slot_name (dungeon_structure dungeon, uint index) { return (dungeon->item_slot_array [index]->name); }
-static uint dungeon_item_define (dungeon_structure dungeon, const char * name, uint slot, uint effect) {
+static uint dungeon_item_define (dungeon_structure dungeon, char * name, uint slot, uint effect) {
dungeon_item_definition item = arena_add (sizeof (* item));
fatal_failure (dungeon == null, "item_define: Dungeon is not configured.");
static uint y = 0;
static void render_character (char character) {
- const ulong font_code [font_count] = {
+ ulong font_code [font_count] = {
0x0000000000000000, 0x00180018183c3c18, 0x0000000000363636, 0x006c6cfe6cfe6c6c,
0x00187ed07c16fc30, 0x0060660c18306606, 0x00dc66b61c36361c, 0x0000000000181818,
0x0030180c0c0c1830, 0x000c18303030180c, 0x0000187e3c7e1800, 0x000018187e181800,
x += font_width + 1;
}
-static void render_string (const char * string, uint length) {
+static void render_string (char * string, uint length) {
for (uint offset = 0; offset < length; ++offset) {
if (string [offset] == '\t') {
x += font_width * font_indent;
uint length = 0;
char * buffer = null;
- const char separator [] = ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n";
+ char separator [] = ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n";
- const char * keywords [] = {
+ char * keywords [] = {
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
"do", "while", "for", "continue", "switch", "case", "default", "break",
"enum", "union", "struct", "typedef", "goto", "void", "return", "sizeof",
return (deallocate (syntax));
}
-static uint syntax_define (syntax_structure * syntax, bool enrange, bool derange, const char * begin, const char * end, char escape,
+static uint syntax_define (syntax_structure * syntax, bool enrange, bool derange, char * begin, char * end, char escape,
uint colour, uint effect) {
++syntax->count;
return (current);
}
-static uint syntax_select (syntax_structure * syntax, const char * string, uint * length) {
+static uint syntax_select (syntax_structure * syntax, char * string, uint * length) {
uint offset = 0;
uint subset = 0;
uint select = 0;