1 /** 2 * Basic geometric 3D shapes drawing functions 3 */ 4 module bindbc.raylib.bind.rlgl; 5 6 import bindbc.raylib.config; 7 import bindbc.raylib.types; 8 9 version (BindRaylib_Static) { 10 extern (C) @nogc nothrow { 11 } 12 } else { 13 extern (C) @nogc nothrow { 14 //------------------------------------------------------------------------------------ 15 // Functions Declaration - Matrix operations 16 //------------------------------------------------------------------------------------ 17 alias prlMatrixMode = void function(int mode); // Choose the current matrix to be transformed 18 alias prlPushMatrix = void function(); // Push the current matrix to stack 19 alias prlPopMatrix = void function(); // Pop lattest inserted matrix from stack 20 alias prlLoadIdentity = void function(); // Reset current matrix to identity matrix 21 alias prlTranslatef = void function(float x, float y, float z); // Multiply the current matrix by a translation matrix 22 alias prlRotatef = void function(float angleDeg, float x, float y, float z); // Multiply the current matrix by a rotation matrix 23 alias prlScalef = void function(float x, float y, float z); // Multiply the current matrix by a scaling matrix 24 alias prlMultMatrixf = void function(float* matf); // Multiply the current matrix by another matrix 25 alias prlFrustum = void function(double left, double right, double bottom, double top, double znear, double zfar); 26 alias prlOrtho = void function(double left, double right, double bottom, double top, double znear, double zfar); 27 alias prlViewport = void function(int x, int y, int width, int height); // Set the viewport area 28 29 //------------------------------------------------------------------------------------ 30 // Functions Declaration - Vertex level operations 31 //------------------------------------------------------------------------------------ 32 alias prlBegin = void function(int mode); // Initialize drawing mode (how to organize vertex) 33 alias prlEnd = void function(); // Finish vertex providing 34 alias prlVertex2i = void function(int x, int y); // Define one vertex (position) - 2 int 35 alias prlVertex2f = void function(float x, float y); // Define one vertex (position) - 2 float 36 alias prlVertex3f = void function(float x, float y, float z); // Define one vertex (position) - 3 float 37 alias prlTexCoord2f = void function(float x, float y); // Define one vertex (texture coordinate) - 2 float 38 alias prlNormal3f = void function(float x, float y, float z); // Define one vertex (normal) - 3 float 39 alias prlColor4ub = void function(char r, char g, char b, char a); // Define one vertex (color) - 4 byte 40 alias prlColor3f = void function(float x, float y, float z); // Define one vertex (color) - 3 float 41 alias prlColor4f = void function(float x, float y, float z, float w); // Define one vertex (color) - 4 float 42 43 //------------------------------------------------------------------------------------ 44 // Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2) 45 // NOTE: This functions are used to completely abstract raylib code from OpenGL layer 46 //------------------------------------------------------------------------------------ 47 alias prlEnableTexture = void function(uint id); // Enable texture usage 48 alias prlDisableTexture = void function(); // Disable texture usage 49 alias prlTextureParameters = void function(uint id, int param, int value); // Set texture parameters (filter, wrap) 50 51 alias prlEnableDepthTest = void function(); // Enable depth test 52 alias prlDisableDepthTest = void function(); // Disable depth test 53 alias prlEnableBackfaceCulling = void function(); // Enable backface culling 54 alias prlDisableBackfaceCulling = void function(); // Disable backface culling 55 alias prlEnableScissorTest = void function(); // Enable scissor test 56 alias prlDisableScissorTest = void function(); // Disable scissor test 57 alias prlScissor = void function(int x, int y, int width, int height); // Scissor test 58 alias prlEnableWireMode = void function(); // Enable wire mode 59 alias prlDisableWireMode = void function(); // Disable wire mode 60 61 alias prlClearColor = void function(char r, char g, char b, char a); // Clear color buffer with color 62 alias prlClearScreenBuffers = void function(); // Clear used screen buffers (color and depth) 63 alias prlUpdateBuffer = void function(int bufferId, void* data, int dataSize); // Update GPU buffer with new data 64 alias prlLoadAttribBuffer = uint function(uint vaoId, int shaderLoc, void* buffer, int size, bool dynamic); // Load a new attributes buffer 65 66 //------------------------------------------------------------------------------------ 67 // Functions Declaration - rlgl functionality 68 //------------------------------------------------------------------------------------ 69 alias prlglInit = void function(int width, int height); // Initialize rlgl (buffers, shaders, textures, states) 70 alias prlglClose = void function(); // De-inititialize rlgl (buffers, shaders, textures) 71 alias prlglDraw = void function(); // Update and draw default internal buffers 72 73 alias prlGetVersion = int function(); // Returns current OpenGL version 74 alias prlCheckBufferLimit = bool function(int vCount); // Check internal buffer overflow for a given number of vertex 75 alias prlSetDebugMarker = void function(const char* text); // Set debug marker for analysis 76 alias prlLoadExtensions = void function(void* loader); // Load OpenGL extensions 77 78 // Textures data management 79 alias prlLoadTexture = uint function(void* data, int width, int height, int format, int mipmapCount); // Load texture in GPU 80 alias prlLoadTextureCubemap = uint function(void* data, int size, int format); // Load texture cubemap 81 alias prlGetGlTextureFormats = void function(int format, uint* glInternalFormat, uint* glFormat, uint* glType); // Get OpenGL internal formats 82 alias prlUnloadTexture = void function(uint id); // Unload texture from GPU memory 83 84 alias prlGenerateMipmaps = void function(Texture2D* texture); // Generate mipmap data for selected texture 85 alias prlReadTexturePixels = void* function(Texture2D texture); // Read texture pixel data 86 alias prlReadScreenPixels = char* function(int width, int height); // Read screen pixel data (color buffer) 87 88 // Vertex data management 89 alias prlLoadMesh = void function(Mesh* mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids 90 alias prlUpdateMesh = void function(Mesh mesh, int buffer, int count); // Update vertex or index data on GPU (upload new data to one buffer) 91 alias prlUpdateMeshAt = void function(Mesh mesh, int buffer, int count, int index); // Update vertex or index data on GPU, at index 92 alias prlDrawMesh = void function(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform 93 alias prlUnloadMesh = void function(Mesh mesh); // Unload mesh data from CPU and GPU 94 95 } 96 __gshared { 97 prlMatrixMode rlMatrixMode; 98 prlPushMatrix rlPushMatrix; 99 prlPopMatrix rlPopMatrix; 100 prlLoadIdentity rlLoadIdentity; 101 prlTranslatef rlTranslatef; 102 prlRotatef rlRotatef; 103 prlScalef rlScalef; 104 prlMultMatrixf rlMultMatrixf; 105 prlFrustum rlFrustum; 106 prlOrtho rlOrtho; 107 prlViewport rlViewport; 108 prlBegin rlBegin; 109 prlEnd rlEnd; 110 prlVertex2i rlVertex2i; 111 prlVertex2f rlVertex2f; 112 prlVertex3f rlVertex3f; 113 prlTexCoord2f rlTexCoord2f; 114 prlNormal3f rlNormal3f; 115 prlColor4ub rlColor4ub; 116 prlColor3f rlColor3f; 117 prlColor4f rlColor4f; 118 prlEnableTexture rlEnableTexture; 119 prlDisableTexture rlDisableTexture; 120 prlTextureParameters rlTextureParameters; 121 prlEnableDepthTest rlEnableDepthTest; 122 prlDisableDepthTest rlDisableDepthTest; 123 prlEnableBackfaceCulling rlEnableBackfaceCulling; 124 prlDisableBackfaceCulling rlDisableBackfaceCulling; 125 prlEnableScissorTest rlEnableScissorTest; 126 prlDisableScissorTest rlDisableScissorTest; 127 prlScissor rlScissor; 128 prlEnableWireMode rlEnableWireMode; 129 prlDisableWireMode rlDisableWireMode; 130 prlClearColor rlClearColor; 131 prlClearScreenBuffers rlClearScreenBuffers; 132 prlUpdateBuffer rlUpdateBuffer; 133 prlLoadAttribBuffer rlLoadAttribBuffer; 134 prlglInit rlglInit; 135 prlglClose rlglClose; 136 prlglDraw rlglDraw; 137 prlGetVersion rlGetVersion; 138 prlCheckBufferLimit rlCheckBufferLimit; 139 prlSetDebugMarker rlSetDebugMarker; 140 prlLoadExtensions rlLoadExtensions; 141 prlLoadTexture rlLoadTexture; 142 prlLoadTextureCubemap rlLoadTextureCubemap; 143 prlGetGlTextureFormats rlGetGlTextureFormats; 144 prlUnloadTexture rlUnloadTexture; 145 prlGenerateMipmaps rlGenerateMipmaps; 146 prlReadTexturePixels rlReadTexturePixels; 147 prlReadScreenPixels rlReadScreenPixels; 148 prlLoadMesh rlLoadMesh; 149 prlUpdateMesh rlUpdateMesh; 150 prlUpdateMeshAt rlUpdateMeshAt; 151 prlDrawMesh rlDrawMesh; 152 prlUnloadMesh rlUnloadMesh; 153 } 154 155 static if (raylibSupport > RaylibSupport.raylib300_70) { 156 extern (C) @nogc nothrow { 157 alias prlEnableShader = void function(uint id); // Enable shader program usage 158 alias prlDisableShader = void function(); // Disable shader program usage 159 alias prlEnableFramebuffer = void function(uint id); // Enable render texture (fbo) 160 alias prlDisableFramebuffer = void function(); // Disable render texture (fbo), return to default framebuffer 161 alias prlCheckErrors = void function(); // Check and log OpenGL error codes 162 alias prlSetBlendMode = void function(int glSrcFactor, int glDstFactor, int glEquation); // // Set blending mode factor and equation (using OpenGL factors) 163 alias prlLoadTextureDepth = uint function(int width, int height, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) 164 alias prlUpdateTexture = void function(uint id, int offsetX, int offsetY, int width, int height, int format, const(void)* data); // Update GPU texture with new data 165 166 // Framebuffer management (fbo) 167 alias prlLoadFramebuffer = uint function(int width, int height); // Load an empty framebuffer 168 alias prlFramebufferAttach = void function(uint fboId, uint texId, int attachType, int texType); // Attach texture/renderbuffer to a framebuffer 169 alias prlFramebufferComplete = bool function(uint id); // Verify framebuffer is complete 170 alias prlUnloadFramebuffer = void function(uint id); // Delete framebuffer from GPU 171 alias prlDrawMeshInstanced = void function(Mesh mesh, Material material, Matrix* transforms, int count); // Draw a 3d mesh with material and transform 172 } 173 __gshared { 174 prlEnableShader rlEnableShader; 175 prlDisableShader rlDisableShader; 176 prlEnableFramebuffer rlEnableFramebuffer; 177 prlDisableFramebuffer rlDisableFramebuffer; 178 prlCheckErrors rlCheckErrors; 179 prlSetBlendMode rlSetBlendMode; 180 prlLoadTextureDepth rlLoadTextureDepth; 181 prlUpdateTexture rlUpdateTexture; 182 183 prlLoadFramebuffer rlLoadFramebuffer; 184 prlFramebufferAttach rlFramebufferAttach; 185 prlFramebufferComplete rlFramebufferComplete; 186 prlUnloadFramebuffer rlUnloadFramebuffer; 187 prlDrawMeshInstanced rlDrawMeshInstanced; 188 } 189 } else { 190 // 300, 300_70 191 extern (C) @nogc nothrow { 192 alias prlEnableRenderTexture = void function(uint id); // Enable render texture (fbo) 193 alias prlDisableRenderTexture = void function(); // Disable render texture (fbo), return to default framebufferP 194 alias prlDeleteTextures = void function(uint id); // Delete OpenGL texture from GPU 195 alias prlDeleteRenderTextures = void function(RenderTexture2D target); // Delete render textures (fbo) from GPU 196 alias prlDeleteShader = void function(uint id); // Delete OpenGL shader program from GPU 197 alias prlDeleteVertexArrays = void function(uint id); // Unload vertex data (VAO) from GPU memory 198 alias prlDeleteBuffers = void function(uint id); // Unload vertex data (VBO) from GPU memory 199 alias prlUnproject = Vector3 function(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates 200 alias prlLoadTextureDepth = uint function(int width, int height, int bits, bool useRenderBuffer); // Load depth texture/renderbuffer (to be attached to fbo) 201 alias prlUpdateTexture = void function(uint id, int width, int height, int format, const(void)* data); // Update GPU texture with new data 202 alias prlLoadRenderTexture = RenderTexture2D function(int width, int height, int format, int depthBits, bool useDepthTexture); // Load a render texture (with color and depth attachments) 203 alias prlRenderTextureAttach = void function(RenderTexture target, uint id, int attachType); // Attach texture/renderbuffer to an fbo 204 alias prlRenderTextureComplete = bool function(RenderTexture target); // Verify render texture is complete 205 } 206 207 __gshared { 208 prlEnableRenderTexture rlEnableRenderTexture; 209 prlDisableRenderTexture rlDisableRenderTexture; 210 prlDeleteTextures rlDeleteTextures; 211 prlDeleteRenderTextures rlDeleteRenderTextures; 212 prlDeleteShader rlDeleteShader; 213 prlDeleteVertexArrays rlDeleteVertexArrays; 214 prlDeleteBuffers rlDeleteBuffers; 215 prlUnproject rlUnproject; 216 prlLoadTextureDepth rlLoadTextureDepth; 217 prlUpdateTexture rlUpdateTexture; 218 prlLoadRenderTexture rlLoadRenderTexture; 219 prlRenderTextureAttach rlRenderTextureAttach; 220 prlRenderTextureComplete rlRenderTextureComplete; 221 } 222 } 223 }