| 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 |
|
| 7 |
package gl |
| 8 |
|
| 9 |
import "fmt" |
| 10 |
|
| 11 |
// Enum is equivalent to GLenum, and is normally used with one of the |
| 12 |
// constants defined in this package. |
| 13 |
type Enum uint32 |
| 14 |
|
| 15 |
// Types are defined a structs so that in debug mode they can carry |
| 16 |
// extra information, such as a string name. See typesdebug.go. |
| 17 |
|
| 18 |
// Attrib identifies the location of a specific attribute variable. |
| 19 |
type Attrib struct { |
| 20 |
Value uint |
| 21 |
} |
| 22 |
|
| 23 |
// Program identifies a compiled shader program. |
| 24 |
type Program struct { |
| 25 |
// Init is set by CreateProgram, as some GL drivers (in particular, |
| 26 |
// ANGLE) return true for glIsProgram(0). |
| 27 |
Init bool |
| 28 |
Value uint32 |
| 29 |
} |
| 30 |
|
| 31 |
// Shader identifies a GLSL shader. |
| 32 |
type Shader struct { |
| 33 |
Value uint32 |
| 34 |
} |
| 35 |
|
| 36 |
// Buffer identifies a GL buffer object. |
| 37 |
type Buffer struct { |
| 38 |
Value uint32 |
| 39 |
} |
| 40 |
|
| 41 |
// Framebuffer identifies a GL framebuffer. |
| 42 |
type Framebuffer struct { |
| 43 |
Value uint32 |
| 44 |
} |
| 45 |
|
| 46 |
// A Renderbuffer is a GL object that holds an image in an internal format. |
| 47 |
type Renderbuffer struct { |
| 48 |
Value uint32 |
| 49 |
} |
| 50 |
|
| 51 |
// A Texture identifies a GL texture unit. |
| 52 |
type Texture struct { |
| 53 |
Value uint32 |
| 54 |
} |
| 55 |
|
| 56 |
// Uniform identifies the location of a specific uniform variable. |
| 57 |
type Uniform struct { |
| 58 |
Value int32 |
| 59 |
} |
| 60 |
|
| 61 |
// A VertexArray is a GL object that holds vertices in an internal format. |
| 62 |
type VertexArray struct { |
| 63 |
Value uint32 |
| 64 |
} |
| 65 |
|
| 66 |
func (v Attrib) c() uintptr { return uintptr(v.Value) } |
| 67 |
func (v Enum) c() uintptr { return uintptr(v) } |
| 68 |
func (v Program) c() uintptr { |
| 69 |
if !v.Init { |
| 70 |
ret := uintptr(0) |
| 71 |
ret-- |
| 72 |
return ret |
| 73 |
} |
| 74 |
return uintptr(v.Value) |
| 75 |
} |
| 76 |
func (v Shader) c() uintptr { return uintptr(v.Value) } |
| 77 |
func (v Buffer) c() uintptr { return uintptr(v.Value) } |
| 78 |
func (v Framebuffer) c() uintptr { return uintptr(v.Value) } |
| 79 |
func (v Renderbuffer) c() uintptr { return uintptr(v.Value) } |
| 80 |
func (v Texture) c() uintptr { return uintptr(v.Value) } |
| 81 |
func (v Uniform) c() uintptr { return uintptr(v.Value) } |
| 82 |
func (v VertexArray) c() uintptr { return uintptr(v.Value) } |
| 83 |
|
| 84 |
func (v Attrib) String() string { return fmt.Sprintf("Attrib(%d)", v.Value) } |
| 85 |
func (v Program) String() string { return fmt.Sprintf("Program(%d)", v.Value) } |
| 86 |
func (v Shader) String() string { return fmt.Sprintf("Shader(%d)", v.Value) } |
| 87 |
func (v Buffer) String() string { return fmt.Sprintf("Buffer(%d)", v.Value) } |
| 88 |
func (v Framebuffer) String() string { return fmt.Sprintf("Framebuffer(%d)", v.Value) } |
| 89 |
func (v Renderbuffer) String() string { return fmt.Sprintf("Renderbuffer(%d)", v.Value) } |
| 90 |
func (v Texture) String() string { return fmt.Sprintf("Texture(%d)", v.Value) } |
| 91 |
func (v Uniform) String() string { return fmt.Sprintf("Uniform(%d)", v.Value) } |
| 92 |
func (v VertexArray) String() string { return fmt.Sprintf("VertexArray(%d)", v.Value) } |