Skip to content

Commit

Permalink
gg!
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlank committed Oct 2, 2024
1 parent 9c5d758 commit b5ad3b6
Show file tree
Hide file tree
Showing 3 changed files with 412 additions and 298 deletions.
7 changes: 4 additions & 3 deletions generator/GLADGenetator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import sys.io.File.getContent;

using StringTools;

typedef Thingy = {name:String, defineName:String, ?appendFile:String, output:String, xmlName:String, haxeName:String, lightColor:Int, darkColor:Int, features:Array<String>, ?exclude:EReg}
typedef Thingy = {name:String, defineName:String, ?appendFile:String, output:String, xmlName:String, haxeName:String, lightColor:Int, darkColor:Int, features:Array<String>, ?exclude:Array<String>, ?excludeReg:Array<EReg>}

class GLADGenetator {
final typeMap:Map<String, String> = [
Expand Down Expand Up @@ -178,7 +178,7 @@ class GLADGenetator {
'GL_VERSION_4_2',
'GL_VERSION_4_3',
'GL_VERSION_4_4'
], appendFile: 'glInclude', haxeName: 'OpenGL', defineName: 'GLAD_GL_IMPLEMENTATION', exclude: ~/\bglGen\w*\b/},
], appendFile: 'glInclude', haxeName: 'OpenGL', defineName: 'GLAD_GL_IMPLEMENTATION', exclude: ['glBufferData', 'glDrawElements', 'glShaderSource', 'glVertexAttribPointer', 'glGetUniformLocation'], excludeReg: [~/\bglGen\w*\b/, ~/\bglUniform\w*\b/]},
// will do later when im not lazy
// {name: 'vulkan', output: 'out/vulkan', xmlName: 'vk.xml', lightColor: 91, darkColor: 31, features: [
// 'VK_VERSION_1_0',
Expand Down Expand Up @@ -264,7 +264,8 @@ class GLADGenetator {
var proto = command.elementsNamed('proto').next();
var name = proto.elementsNamed('name').next().firstChild().nodeValue;

if (!requiredFunctions.contains(name) || data.exclude.match(name)) continue;
var exclude:Bool = [for (reg in data.excludeReg) reg.match(name)].contains(true);
if (!requiredFunctions.contains(name) || exclude || data.exclude.contains(name)) continue;

var jaxeReturn:String = '';
var typeThing:StringBuf = new StringBuf();
Expand Down
200 changes: 200 additions & 0 deletions generator/glInclude.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,203 @@ DEFINE_PRIM(_I32, PRIM_NAME(gl_gen_textures), _NO_ARG);
DEFINE_PRIM(_I32, PRIM_NAME(gl_gen_transform_feedbacks), _NO_ARG);
DEFINE_PRIM(_I32, PRIM_NAME(gl_gen_vertex_arrays), _NO_ARG);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_generate_mipmap), _I32);

HL_PRIM void FUNC_NAME(gl_shader_source)(GLuint shader, vstring* string) {
char* gay = hl_to_utf8(string->bytes);
return glShaderSource(shader, 1, &gay, NULL);
}

HL_PRIM void FUNC_NAME(gl_vertex_attrib_pointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, int offset) {
return glVertexAttribPointer(index, size, type, normalized, stride, (void*)(intptr_t)offset);
}

HL_PRIM void FUNC_NAME(gl_buffer_data)(GLenum target, int size, vbyte *data, GLenum usage) {
return glBufferData(target, size, data, usage);
}

HL_PRIM void FUNC_NAME(gl_draw_elements)(GLenum mode, GLsizei count, GLenum type, int start) {
return glDrawElements(mode, count, type, (void*)(intptr_t)start);
}

DEFINE_PRIM(_VOID, PRIM_NAME(gl_shader_source), _I32 _STRING);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_vertex_attrib_pointer), _I32 _I32 _I32 _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_buffer_data), _I32 _I32 _BYTES _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_draw_elements), _I32 _I32 _I32 _I32);

HL_PRIM void FUNC_NAME(gl_uniform1d)(GLint location, GLdouble x) {
return glUniform1d(location, x);
}

HL_PRIM void FUNC_NAME(gl_uniform1f)(GLint location, GLfloat v0) {
return glUniform1f(location, v0);
}

HL_PRIM void FUNC_NAME(gl_uniform1i)(GLint location, GLint v0) {
return glUniform1i(location, v0);
}

HL_PRIM void FUNC_NAME(gl_uniform1ui)(GLint location, GLuint v0) {
return glUniform1ui(location, v0);
}

HL_PRIM void FUNC_NAME(gl_uniform2d)(GLint location, GLdouble x, GLdouble y) {
return glUniform2d(location, x, y);
}

HL_PRIM void FUNC_NAME(gl_uniform2f)(GLint location, GLfloat v0, GLfloat v1) {
return glUniform2f(location, v0, v1);
}

HL_PRIM void FUNC_NAME(gl_uniform2i)(GLint location, GLint v0, GLint v1) {
return glUniform2i(location, v0, v1);
}

HL_PRIM void FUNC_NAME(gl_uniform2ui)(GLint location, GLuint v0, GLuint v1) {
return glUniform2ui(location, v0, v1);
}

HL_PRIM void FUNC_NAME(gl_uniform3d)(GLint location, GLdouble x, GLdouble y, GLdouble z) {
return glUniform3d(location, x, y, z);
}

HL_PRIM void FUNC_NAME(gl_uniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
return glUniform3f(location, v0, v1, v2);
}

HL_PRIM void FUNC_NAME(gl_uniform3i)(GLint location, GLint v0, GLint v1, GLint v2) {
return glUniform3i(location, v0, v1, v2);
}

HL_PRIM void FUNC_NAME(gl_uniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) {
return glUniform3ui(location, v0, v1, v2);
}

HL_PRIM void FUNC_NAME(gl_uniform4d)(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w) {
return glUniform4d(location, x, y, z, w);
}

HL_PRIM void FUNC_NAME(gl_uniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
return glUniform4f(location, v0, v1, v2, v3);
}

HL_PRIM void FUNC_NAME(gl_uniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
return glUniform4i(location, v0, v1, v2, v3);
}

HL_PRIM void FUNC_NAME(gl_uniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
return glUniform4ui(location, v0, v1, v2, v3);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix2dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix2dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix2fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix2fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix2x3dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix2x3dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix2x3fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix2x3fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix2x4dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix2x4dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix2x4fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix2x4fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix3dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix3dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix3fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix3fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix3x2dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix3x2dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix3x2fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix3x2fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix3x4dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix3x4dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix3x4fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix3x4fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix4dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix4dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix4fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix4fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix4x2dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix4x2dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix4x2fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix4x2fv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix4x3dv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix4x3dv(location, count, transpose, value);
}

HL_PRIM void FUNC_NAME(gl_uniform_matrix4x3fv)(GLint location, int count, GLboolean transpose, vbyte* value) {
return glUniformMatrix4x3fv(location, count, transpose, value);
}

HL_PRIM GLint FUNC_NAME(gl_get_uniform_location)(GLuint program, vstring *name) {
char* gay = hl_to_utf8(name->bytes);
return glGetUniformLocation(program, gay);
}

DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform1d), _I32 _F64);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform1f), _I32 _F32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform1i), _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform1ui), _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform2d), _I32 _F64 _F64);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform2f), _I32 _F32 _F32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform2i), _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform2ui), _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform3d), _I32 _F64 _F64 _F64);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform3f), _I32 _F32 _F32 _F32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform3i), _I32 _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform3ui), _I32 _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform4d), _I32 _F64 _F64 _F64 _F64);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform4f), _I32 _F32 _F32 _F32 _F32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform4i), _I32 _I32 _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform4ui), _I32 _I32 _I32 _I32 _I32);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix2dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix2fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix2x3dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix2x3fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix2x4dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix2x4fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix3dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix3fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix3x2dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix3x2fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix3x4dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix3x4fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix4dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix4fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix4x2dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix4x2fv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix4x3dv), _I32 _I32 _I32 _BYTES);
DEFINE_PRIM(_VOID, PRIM_NAME(gl_uniform_matrix4x3fv), _I32 _I32 _I32 _BYTES);

DEFINE_PRIM(_I32, PRIM_NAME(gl_get_uniform_location), _I32 _STRING);
Loading

0 comments on commit b5ad3b6

Please sign in to comment.