using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; namespace Raylib_cs; [SuppressUnmanagedCodeSecurity] public static unsafe partial class Rlgl { /// /// Used by LibraryImport to load the native library /// public const string NativeLibName = "raylib"; public const int DEFAULT_BATCH_BUFFER_ELEMENTS = 8192; public const int DEFAULT_BATCH_BUFFERS = 1; public const int DEFAULT_BATCH_DRAWCALLS = 256; public const int MAX_BATCH_ACTIVE_TEXTURES = 4; public const int MAX_MATRIX_STACK_SIZE = 32; public const float CULL_DISTANCE_NEAR = 0.01f; public const float CULL_DISTANCE_FAR = 1000.0f; // Texture parameters (equivalent to OpenGL defines) public const int TEXTURE_WRAP_S = 0x2802; public const int TEXTURE_WRAP_T = 0x2803; public const int TEXTURE_MAG_FILTER = 0x2800; public const int TEXTURE_MIN_FILTER = 0x2801; public const int TEXTURE_FILTER_NEAREST = 0x2600; public const int TEXTURE_FILTER_LINEAR = 0x2601; public const int TEXTURE_FILTER_MIP_NEAREST = 0x2700; public const int TEXTURE_FILTER_NEAREST_MIP_LINEAR = 0x2702; public const int TEXTURE_FILTER_LINEAR_MIP_NEAREST = 0x2701; public const int TEXTURE_FILTER_MIP_LINEAR = 0x2703; public const int TEXTURE_FILTER_ANISOTROPIC = 0x3000; public const int TEXTURE_MIPMAP_BIAS_RATIO = 0x4000; public const int TEXTURE_WRAP_REPEAT = 0x2901; public const int TEXTURE_WRAP_CLAMP = 0x812F; public const int TEXTURE_WRAP_MIRROR_REPEAT = 0x8370; public const int TEXTURE_WRAP_MIRROR_CLAMP = 0x8742; // GL equivalent data types public const int UNSIGNED_BYTE = 0x1401; public const int FLOAT = 0x1406; // Buffer usage hint public const int STREAM_DRAW = 0x88E0; public const int STREAM_READ = 0x88E1; public const int STREAM_COPY = 0x88E2; public const int STATIC_DRAW = 0x88E4; public const int STATIC_READ = 0x88E5; public const int STATIC_COPY = 0x88E6; public const int DYNAMIC_DRAW = 0x88E8; public const int DYNAMIC_READ = 0x88E9; public const int DYNAMIC_COPY = 0x88EA; // GL blending factors public const int ZERO = 0; public const int ONE = 1; public const int SRC_COLOR = 0x0300; public const int ONE_MINUS_SRC_COLOR = 0x0301; public const int SRC_ALPHA = 0x0302; public const int ONE_MINUS_SRC_ALPHA = 0x0303; public const int DST_ALPHA = 0x0304; public const int ONE_MINUS_DST_ALPHA = 0x0305; public const int DST_COLOR = 0x0306; public const int ONE_MINUS_DST_COLOR = 0x0307; public const int SRC_ALPHA_SATURATE = 0x0308; public const int CONSTANT_COLOR = 0x8001; public const int ONE_MINUS_CONSTANT_COLOR = 0x8002; public const int CONSTANT_ALPHA = 0x8003; public const int ONE_MINUS_CONSTANT_ALPHA = 0x8004; // GL blending functions/equations public const int FUNC_ADD = 0x8006; public const int MIN = 0x8007; public const int MAX = 0x8008; public const int FUNC_SUBTRACT = 0x800A; public const int FUNC_REVERSE_SUBTRACT = 0x800B; public const int BLEND_EQUATION = 0x8009; public const int BLEND_EQUATION_RGB = 0x8009; public const int BLEND_EQUATION_ALPHA = 0x883D; public const int BLEND_DST_RGB = 0x80C8; public const int BLEND_SRC_RGB = 0x80C9; public const int BLEND_DST_ALPHA = 0x80CA; public const int BLEND_SRC_ALPHA = 0x80CB; public const int BLEND_COLOR = 0x8005; // ------------------------------------------------------------------------------------ // Functions Declaration - Matrix operations // ------------------------------------------------------------------------------------ /// Choose the current matrix to be transformed [LibraryImport(NativeLibName, EntryPoint = "rlMatrixMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void MatrixMode(int mode); /// public static void MatrixMode(MatrixMode mode) { MatrixMode((int)mode); } /// Push the current matrix to stack [LibraryImport(NativeLibName, EntryPoint = "rlPushMatrix")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void PushMatrix(); /// Pop lattest inserted matrix from stack [LibraryImport(NativeLibName, EntryPoint = "rlPopMatrix")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void PopMatrix(); /// Reset current matrix to identity matrix [LibraryImport(NativeLibName, EntryPoint = "rlLoadIdentity")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void LoadIdentity(); /// Multiply the current matrix by a translation matrix [LibraryImport(NativeLibName, EntryPoint = "rlTranslatef")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Translatef(float x, float y, float z); /// Multiply the current matrix by a rotation matrix [LibraryImport(NativeLibName, EntryPoint = "rlRotatef")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Rotatef(float angle, float x, float y, float z); /// Multiply the current matrix by a scaling matrix [LibraryImport(NativeLibName, EntryPoint = "rlScalef")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Scalef(float x, float y, float z); /// /// Multiply the current matrix by another matrix
/// Current Matrix can be set via ///
[LibraryImport(NativeLibName, EntryPoint = "rlMultMatrixf")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void MultMatrixf(float* matf); /// public static void MultMatrixf(Matrix4x4 matf) { Float16 f = Raymath.MatrixToFloatV(matf); MultMatrixf(f.v); } [LibraryImport(NativeLibName, EntryPoint = "rlFrustum")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Frustum( double left, double right, double bottom, double top, double znear, double zfar ); [LibraryImport(NativeLibName, EntryPoint = "rlOrtho")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Ortho( double left, double right, double bottom, double top, double znear, double zfar ); /// Set the viewport area [LibraryImport(NativeLibName, EntryPoint = "rlViewport")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Viewport(int x, int y, int width, int height); /// Set clip planes distances [LibraryImport(NativeLibName, EntryPoint = "rlSetClipPlanes")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetClipPlanes(double nearPlane, double farPlane); /// Get cull plane distance near [LibraryImport(NativeLibName, EntryPoint = "rlGetCullDistanceNear")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial double GetCullDistanceNear(); /// Get cull plane distance far [LibraryImport(NativeLibName, EntryPoint = "rlGetCullDistanceFar")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial double GetCullDistanceFar(); // ------------------------------------------------------------------------------------ // Functions Declaration - Vertex level operations // ------------------------------------------------------------------------------------ /// Initialize drawing mode (how to organize vertex) [LibraryImport(NativeLibName, EntryPoint = "rlBegin")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Begin(int mode); public static void Begin(DrawMode mode) { Begin((int)mode); } /// Finish vertex providing [LibraryImport(NativeLibName, EntryPoint = "rlEnd")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void End(); /// Define one vertex (position) - 2 int [LibraryImport(NativeLibName, EntryPoint = "rlVertex2i")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Vertex2i(int x, int y); /// Define one vertex (position) - 2 float [LibraryImport(NativeLibName, EntryPoint = "rlVertex2f")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Vertex2f(float x, float y); /// Define one vertex (position) - 3 float [LibraryImport(NativeLibName, EntryPoint = "rlVertex3f")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Vertex3f(float x, float y, float z); /// Define one vertex (texture coordinate) - 2 float [LibraryImport(NativeLibName, EntryPoint = "rlTexCoord2f")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void TexCoord2f(float x, float y); /// Define one vertex (normal) - 3 float [LibraryImport(NativeLibName, EntryPoint = "rlNormal3f")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Normal3f(float x, float y, float z); /// Define one vertex (color) - 4 byte [LibraryImport(NativeLibName, EntryPoint = "rlColor4ub")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Color4ub(byte r, byte g, byte b, byte a); /// Define one vertex (color) - 3 float [LibraryImport(NativeLibName, EntryPoint = "rlColor3f")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Color3f(float x, float y, float z); /// Define one vertex (color) - 4 float [LibraryImport(NativeLibName, EntryPoint = "rlColor4f")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Color4f(float x, float y, float z, float w); // ------------------------------------------------------------------------------------ // Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2) // NOTE: This functions are used to completely abstract raylib code from OpenGL layer // ------------------------------------------------------------------------------------ /// Vertex buffers state /// Enable vertex array (VAO, if supported) [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexArray")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool EnableVertexArray(uint vaoId); /// Disable vertex array (VAO, if supported) [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexArray")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableVertexArray(); /// Enable vertex buffer (VBO) [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableVertexBuffer(uint id); /// Disable vertex buffer (VBO) [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableVertexBuffer(); /// Enable vertex buffer element (VBO element) [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexBufferElement")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableVertexBufferElement(uint id); /// Disable vertex buffer element (VBO element) [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexBufferElement")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableVertexBufferElement(); /// Enable vertex attribute index [LibraryImport(NativeLibName, EntryPoint = "rlEnableVertexAttribute")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableVertexAttribute(uint index); /// Disable vertex attribute index [LibraryImport(NativeLibName, EntryPoint = "rlDisableVertexAttribute")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableVertexAttribute(uint index); // Textures state /// Select and active a texture slot [LibraryImport(NativeLibName, EntryPoint = "rlActiveTextureSlot")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ActiveTextureSlot(int slot); /// Enable texture [LibraryImport(NativeLibName, EntryPoint = "rlEnableTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableTexture(uint id); /// Disable texture [LibraryImport(NativeLibName, EntryPoint = "rlDisableTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableTexture(); /// Enable texture cubemap [LibraryImport(NativeLibName, EntryPoint = "rlEnableTextureCubemap")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableTextureCubemap(uint id); /// Disable texture cubemap [LibraryImport(NativeLibName, EntryPoint = "rlDisableTextureCubemap")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableTextureCubemap(); /// Set texture parameters (filter, wrap) [LibraryImport(NativeLibName, EntryPoint = "rlTextureParameters")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void TextureParameters(uint id, int param, int value); /// Set cubemap parameters (filter, wrap) [LibraryImport(NativeLibName, EntryPoint = "rlCubemapParameters")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void CubemapParameters(uint id, int param, int value); // Shader state /// Enable shader program [LibraryImport(NativeLibName, EntryPoint = "rlEnableShader")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableShader(uint id); /// Disable shader program [LibraryImport(NativeLibName, EntryPoint = "rlDisableShader")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableShader(); // Framebuffer state /// Enable render texture (fbo) [LibraryImport(NativeLibName, EntryPoint = "rlEnableFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableFramebuffer(uint id); /// Disable render texture (fbo), return to default framebuffer [LibraryImport(NativeLibName, EntryPoint = "rlDisableFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableFramebuffer(); /// Get the currently active render texture (fbo), 0 for default framebuffer [LibraryImport(NativeLibName, EntryPoint = "rlGetActiveFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint GetActiveFramebuffer(); /// Blit active framebuffer to main framebuffer [LibraryImport(NativeLibName, EntryPoint = "rlBlitFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void BlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask); /// Bind framebuffer (FBO) [LibraryImport(NativeLibName, EntryPoint = "rlBindFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void BindFramebuffer(uint target, uint framebuffer); /// Activate multiple draw color buffers [LibraryImport(NativeLibName, EntryPoint = "rlActiveDrawBuffers")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ActiveDrawBuffers(int count); // General render state /// Enable color blending [LibraryImport(NativeLibName, EntryPoint = "rlEnableColorBlend")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableColorBlend(); /// Disable color blending [LibraryImport(NativeLibName, EntryPoint = "rlDisableColorBlend")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableColorBlend(); /// Enable depth test [LibraryImport(NativeLibName, EntryPoint = "rlEnableDepthTest")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableDepthTest(); /// Disable depth test [LibraryImport(NativeLibName, EntryPoint = "rlDisableDepthTest")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableDepthTest(); /// Enable depth write [LibraryImport(NativeLibName, EntryPoint = "rlEnableDepthMask")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableDepthMask(); /// Disable depth write [LibraryImport(NativeLibName, EntryPoint = "rlDisableDepthMask")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableDepthMask(); /// Enable backface culling [LibraryImport(NativeLibName, EntryPoint = "rlEnableBackfaceCulling")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableBackfaceCulling(); /// Disable backface culling [LibraryImport(NativeLibName, EntryPoint = "rlDisableBackfaceCulling")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableBackfaceCulling(); /// Color mask control [LibraryImport(NativeLibName, EntryPoint = "rlColorMask")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ColorMask(CBool r, CBool g, CBool b, CBool a); /// Set face culling mode [LibraryImport(NativeLibName, EntryPoint = "rlSetCullFace")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetCullFace(int mode); /// Enable scissor test [LibraryImport(NativeLibName, EntryPoint = "rlEnableScissorTest")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableScissorTest(); /// Disable scissor test [LibraryImport(NativeLibName, EntryPoint = "rlDisableScissorTest")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableScissorTest(); /// Scissor test [LibraryImport(NativeLibName, EntryPoint = "rlScissor")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void Scissor(int x, int y, int width, int height); /// Enable point mode [LibraryImport(NativeLibName, EntryPoint = "rlEnablePointMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnablePointMode(); /// Disable point mode [LibraryImport(NativeLibName, EntryPoint = "rlDisablePointMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisablePointMode(); /// Set the point drawing size [LibraryImport(NativeLibName, EntryPoint = "rlSetPointSize")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetPointSize(float size); /// Get the point drawing size [LibraryImport(NativeLibName, EntryPoint = "rlGetPointSize")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial float GetPointSize(); /// Enable wire mode [LibraryImport(NativeLibName, EntryPoint = "rlEnableWireMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableWireMode(); /// Disable wire mode [LibraryImport(NativeLibName, EntryPoint = "rlDisableWireMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableWireMode(); /// Set the line drawing width [LibraryImport(NativeLibName, EntryPoint = "rlSetLineWidth")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetLineWidth(float width); /// Get the line drawing width [LibraryImport(NativeLibName, EntryPoint = "rlGetLineWidth")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial float GetLineWidth(); /// Enable line aliasing [LibraryImport(NativeLibName, EntryPoint = "rlEnableSmoothLines")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableSmoothLines(); /// Disable line aliasing [LibraryImport(NativeLibName, EntryPoint = "rlDisableSmoothLines")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableSmoothLines(); /// Enable stereo rendering [LibraryImport(NativeLibName, EntryPoint = "rlEnableStereoRender")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void EnableStereoRender(); /// Disable stereo rendering [LibraryImport(NativeLibName, EntryPoint = "rlDisableStereoRender")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DisableStereoRender(); /// Check if stereo render is enabled [LibraryImport(NativeLibName, EntryPoint = "rlIsStereoRenderEnabled")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool IsStereoRenderEnabled(); /// Clear color buffer with color [LibraryImport(NativeLibName, EntryPoint = "rlClearColor")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ClearColor(byte r, byte g, byte b, byte a); /// Clear used screen buffers (color and depth) [LibraryImport(NativeLibName, EntryPoint = "rlClearScreenBuffers")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ClearScreenBuffers(); /// Check and log OpenGL error codes [LibraryImport(NativeLibName, EntryPoint = "rlCheckErrors")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void CheckErrors(); /// Set blending mode [LibraryImport(NativeLibName, EntryPoint = "rlSetBlendMode")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetBlendMode(BlendMode mode); /// Set blending mode factor and equation (using OpenGL factors) [LibraryImport(NativeLibName, EntryPoint = "rlSetBlendFactors")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); /// Set blending mode factors and equations separately (using OpenGL factors) [LibraryImport(NativeLibName, EntryPoint = "rlSetBlendFactorsSeparate")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ); // ------------------------------------------------------------------------------------ // Functions Declaration - rlgl functionality // ------------------------------------------------------------------------------------ /// Initialize rlgl (buffers, shaders, textures, states) [LibraryImport(NativeLibName, EntryPoint = "rlglInit")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void GlInit(int width, int height); /// De-inititialize rlgl (buffers, shaders, textures) [LibraryImport(NativeLibName, EntryPoint = "rlglClose")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void GlClose(); /// Load OpenGL extensions [LibraryImport(NativeLibName, EntryPoint = "rlLoadExtensions")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void LoadExtensions(void* loader); /// Get OpenGL procedure address [LibraryImport(NativeLibName, EntryPoint = "rlGetProcAddress")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void* GetProcAddress(sbyte* procName); /// Get current OpenGL version [LibraryImport(NativeLibName, EntryPoint = "rlGetVersion")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial GlVersion GetVersion(); /// Set current framebuffer width [LibraryImport(NativeLibName, EntryPoint = "rlSetFramebufferWidth")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int SetFramebufferWidth(int width); /// Set current framebuffer height [LibraryImport(NativeLibName, EntryPoint = "rlSetFramebufferHeight")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int SetFramebufferHeight(int height); /// Get default framebuffer width [LibraryImport(NativeLibName, EntryPoint = "rlGetFramebufferWidth")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int GetFramebufferWidth(); /// Get default framebuffer height [LibraryImport(NativeLibName, EntryPoint = "rlGetFramebufferHeight")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int GetFramebufferHeight(); /// Get default texture [LibraryImport(NativeLibName, EntryPoint = "rlGetTextureIdDefault")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint GetTextureIdDefault(); /// Get default shader [LibraryImport(NativeLibName, EntryPoint = "rlGetShaderIdDefault")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint GetShaderIdDefault(); /// Get default shader locations [LibraryImport(NativeLibName, EntryPoint = "rlGetShaderLocsDefault")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int* GetShaderLocsDefault(); // Render batch management /// Load a render batch system
/// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
/// but this render batch API is exposed in case custom batches are required
[LibraryImport(NativeLibName, EntryPoint = "rlLoadRenderBatch")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial RenderBatch LoadRenderBatch(int numBuffers, int bufferElements); /// Unload render batch system [LibraryImport(NativeLibName, EntryPoint = "rlUnloadRenderBatch")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadRenderBatch(RenderBatch batch); /// Draw render batch data (Update->Draw->Reset) [LibraryImport(NativeLibName, EntryPoint = "rlDrawRenderBatch")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawRenderBatch(RenderBatch* batch); /// Set the active render batch for rlgl (NULL for default internal) [LibraryImport(NativeLibName, EntryPoint = "rlSetRenderBatchActive")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetRenderBatchActive(RenderBatch* batch); /// Update and draw internal render batch [LibraryImport(NativeLibName, EntryPoint = "rlDrawRenderBatchActive")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawRenderBatchActive(); /// Check internal buffer overflow for a given number of vertex [LibraryImport(NativeLibName, EntryPoint = "rlCheckRenderBatchLimit")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool CheckRenderBatchLimit(int vCount); /// Set current texture for render batch and check buffers limits [LibraryImport(NativeLibName, EntryPoint = "rlSetTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetTexture(uint id); // Vertex buffers management /// Load vertex array (vao) if supported [LibraryImport(NativeLibName, EntryPoint = "rlLoadVertexArray")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadVertexArray(); /// Load a vertex buffer attribute [LibraryImport(NativeLibName, EntryPoint = "rlLoadVertexBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadVertexBuffer(void* buffer, int size, CBool dynamic); /// Load a new attributes element buffer [LibraryImport(NativeLibName, EntryPoint = "rlLoadVertexBufferElement")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadVertexBufferElement(void* buffer, int size, CBool dynamic); /// Update GPU buffer with new data [LibraryImport(NativeLibName, EntryPoint = "rlUpdateVertexBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UpdateVertexBuffer(uint bufferId, void* data, int dataSize, int offset); /// Update vertex buffer elements with new data [LibraryImport(NativeLibName, EntryPoint = "rlUpdateVertexBufferElements")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UpdateVertexBufferElements(uint id, void* data, int dataSize, int offset); [LibraryImport(NativeLibName, EntryPoint = "rlUnloadVertexArray")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadVertexArray(uint vaoId); [LibraryImport(NativeLibName, EntryPoint = "rlUnloadVertexBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadVertexBuffer(uint vboId); /// Set vertex attribute data configuration [LibraryImport(NativeLibName, EntryPoint = "rlSetVertexAttribute")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetVertexAttribute( uint index, int compSize, int type, CBool normalized, int stride, int offset ); [LibraryImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDivisor")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetVertexAttributeDivisor(uint index, int divisor); /// Set vertex attribute default value [LibraryImport(NativeLibName, EntryPoint = "rlSetVertexAttributeDefault")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetVertexAttributeDefault(int locIndex, void* value, int attribType, int count); [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArray")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawVertexArray(int offset, int count); [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElements")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawVertexArrayElements(int offset, int count, void* buffer); [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArrayInstanced")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawVertexArrayInstanced(int offset, int count, int instances); [LibraryImport(NativeLibName, EntryPoint = "rlDrawVertexArrayElementsInstanced")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void DrawVertexArrayElementsInstanced( int offset, int count, void* buffer, int instances ); // Textures data management /// Load texture in GPU [LibraryImport(NativeLibName, EntryPoint = "rlLoadTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadTexture(void* data, int width, int height, PixelFormat format, int mipmapCount); /// Load depth texture/renderbuffer (to be attached to fbo) [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureDepth")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadTextureDepth(int width, int height, CBool useRenderBuffer); /// Load texture cubemap data [LibraryImport(NativeLibName, EntryPoint = "rlLoadTextureCubemap")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadTextureCubemap(void* data, int size, PixelFormat format, int mipmapCount); /// Update GPU texture with new data [LibraryImport(NativeLibName, EntryPoint = "rlUpdateTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UpdateTexture( uint id, int offsetX, int offsetY, int width, int height, PixelFormat format, void* data ); /// Get OpenGL internal formats [LibraryImport(NativeLibName, EntryPoint = "rlGetGlTextureFormats")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void GetGlTextureFormats( PixelFormat format, uint* glInternalFormat, uint* glFormat, uint* glType ); /// Get OpenGL internal formats [LibraryImport(NativeLibName, EntryPoint = "rlGetPixelFormatName")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial sbyte* GetPixelFormatName(PixelFormat format); /// Unload texture from GPU memory [LibraryImport(NativeLibName, EntryPoint = "rlUnloadTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadTexture(uint id); /// Generate mipmap data for selected texture [LibraryImport(NativeLibName, EntryPoint = "rlGenTextureMipmaps")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void GenTextureMipmaps(uint id, int width, int height, PixelFormat format, int* mipmaps); /// Read texture pixel data [LibraryImport(NativeLibName, EntryPoint = "rlReadTexturePixels")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void* ReadTexturePixels(uint id, int width, int height, PixelFormat format); /// Read screen pixel data (color buffer) [LibraryImport(NativeLibName, EntryPoint = "rlReadScreenPixels")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial byte* ReadScreenPixels(int width, int height); // Framebuffer management (fbo) /// Load an empty framebuffer [LibraryImport(NativeLibName, EntryPoint = "rlLoadFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadFramebuffer(); /// Attach texture/renderbuffer to a framebuffer [LibraryImport(NativeLibName, EntryPoint = "rlFramebufferAttach")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void FramebufferAttach( uint fboId, uint texId, FramebufferAttachType attachType, FramebufferAttachTextureType texType, int mipLevel ); /// Verify framebuffer is complete [LibraryImport(NativeLibName, EntryPoint = "rlFramebufferComplete")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial CBool FramebufferComplete(uint id); /// Delete framebuffer from GPU [LibraryImport(NativeLibName, EntryPoint = "rlUnloadFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadFramebuffer(uint id); /// Copy framebuffer pixel data to internal buffer [LibraryImport(NativeLibName, EntryPoint = "rlCopyFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void CopyFramebuffer(int x, int y, int width, int height, int format, void* pixels); /// Resize internal framebuffer [LibraryImport(NativeLibName, EntryPoint = "rlResizeFramebuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ResizeFramebuffer(int width, int height); // Shaders management /// Load (compile) shader and return shader id (type: RL_VERTEX_SHADER, RL_FRAGMENT_SHADER, RL_COMPUTE_SHADER) [LibraryImport(NativeLibName, EntryPoint = "rlLoadShader")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadShader(sbyte* vsCode, int type); /// Load shader from code strings [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgram")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadShaderProgram(sbyte* vsCode, sbyte* fsCode); /// Load shader program, using already loaded shader ids [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgramEx")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadShaderProgramEx(uint vsId, uint fsId); /// Load compute shader program [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderProgramCompute")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadShaderProgramCompute(uint csId); /// Unload shader, loaded with LoadShader() [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShader")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadShader(uint id); /// Unload shader program [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShaderProgram")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadShaderProgram(uint id); /// Get shader location uniform, requires shader program id [LibraryImport(NativeLibName, EntryPoint = "rlGetLocationUniform")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int GetLocationUniform(uint shaderId, sbyte* uniformName); /// Get shader location attribute, requires shader program id [LibraryImport(NativeLibName, EntryPoint = "rlGetLocationAttrib")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int GetLocationAttrib(uint shaderId, sbyte* attribName); /// Set shader value uniform [LibraryImport(NativeLibName, EntryPoint = "rlSetUniform")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetUniform(int locIndex, void* value, int uniformType, int count); /// Set shader value matrix [LibraryImport(NativeLibName, EntryPoint = "rlSetUniformMatrix")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetUniformMatrix(int locIndex, Matrix4x4 mat); /// Set shader value matrices [LibraryImport(NativeLibName, EntryPoint = "rlSetUniformMatrices")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetUniformMatrices(int locIndex, Matrix4x4* mat, int count); /// Set shader value sampler [LibraryImport(NativeLibName, EntryPoint = "rlSetUniformSampler")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetUniformSampler(int locIndex, uint textureId); /// Set shader currently active (id and locations) [LibraryImport(NativeLibName, EntryPoint = "rlSetShader")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetShader(uint id, int* locs); // Compute shader management /// Dispatch compute shader (equivalent to *draw* for graphics pilepine) [LibraryImport(NativeLibName, EntryPoint = "rlComputeShaderDispatch")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ComputeShaderDispatch(uint groupX, uint groupY, uint groupZ); // Shader buffer storage object management (ssbo) /// Load shader storage buffer object (SSBO) [LibraryImport(NativeLibName, EntryPoint = "rlLoadShaderBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint LoadShaderBuffer(uint size, void* data, int usageHint); /// Unload shader storage buffer object (SSBO) [LibraryImport(NativeLibName, EntryPoint = "rlUnloadShaderBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UnloadShaderBuffer(uint ssboId); /// Update SSBO buffer data [LibraryImport(NativeLibName, EntryPoint = "rlUpdateShaderBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void UpdateShaderBuffer(uint id, void* data, uint dataSize, uint offset); /// Bind SSBO buffer data [LibraryImport(NativeLibName, EntryPoint = "rlBindShaderBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void BindShaderBuffer(uint id, uint index); /// Read SSBO buffer data (GPU->CPU) [LibraryImport(NativeLibName, EntryPoint = "rlReadShaderBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ReadShaderBuffer(uint id, void* dest, uint count, uint offset); /// Copy SSBO data between buffers [LibraryImport(NativeLibName, EntryPoint = "rlCopyShaderBuffer")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void CopyShaderBuffer( uint destId, uint srcId, uint destOffset, uint srcOffset, uint count ); /// Get SSBO buffer size [LibraryImport(NativeLibName, EntryPoint = "rlGetShaderBufferSize")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial uint GetShaderBufferSize(uint id); // Buffer management /// Bind image texture [LibraryImport(NativeLibName, EntryPoint = "rlBindImageTexture")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void BindImageTexture(uint id, uint index, int format, CBool readOnly); // Matrix state management /// Get internal modelview matrix [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixModelview")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial Matrix4x4 GetMatrixModelview(); /// Get internal projection matrix [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixProjection")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial Matrix4x4 GetMatrixProjection(); /// Get internal accumulated transform matrix [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixTransform")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial Matrix4x4 GetMatrixTransform(); /// Get internal projection matrix for stereo render (selected eye) [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixProjectionStereo")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial Matrix4x4 GetMatrixProjectionStereo(int eye); /// Get internal view offset matrix for stereo render (selected eye) [LibraryImport(NativeLibName, EntryPoint = "rlGetMatrixViewOffsetStereo")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial Matrix4x4 GetMatrixViewOffsetStereo(int eye); /// Set a custom projection matrix (replaces internal projection matrix) [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixProjection")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetMatrixProjection(Matrix4x4 view); /// Set a custom modelview matrix (replaces internal modelview matrix) [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixModelview")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetMatrixModelView(Matrix4x4 proj); /// Set eyes projection matrices for stereo rendering [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixProjectionStereo")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetMatrixProjectionStereo(Matrix4x4 right, Matrix4x4 left); /// Set eyes view offsets matrices for stereo rendering [LibraryImport(NativeLibName, EntryPoint = "rlSetMatrixViewOffsetStereo")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void SetMatrixViewOffsetStereo(Matrix4x4 right, Matrix4x4 left); // Quick and dirty cube/quad buffers load->draw->unload /// Load and draw a cube [LibraryImport(NativeLibName, EntryPoint = "rlLoadDrawCube")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void LoadDrawCube(); /// Load and draw a quad [LibraryImport(NativeLibName, EntryPoint = "rlLoadDrawQuad")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void LoadDrawQuad(); }