1 module evael.renderer.gl.gl_enum_converter; 2 3 import evael.renderer.enums; 4 import bindbc.opengl; 5 6 static class GLEnumConverter 7 { 8 @nogc 9 public static GLenum bufferType(BufferType type) nothrow 10 { 11 final switch(type) 12 { 13 case BufferType.Vertex: return GL_ARRAY_BUFFER; 14 case BufferType.Index: return GL_ELEMENT_ARRAY_BUFFER; 15 case BufferType.Uniform: return GL_UNIFORM_BUFFER; 16 } 17 } 18 19 @nogc 20 public static GLenum shaderType(ShaderType type) nothrow 21 { 22 final switch(type) 23 { 24 case ShaderType.Vertex: return GL_VERTEX_SHADER; 25 case ShaderType.Fragment: return GL_FRAGMENT_SHADER; 26 case ShaderType.Geometry: return GL_GEOMETRY_SHADER; 27 } 28 } 29 30 @nogc 31 public static GLenum attributeType(AttributeType type) nothrow 32 { 33 final switch(type) 34 { 35 case AttributeType.Float: return GL_FLOAT; 36 case AttributeType.UByte: return GL_UNSIGNED_BYTE; 37 } 38 } 39 40 @nogc 41 public static GLenum blendFactor(BlendFactor blendFactor) nothrow 42 { 43 final switch(blendFactor) 44 { 45 case BlendFactor.Zero : return GL_ZERO; 46 case BlendFactor.One : return GL_ONE; 47 case BlendFactor.SourceColor : return GL_SRC_COLOR; 48 case BlendFactor.InverseSourceColor : return GL_ONE_MINUS_SRC_COLOR; 49 case BlendFactor.DestinationColor : return GL_DST_COLOR; 50 case BlendFactor.InverseDestinationColor : return GL_ONE_MINUS_DST_COLOR; 51 case BlendFactor.SourceAlpha : return GL_SRC_ALPHA; 52 case BlendFactor.InverseSourceAlpha : return GL_ONE_MINUS_SRC_ALPHA; 53 case BlendFactor.DestinationAlpha : return GL_DST_ALPHA; 54 case BlendFactor.InverseDestinationAlpha : return GL_ONE_MINUS_DST_ALPHA; 55 } 56 } 57 58 @nogc 59 public static GLenum blendFunction(BlendFunction blendFunction) nothrow 60 { 61 final switch(blendFunction) 62 { 63 case BlendFunction.Add : return GL_FUNC_ADD; 64 case BlendFunction.Subtract : return GL_FUNC_SUBTRACT; 65 case BlendFunction.ReverseSubtract : return GL_FUNC_REVERSE_SUBTRACT; 66 case BlendFunction.Minimum : return GL_MIN; 67 case BlendFunction.Maximum : return GL_MAX; 68 } 69 } 70 }