diff --git a/lib/c3/0.1/array.facts b/lib/c3/0.1/array.facts
index 4bcb97c..df6c79d 100644
--- a/lib/c3/0.1/array.facts
+++ b/lib/c3/0.1/array.facts
@@ -2,4 +2,4 @@
version: 1}
add {Array, :is_a, :module}
add {Array, :symbol, Array.data}
-replace {Array.data, :cfn, cfn :tag "array_data_tag" (:tag, :tag, :&result)}
+replace {Array.data, :cfn, cfn Tag "array_data_tag" (Tag, Tag, Result)}
diff --git a/libc3/sym.c b/libc3/sym.c
index 032c527..40d82e1 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -211,8 +211,8 @@ const s_sym * sym_new (const s_str *src)
bool sym_to_buf_inspect (const s_sym *type, f_buf_inspect *dest)
{
- if (type == sym_1("Void")) {
- *dest = (f_buf_inspect) buf_inspect_var;
+ if (type == sym_1("Array")) {
+ *dest = (f_buf_inspect) buf_inspect_array;
return true;
}
if (type == sym_1("Bool")) {
@@ -255,82 +255,90 @@ bool sym_to_buf_inspect (const s_sym *type, f_buf_inspect *dest)
*dest = (f_buf_inspect) buf_inspect_integer;
return true;
}
- if (type == sym_1("Sw")) {
- *dest = (f_buf_inspect) buf_inspect_sw;
+ if (type == sym_1("List")) {
+ *dest = (f_buf_inspect) buf_inspect_list;
return true;
}
- if (type == sym_1("S64")) {
- *dest = (f_buf_inspect) buf_inspect_s64;
+ if (type == sym_1("Ptag")) {
+ *dest = (f_buf_inspect) buf_inspect_ptag;
return true;
}
- if (type == sym_1("S32")) {
- *dest = (f_buf_inspect) buf_inspect_s32;
+ if (type == sym_1("Ptr")) {
+ *dest = (f_buf_inspect) buf_inspect_ptr;
return true;
}
- if (type == sym_1("S16")) {
- *dest = (f_buf_inspect) buf_inspect_s16;
+ if (type == sym_1("PtrFree")) {
+ *dest = (f_buf_inspect) buf_inspect_ptr_free;
+ return true;
+ }
+ if (type == sym_1("Quote")) {
+ *dest = (f_buf_inspect) buf_inspect_quote;
return true;
}
if (type == sym_1("S8")) {
*dest = (f_buf_inspect) buf_inspect_s8;
return true;
}
- if (type == sym_1("U8")) {
- *dest = (f_buf_inspect) buf_inspect_u8;
+ if (type == sym_1("S16")) {
+ *dest = (f_buf_inspect) buf_inspect_s16;
return true;
}
- if (type == sym_1("U16")) {
- *dest = (f_buf_inspect) buf_inspect_u16;
+ if (type == sym_1("S32")) {
+ *dest = (f_buf_inspect) buf_inspect_s32;
return true;
}
- if (type == sym_1("U32")) {
- *dest = (f_buf_inspect) buf_inspect_u32;
+ if (type == sym_1("S64")) {
+ *dest = (f_buf_inspect) buf_inspect_s64;
return true;
}
- if (type == sym_1("U64")) {
- *dest = (f_buf_inspect) buf_inspect_u64;
+ if (type == sym_1("Str")) {
+ *dest = (f_buf_inspect) buf_inspect_str;
return true;
}
- if (type == sym_1("Uw")) {
- *dest = (f_buf_inspect) buf_inspect_uw;
+ if (type == sym_1("Struct")) {
+ *dest = (f_buf_inspect) buf_inspect_struct;
return true;
}
- if (type == sym_1("List")) {
- *dest = (f_buf_inspect) buf_inspect_list;
+ if (type == sym_1("Sw")) {
+ *dest = (f_buf_inspect) buf_inspect_sw;
return true;
}
- if (type == sym_1("Ptag")) {
- *dest = (f_buf_inspect) buf_inspect_ptag;
+ if (type == sym_1("Sym")) {
+ *dest = (f_buf_inspect) buf_inspect_sym;
return true;
}
- if (type == sym_1("Ptr")) {
- *dest = (f_buf_inspect) buf_inspect_ptr;
+ if (type == sym_1("Tuple")) {
+ *dest = (f_buf_inspect) buf_inspect_tuple;
return true;
}
- if (type == sym_1("PtrFree")) {
- *dest = (f_buf_inspect) buf_inspect_ptr_free;
+ if (type == sym_1("U8")) {
+ *dest = (f_buf_inspect) buf_inspect_u8;
return true;
}
- if (type == sym_1("Quote")) {
- *dest = (f_buf_inspect) buf_inspect_quote;
+ if (type == sym_1("U16")) {
+ *dest = (f_buf_inspect) buf_inspect_u16;
return true;
}
- if (type == sym_1("Str")) {
- *dest = (f_buf_inspect) buf_inspect_str;
+ if (type == sym_1("U32")) {
+ *dest = (f_buf_inspect) buf_inspect_u32;
return true;
}
- if (type == sym_1("Sym")) {
- *dest = (f_buf_inspect) buf_inspect_sym;
+ if (type == sym_1("U64")) {
+ *dest = (f_buf_inspect) buf_inspect_u64;
return true;
}
- if (type == sym_1("Tuple")) {
- *dest = (f_buf_inspect) buf_inspect_tuple;
+ if (type == sym_1("Uw")) {
+ *dest = (f_buf_inspect) buf_inspect_uw;
return true;
}
if (type == sym_1("Var")) {
*dest = (f_buf_inspect) buf_inspect_var;
return true;
}
+ if (type == sym_1("Void")) {
+ *dest = (f_buf_inspect) buf_inspect_var;
+ return true;
+ }
if (struct_type_exists(type)) {
*dest = (f_buf_inspect) buf_inspect_struct;
return true;
@@ -344,6 +352,10 @@ bool sym_to_buf_inspect (const s_sym *type, f_buf_inspect *dest)
bool sym_to_buf_inspect_size (const s_sym *type, f_buf_inspect_size *dest)
{
+ if (type == sym_1("Array")) {
+ *dest = (f_buf_inspect_size) buf_inspect_array_size;
+ return true;
+ }
if (type == sym_1("Bool")) {
*dest = (f_buf_inspect_size) buf_inspect_bool_size;
return true;
@@ -384,76 +396,80 @@ bool sym_to_buf_inspect_size (const s_sym *type, f_buf_inspect_size *dest)
*dest = (f_buf_inspect_size) buf_inspect_integer_size;
return true;
}
- if (type == sym_1("Sw")) {
- *dest = (f_buf_inspect_size) buf_inspect_sw_size;
+ if (type == sym_1("List")) {
+ *dest = (f_buf_inspect_size) buf_inspect_list_size;
return true;
}
- if (type == sym_1("S64")) {
- *dest = (f_buf_inspect_size) buf_inspect_s64_size;
+ if (type == sym_1("Ptag")) {
+ *dest = (f_buf_inspect_size) buf_inspect_ptag_size;
return true;
}
- if (type == sym_1("S32")) {
- *dest = (f_buf_inspect_size) buf_inspect_s32_size;
+ if (type == sym_1("Ptr")) {
+ *dest = (f_buf_inspect_size) buf_inspect_ptr_size;
return true;
}
- if (type == sym_1("S16")) {
- *dest = (f_buf_inspect_size) buf_inspect_s16_size;
+ if (type == sym_1("PtrFree")) {
+ *dest = (f_buf_inspect_size) buf_inspect_ptr_free_size;
+ return true;
+ }
+ if (type == sym_1("Quote")) {
+ *dest = (f_buf_inspect_size) buf_inspect_quote_size;
return true;
}
if (type == sym_1("S8")) {
*dest = (f_buf_inspect_size) buf_inspect_s8_size;
return true;
}
- if (type == sym_1("U8")) {
- *dest = (f_buf_inspect_size) buf_inspect_u8_size;
+ if (type == sym_1("S16")) {
+ *dest = (f_buf_inspect_size) buf_inspect_s16_size;
return true;
}
- if (type == sym_1("U16")) {
- *dest = (f_buf_inspect_size) buf_inspect_u16_size;
+ if (type == sym_1("S32")) {
+ *dest = (f_buf_inspect_size) buf_inspect_s32_size;
return true;
}
- if (type == sym_1("U32")) {
- *dest = (f_buf_inspect_size) buf_inspect_u32_size;
+ if (type == sym_1("S64")) {
+ *dest = (f_buf_inspect_size) buf_inspect_s64_size;
return true;
}
- if (type == sym_1("U64")) {
- *dest = (f_buf_inspect_size) buf_inspect_u64_size;
+ if (type == sym_1("Str")) {
+ *dest = (f_buf_inspect_size) buf_inspect_str_size;
return true;
}
- if (type == sym_1("Uw")) {
- *dest = (f_buf_inspect_size) buf_inspect_uw_size;
+ if (type == sym_1("Struct")) {
+ *dest = (f_buf_inspect_size) buf_inspect_struct_size;
return true;
}
- if (type == sym_1("List")) {
- *dest = (f_buf_inspect_size) buf_inspect_list_size;
+ if (type == sym_1("Sw")) {
+ *dest = (f_buf_inspect_size) buf_inspect_sw_size;
return true;
}
- if (type == sym_1("Ptag")) {
- *dest = (f_buf_inspect_size) buf_inspect_ptag_size;
+ if (type == sym_1("Sym")) {
+ *dest = (f_buf_inspect_size) buf_inspect_sym_size;
return true;
}
- if (type == sym_1("Ptr")) {
- *dest = (f_buf_inspect_size) buf_inspect_ptr_size;
+ if (type == sym_1("Tuple")) {
+ *dest = (f_buf_inspect_size) buf_inspect_tuple_size;
return true;
}
- if (type == sym_1("PtrFree")) {
- *dest = (f_buf_inspect_size) buf_inspect_ptr_free_size;
+ if (type == sym_1("U8")) {
+ *dest = (f_buf_inspect_size) buf_inspect_u8_size;
return true;
}
- if (type == sym_1("Quote")) {
- *dest = (f_buf_inspect_size) buf_inspect_quote_size;
+ if (type == sym_1("U16")) {
+ *dest = (f_buf_inspect_size) buf_inspect_u16_size;
return true;
}
- if (type == sym_1("Str")) {
- *dest = (f_buf_inspect_size) buf_inspect_str_size;
+ if (type == sym_1("U32")) {
+ *dest = (f_buf_inspect_size) buf_inspect_u32_size;
return true;
}
- if (type == sym_1("Sym")) {
- *dest = (f_buf_inspect_size) buf_inspect_sym_size;
+ if (type == sym_1("U64")) {
+ *dest = (f_buf_inspect_size) buf_inspect_u64_size;
return true;
}
- if (type == sym_1("Tuple")) {
- *dest = (f_buf_inspect_size) buf_inspect_tuple_size;
+ if (type == sym_1("Uw")) {
+ *dest = (f_buf_inspect_size) buf_inspect_uw_size;
return true;
}
if (type == sym_1("Var")) {
@@ -477,6 +493,10 @@ bool sym_to_buf_inspect_size (const s_sym *type, f_buf_inspect_size *dest)
bool sym_to_clean (const s_sym *type, f_clean *dest)
{
+ if (type == sym_1("Array")) {
+ *dest = (f_clean) array_clean;
+ return true;
+ }
if (type == sym_1("Bool")) {
*dest = NULL;
return true;
@@ -517,80 +537,84 @@ bool sym_to_clean (const s_sym *type, f_clean *dest)
*dest = (f_clean) integer_clean;
return true;
}
- if (type == sym_1("Sw")) {
- *dest = NULL;
+ if (type == sym_1("List")) {
+ *dest = (f_clean) list_f_clean;
return true;
}
- if (type == sym_1("S64")) {
- *dest = NULL;
+ if (type == sym_1("Map")) {
+ *dest = (f_clean) map_clean;
return true;
}
- if (type == sym_1("S32")) {
+ if (type == sym_1("Ptag")) {
*dest = NULL;
return true;
}
- if (type == sym_1("S16")) {
+ if (type == sym_1("Ptr")) {
*dest = NULL;
return true;
}
- if (type == sym_1("S8")) {
- *dest = NULL;
+ if (type == sym_1("PtrFree")) {
+ *dest = (f_clean) ptr_free_clean;
return true;
}
- if (type == sym_1("U8")) {
- *dest = NULL;
+ if (type == sym_1("Quote")) {
+ *dest = (f_clean) quote_clean;
return true;
}
- if (type == sym_1("U16")) {
+ if (type == sym_1("S8")) {
*dest = NULL;
return true;
}
- if (type == sym_1("U32")) {
+ if (type == sym_1("S16")) {
*dest = NULL;
return true;
}
- if (type == sym_1("U64")) {
+ if (type == sym_1("S32")) {
*dest = NULL;
return true;
}
- if (type == sym_1("Uw")) {
+ if (type == sym_1("S64")) {
*dest = NULL;
return true;
}
- if (type == sym_1("List")) {
- *dest = (f_clean) list_f_clean;
+ if (type == sym_1("Str")) {
+ *dest = (f_clean) str_clean;
return true;
}
- if (type == sym_1("Map")) {
- *dest = (f_clean) map_clean;
+ if (type == sym_1("Struct")) {
+ *dest = (f_clean) struct_clean;
return true;
}
- if (type == sym_1("Ptag")) {
+ if (type == sym_1("Sw")) {
*dest = NULL;
return true;
}
- if (type == sym_1("Ptr")) {
+ if (type == sym_1("Sym")) {
*dest = NULL;
return true;
}
- if (type == sym_1("PtrFree")) {
- *dest = (f_clean) ptr_free_clean;
+ if (type == sym_1("Tuple")) {
+ *dest = (f_clean) tuple_clean;
return true;
}
- if (type == sym_1("Quote")) {
- *dest = (f_clean) quote_clean;
+ if (type == sym_1("U8")) {
+ *dest = NULL;
return true;
}
- if (type == sym_1("Str")) {
- *dest = (f_clean) str_clean;
+ if (type == sym_1("U16")) {
+ *dest = NULL;
return true;
}
- if (type == sym_1("Sym")) {
+ if (type == sym_1("U32")) {
*dest = NULL;
return true;
}
- if (type == sym_1("Tuple")) {
- *dest = (f_clean) tuple_clean;
+ if (type == sym_1("U64")) {
+ *dest = NULL;
+ return true;
+ }
+ if (type == sym_1("Uw")) {
+ *dest = NULL;
return true;
}
if (type == sym_1("Var")) {
@@ -624,6 +648,10 @@ bool sym_to_ffi_type (const s_sym *sym, ffi_type *result_type,
*dest = result_type;
return true;
}
+ if (sym == sym_1("Array")) {
+ *dest = &ffi_type_pointer;
+ return true;
+ }
if (sym == sym_1("Bool")) {
*dest = &ffi_type_uint8;
return true;
@@ -737,6 +765,10 @@ bool sym_to_ffi_type (const s_sym *sym, ffi_type *result_type,
bool sym_to_init_cast (const s_sym *type, f_init_cast *dest)
{
+ if (type == sym_1("Array")) {
+ *dest = (f_init_cast) array_init_cast;
+ return true;
+ }
if (type == sym_1("Bool")) {
*dest = (f_init_cast) bool_init_cast;
return true;
@@ -781,72 +813,76 @@ bool sym_to_init_cast (const s_sym *type, f_init_cast *dest)
*dest = (f_init_cast) list_init_cast;
return true;
}
- if (type == sym_1("Sw")) {
- *dest = (f_init_cast) sw_init_cast;
+ if (type == sym_1("Ptag")) {
+ *dest = (f_init_cast) ptag_init_cast;
return true;
}
- if (type == sym_1("S64")) {
- *dest = (f_init_cast) s64_init_cast;
+ if (type == sym_1("Ptr")) {
+ *dest = (f_init_cast) ptr_init_cast;
return true;
}
- if (type == sym_1("S32")) {
- *dest = (f_init_cast) s32_init_cast;
+ if (type == sym_1("PtrFree")) {
+ *dest = (f_init_cast) ptr_free_init_cast;
return true;
}
- if (type == sym_1("S16")) {
- *dest = (f_init_cast) s16_init_cast;
+ if (type == sym_1("Quote")) {
+ *dest = (f_init_cast) quote_init_cast;
return true;
}
if (type == sym_1("S8")) {
*dest = (f_init_cast) s8_init_cast;
return true;
}
- if (type == sym_1("U8")) {
- *dest = (f_init_cast) u8_init_cast;
+ if (type == sym_1("S16")) {
+ *dest = (f_init_cast) s16_init_cast;
return true;
}
- if (type == sym_1("U16")) {
- *dest = (f_init_cast) u16_init_cast;
+ if (type == sym_1("S32")) {
+ *dest = (f_init_cast) s32_init_cast;
return true;
}
- if (type == sym_1("U32")) {
- *dest = (f_init_cast) u32_init_cast;
+ if (type == sym_1("S64")) {
+ *dest = (f_init_cast) s64_init_cast;
return true;
}
- if (type == sym_1("U64")) {
- *dest = (f_init_cast) u64_init_cast;
+ if (type == sym_1("Str")) {
+ *dest = (f_init_cast) str_init_cast;
return true;
}
- if (type == sym_1("Uw")) {
- *dest = (f_init_cast) uw_init_cast;
+ if (type == sym_1("Struct")) {
+ *dest = (f_init_cast) struct_init_cast;
return true;
}
- if (type == sym_1("Ptag")) {
- *dest = (f_init_cast) ptag_init_cast;
+ if (type == sym_1("Sw")) {
+ *dest = (f_init_cast) sw_init_cast;
return true;
}
- if (type == sym_1("Ptr")) {
- *dest = (f_init_cast) ptr_init_cast;
+ if (type == sym_1("Sym")) {
+ *dest = (f_init_cast) sym_init_cast;
return true;
}
- if (type == sym_1("PtrFree")) {
- *dest = (f_init_cast) ptr_free_init_cast;
+ if (type == sym_1("Tuple")) {
+ *dest = (f_init_cast) tuple_init_cast;
return true;
}
- if (type == sym_1("Quote")) {
- *dest = (f_init_cast) quote_init_cast;
+ if (type == sym_1("U8")) {
+ *dest = (f_init_cast) u8_init_cast;
return true;
}
- if (type == sym_1("Str")) {
- *dest = (f_init_cast) str_init_cast;
+ if (type == sym_1("U16")) {
+ *dest = (f_init_cast) u16_init_cast;
return true;
}
- if (type == sym_1("Sym")) {
- *dest = (f_init_cast) sym_init_cast;
+ if (type == sym_1("U32")) {
+ *dest = (f_init_cast) u32_init_cast;
return true;
}
- if (type == sym_1("Tuple")) {
- *dest = (f_init_cast) tuple_init_cast;
+ if (type == sym_1("U64")) {
+ *dest = (f_init_cast) u64_init_cast;
+ return true;
+ }
+ if (type == sym_1("Uw")) {
+ *dest = (f_init_cast) uw_init_cast;
return true;
}
if (type == sym_1("Var")) {
@@ -870,6 +906,10 @@ bool sym_to_init_cast (const s_sym *type, f_init_cast *dest)
bool sym_to_init_copy (const s_sym *type, f_init_copy *dest)
{
+ if (type == sym_1("Array")) {
+ *dest = (f_init_copy) array_init_copy;
+ return true;
+ }
if (type == sym_1("Bool")) {
*dest = (f_init_copy) bool_init_copy;
return true;
@@ -914,72 +954,76 @@ bool sym_to_init_copy (const s_sym *type, f_init_copy *dest)
*dest = (f_init_copy) list_init_copy;
return true;
}
- if (type == sym_1("Sw")) {
- *dest = (f_init_copy) sw_init_copy;
+ if (type == sym_1("Ptag")) {
+ *dest = (f_init_copy) ptag_init_copy;
return true;
}
- if (type == sym_1("S64")) {
- *dest = (f_init_copy) s64_init_copy;
+ if (type == sym_1("Ptr")) {
+ *dest = (f_init_copy) ptr_init_copy;
return true;
}
- if (type == sym_1("S32")) {
- *dest = (f_init_copy) s32_init_copy;
+ if (type == sym_1("PtrFree")) {
+ *dest = (f_init_copy) ptr_free_init_copy;
return true;
}
- if (type == sym_1("S16")) {
- *dest = (f_init_copy) s16_init_copy;
+ if (type == sym_1("Quote")) {
+ *dest = (f_init_copy) quote_init_copy;
return true;
}
if (type == sym_1("S8")) {
*dest = (f_init_copy) s8_init_copy;
return true;
}
- if (type == sym_1("U8")) {
- *dest = (f_init_copy) u8_init_copy;
+ if (type == sym_1("S16")) {
+ *dest = (f_init_copy) s16_init_copy;
return true;
}
- if (type == sym_1("U16")) {
- *dest = (f_init_copy) u16_init_copy;
+ if (type == sym_1("S32")) {
+ *dest = (f_init_copy) s32_init_copy;
return true;
}
- if (type == sym_1("U32")) {
- *dest = (f_init_copy) u32_init_copy;
+ if (type == sym_1("S64")) {
+ *dest = (f_init_copy) s64_init_copy;
return true;
}
- if (type == sym_1("U64")) {
- *dest = (f_init_copy) u64_init_copy;
+ if (type == sym_1("Str")) {
+ *dest = (f_init_copy) str_init_copy;
return true;
}
- if (type == sym_1("Uw")) {
- *dest = (f_init_copy) uw_init_copy;
+ if (type == sym_1("Struct")) {
+ *dest = (f_init_copy) struct_init_copy;
return true;
}
- if (type == sym_1("Ptag")) {
- *dest = (f_init_copy) ptag_init_copy;
+ if (type == sym_1("Sw")) {
+ *dest = (f_init_copy) sw_init_copy;
return true;
}
- if (type == sym_1("Ptr")) {
- *dest = (f_init_copy) ptr_init_copy;
+ if (type == sym_1("Sym")) {
+ *dest = (f_init_copy) sym_init_copy;
return true;
}
- if (type == sym_1("PtrFree")) {
- *dest = (f_init_copy) ptr_free_init_copy;
+ if (type == sym_1("Tuple")) {
+ *dest = (f_init_copy) tuple_init_copy;
return true;
}
- if (type == sym_1("Quote")) {
- *dest = (f_init_copy) quote_init_copy;
+ if (type == sym_1("U8")) {
+ *dest = (f_init_copy) u8_init_copy;
return true;
}
- if (type == sym_1("Str")) {
- *dest = (f_init_copy) str_init_copy;
+ if (type == sym_1("U16")) {
+ *dest = (f_init_copy) u16_init_copy;
return true;
}
- if (type == sym_1("Sym")) {
- *dest = (f_init_copy) sym_init_copy;
+ if (type == sym_1("U32")) {
+ *dest = (f_init_copy) u32_init_copy;
return true;
}
- if (type == sym_1("Tuple")) {
- *dest = (f_init_copy) tuple_init_copy;
+ if (type == sym_1("U64")) {
+ *dest = (f_init_copy) u64_init_copy;
+ return true;
+ }
+ if (type == sym_1("Uw")) {
+ *dest = (f_init_copy) uw_init_copy;
return true;
}
if (type == sym_1("Var")) {
@@ -1003,8 +1047,8 @@ bool sym_to_init_copy (const s_sym *type, f_init_copy *dest)
bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest)
{
- if (sym == sym_1("Void")) {
- *dest = TAG_VOID;
+ if (sym == sym_1("Array")) {
+ *dest = TAG_ARRAY;
return true;
}
if (sym == sym_1("Bool")) {
@@ -1123,6 +1167,14 @@ bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest)
*dest = TAG_UW;
return true;
}
+ if (sym == sym_1("Var")) {
+ *dest = TAG_VAR;
+ return true;
+ }
+ if (sym == sym_1("Void")) {
+ *dest = TAG_VOID;
+ return true;
+ }
if (struct_type_exists(sym)) {
*dest = TAG_STRUCT;
return true;
@@ -1137,6 +1189,10 @@ bool sym_to_tag_type (const s_sym *sym, e_tag_type *dest)
bool sym_type_size (const s_sym *type, uw *dest)
{
s_struct_type st;
+ if (type == sym_1("Array")) {
+ *dest = sizeof(s_array);
+ return true;
+ }
if (type == sym_1("Bool")) {
*dest = sizeof(bool);
return true;
diff --git a/libc3/window/sdl2/gl_camera.c b/libc3/window/sdl2/gl_camera.c
index d886e28..0d040df 100644
--- a/libc3/window/sdl2/gl_camera.c
+++ b/libc3/window/sdl2/gl_camera.c
@@ -20,7 +20,7 @@ static const s8 * g_gl_camera_vertex_shader_src = "#version 460 core\n"
"uniform dmat4 matrix;\n"
"\n"
"void main() {\n"
-" gl_Position = matrix * dvec4(aPos, 1.0);\n"
+" gl_Position = vec4(matrix * dvec4(aPos, 1.0));\n"
"}\n";
void gl_camera_clean (s_gl_camera *camera)
@@ -37,6 +37,7 @@ void gl_camera_delete (s_gl_camera *camera)
s_gl_camera * gl_camera_init (s_gl_camera *camera, uw w, uw h)
{
+ GLint success;
u32 vertex_shader;
assert(camera);
gl_camera_set_aspect_ratio(camera, w, h);
@@ -53,6 +54,13 @@ s_gl_camera * gl_camera_init (s_gl_camera *camera, uw w, uw h)
glShaderSource(vertex_shader, 1, &g_gl_camera_vertex_shader_src,
NULL);
glCompileShader(vertex_shader);
+ glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &success);
+ if (! success) {
+ s8 info_log[512];
+ glGetShaderInfoLog(vertex_shader, sizeof(info_log), NULL, info_log);
+ err_write_1("gl_camera_init: shader compilation failed: ");
+ err_puts(info_log);
+ }
camera->gl_shader_program = glCreateProgram();
glAttachShader(camera->gl_shader_program, vertex_shader);
glLinkProgram(camera->gl_shader_program);
@@ -97,6 +105,13 @@ void gl_camera_render (s_gl_camera *camera)
&camera->matrix.xx);
}
+void gl_camera_render_end (s_gl_camera *camera)
+{
+ assert(camera);
+ (void) camera;
+ glUseProgram(0);
+}
+
s_gl_camera * gl_camera_set_aspect_ratio (s_gl_camera *camera, uw w,
uw h)
{
diff --git a/libc3/window/sdl2/sdl2_sprite.c b/libc3/window/sdl2/sdl2_sprite.c
index 8680bdb..863e349 100644
--- a/libc3/window/sdl2/sdl2_sprite.c
+++ b/libc3/window/sdl2/sdl2_sprite.c
@@ -237,7 +237,7 @@ s_sdl2_sprite * sdl2_sprite_init (s_sdl2_sprite *sprite,
sprite->dim_y = dim_y;
sprite->w = sprite->total_w / dim_x;
sprite->h = sprite->total_h / dim_y;
- sprite->texture = malloc(sprite->frame_count * sizeof(GLuint));
+ sprite->texture = calloc(sprite->frame_count, sizeof(GLuint));
if (! sprite->texture) {
err_puts("sdl2_sprite_init: sprite->texture:"
" failed to allocate memory");
@@ -282,15 +282,33 @@ s_sdl2_sprite * sdl2_sprite_init (s_sdl2_sprite *sprite,
v++;
}
glBindTexture(GL_TEXTURE_2D, sprite->texture[i]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ gl_error = glGetError();
+ if (gl_error != GL_NO_ERROR) {
+ err_write_1("sdl2_sprite_init: ");
+ err_inspect_str(&sprite->real_path);
+ err_write_1(": glBindTexture: ");
+ err_puts((const s8 *) gluErrorString(gl_error));
+ return NULL;
+ }
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- /* glTexImage2D(GL_TEXTURE_2D, 0, gl_format, sprite->w, sprite->h,
- 0, gl_format, gl_type, data);*/
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sprite->w, sprite->h,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ gl_error = glGetError();
+ if (gl_error != GL_NO_ERROR) {
+ err_write_1("sdl2_sprite_init: ");
+ err_inspect_str(&sprite->real_path);
+ err_write_1(": glTexParameteri: ");
+ err_puts((const s8 *) gluErrorString(gl_error));
+ return NULL;
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0, gl_format, sprite->w, sprite->h,
+ 0, gl_format, gl_type, data);
+ //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sprite->w, sprite->h,
+ // 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
gl_error = glGetError();
if (gl_error != GL_NO_ERROR) {
err_write_1("sdl2_sprite_init: ");
diff --git a/libc3/window/sdl2/window_sdl2.c b/libc3/window/sdl2/window_sdl2.c
index 3db8747..f112a6b 100644
--- a/libc3/window/sdl2/window_sdl2.c
+++ b/libc3/window/sdl2/window_sdl2.c
@@ -176,6 +176,7 @@ bool window_sdl2_run (s_window_sdl2 *window)
SDL_GetError());
goto ko;
}
+ glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) {
warnx("window_sdl2_run: failed to initialize GLEW");
goto ko;