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