From 07a09185389c749de32d26ffa7ca245544dfae3a Mon Sep 17 00:00:00 2001 From: Antonis Geralis Date: Thu, 25 Apr 2024 00:52:27 +0300 Subject: [PATCH] update --- api/rlgl.json | 168 +++++++++++++++++++++++++++++++++++++++------ mangle_names.patch | 20 +++--- src/raylib | 2 +- src/rlgl.nim | 30 +++++++- tools/rlgl_gen.nim | 20 +++++- 5 files changed, 201 insertions(+), 39 deletions(-) diff --git a/api/rlgl.json b/api/rlgl.json index 67344da..d2b3a7a 100644 --- a/api/rlgl.json +++ b/api/rlgl.json @@ -9,7 +9,7 @@ { "name": "RLGL_VERSION", "type": "STRING", - "value": "4.5", + "value": "5.0", "description": "" }, { @@ -504,6 +504,18 @@ "value": 32773, "description": "GL_BLEND_COLOR" }, + { + "name": "RL_READ_FRAMEBUFFER", + "type": "INT", + "value": 36008, + "description": "GL_READ_FRAMEBUFFER" + }, + { + "name": "RL_DRAW_FRAMEBUFFER", + "type": "INT", + "value": 36009, + "description": "GL_DRAW_FRAMEBUFFER" + }, { "name": "RL_MATRIX_TYPE", "type": "GUARD", @@ -678,6 +690,18 @@ "value": 34046, "description": "" }, + { + "name": "GL_PROGRAM_POINT_SIZE", + "type": "INT", + "value": 34370, + "description": "" + }, + { + "name": "GL_LINE_WIDTH", + "type": "INT", + "value": 2849, + "description": "" + }, { "name": "GL_UNSIGNED_SHORT_5_6_5", "type": "INT", @@ -726,41 +750,77 @@ "value": "GL_FRAMEBUFFER", "description": "" }, + { + "name": "RL_DEFAULT_SHADER_ATTRIB_LOCATION_POSITION", + "type": "INT", + "value": 0, + "description": "" + }, + { + "name": "RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD", + "type": "INT", + "value": 1, + "description": "" + }, + { + "name": "RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL", + "type": "INT", + "value": 2, + "description": "" + }, + { + "name": "RL_DEFAULT_SHADER_ATTRIB_LOCATION_COLOR", + "type": "INT", + "value": 3, + "description": "" + }, + { + "name": "RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT", + "type": "INT", + "value": 4, + "description": "" + }, + { + "name": "RL_DEFAULT_SHADER_ATTRIB_LOCATION_TEXCOORD2", + "type": "INT", + "value": 5, + "description": "" + }, { "name": "RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION", "type": "STRING", "value": "vertexPosition", - "description": "Bound by default to shader location: 0" + "description": "Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION" }, { "name": "RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD", "type": "STRING", "value": "vertexTexCoord", - "description": "Bound by default to shader location: 1" + "description": "Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD" }, { "name": "RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL", "type": "STRING", "value": "vertexNormal", - "description": "Bound by default to shader location: 2" + "description": "Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL" }, { "name": "RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR", "type": "STRING", "value": "vertexColor", - "description": "Bound by default to shader location: 3" + "description": "Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR" }, { "name": "RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT", "type": "STRING", "value": "vertexTangent", - "description": "Bound by default to shader location: 4" + "description": "Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT" }, { "name": "RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2", "type": "STRING", "value": "vertexTexCoord2", - "description": "Bound by default to shader location: 5" + "description": "Bound by default to shader location: RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2" }, { "name": "RL_DEFAULT_SHADER_UNIFORM_NAME_MVP", @@ -816,6 +876,12 @@ "value": "texture2", "description": "texture2 (texture slot active 2)" }, + { + "name": "rlMatrixToFloat(mat)", + "type": "MACRO", + "value": "(rlMatrixToFloatV(mat).v)", + "description": "Get float vector for Matrix" + }, { "name": "MIN(a,b)", "type": "MACRO", @@ -951,9 +1017,9 @@ "description": "OpenGL Vertex Array Object id" }, { - "type": "unsigned int[4]", + "type": "unsigned int[5]", "name": "vboId", - "description": "OpenGL Vertex Buffer Objects id (4 types of vertex data)" + "description": "OpenGL Vertex Buffer Objects id (5 types of vertex data)" } ] }, @@ -2068,6 +2134,31 @@ } ] }, + { + "name": "rlSetClipPlanes", + "description": "Set clip planes distances", + "returnType": "void", + "params": [ + { + "type": "double", + "name": "near" + }, + { + "type": "double", + "name": "far" + } + ] + }, + { + "name": "rlGetCullDistanceNear", + "description": "Get cull plane distance near", + "returnType": "double" + }, + { + "name": "rlGetCullDistanceFar", + "description": "Get cull plane distance far", + "returnType": "double" + }, { "name": "rlBegin", "description": "Initialize drawing mode (how to organize vertex)", @@ -2441,6 +2532,11 @@ "description": "Disable render texture (fbo), return to default framebuffer", "returnType": "void" }, + { + "name": "rlGetActiveFramebuffer", + "description": "Get the currently active render texture (fbo), 0 for default framebuffer", + "returnType": "unsigned int" + }, { "name": "rlActiveDrawBuffers", "description": "Activate multiple draw color buffers", @@ -2495,6 +2591,21 @@ } ] }, + { + "name": "rlBindFramebuffer", + "description": "Bind framebuffer (FBO)", + "returnType": "void", + "params": [ + { + "type": "unsigned int", + "name": "target" + }, + { + "type": "unsigned int", + "name": "framebuffer" + } + ] + }, { "name": "rlEnableColorBlend", "description": "Enable color blending", @@ -2535,6 +2646,29 @@ "description": "Disable backface culling", "returnType": "void" }, + { + "name": "rlColorMask", + "description": "Color mask control", + "returnType": "void", + "params": [ + { + "type": "bool", + "name": "r" + }, + { + "type": "bool", + "name": "g" + }, + { + "type": "bool", + "name": "b" + }, + { + "type": "bool", + "name": "a" + } + ] + }, { "name": "rlSetCullFace", "description": "Set face culling mode", @@ -3024,8 +3158,8 @@ "name": "stride" }, { - "type": "const void *", - "name": "pointer" + "type": "int", + "name": "offset" } ] }, @@ -3356,17 +3490,7 @@ { "name": "rlLoadFramebuffer", "description": "Load an empty framebuffer", - "returnType": "unsigned int", - "params": [ - { - "type": "int", - "name": "width" - }, - { - "type": "int", - "name": "height" - } - ] + "returnType": "unsigned int" }, { "name": "rlFramebufferAttach", diff --git a/mangle_names.patch b/mangle_names.patch index 7ddbe2a..7ed9548 100644 --- a/mangle_names.patch +++ b/mangle_names.patch @@ -153,7 +153,7 @@ index d8568d9..5f38019 100644 #endif diff --git a/src/platforms/rcore_desktop.c b/src/platforms/rcore_desktop.c -index 211a6cb..1cb2689 100644 +index de289ca..dd087cd 100644 --- a/src/platforms/rcore_desktop.c +++ b/src/platforms/rcore_desktop.c @@ -951,7 +951,7 @@ const char *GetClipboardText(void) @@ -446,7 +446,7 @@ index b946322..4727c69 100644 // Mesh management functions RLAPI void UploadMesh(Mesh *mesh, bool dynamic); // Upload mesh vertex data in GPU and provide VAO/VBO ids diff --git a/src/rcore.c b/src/rcore.c -index d2e4a35..acb156c 100644 +index b229589..1f09fb4 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -638,16 +638,16 @@ void InitWindow(int width, int height, const char *title) @@ -497,10 +497,10 @@ index d2e4a35..acb156c 100644 #endif diff --git a/src/rmodels.c b/src/rmodels.c -index e669a2f..a967b84 100644 +index 5efc322..26b8636 100644 --- a/src/rmodels.c +++ b/src/rmodels.c -@@ -3574,13 +3574,13 @@ void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float +@@ -3580,13 +3580,13 @@ void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float // Draw a billboard void DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float size, Color tint) { @@ -516,16 +516,16 @@ index e669a2f..a967b84 100644 { // NOTE: Billboard locked on axis-Y Vector3 up = { 0.0f, 1.0f, 0.0f }; -@@ -3588,7 +3588,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector - DrawBillboardPro(camera, texture, source, position, up, size, Vector2Zero(), 0.0f, tint); - } +@@ -3596,7 +3596,7 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector + // Draw a billboard with additional parameters + // NOTE: Size defines the destination rectangle size, stretching the source texture as required -void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint) +void DrawBillboardPro(Camera camera, Texture2D texture, rlRectangle source, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint) { // NOTE: Billboard size will maintain source rectangle aspect ratio, size will represent billboard width Vector2 sizeRatio = { size.x*fabsf((float)source.width/source.height), size.y }; -@@ -4807,7 +4807,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat +@@ -4815,7 +4815,7 @@ static Image LoadImageFromCgltfImage(cgltf_image *cgltfImage, const char *texPat } else // Check if image is provided as image path { @@ -535,7 +535,7 @@ index e669a2f..a967b84 100644 } else if (cgltfImage->buffer_view->buffer->data != NULL) // Check if image is provided as data buffer diff --git a/src/rshapes.c b/src/rshapes.c -index e2b55bc..db1aebd 100644 +index 9020195..7231363 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -80,7 +80,7 @@ @@ -995,7 +995,7 @@ index 47f3e06..c627686 100644 // Save data properly in sprite font font.glyphs[i].value = charId; diff --git a/src/rtextures.c b/src/rtextures.c -index 90c0de2..7ba0962 100644 +index 0658a68..3e117aa 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -271,7 +271,7 @@ static Vector4 *LoadImageDataNormalized(Image image); // Load pixel data f diff --git a/src/raylib b/src/raylib index cf47fbb..e47ebec 160000 --- a/src/raylib +++ b/src/raylib @@ -1 +1 @@ -Subproject commit cf47fbb20bbaacb986fcfe05f0c0e6c6d89c5690 +Subproject commit e47ebec66134800e734710038ea4e5f070f3ef06 diff --git a/src/rlgl.nim b/src/rlgl.nim index 0c70002..97e5038 100644 --- a/src/rlgl.nim +++ b/src/rlgl.nim @@ -110,6 +110,18 @@ type BlendSrcAlpha = 0x80CB ## GL_BLEND_SRC_ALPHA BlendEquationAlpha = 0x883D ## GL_BLEND_EQUATION_ALPHA + FramebufferTarget* {.size: sizeof(int32).} = enum + ReadFramebuffer = 0x8CA8 ## GL_READ_FRAMEBUFFER + DrawFramebuffer = 0x8CA9 ## GL_DRAW_FRAMEBUFFER + + DefaultShaderLocationIndex* {.size: sizeof(int32).} = enum ## Default shader vertex attribute locations + AttribPosition = 0 + AttribTexcoord + AttribNormal + AttribColor + AttribTangent + AttribTexcoord2 + DefaultShaderVariableName* = enum ## Default shader vertex attribute names to set location points AttribPosition = "vertexPosition" ## Binded by default to shader location: 0 AttribTexcoord = "vertexTexCoord" ## Binded by default to shader location: 1 @@ -174,7 +186,7 @@ type else: indices: ptr UncheckedArray[uint16] vaoId*: uint32 ## OpenGL Vertex Array Object id - vboId*: array[4, uint32] ## OpenGL Vertex Buffer Objects id (4 types of vertex data) + vboId*: array[5, uint32] ## OpenGL Vertex Buffer Objects id (5 types of vertex data) DrawCall* {.importc: "rlDrawCall", nodecl, bycopy.} = object ## of those state-change happens (this is done in core module) mode*: int32 ## Drawing mode: LINES, TRIANGLES, QUADS @@ -218,6 +230,12 @@ proc frustum*(left: float, right: float, bottom: float, top: float, znear: float proc ortho*(left: float, right: float, bottom: float, top: float, znear: float, zfar: float) {.importc: "rlOrtho".} proc viewport*(x: int32, y: int32, width: int32, height: int32) {.importc: "rlViewport".} ## Set the viewport area +proc setClipPlanes*(near: float, far: float) {.importc: "rlSetClipPlanes".} + ## Set clip planes distances +proc getCullDistanceNear*(): float {.importc: "rlGetCullDistanceNear".} + ## Get cull plane distance near +proc getCullDistanceFar*(): float {.importc: "rlGetCullDistanceFar".} + ## Get cull plane distance far proc rlBegin*(mode: DrawMode) {.importc: "rlBegin".} ## Initialize drawing mode (how to organize vertex) proc rlEnd*() {.importc: "rlEnd".} @@ -280,10 +298,14 @@ proc enableFramebuffer*(id: uint32) {.importc: "rlEnableFramebuffer".} ## Enable render texture (fbo) proc disableFramebuffer*() {.importc: "rlDisableFramebuffer".} ## Disable render texture (fbo), return to default framebuffer +proc getActiveFramebuffer*(): uint32 {.importc: "rlGetActiveFramebuffer".} + ## Get the currently active render texture (fbo), 0 for default framebuffer proc activeDrawBuffers*(count: int32) {.importc: "rlActiveDrawBuffers".} ## Activate multiple draw color buffers proc blitFramebuffer*(srcX: int32, srcY: int32, srcWidth: int32, srcHeight: int32, dstX: int32, dstY: int32, dstWidth: int32, dstHeight: int32, bufferMask: int32) {.importc: "rlBlitFramebuffer".} ## Blit active framebuffer to main framebuffer +proc bindFramebuffer*(target: FramebufferTarget, framebuffer: uint32) {.importc: "rlBindFramebuffer".} + ## Bind framebuffer (FBO) proc enableColorBlend*() {.importc: "rlEnableColorBlend".} ## Enable color blending proc disableColorBlend*() {.importc: "rlDisableColorBlend".} @@ -300,6 +322,8 @@ proc enableBackfaceCulling*() {.importc: "rlEnableBackfaceCulling".} ## Enable backface culling proc disableBackfaceCulling*() {.importc: "rlDisableBackfaceCulling".} ## Disable backface culling +proc colorMask*(r: bool, g: bool, b: bool, a: bool) {.importc: "rlColorMask".} + ## Color mask control proc setCullFace*(mode: CullMode) {.importc: "rlSetCullFace".} ## Set face culling mode proc enableScissorTest*() {.importc: "rlEnableScissorTest".} @@ -390,7 +414,7 @@ proc unloadVertexArray*(vaoId: uint32) {.importc: "rlUnloadVertexArray".} ## Unload vertex array (vao) proc unloadVertexBuffer*(vboId: uint32) {.importc: "rlUnloadVertexBuffer".} ## Unload vertex buffer object -proc setVertexAttribute*(index: uint32, compSize: int32, `type`: GlType, normalized: bool, stride: int32, pointer: pointer) {.importc: "rlSetVertexAttribute".} +proc setVertexAttribute*(index: uint32, compSize: int32, `type`: GlType, normalized: bool, stride: int32, offset: int32) {.importc: "rlSetVertexAttribute".} ## Set vertex attribute data configuration proc setVertexAttributeDivisor*(index: uint32, divisor: int32) {.importc: "rlSetVertexAttributeDivisor".} ## Set vertex attribute data divisor @@ -422,7 +446,7 @@ proc readTexturePixels*(id: uint32, width: int32, height: int32, format: PixelFo ## Read texture pixel data proc readScreenPixels*(width: int32, height: int32): var uint8 {.importc: "rlReadScreenPixels".} ## Read screen pixel data (color buffer) -proc loadFramebuffer*(width: int32, height: int32): uint32 {.importc: "rlLoadFramebuffer".} +proc loadFramebuffer*(): uint32 {.importc: "rlLoadFramebuffer".} ## Load an empty framebuffer proc framebufferAttach*(fboId: uint32, texId: uint32, attachType: FramebufferAttachType, texType: FramebufferAttachTextureType, mipLevel: int32) {.importc: "rlFramebufferAttach".} ## Attach texture/renderbuffer to a framebuffer diff --git a/tools/rlgl_gen.nim b/tools/rlgl_gen.nim index a66d7c0..68fd136 100644 --- a/tools/rlgl_gen.nim +++ b/tools/rlgl_gen.nim @@ -119,6 +119,18 @@ type BlendSrcAlpha = 0x80CB ## GL_BLEND_SRC_ALPHA BlendEquationAlpha = 0x883D ## GL_BLEND_EQUATION_ALPHA + FramebufferTarget* {.size: sizeof(int32).} = enum + ReadFramebuffer = 0x8CA8 ## GL_READ_FRAMEBUFFER + DrawFramebuffer = 0x8CA9 ## GL_DRAW_FRAMEBUFFER + + DefaultShaderLocationIndex* {.size: sizeof(int32).} = enum ## Default shader vertex attribute locations + AttribPosition = 0 + AttribTexcoord + AttribNormal + AttribColor + AttribTangent + AttribTexcoord2 + DefaultShaderVariableName* = enum ## Default shader vertex attribute names to set location points AttribPosition = "vertexPosition" ## Binded by default to shader location: 0 AttribTexcoord = "vertexTexCoord" ## Binded by default to shader location: 1 @@ -285,9 +297,9 @@ proc getPixelFormatName*(format: PixelFormat): string = "rlglData" ] enumInFuncReturn = [ - ("rlGetLocationUniform", 19), - ("rlGetLocationAttrib", 19), - ("rlGetVersion", 32), + ("rlGetLocationUniform", 20), + ("rlGetLocationAttrib", 20), + ("rlGetVersion", 33), ] enumInFuncParams = [ # TextureParameter @@ -296,6 +308,7 @@ proc getPixelFormatName*(format: PixelFormat): string = ("rlBegin", "mode"), ("rlSetVertexAttribute", "type"), ("rlCompileShader", "type"), + ("rlBindFramebuffer", "target"), ("rlLoadShaderBuffer", "usageHint"), ("rlFramebufferAttach", "attachType"), ("rlFramebufferAttach", "texType"), @@ -330,6 +343,7 @@ proc getPixelFormatName*(format: PixelFormat): string = "DrawMode", "GlType", "ShaderType", + "FramebufferTarget", "BufferUsageHint", "FramebufferAttachType", "FramebufferAttachTextureType",