ogl - A safe, DSA-only OpenGL 4.5+ wrapper for Nim
Imports the standard Nim opengl bindings internally but only exposes the Direct State Access (DSA) subset along with type-safe enums and distinct handle types. The legacy bind-to-edit API is completely hidden.
Types
AttribType {.pure.} = enum Byte = 5120, UByte = 5121, Short = 5122, UShort = 5123, Int = 5124, UInt = 5125, HalfFloat = 5131, Float = 5126, Double = 5130
- Source Edit
BlendFactor {.pure.} = enum Zero = 0, One = 1, SrcColor = 768, OneMinusSrcColor = 769, SrcAlpha = 770, OneMinusSrcAlpha = 771, DstAlpha = 772, OneMinusDstAlpha = 773, DstColor = 774, OneMinusDstColor = 775, ConstantColor = 32769, OneMinusConstantColor = 32770, ConstantAlpha = 32771, OneMinusConstantAlpha = 32772
- Source Edit
BlendOp {.pure.} = enum Add = 32774, Min = 32775, Max = 32776, Subtract = 32778, ReverseSubtract = 32779
- Source Edit
BufferFlag {.pure.} = enum MapRead, MapWrite, MapPersistent, MapCoherent, DynamicStorage, ClientStorage
- Source Edit
BufferUsage {.pure.} = enum StreamDraw = 35040, StreamRead = 35041, StreamCopy = 35042, StaticDraw = 35044, StaticRead = 35045, StaticCopy = 35046, DynamicDraw = 35048, DynamicRead = 35049, DynamicCopy = 35050
- Source Edit
Capability {.pure.} = enum CullFace = 2884, DepthTest = 2929, StencilTest = 2960, Blend = 3042, ScissorTest = 3089, Multisample = 32925, ProgramPointSize = 34370, SeamlessCubeMap = 34895, FramebufferSRGB = 36281
- Source Edit
CompareFunc {.pure.} = enum Never = 512, Less = 513, Equal = 514, LessOrEqual = 515, Greater = 516, NotEqual = 517, GreaterOrEqual = 518, Always = 519
- Source Edit
FbAttachment {.pure.} = enum DepthStencil = 33306, Color0 = 36064, Color1 = 36065, Color2 = 36066, Color3 = 36067, Color4 = 36068, Color5 = 36069, Color6 = 36070, Color7 = 36071, Depth = 36096, Stencil = 36128
- Source Edit
FbStatus {.pure.} = enum Undefined = 33305, Complete = 36053, IncompleteAttachment = 36054, IncompleteMissingAttachment = 36055, IncompleteDrawBuffer = 36059, IncompleteReadBuffer = 36060, Unsupported = 36061, IncompleteMultisample = 36182, IncompleteLayerTargets = 36264
- Source Edit
Framebuffer = distinct GLuint
- Source Edit
InternalFormat {.pure.} = enum R8 = 33321, RG8 = 33323, RGB8 = 32849, RGBA8 = 32856, SRGB8 = 35905, SRGBA8 = 35907, R16F = 33325, RG16F = 33327, RGB16F = 34843, RGBA16F = 34842, R32F = 33326, RG32F = 33328, RGB32F = 34837, RGBA32F = 34836, R8I = 33329, R8UI = 33330, R16I = 33331, R16UI = 33332, R32I = 33333, R32UI = 33334, Depth16 = 33189, Depth24 = 33190, Depth32F = 36012, Depth24Stencil8 = 35056, Depth32FStencil8 = 36013
- Source Edit
PixelFormat {.pure.} = enum Red = 6403, RG = 33319, RGB = 6407, BGR = 32992, RGBA = 6408, BGRA = 32993, DepthComponent = 6402, StencilIndex = 6401, DepthStencil = 34041
- Source Edit
PixelType {.pure.} = enum Byte = 5120, UByte = 5121, Short = 5122, UShort = 5123, Int = 5124, UInt = 5125, HalfFloat = 5131, Float = 5126
- Source Edit
Primitive {.pure.} = enum Points = 0, Lines = 1, LineLoop = 2, LineStrip = 3, Triangles = 4, TriangleStrip = 5, TriangleFan = 6, Patches = 14
- Source Edit
Renderbuffer = distinct GLuint
- Source Edit
ShaderKind {.pure.} = enum Fragment = 35632, Vertex = 35633, Geometry = 36313, TessEvaluation = 36487, TessControl = 36488, Compute = 37305
- Source Edit
TextureFilter {.pure.} = enum Nearest = 9728, Linear = 9729, NearestMipmapNearest = 9984, LinearMipmapNearest = 9985, NearestMipmapLinear = 9986, LinearMipmapLinear = 9987
- Source Edit
UniformLoc = distinct GLint
- Source Edit
VertexArray = distinct GLuint
- Source Edit
VertexAttrib = object location*: uint32 size*: int32 kind*: AttribType normalized*: bool
- Source Edit
Consts
InvalidUniform = -1'i32
- Source Edit
NoFramebuffer = 0'u
- Source Edit
NoRenderbuffer = 0'u
- Source Edit
NoVertexArray = 0'u
- Source Edit
Procs
proc `$`(x: Framebuffer): string {....raises: [], tags: [], forbids: [].}
- Source Edit
proc `$`(x: Renderbuffer): string {....raises: [], tags: [], forbids: [].}
- Source Edit
proc `$`(x: VertexArray): string {....raises: [], tags: [], forbids: [].}
- Source Edit
proc `==`(a, b: Framebuffer): bool {.borrow, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc `==`(a, b: Renderbuffer): bool {.borrow, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc `==`(a, b: UniformLoc): bool {.borrow, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc `==`(a, b: VertexArray): bool {.borrow, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc addBuffer(vao: VertexArray; buf: Buffer; attribs: openArray[VertexAttrib]; binding = 0) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc attachRenderbuffer(fb: Framebuffer; attachment: FbAttachment; rb: Renderbuffer) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc attachTexture(fb: Framebuffer; attachment: FbAttachment; tex: Texture; level = 0) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc attr(location, size: int; kind: AttribType; normalized = false): VertexAttrib {. ...raises: [], tags: [], forbids: [].}
- Source Edit
proc attr(location, size: int; T: typedesc[float32]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[float64]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[int8]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[int16]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[int32]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[uint8]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[uint16]): VertexAttrib
- Source Edit
proc attr(location, size: int; T: typedesc[uint32]): VertexAttrib
- Source Edit
proc bindFb(fb: Framebuffer) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc bindToUnit(s: Sampler; unit: int) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc bindToUnit(tex: Texture; unit: int) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc bindVao(vao: VertexArray) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc blendEquation(op: BlendOp) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc blendEquationSeparate(rgb, alpha: BlendOp) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc blendFunc(src, dst: BlendFactor) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha: BlendFactor) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc checkStatus(fb: Framebuffer): FbStatus {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc clearColor(r, g, b, a: float32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc clearDepth(depth: float64) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc clearStencil(value: int32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc createBuffer(): Buffer {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc createTexture2D(): Texture {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc depthFunc(f: CompareFunc) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc destroy(fb: var Framebuffer) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc destroy(rb: var Renderbuffer) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc destroy(vao: var VertexArray) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc disable(cap: Capability) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc disableAttrib(vao: VertexArray; location: int) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc drawArrays(mode: Primitive; first, count: int) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc drawArraysInstanced(mode: Primitive; first, count, instances: int) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc drawElements(mode: Primitive; count: int; indexType: IndexType; offset = 0) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc drawElementsInstanced(mode: Primitive; count: int; indexType: IndexType; instances: int; offset = 0) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc enable(cap: Capability) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc enableAttrib(vao: VertexArray; location: int) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc generateMipmaps(tex: Texture) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc initStorage(buf: Buffer; size: int; data: pointer; flags: set[BufferFlag]) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc initStorage[T](buf: Buffer; data: openArray[T]; flags: set[BufferFlag])
- Source Edit
proc magFilter=(s: Sampler; filter: TextureFilter) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc magFilter=(tex: Texture; filter: TextureFilter) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc maxAnisotropy=(s: Sampler; value: float32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc maxAnisotropy=(tex: Texture; value: float32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc minFilter=(s: Sampler; filter: TextureFilter) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc minFilter=(tex: Texture; filter: TextureFilter) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newBuffer(size: int; data: pointer; usage: BufferUsage): Buffer {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newBuffer(size: int; usage: BufferUsage): Buffer {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newBuffer[T](data: openArray[T]; usage: BufferUsage): Buffer
- Source Edit
proc newFramebuffer(): Framebuffer {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newProgram(shaders: varargs[Shader]): Program {. ...raises: [GLerror, OglError], tags: [], forbids: [].}
- Source Edit
proc newProgram(vertSource, fragSource: string): Program {. ...raises: [GLerror, OglError, GLerror, OglError], tags: [], forbids: [].}
- Convenience: compiles both shaders and links them into a program. Source Edit
proc newRenderbuffer(format: InternalFormat; width, height: int): Renderbuffer {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newRenderbufferMultisample(samples: int; format: InternalFormat; width, height: int): Renderbuffer {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newSampler(): Sampler {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newShader(kind: ShaderKind; source: string): Shader {. ...raises: [GLerror, OglError], tags: [], forbids: [].}
- Source Edit
proc newTexture2D(format: InternalFormat; width, height: int; levels = 1): Texture {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc newVertexArray(): VertexArray {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc polygonMode(face: Face; mode: FillMode) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setData(buf: Buffer; size: int; data: pointer; usage: BufferUsage) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setData[T](buf: Buffer; data: openArray[T]; usage: BufferUsage)
- Source Edit
proc setDrawBuffers(fb: Framebuffer; attachments: openArray[FbAttachment]) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setElementBuffer(vao: VertexArray; buf: Buffer) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setSubData(buf: Buffer; offset, size: int; data: pointer) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setSubData[T](buf: Buffer; offset: int; data: openArray[T])
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; value: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; value: int32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; x, y, z, w: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; x, y, z, w: int32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; x, y, z: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; x, y, z: int32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; x, y: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; loc: UniformLoc; x, y: int32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; name: string; value: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; name: string; value: int32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; name: string; x, y, z, w: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; name: string; x, y, z: float32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniform(prog: Program; name: string; x, y: float32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniformMat4(prog: Program; loc: UniformLoc; mat: ptr float32; transpose = false) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc setUniformMat4(prog: Program; loc: UniformLoc; mat: var array[16, float32]; transpose = false) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc stencilFunc(f: CompareFunc; reference: int32; mask: uint32) {. ...raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc stencilMask(mask: uint32) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc storage2D(tex: Texture; levels: int; format: InternalFormat; width, height: int) {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit
proc uniformLoc(prog: Program; name: string): UniformLoc {....raises: [GLerror], tags: [], forbids: [].}
- Source Edit