add the stuff
This commit is contained in:
49
src/files/gryphn_file.cpp
Normal file
49
src/files/gryphn_file.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "gryphn_file.h"
|
||||
#include "fstream"
|
||||
#include "iostream"
|
||||
|
||||
gnFile gnLoadFile(const gnString& path, gnFileType type) {
|
||||
gnFile new_file = gnFile();
|
||||
|
||||
if (type == gnFileType::Text) {
|
||||
std::ifstream file(gnToCString(path));
|
||||
if (!file.is_open()) throw std::runtime_error("failed to open text file!"); // thats right I wont use std::vector but il use std::runtime_error my priorities are straight
|
||||
// not as straight as me around ethan mooney, il see myself out now. (PS i actually did go to bed these will stop now)
|
||||
|
||||
std::string line;
|
||||
while(std::getline(file, line)) {
|
||||
gnListAdd(new_file.lines, gnCreateString(line.c_str()));
|
||||
}
|
||||
} else if (type == gnFileType::Binary) {
|
||||
std::ifstream file(gnToCString(path), std::ios::ate | std::ios::binary);
|
||||
|
||||
if (!file.is_open()) throw std::runtime_error("failed to open file!");
|
||||
|
||||
size_t file_size = (size_t)file.tellg();
|
||||
new_file.bytes = gnCreateList<gnChar>(file_size);
|
||||
|
||||
file.seekg(0);
|
||||
file.read(gnListData(new_file.bytes), file_size);
|
||||
|
||||
file.close(); // straight from vulkan-tutorial.com, not as strai, imma stop myself now
|
||||
}
|
||||
new_file.path = path;
|
||||
|
||||
return new_file;
|
||||
}
|
||||
|
||||
gnString gnGetFileData(const gnFile& file) {
|
||||
gnString file_data;
|
||||
for (int i = 0; i < gnListLength(file.lines); i++) {
|
||||
file_data += gnListGet(file.lines, i) + '\n';
|
||||
}
|
||||
return file_data;
|
||||
} // why I dont just return the file as a list of lines, cuz thats the easy way this way revealed so many errors in my string class,
|
||||
// dont you love it when you dont actually copy a string and then the data gets lost and you dont know why because your an idiot
|
||||
// thats never happened to me...... yea so im an idiot shouve actually copied the bytes over not just haphazardly asigned them to a string.
|
||||
|
||||
gnString gnGetFilePath(const gnFile& file) {
|
||||
return file.path;
|
||||
}
|
||||
|
||||
gnList<gnChar> gnGetFileBytes(const gnFile& file) { return file.bytes; }
|
44
src/files/gryphn_file.h
Normal file
44
src/files/gryphn_file.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include <utils/gryphn_access_level.h>
|
||||
|
||||
// TODO: this file API is shit
|
||||
// have you ever wanted to write a file, well too bad cuz that shits a lot of work and im not doing allllll that
|
||||
// also like im pretty sure something is fucked up in the reading of binary files, what, I dont know but something is
|
||||
// other than that im pretty happy with it cuz like I still have zero fuckcking clue how it works
|
||||
// the binary part that is
|
||||
|
||||
#include "../strings/gryphn_string.h"
|
||||
#include "../lists/gryphn_list.h"
|
||||
|
||||
enum class gnFileType {
|
||||
Text, Binary
|
||||
};
|
||||
|
||||
struct gnFile {
|
||||
ACCESS_LEVEL:
|
||||
gnList<gnString> lines = gnCreateList<gnString>(); // if file type is string
|
||||
gnList<gnChar> bytes = gnCreateList<gnChar>(); // if file type is binary
|
||||
// ofc dumbass they should know what file type there loading
|
||||
// wellllllll actually this is horrible cuz im storing the like 4 bytes it take for an empty list in every loaded file
|
||||
// regardless of if there is actually any data in the list
|
||||
// buttttt as code astetic once said "premature optimization is like totally the root of all evil bro *procedes to hit bong*"
|
||||
// i think i remember that right, i need to fix this but templates are hard and im not
|
||||
|
||||
gnString path = gnCreateString();
|
||||
gnFileType type = gnFileType::Text; // who loads binary files anyway *silence*, i do I guess thats why I wrote this
|
||||
public:
|
||||
gnFile() {}
|
||||
};
|
||||
|
||||
gnFile gnLoadFile(const gnString& path, gnFileType type = gnFileType::Text);
|
||||
// gnFile gnCreateFile(const gnString& path);
|
||||
// gnFile gnCreateFile();
|
||||
// gnFile gnWriteFile(const gnFile& file);
|
||||
// which fucking loser thought they were writing a file writing API
|
||||
// ...... that was me, im lazy, its 10:30, 2.5 hours after I go to sleep, imma go to sleep.
|
||||
|
||||
gnString gnGetFilePath(const gnFile& file);
|
||||
gnString gnGetFileData(const gnFile& file); // i should rename this
|
||||
gnList<gnChar> gnGetFileBytes(const gnFile& file); // fuck object oriented code
|
||||
// and fuck error detection the user can get the bytes of a text file if they want to cuz its slow to do error checking, its also smart but im slow
|
||||
// so me and this project are one in the same
|
7
src/gryphn_access_level.h
Normal file
7
src/gryphn_access_level.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
#define ACCESS_LEVEL public
|
||||
#else
|
||||
#define ACCESS_LEVEL protected
|
||||
#endif
|
5
src/gryphn_bool.h
Normal file
5
src/gryphn_bool.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
typedef int gnBool;
|
||||
#define gnFalse 0;
|
||||
#define gnTrue 1;
|
40
src/gryphn_error_code.h
Normal file
40
src/gryphn_error_code.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "utils/strings/gryphn_string.h"
|
||||
|
||||
typedef enum gnReturnCode {
|
||||
GN_SUCCESS, GN_FAILED, GN_FATAL,
|
||||
GN_ERROR = GN_FAILED
|
||||
} gnReturnCode;
|
||||
|
||||
typedef gnReturnCode gnErrorCode;
|
||||
|
||||
typedef enum gnReturnMessage {
|
||||
GN_UNKNOWN_ERROR,
|
||||
GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
|
||||
GN_UNKNOWN_SHADER_MODULE,
|
||||
GN_SHADER_FAILED_TO_COMPILE,
|
||||
GN_UNSUPPORTED_COLOR_FORMAT,
|
||||
GN_UNKNOWN_COLOR_FORMAT,
|
||||
GN_UNSUPPORTED_RENDERING_API,
|
||||
GN_FUNCTION_NOT_FOUND,
|
||||
GN_UNABLE_TO_LOAD_DLL,
|
||||
GN_FAILED_CREATE_DEVICE,
|
||||
GN_FAILED_CREATE_GRAPHICS_PIPELINE,
|
||||
GN_FAILED_CREATE_PRESENTATION_QUEUE,
|
||||
GN_FAILED_TO_CREATE_FRAMEBUFFER,
|
||||
GN_FAILED_CREATE_RENDERPASS,
|
||||
GN_FAILED_CREATE_INSTANCE,
|
||||
GN_FAILED_TO_ATTACH_WINDOW,
|
||||
GN_FAILED_TO_CREATE_IMAGE
|
||||
} gnReturnMessage;
|
||||
|
||||
inline gnString lastReturnAPIMessage = "";
|
||||
inline gnReturnMessage lastReturnMessage = GN_UNKNOWN_ERROR;
|
||||
|
||||
static const gnString gnGetErrorString() { return lastReturnAPIMessage; }
|
||||
static const gnReturnMessage gnGetErrorMessage() { return lastReturnMessage; }
|
||||
|
||||
static gnReturnCode gnReturnError(gnReturnMessage message, gnString errorMessage) {
|
||||
lastReturnAPIMessage = errorMessage;
|
||||
lastReturnMessage = message;
|
||||
return GN_ERROR;
|
||||
}
|
85
src/lists/gryphn_list.h
Normal file
85
src/lists/gryphn_list.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
#include "math.h"
|
||||
#include "stdio.h"
|
||||
|
||||
// TODO: Wack ass list class, needs some serious refactoring, buttttt it works for what I need it to do
|
||||
// Imma touch this later cuz like I dont like working with C code cuz its wierd but like its also fun
|
||||
// who needs std::vector when you've got malloc, calloc, and free
|
||||
// shit just forgot that I dont clean any of this up, imma do this later cuz like its boring
|
||||
// ive decided to do it now, I hate this, I hate coding, C is fun, this is a Cpp file, what am I doing with life
|
||||
// I never did it id be super easy just like one anitconstructor????? i dont remeber what is called its the one with the squigly bracked
|
||||
// TODO: future me rewirte these comments to be less stupid
|
||||
// TODO: Add insert function, also remove function, orrrrrr i could have people copy lists whever they wanna remove stuff, nah thats gunna piss me off too
|
||||
|
||||
#define GRYPHN_LIST_GROWTH_RATE 2 // number straight from my ass I wanted to use 1.5f cuz thats what STL does but like it complained
|
||||
// im in an abbusive relationship with the compiler, I need to get out of this
|
||||
// but like I also kinda like it imma pick of drinking (not actually imma just play minecraft)
|
||||
|
||||
template <typename Type> // fuck templates
|
||||
struct gnList {
|
||||
protected:
|
||||
Type* items = nullptr;
|
||||
int size = 0, max_size = 0;
|
||||
public:
|
||||
gnList() {}
|
||||
|
||||
// why did I make shit protected
|
||||
// theres gotta be a better way to do this with compiler macros but like that sounds hard
|
||||
// im never touching this wack ass code ever again
|
||||
template <typename T>
|
||||
friend gnList<T> gnCreateList(int size);
|
||||
template <typename T>
|
||||
friend void gnListAdd(gnList<T>& list, T item);
|
||||
template <typename T>
|
||||
friend int gnListLength(const gnList<T>& list);
|
||||
template <typename T>
|
||||
friend T& gnListGet(const gnList<T>& list, int index);
|
||||
template <typename T>
|
||||
friend T* gnListGetPtr(const gnList<T>& list, int index);
|
||||
template <typename T>
|
||||
friend void gnListSet(const gnList<T>& list, int index, T item);
|
||||
template <typename T>
|
||||
friend T* gnListData(const gnList<T>& list);
|
||||
public:
|
||||
Type operator[](int index) const { return items[index]; } // idfk what that const is doin there but the compiler complained I was tryna change a const value
|
||||
// .... I was not, I really am in an abusive relationship
|
||||
Type& operator[](int index) { return items[index]; }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
gnList<T> gnCreateList(int size = 0) {
|
||||
gnList<T> new_list = gnList<T>();
|
||||
new_list.size = size;
|
||||
if (size == 0) size = round(GRYPHN_LIST_GROWTH_RATE);
|
||||
new_list.items = (T*)malloc(sizeof(T) * size);
|
||||
new_list.max_size = size;
|
||||
return new_list;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void gnListAdd(gnList<T>& list, T item) {
|
||||
if (gnListLength(list) == list.max_size) {
|
||||
list.max_size = list.max_size * GRYPHN_LIST_GROWTH_RATE;
|
||||
list.items = (T*)realloc(list.items, sizeof(T) * list.max_size);
|
||||
}
|
||||
|
||||
list.items[list.size] = item;
|
||||
list.size++;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int gnListLength(const gnList<T>& list) { return list.size; }
|
||||
|
||||
template <typename T>
|
||||
T& gnListGet(const gnList<T>& list, int index) { return list.items[index]; }
|
||||
|
||||
template <typename T>
|
||||
T* gnListGetPtr(const gnList<T>& list, int index) { return &list.items[index]; }
|
||||
|
||||
template <typename T>
|
||||
void gnListSet(const gnList<T>& list, int index, T item) { list.items[index] = item; }
|
||||
|
||||
template <typename T>
|
||||
T* gnListData(const gnList<T>& list) { return list.items; } // wack ass function for binary shit
|
||||
// if this ever breaks change it to return &list.items[0] cuz that might work
|
||||
// I have zero clue what any of this shit does
|
44
src/math/gryphn_vec2.h
Normal file
44
src/math/gryphn_vec2.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
// very shitty vec2 class
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
template <typename T>
|
||||
struct gnType2 {
|
||||
union {
|
||||
struct { T a, b; };
|
||||
struct { T x, y; };
|
||||
};
|
||||
public:
|
||||
gnType2(T a, T b) { this->a = a; this->b = b; }
|
||||
gnType2() {};
|
||||
|
||||
gnType2 operator-(const gnType2& other) {
|
||||
gnType2 returnGnVec2;
|
||||
returnGnVec2.x = this->x - other.x;
|
||||
returnGnVec2.y = this->y - other.y;
|
||||
return returnGnVec2;
|
||||
}
|
||||
|
||||
bool operator==(const gnType2& other) const {
|
||||
return this->a == other.a && this->b == other.b;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
typedef gnType2<float> gnVec2;
|
||||
typedef gnType2<float> gnFloat2;
|
||||
typedef gnType2<uint32_t> gnUInt2;
|
||||
typedef gnType2<int32_t> gnInt2;
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<gnUInt2> {
|
||||
std::size_t operator()(const gnUInt2& k) const {
|
||||
return std::hash<uint32_t>()(k.x) ^ (std::hash<uint32_t>()(k.y) << 1);
|
||||
}
|
||||
};
|
||||
}
|
37
src/math/gryphn_vec3.h
Normal file
37
src/math/gryphn_vec3.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
// very shitty vec3 class
|
||||
// i really want to write some math for this shit but im a lazy little cunt and im not doing all that shit
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
template <typename T>
|
||||
struct gnType3 {
|
||||
union {
|
||||
struct { T a, b, c; };
|
||||
struct { T x, y, z; };
|
||||
};
|
||||
public:
|
||||
gnType3(T a, T b, T c) { this->a = a; this->b = b; this->c = c; }
|
||||
gnType3() {};
|
||||
|
||||
bool operator==(const gnType3& other) const {
|
||||
return this->a == other.a && this->b == other.b && this->c == other.c;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct gnMultiType3 {
|
||||
union {
|
||||
struct { T1 a; T2 b; T3 c; };
|
||||
struct { T1 x; T2 y; T3 z; };
|
||||
};
|
||||
public:
|
||||
gnMultiType3(T1 a, T2 b, T3 c) { this->a = a; this->b = b; this->c = c; }
|
||||
gnMultiType3() {};
|
||||
};
|
||||
|
||||
typedef gnType3<float> gnVec3;
|
||||
typedef gnVec3 gnFloat3;
|
||||
typedef gnType3<uint32_t> gnUInt3;
|
||||
typedef gnType3<int32_t> gnInt3;
|
33
src/math/gryphn_vec4.h
Normal file
33
src/math/gryphn_vec4.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
// very shitty vec4 class
|
||||
// I also use this same thing to make my color class dont worry abt it
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
template <typename T>
|
||||
struct gnType4 {
|
||||
union {
|
||||
struct { T a, b, c, d; };
|
||||
struct { T x, y, z, w; };
|
||||
};
|
||||
public:
|
||||
gnType4(T a, T b, T c, T d) { this->a = a; this->b = b; this->c = c; this->d = d; }
|
||||
gnType4() {};
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct gnMultiType4 {
|
||||
union {
|
||||
struct { T1 r; T2 g; T3 b; T4 a; };
|
||||
struct { T1 x; T2 y; T3 z; T4 w; };
|
||||
};
|
||||
public:
|
||||
gnMultiType4(T1 r, T2 g, T3 b, T4 a) { this->r = r; this->g = g; this->b = b; this->a = a; }
|
||||
gnMultiType4() {};
|
||||
};
|
||||
|
||||
typedef gnType4<float> gnVec4;
|
||||
typedef gnVec4 gnFloat4;
|
||||
typedef gnType4<uint32_t> gnUInt4;
|
||||
typedef gnType4<int32_t> gnInt4;
|
1
src/strings/gryphn_string.cpp
Normal file
1
src/strings/gryphn_string.cpp
Normal file
@@ -0,0 +1 @@
|
||||
//#include "gryphn_string.h"
|
181
src/strings/gryphn_string.h
Normal file
181
src/strings/gryphn_string.h
Normal file
@@ -0,0 +1,181 @@
|
||||
#pragma once
|
||||
#include <utils/gryphn_access_level.h>
|
||||
#include <utils/gryphn_bool.h>
|
||||
#include <cstring>
|
||||
|
||||
typedef char gnChar; // OpenGL does it so I do it
|
||||
|
||||
struct gnString;
|
||||
static const char* gnToCString(const gnString& string);
|
||||
|
||||
// apis for char buffers togethers
|
||||
// wack ass name idk what it means but im keepin it
|
||||
// this just adds to char buffers into one big buffer
|
||||
static char* add_string(char* str1, char* str2) {
|
||||
char* buffer = new char[strlen(str1) + strlen(str2) + 1];
|
||||
strcpy(buffer, str1);
|
||||
strcat(buffer, str2);
|
||||
buffer[strlen(str1) + strlen(str2)] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
// add char to char buffer
|
||||
// better name
|
||||
static char* add_string(char* str1, char str2) {
|
||||
char* buffer = new char[strlen(str1) + 2];
|
||||
strcpy(buffer, str1);
|
||||
buffer[strlen(str1)] = str2;
|
||||
buffer[strlen(str1) + 1] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
|
||||
struct gnString {
|
||||
ACCESS_LEVEL:
|
||||
gnChar* value = new gnChar[1]{ '\0' };
|
||||
public:
|
||||
gnString(const gnChar* input) {
|
||||
this->value = new gnChar[strlen(input) + 1]; // so like my dumbass forgot to put this earlier and some shit was broken but now it fixed
|
||||
// I was wondering why one specific string crashed my program, it was my fault
|
||||
|
||||
char* converted_input = const_cast<char*>(input); // yea un const that const value, this line cost me hours cuz I cant read error codes
|
||||
strcpy(this->value, input);
|
||||
this->value[strlen(input)] = '\0';
|
||||
}
|
||||
gnString(gnChar* input) {
|
||||
this->value = new gnChar[strlen(input) + 1];
|
||||
|
||||
strcpy(this->value, input);
|
||||
this->value[strlen(input)] = '\0';
|
||||
}
|
||||
gnString(gnChar input) {
|
||||
this->value = new char[2];
|
||||
this->value[0] = input;
|
||||
this->value[1] = '\0';
|
||||
}
|
||||
gnString() {
|
||||
this->value = new char[1];
|
||||
this->value[0] = '\0';
|
||||
}
|
||||
|
||||
friend int gnStringLength(const gnString& length);
|
||||
friend int gnStringFind(const gnString& string, const gnChar& letter);
|
||||
friend int gnStringFind(const gnString& string, const gnString& value);
|
||||
friend const char* gnToCString(const gnString& string); // dumb ass name but this shit gets used so much
|
||||
friend gnString gnSubstring(const gnString& string, int index1, int index2);
|
||||
|
||||
friend int gnLetterCount(const gnString& string, const gnChar& letter);
|
||||
friend gnChar gnGetCharAt(const gnString& string, int index);
|
||||
friend void gnSetCharAt(gnString& string, int index, gnChar letter);
|
||||
|
||||
friend void gnAddToString(gnString& string, char val);
|
||||
friend void gnAddToString(gnString& string, char* val);
|
||||
friend void gnAddToString(gnString& string, const char* val);
|
||||
friend void gnAddToString(gnString& string, const gnString& val);
|
||||
|
||||
friend gnString gnCombineStrings(const gnString& string, char val); // this shit is not combining a string but im lazy, fuck off
|
||||
friend gnString gnCombineStrings(const gnString& string, char* val);
|
||||
friend gnString gnCombineStrings(const gnString& string, const char* val);
|
||||
friend gnString gnCombineStrings(const gnString& string, const gnString& val);
|
||||
|
||||
friend gnBool gnStringEquals(const gnString& string, char* val);
|
||||
friend gnBool gnStringEquals(const gnString& string, const char* val);
|
||||
friend gnBool gnStringEquals(const gnString& string, const gnString& val);
|
||||
|
||||
friend void gnSetString(gnString& string, const gnString& input);
|
||||
friend void gnSetString(gnString& string, const gnChar* input);
|
||||
friend void gnSetString(gnString& string, gnChar* input);
|
||||
friend void gnSetString(gnString& string, gnChar input);
|
||||
public:
|
||||
char operator[](int index) { return value [index]; }
|
||||
const char operator[](int index) const { return value [index]; }
|
||||
void operator +=(char val) { value = add_string(value, val); }
|
||||
void operator +=(char* val) { value = add_string(value, val); }
|
||||
void operator +=(const char* val) { value = add_string(value, const_cast<char*>(val)); }
|
||||
void operator +=(const gnString& string) { value = add_string(value, const_cast<char*>(gnToCString(string))); }
|
||||
|
||||
gnString operator +(char val) { return gnString(add_string(value, val)); }
|
||||
gnString operator +(char* val){ return gnString(add_string(value, val)); }
|
||||
gnString operator +(const char* val) { return gnString(add_string(value, const_cast<char*>(val))); }
|
||||
gnString operator +(const gnString& val) { return gnString(add_string(value, const_cast<char*>(val.value))); }
|
||||
|
||||
gnBool operator ==(char* val) { return (strcmp(value, val) == 0); }
|
||||
gnBool operator ==(const char* val) { return (strcmp(value, const_cast<char*>(val)) == 0); }
|
||||
gnBool operator ==(const gnString& val) { return (strcmp(value, const_cast<char*>(val.value)) == 0); }
|
||||
|
||||
void operator =(char val) {
|
||||
this->value = new char[2];
|
||||
this->value[0] = val;
|
||||
this->value[1] = '\0';
|
||||
}
|
||||
void operator =(char* val) { this->value = val; }
|
||||
void operator =(const char* val) { this->value = const_cast<char*>(val); }
|
||||
void operator =(const gnString& val) { this->value = val.value; }
|
||||
};
|
||||
|
||||
inline gnString gnCreateString(const gnChar* input) { return gnString(input); }
|
||||
inline gnString gnCreateString(gnChar* input) { return gnString(input); }
|
||||
inline gnString gnCreateString(gnChar input) { return gnString(input); }
|
||||
inline gnString gnCreateString() { return gnString(); }
|
||||
|
||||
inline int gnStringLength(const gnString& string) { return strlen(string.value); }
|
||||
inline const char* gnToCString(const gnString& string) { return string.value; } // this is what Bjarne Stroustrup Sausage man intented me to do with his language
|
||||
|
||||
inline int gnStringFind(const gnString& string, const gnChar& letter) {
|
||||
for (int i = 0; i < strlen(string.value); i++)
|
||||
if (string.value[i] == letter)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
inline int gnStringFind(const gnString& string, const gnString& value) {
|
||||
char first_char = value.value[0];
|
||||
for (int i = 0; i < strlen(string.value); i++)
|
||||
if (string.value[i] == first_char) {
|
||||
bool same = true;
|
||||
for (int c = 1; c < strlen(value.value); c++)
|
||||
if (string.value[i + c] != value.value[c]) {
|
||||
same = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (same)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline gnString gnSubstring(const gnString& string, int index1, int index2) {
|
||||
if (index2 == -1) index2 = gnStringLength(string);
|
||||
char* out_value = new char[(index2 - index1) + 1];
|
||||
for (int i = 0; i < (index2 - index1); i++)
|
||||
out_value[i] = string.value[i + index1];
|
||||
out_value[(index2 - index1)] = '\0';
|
||||
return gnCreateString(out_value); // zero error checking on this function should really add that in later but like I dont have a logging library that I want to use
|
||||
// my code never breaks either so I dont need error checks, il just not make errors cuz im not tim
|
||||
}
|
||||
|
||||
inline int gnLetterCount(const gnString& string, const gnChar& letter) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < gnStringLength(string); i++) if (string.value[i] == letter) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
inline void gnAddToString(gnString& string, char val) { string += val; }
|
||||
inline void gnAddToString(gnString& string, char* val) { string += val; }
|
||||
inline void gnAddToString(gnString& string, const char* val) { string += val; }
|
||||
inline void gnAddToString(gnString& string, const gnString& val) { string += val; }
|
||||
|
||||
inline gnString gnCombineStrings(const gnString& string, char val) { return gnCreateString(add_string(string.value, val)); }
|
||||
inline gnString gnCombineStrings(const gnString& string, char* val) { return gnCreateString(add_string(string.value, val)); }
|
||||
inline gnString gnCombineStrings(const gnString& string, const char* val) { return gnCreateString(add_string(string.value, const_cast<char*>(val))); }
|
||||
inline gnString gnCombineStrings(const gnString& string, const gnString& val) { return gnCreateString(add_string(string.value, const_cast<char*>(val.value))); }
|
||||
|
||||
inline gnBool gnStringEquals(const gnString& string, char* val) { return (strcmp(string.value, val) == 0); }
|
||||
inline gnBool gnStringEquals(const gnString& string,const char* val) { return (strcmp(string.value, const_cast<char*>(val)) == 0); }
|
||||
inline gnBool gnStringEquals(const gnString& string, const gnString& val) { return (strcmp(string.value, const_cast<char*>(val.value)) == 0); }
|
||||
|
||||
inline gnChar gnGetCharAt(const gnString& string, int index) { return string.value[0]; }
|
||||
inline void gnSetCharAt(gnString& string, int index, gnChar letter) { string.value[0] = letter; }
|
||||
|
||||
inline void gnSetString(gnString& string, const gnString& input) { string.value = input.value; }
|
||||
inline void gnSetString(gnString& string, const gnChar* input) { string.value = const_cast<char*>(input); }
|
||||
inline void gnSetString(gnString& string, gnChar* input) { string.value = input; }
|
||||
inline void gnSetString(gnString& string, gnChar input) { string = input; }
|
3
src/types/gryphn_color.h
Normal file
3
src/types/gryphn_color.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "../math/gryphn_vec4.h"
|
||||
|
||||
typedef gnMultiType4<int, int, int, float> gnColor;
|
7
src/types/gryphn_color_format.h
Normal file
7
src/types/gryphn_color_format.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
enum gnColorMode {
|
||||
GN_RED, GN_RGB8, GN_RGBA8, GN_BGRA8,
|
||||
GN_DEPTH8_STENCIL24,
|
||||
GN_DEPTH_STENCIL = GN_DEPTH8_STENCIL24
|
||||
};
|
188
src/types/gryphn_image_format.h
Normal file
188
src/types/gryphn_image_format.h
Normal file
@@ -0,0 +1,188 @@
|
||||
#pragma once
|
||||
|
||||
typedef int gnImageFormat;
|
||||
#define GN_FORMAT_UNDEFINED 0
|
||||
#define GN_FORMAT_R4G4_UNORM_PACK8 1
|
||||
#define GN_FORMAT_R4G4B4A4_UNORM_PACK16 2
|
||||
#define GN_FORMAT_B4G4R4A4_UNORM_PACK16 3
|
||||
#define GN_FORMAT_R5G6B5_UNORM_PACK16 4
|
||||
#define GN_FORMAT_B5G6R5_UNORM_PACK16 5
|
||||
#define GN_FORMAT_R5G5B5A1_UNORM_PACK16 6
|
||||
#define GN_FORMAT_B5G5R5A1_UNORM_PACK16 7
|
||||
#define GN_FORMAT_A1R5G5B5_UNORM_PACK16 8
|
||||
#define GN_FORMAT_R8_UNORM 9
|
||||
#define GN_FORMAT_R8_SNORM 10
|
||||
#define GN_FORMAT_R8_USCALED 11
|
||||
#define GN_FORMAT_R8_SSCALED 12
|
||||
#define GN_FORMAT_R8_UINT 13
|
||||
#define GN_FORMAT_R8_SINT 14
|
||||
#define GN_FORMAT_R8_SRGB 15
|
||||
#define GN_FORMAT_R8G8_UNORM 16
|
||||
#define GN_FORMAT_R8G8_SNORM 17
|
||||
#define GN_FORMAT_R8G8_USCALED 18
|
||||
#define GN_FORMAT_R8G8_SSCALED 19
|
||||
#define GN_FORMAT_R8G8_UINT 20
|
||||
#define GN_FORMAT_R8G8_SINT 21
|
||||
#define GN_FORMAT_R8G8_SRGB 22
|
||||
#define GN_FORMAT_R8G8B8_UNORM 23
|
||||
#define GN_FORMAT_R8G8B8_SNORM 24
|
||||
#define GN_FORMAT_R8G8B8_USCALED 25
|
||||
#define GN_FORMAT_R8G8B8_SSCALED 26
|
||||
#define GN_FORMAT_R8G8B8_UINT 27
|
||||
#define GN_FORMAT_R8G8B8_SINT 28
|
||||
#define GN_FORMAT_R8G8B8_SRGB 29
|
||||
#define GN_FORMAT_B8G8R8_UNORM 30
|
||||
#define GN_FORMAT_B8G8R8_SNORM 31
|
||||
#define GN_FORMAT_B8G8R8_USCALED 32
|
||||
#define GN_FORMAT_B8G8R8_SSCALED 33
|
||||
#define GN_FORMAT_B8G8R8_UINT 34
|
||||
#define GN_FORMAT_B8G8R8_SINT 35
|
||||
#define GN_FORMAT_B8G8R8_SRGB 36
|
||||
#define GN_FORMAT_R8G8B8A8_UNORM 37
|
||||
#define GN_FORMAT_R8G8B8A8_SNORM 38
|
||||
#define GN_FORMAT_R8G8B8A8_USCALED 39
|
||||
#define GN_FORMAT_R8G8B8A8_SSCALED 40
|
||||
#define GN_FORMAT_R8G8B8A8_UINT 41
|
||||
#define GN_FORMAT_R8G8B8A8_SINT 42
|
||||
#define GN_FORMAT_R8G8B8A8_SRGB 43
|
||||
#define GN_FORMAT_B8G8R8A8_UNORM 44
|
||||
#define GN_FORMAT_B8G8R8A8_SNORM 45
|
||||
#define GN_FORMAT_B8G8R8A8_USCALED 46
|
||||
#define GN_FORMAT_B8G8R8A8_SSCALED 47
|
||||
#define GN_FORMAT_B8G8R8A8_UINT 48
|
||||
#define GN_FORMAT_B8G8R8A8_SINT 49
|
||||
#define GN_FORMAT_B8G8R8A8_SRGB 50
|
||||
#define GN_FORMAT_A8B8G8R8_UNORM_PACK32 51
|
||||
#define GN_FORMAT_A8B8G8R8_SNORM_PACK32 52
|
||||
#define GN_FORMAT_A8B8G8R8_USCALED_PACK32 53
|
||||
#define GN_FORMAT_A8B8G8R8_SSCALED_PACK32 54
|
||||
#define GN_FORMAT_A8B8G8R8_UINT_PACK32 55
|
||||
#define GN_FORMAT_A8B8G8R8_SINT_PACK32 56
|
||||
#define GN_FORMAT_A8B8G8R8_SRGB_PACK32 57
|
||||
#define GN_FORMAT_A2R10G10B10_UNORM_PACK32 58
|
||||
#define GN_FORMAT_A2R10G10B10_SNORM_PACK32 59
|
||||
#define GN_FORMAT_A2R10G10B10_USCALED_PACK32 60
|
||||
#define GN_FORMAT_A2R10G10B10_SSCALED_PACK32 61
|
||||
#define GN_FORMAT_A2R10G10B10_UINT_PACK32 62
|
||||
#define GN_FORMAT_A2R10G10B10_SINT_PACK32 63
|
||||
#define GN_FORMAT_A2B10G10R10_UNORM_PACK32 64
|
||||
#define GN_FORMAT_A2B10G10R10_SNORM_PACK32 65
|
||||
#define GN_FORMAT_A2B10G10R10_USCALED_PACK32 66
|
||||
#define GN_FORMAT_A2B10G10R10_SSCALED_PACK32 67
|
||||
#define GN_FORMAT_A2B10G10R10_UINT_PACK32 68
|
||||
#define GN_FORMAT_A2B10G10R10_SINT_PACK32 69
|
||||
#define GN_FORMAT_R16_UNORM 70
|
||||
#define GN_FORMAT_R16_SNORM 71
|
||||
#define GN_FORMAT_R16_USCALED 72
|
||||
#define GN_FORMAT_R16_SSCALED 73
|
||||
#define GN_FORMAT_R16_UINT 74
|
||||
#define GN_FORMAT_R16_SINT 75
|
||||
#define GN_FORMAT_R16_SFLOAT 76
|
||||
#define GN_FORMAT_R16G16_UNORM 77
|
||||
#define GN_FORMAT_R16G16_SNORM 78
|
||||
#define GN_FORMAT_R16G16_USCALED 79
|
||||
#define GN_FORMAT_R16G16_SSCALED 80
|
||||
#define GN_FORMAT_R16G16_UINT 81
|
||||
#define GN_FORMAT_R16G16_SINT 82
|
||||
#define GN_FORMAT_R16G16_SFLOAT 83
|
||||
#define GN_FORMAT_R16G16B16_UNORM 84
|
||||
#define GN_FORMAT_R16G16B16_SNORM 85
|
||||
#define GN_FORMAT_R16G16B16_USCALED 86
|
||||
#define GN_FORMAT_R16G16B16_SSCALED 87
|
||||
#define GN_FORMAT_R16G16B16_UINT 88
|
||||
#define GN_FORMAT_R16G16B16_SINT 89
|
||||
#define GN_FORMAT_R16G16B16_SFLOAT 90
|
||||
#define GN_FORMAT_R16G16B16A16_UNORM 91
|
||||
#define GN_FORMAT_R16G16B16A16_SNORM 92
|
||||
#define GN_FORMAT_R16G16B16A16_USCALED 93
|
||||
#define GN_FORMAT_R16G16B16A16_SSCALED 94
|
||||
#define GN_FORMAT_R16G16B16A16_UINT 95
|
||||
#define GN_FORMAT_R16G16B16A16_SINT 96
|
||||
#define GN_FORMAT_R16G16B16A16_SFLOAT 97
|
||||
#define GN_FORMAT_R32_UINT 98
|
||||
#define GN_FORMAT_R32_SINT 99
|
||||
#define GN_FORMAT_R32_SFLOAT 100
|
||||
#define GN_FORMAT_R32G32_UINT 101
|
||||
#define GN_FORMAT_R32G32_SINT 102
|
||||
#define GN_FORMAT_R32G32_SFLOAT 103
|
||||
#define GN_FORMAT_R32G32B32_UINT 104
|
||||
#define GN_FORMAT_R32G32B32_SINT 105
|
||||
#define GN_FORMAT_R32G32B32_SFLOAT 106
|
||||
#define GN_FORMAT_R32G32B32A32_UINT 107
|
||||
#define GN_FORMAT_R32G32B32A32_SINT 108
|
||||
#define GN_FORMAT_R32G32B32A32_SFLOAT 109
|
||||
#define GN_FORMAT_R64_UINT 110
|
||||
#define GN_FORMAT_R64_SINT 111
|
||||
#define GN_FORMAT_R64_SFLOAT 112
|
||||
#define GN_FORMAT_R64G64_UINT 113
|
||||
#define GN_FORMAT_R64G64_SINT 114
|
||||
#define GN_FORMAT_R64G64_SFLOAT 115
|
||||
#define GN_FORMAT_R64G64B64_UINT 116
|
||||
#define GN_FORMAT_R64G64B64_SINT 117
|
||||
#define GN_FORMAT_R64G64B64_SFLOAT 118
|
||||
#define GN_FORMAT_R64G64B64A64_UINT 119
|
||||
#define GN_FORMAT_R64G64B64A64_SINT 120
|
||||
#define GN_FORMAT_R64G64B64A64_SFLOAT 121
|
||||
#define GN_FORMAT_B10G11R11_UFLOAT_PACK32 122
|
||||
#define GN_FORMAT_E5B9G9R9_UFLOAT_PACK32 123
|
||||
#define GN_FORMAT_D16_UNORM 124
|
||||
#define GN_FORMAT_X8_D24_UNORM_PACK32 125
|
||||
#define GN_FORMAT_D32_SFLOAT 126
|
||||
#define GN_FORMAT_S8_UINT 127
|
||||
#define GN_FORMAT_D16_UNORM_S8_UINT 128
|
||||
#define GN_FORMAT_D24_UNORM_S8_UINT 129
|
||||
#define GN_FORMAT_D32_SFLOAT_S8_UINT 130
|
||||
#define GN_FORMAT_BC1_RGB_UNORM_BLOCK 131
|
||||
#define GN_FORMAT_BC1_RGB_SRGB_BLOCK 132
|
||||
#define GN_FORMAT_BC1_RGBA_UNORM_BLOCK 133
|
||||
#define GN_FORMAT_BC1_RGBA_SRGB_BLOCK 134
|
||||
#define GN_FORMAT_BC2_UNORM_BLOCK 135
|
||||
#define GN_FORMAT_BC2_SRGB_BLOCK 136
|
||||
#define GN_FORMAT_BC3_UNORM_BLOCK 137
|
||||
#define GN_FORMAT_BC3_SRGB_BLOCK 138
|
||||
#define GN_FORMAT_BC4_UNORM_BLOCK 139
|
||||
#define GN_FORMAT_BC4_SNORM_BLOCK 140
|
||||
#define GN_FORMAT_BC5_UNORM_BLOCK 141
|
||||
#define GN_FORMAT_BC5_SNORM_BLOCK 142
|
||||
#define GN_FORMAT_BC6H_UFLOAT_BLOCK 143
|
||||
#define GN_FORMAT_BC6H_SFLOAT_BLOCK 144
|
||||
#define GN_FORMAT_BC7_UNORM_BLOCK 145
|
||||
#define GN_FORMAT_BC7_SRGB_BLOCK 146
|
||||
#define GN_FORMAT_ETC2_R8G8B8_UNORM_BLOCK 147
|
||||
#define GN_FORMAT_ETC2_R8G8B8_SRGB_BLOCK 148
|
||||
#define GN_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK 149
|
||||
#define GN_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK 150
|
||||
#define GN_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK 151
|
||||
#define GN_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK 152
|
||||
#define GN_FORMAT_EAC_R11_UNORM_BLOCK 153
|
||||
#define GN_FORMAT_EAC_R11_SNORM_BLOCK 154
|
||||
#define GN_FORMAT_EAC_R11G11_UNORM_BLOCK 155
|
||||
#define GN_FORMAT_EAC_R11G11_SNORM_BLOCK 156
|
||||
#define GN_FORMAT_ASTC_4x4_UNORM_BLOCK 157
|
||||
#define GN_FORMAT_ASTC_4x4_SRGB_BLOCK 158
|
||||
#define GN_FORMAT_ASTC_5x4_UNORM_BLOCK 159
|
||||
#define GN_FORMAT_ASTC_5x4_SRGB_BLOCK 160
|
||||
#define GN_FORMAT_ASTC_5x5_UNORM_BLOCK 161
|
||||
#define GN_FORMAT_ASTC_5x5_SRGB_BLOCK 162
|
||||
#define GN_FORMAT_ASTC_6x5_UNORM_BLOCK 163
|
||||
#define GN_FORMAT_ASTC_6x5_SRGB_BLOCK 164
|
||||
#define GN_FORMAT_ASTC_6x6_UNORM_BLOCK 165
|
||||
#define GN_FORMAT_ASTC_6x6_SRGB_BLOCK 166
|
||||
#define GN_FORMAT_ASTC_8x5_UNORM_BLOCK 167
|
||||
#define GN_FORMAT_ASTC_8x5_SRGB_BLOCK 168
|
||||
#define GN_FORMAT_ASTC_8x6_UNORM_BLOCK 169
|
||||
#define GN_FORMAT_ASTC_8x6_SRGB_BLOCK 170
|
||||
#define GN_FORMAT_ASTC_8x8_UNORM_BLOCK 171
|
||||
#define GN_FORMAT_ASTC_8x8_SRGB_BLOCK 172
|
||||
#define GN_FORMAT_ASTC_10x5_UNORM_BLOCK 173
|
||||
#define GN_FORMAT_ASTC_10x5_SRGB_BLOCK 174
|
||||
#define GN_FORMAT_ASTC_10x6_UNORM_BLOCK 175
|
||||
#define GN_FORMAT_ASTC_10x6_SRGB_BLOCK 176
|
||||
#define GN_FORMAT_ASTC_10x8_UNORM_BLOCK 177
|
||||
#define GN_FORMAT_ASTC_10x8_SRGB_BLOCK 178
|
||||
#define GN_FORMAT_ASTC_10x10_UNORM_BLOCK 179
|
||||
#define GN_FORMAT_ASTC_10x10_SRGB_BLOCK 180
|
||||
#define GN_FORMAT_ASTC_12x10_UNORM_BLOCK 181
|
||||
#define GN_FORMAT_ASTC_12x10_SRGB_BLOCK 182
|
||||
#define GN_FORMAT_ASTC_12x12_UNORM_BLOCK 183
|
||||
#define GN_FORMAT_ASTC_12x12_SRGB_BLOCK 184
|
6
src/version/gryphn_version.h
Normal file
6
src/version/gryphn_version.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
#include "stdint.h"
|
||||
|
||||
typedef uint32_t gnVersion; // uint32_t is the loser way to right this I can write it anyway I want
|
||||
|
||||
#define gnCreateVersion(major, minor, patch) ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
|
Reference in New Issue
Block a user