1 module evael.graphics.GL; 2 3 debug import dnogc.Utils; 4 5 public import derelict.opengl; 6 7 struct gl 8 { 9 static string file = __FILE__; 10 static int line = __LINE__; 11 12 @nogc 13 static auto ref opDispatch(string name, Args...)(Args args) nothrow 14 { 15 debug 16 { 17 scope (exit) 18 { 19 immutable uint error = glGetError(); 20 21 if (error != GL_NO_ERROR) 22 { 23 dln(file, ", ", line, " , gl", name, " : ", error); 24 } 25 } 26 } 27 28 return mixin("gl" ~ name ~ "(args)"); 29 } 30 } 31 32 public 33 { 34 enum BufferType 35 { 36 VertexBuffer = GL_ARRAY_BUFFER, 37 IndexBuffer = GL_ELEMENT_ARRAY_BUFFER, 38 FrameBuffer = GL_FRAMEBUFFER 39 } 40 41 enum PrimitiveType 42 { 43 Triangle = GL_TRIANGLES, 44 TriangleStrip = GL_TRIANGLE_STRIP, 45 TriangleFan = GL_TRIANGLE_FAN, 46 Lines = GL_LINES, 47 LineStrip = GL_LINE_STRIP, 48 LineLoop = GL_LINE_LOOP, 49 Unfilled = LineLoop, 50 Circle = TriangleFan, 51 Points = GL_POINTS 52 } 53 54 enum PolygonMode 55 { 56 Line = GL_LINE, 57 Point = GL_POINT, 58 Fill = GL_FILL 59 } 60 61 enum BufferUsage 62 { 63 StreamDraw = GL_STREAM_DRAW, 64 StreamRead = GL_STREAM_READ, 65 StreamCopy = GL_STREAM_COPY, 66 StaticDraw = GL_STATIC_DRAW, 67 StaticRead = GL_STATIC_READ, 68 StaticCopy = GL_STATIC_COPY, 69 DynamicDraw = GL_DYNAMIC_DRAW, 70 DynamicRead = GL_DYNAMIC_READ, 71 DynamicCopy = GL_DYNAMIC_COPY 72 } 73 74 enum TextureTarget 75 { 76 Texture2D = GL_TEXTURE_2D, 77 TextureRectangle = GL_TEXTURE_RECTANGLE, 78 TextureArray = GL_TEXTURE_2D_ARRAY 79 } 80 81 enum EnableCap 82 { 83 DepthTest = GL_DEPTH_TEST, 84 RasterizeDiscard = GL_RASTERIZER_DISCARD, 85 Texture2D = GL_TEXTURE_2D, 86 Blend = GL_BLEND, 87 } 88 89 enum ProjectionType : byte 90 { 91 Perspective, 92 Orthographic, 93 } 94 95 enum ShaderType 96 { 97 Vertex = GL_VERTEX_SHADER, 98 Fragment = GL_FRAGMENT_SHADER, 99 Geometry = GL_GEOMETRY_SHADER, 100 } 101 102 enum GLType 103 { 104 Float = GL_FLOAT, 105 UByte = GL_UNSIGNED_BYTE 106 } 107 }