github.com/provpn/mobile@v0.0.0-20210315122651-28c475f89f6c/gl/types_prod.go (about) 1 // Copyright 2014 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build (darwin || linux || openbsd || windows) && !gldebug 6 // +build darwin linux openbsd windows 7 // +build !gldebug 8 9 package gl 10 11 import "fmt" 12 13 // Enum is equivalent to GLenum, and is normally used with one of the 14 // constants defined in this package. 15 type Enum uint32 16 17 // Types are defined a structs so that in debug mode they can carry 18 // extra information, such as a string name. See typesdebug.go. 19 20 // Attrib identifies the location of a specific attribute variable. 21 type Attrib struct { 22 Value uint 23 } 24 25 // Program identifies a compiled shader program. 26 type Program struct { 27 // Init is set by CreateProgram, as some GL drivers (in particular, 28 // ANGLE) return true for glIsProgram(0). 29 Init bool 30 Value uint32 31 } 32 33 // Shader identifies a GLSL shader. 34 type Shader struct { 35 Value uint32 36 } 37 38 // Buffer identifies a GL buffer object. 39 type Buffer struct { 40 Value uint32 41 } 42 43 // Framebuffer identifies a GL framebuffer. 44 type Framebuffer struct { 45 Value uint32 46 } 47 48 // A Renderbuffer is a GL object that holds an image in an internal format. 49 type Renderbuffer struct { 50 Value uint32 51 } 52 53 // A Texture identifies a GL texture unit. 54 type Texture struct { 55 Value uint32 56 } 57 58 // Uniform identifies the location of a specific uniform variable. 59 type Uniform struct { 60 Value int32 61 } 62 63 // A VertexArray is a GL object that holds vertices in an internal format. 64 type VertexArray struct { 65 Value uint32 66 } 67 68 func (v Attrib) c() uintptr { return uintptr(v.Value) } 69 func (v Enum) c() uintptr { return uintptr(v) } 70 func (v Program) c() uintptr { 71 if !v.Init { 72 ret := uintptr(0) 73 ret-- 74 return ret 75 } 76 return uintptr(v.Value) 77 } 78 func (v Shader) c() uintptr { return uintptr(v.Value) } 79 func (v Buffer) c() uintptr { return uintptr(v.Value) } 80 func (v Framebuffer) c() uintptr { return uintptr(v.Value) } 81 func (v Renderbuffer) c() uintptr { return uintptr(v.Value) } 82 func (v Texture) c() uintptr { return uintptr(v.Value) } 83 func (v Uniform) c() uintptr { return uintptr(v.Value) } 84 func (v VertexArray) c() uintptr { return uintptr(v.Value) } 85 86 func (v Attrib) String() string { return fmt.Sprintf("Attrib(%d)", v.Value) } 87 func (v Program) String() string { return fmt.Sprintf("Program(%d)", v.Value) } 88 func (v Shader) String() string { return fmt.Sprintf("Shader(%d)", v.Value) } 89 func (v Buffer) String() string { return fmt.Sprintf("Buffer(%d)", v.Value) } 90 func (v Framebuffer) String() string { return fmt.Sprintf("Framebuffer(%d)", v.Value) } 91 func (v Renderbuffer) String() string { return fmt.Sprintf("Renderbuffer(%d)", v.Value) } 92 func (v Texture) String() string { return fmt.Sprintf("Texture(%d)", v.Value) } 93 func (v Uniform) String() string { return fmt.Sprintf("Uniform(%d)", v.Value) } 94 func (v VertexArray) String() string { return fmt.Sprintf("VertexArray(%d)", v.Value) }