1 module rlgl;
2 
3 import raylib;
4 
5 extern (C) @nogc nothrow:
6 //------------------------------------------------------------------------------------
7 // Functions Declaration - Matrix operations
8 //------------------------------------------------------------------------------------
9 void rlMatrixMode(int mode);                    // Choose the current matrix to be transformed
10 void rlPushMatrix();                        // Push the current matrix to stack
11 void rlPopMatrix();                         // Pop lattest inserted matrix from stack
12 void rlLoadIdentity();                      // Reset current matrix to identity matrix
13 void rlTranslatef(float x, float y, float z);   // Multiply the current matrix by a translation matrix
14 void rlRotatef(float angleDeg, float x, float y, float z);  // Multiply the current matrix by a rotation matrix
15 void rlScalef(float x, float y, float z);       // Multiply the current matrix by a scaling matrix
16 void rlMultMatrixf(float *matf);                // Multiply the current matrix by another matrix
17 void rlFrustum(double left, double right, double bottom, double top, double znear, double zfar);
18 void rlOrtho(double left, double right, double bottom, double top, double znear, double zfar);
19 void rlViewport(int x, int y, int width, int height); // Set the viewport area
20 
21 //------------------------------------------------------------------------------------
22 // Functions Declaration - Vertex level operations
23 //------------------------------------------------------------------------------------
24 void rlBegin(int mode);                         // Initialize drawing mode (how to organize vertex)
25 void rlEnd();                               // Finish vertex providing
26 void rlVertex2i(int x, int y);                  // Define one vertex (position) - 2 int
27 void rlVertex2f(float x, float y);              // Define one vertex (position) - 2 float
28 void rlVertex3f(float x, float y, float z);     // Define one vertex (position) - 3 float
29 void rlTexCoord2f(float x, float y);            // Define one vertex (texture coordinate) - 2 float
30 void rlNormal3f(float x, float y, float z);     // Define one vertex (normal) - 3 float
31 void rlColor4ub(byte r, byte g, byte b, byte a);    // Define one vertex (color) - 4 byte
32 void rlColor3f(float x, float y, float z);          // Define one vertex (color) - 3 float
33 void rlColor4f(float x, float y, float z, float w); // Define one vertex (color) - 4 float
34 
35 //------------------------------------------------------------------------------------
36 // Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2)
37 // NOTE: This functions are used to completely abstract raylib code from OpenGL layer
38 //------------------------------------------------------------------------------------
39 void rlEnableTexture(uint id);                  // Enable texture usage
40 void rlDisableTexture();                            // Disable texture usage
41 void rlTextureParameters(uint id, int param, int value); // Set texture parameters (filter, wrap)
42 void rlEnableRenderTexture(uint id);            // Enable render texture (fbo)
43 void rlDisableRenderTexture();                      // Disable render texture (fbo), return to default framebuffer
44 void rlEnableDepthTest();                           // Enable depth test
45 void rlDisableDepthTest();                          // Disable depth test
46 void rlEnableBackfaceCulling();                     // Enable backface culling
47 void rlDisableBackfaceCulling();                    // Disable backface culling
48 void rlEnableScissorTest();                         // Enable scissor test
49 void rlDisableScissorTest();                        // Disable scissor test
50 void rlScissor(int x, int y, int width, int height);    // Scissor test
51 void rlEnableWireMode();                            // Enable wire mode
52 void rlDisableWireMode();                           // Disable wire mode
53 void rlDeleteTextures(uint id);                 // Delete OpenGL texture from GPU
54 void rlDeleteRenderTextures(RenderTexture2D target);    // Delete render textures (fbo) from GPU
55 void rlDeleteShader(uint id);                   // Delete OpenGL shader program from GPU
56 void rlDeleteVertexArrays(uint id);             // Unload vertex data (VAO) from GPU memory
57 void rlDeleteBuffers(uint id);                  // Unload vertex data (VBO) from GPU memory
58 void rlClearColor(byte r, byte g, byte b, byte a);      // Clear color buffer with color
59 void rlClearScreenBuffers();                        // Clear used screen buffers (color and depth)
60 void rlUpdateBuffer(int bufferId, void *data, int dataSize); // Update GPU buffer with new data
61 uint rlLoadAttribBuffer(uint vaoId, int shaderLoc, void *buffer, int size, bool dynamic);   // Load a new attributes buffer
62 
63 //------------------------------------------------------------------------------------
64 // Functions Declaration - rlgl functionality
65 //------------------------------------------------------------------------------------
66 void rlglInit(int width, int height);           // Initialize rlgl (buffers, shaders, textures, states)
67 void rlglClose();                           // De-inititialize rlgl (buffers, shaders, textures)
68 void rlglDraw();                            // Update and draw default internal buffers
69 
70 int rlGetVersion();                         // Returns current OpenGL version
71 bool rlCheckBufferLimit(int vCount);            // Check internal buffer overflow for a given number of vertex
72 void rlSetDebugMarker(const char *text);        // Set debug marker for analysis
73 void rlLoadExtensions(void *loader);            // Load OpenGL extensions
74 Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view);  // Get world coordinates from screen coordinates
75 
76 // Textures data management
77 uint rlLoadTexture(void *data, int width, int height, int format, int mipmapCount); // Load texture in GPU
78 uint rlLoadTextureDepth(int width, int height, int bits, bool useRenderBuffer);     // Load depth texture/renderbuffer (to be attached to fbo)
79 uint rlLoadTextureCubemap(void *data, int size, int format);                        // Load texture cubemap
80 void rlUpdateTexture(uint id, int width, int height, int format, const void *data); // Update GPU texture with new data
81 void rlGetGlTextureFormats(int format, uint *glInternalFormat, uint *glFormat, uint *glType);  // Get OpenGL internal formats
82 void rlUnloadTexture(uint id);                              // Unload texture from GPU memory
83 
84 void rlGenerateMipmaps(Texture2D *texture);                         // Generate mipmap data for selected texture
85 void *rlReadTexturePixels(Texture2D texture);                       // Read texture pixel data
86 ubyte *rlReadScreenPixels(int width, int height);           // Read screen pixel data (color buffer)
87 
88 // Render texture management (fbo)
89 RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depthBits, bool useDepthTexture);    // Load a render texture (with color and depth attachments)
90 void rlRenderTextureAttach(RenderTexture target, uint id, int attachType);  // Attach texture/renderbuffer to an fbo
91 bool rlRenderTextureComplete(RenderTexture target);                 // Verify render texture is complete
92 
93 // Vertex data management
94 void rlLoadMesh(Mesh *mesh, bool dynamic);                          // Upload vertex data into GPU and provided VAO/VBO ids
95 void rlUpdateMesh(Mesh mesh, int buffer, int num);                  // Update vertex or index data on GPU (upload new data to one buffer)
96 void rlUpdateMeshAt(Mesh mesh, int buffer, int num, int index);     // Update vertex or index data on GPU, at index
97 void rlDrawMesh(Mesh mesh, Material material, Matrix transform);    // Draw a 3d mesh with material and transform
98 void rlUnloadMesh(Mesh mesh);                                       // Unload mesh data from CPU and GPU