glu

package
v0.0.0-...-2ef904a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2016 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package glu provides OpenGL utility functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	Black   = mgl32.Vec4{0, 0, 0, 1}
	White   = mgl32.Vec4{1, 1, 1, 1}
	Red     = mgl32.Vec4{1, 0, 0, 1}
	Green   = mgl32.Vec4{0, 1, 0, 1}
	Blue    = mgl32.Vec4{0, 0, 1, 1}
	Yellow  = mgl32.Vec4{1, 1, 0, 1}
	Cyan    = mgl32.Vec4{0, 1, 1, 1}
	Magenta = mgl32.Vec4{1, 0, 1, 1}
	Grey    = mgl32.Vec4{0.5, 0.5, 0.5, 1}
)

Predefined colors

View Source
var Debug = false

If debug mode is set then check for GL errors after each call

Functions

func CheckError

func CheckError()

Check for GL errors

func Clamp

func Clamp(x, min, max float32) float32

Force value into range from min to max

func Clear

func Clear(bg mgl32.Vec4)

Clear the screen ready for draing

func GLRef

func GLRef() *GL.GL

Reference to GL function pointers

func Init

func Init(glptr *GL.GL)

Init method should be called to set the pointer to GL functions

Types

type Attrib

type Attrib struct {
	Name   string
	Size   int
	Offset int
}

type Polar

type Polar struct {
	R, Theta, Phi float32
}

Polar type represents polar coordinates

func (*Polar) Clamp

func (p *Polar) Clamp()

bring phi in range 0->360 and theta in range 1->179 degrees

func (*Polar) Set

func (p *Polar) Set(vec mgl32.Vec3) *Polar

Convert vector to polar coords

func (Polar) Vec3

func (p Polar) Vec3() mgl32.Vec3

Convert polar coords to vector

func (Polar) Vec4

func (p Polar) Vec4(w float32) mgl32.Vec4

type Program

type Program struct {
	// contains filtered or unexported fields
}

Type to encapsulate opengl shader program.

func NewProgram

func NewProgram(vertexShader, fragmentShader string, attr []Attrib, stride int) (p *Program, err error)

NewProgram compiles and links a shader. Args are vertex shader, fragment shader source

func (*Program) Set

func (p *Program) Set(name string, v ...interface{})

Set sets the specified uniform value for the program.

func (*Program) SetArray

func (p *Program) SetArray(arr string, index int, v ...interface{})

Set an element in a uniform array arr[index].field

func (*Program) Uniform

func (p *Program) Uniform(typ string, names ...string)

Uniform adds one or more uniforms of the given type

func (*Program) UniformArray

func (p *Program) UniformArray(size int, typ string, names ...string)

UniformArray adds one or more uniforms arrays of the given type

func (*Program) Use

func (p *Program) Use()

Use sets this as the current program.

type Texture

type Texture interface {
	Activate(id int)
	Dims() []int
}

Texture interface type

type Texture2D

type Texture2D struct {
	// contains filtered or unexported fields
}

func NewTexture2D

func NewTexture2D(clamp bool) Texture2D

NewTexture2D creates a new 2D opengl texture. If srgba is set then it is converted to linear RGB space. If clamp is set then clamp to edge, else will wrap texture.

func (Texture2D) Activate

func (t Texture2D) Activate(id int)

func (Texture2D) Dims

func (t Texture2D) Dims() []int

func (Texture2D) SetImage

func (t Texture2D) SetImage(r io.Reader, conv img.ImageConvert) (Texture2D, error)

SetImage loads an image from an io.Reader

func (Texture2D) SetImageFile

func (t Texture2D) SetImageFile(file string, conv img.ImageConvert) (Texture2D, error)

SetImageFile loads an image from a file

type Texture3D

type Texture3D struct {
	// contains filtered or unexported fields
}

func NewTexture3D

func NewTexture3D() Texture3D

NewTexture3D creates a 3D texture mapping.

func (Texture3D) Activate

func (t Texture3D) Activate(id int)

func (Texture3D) Dims

func (t Texture3D) Dims() []int

func (Texture3D) SetImage

func (t Texture3D) SetImage(r io.Reader, conv img.ImageConvert, dims []int) (Texture3D, error)

SetImage loads an image. dims is required to set the x,y,z mapping.

func (Texture3D) SetImageFile

func (t Texture3D) SetImageFile(file string, conv img.ImageConvert, dims []int) (Texture3D, error)

SetImageFile loads an image from a file

type TextureCube

type TextureCube struct {
	// contains filtered or unexported fields
}

func NewTextureCube

func NewTextureCube() TextureCube

NewTextureCube creates a new cubemap texture. If srgba is set then it is converted to linear RGB space.

func (TextureCube) Activate

func (t TextureCube) Activate(id int)

func (TextureCube) Dims

func (t TextureCube) Dims() []int

func (TextureCube) SetImage

func (t TextureCube) SetImage(r io.Reader, conv img.ImageConvert, index int) (TextureCube, error)

SetImage loads an image, if srgba is set then it is converted to linear RGB space. The index is the number of the image in the cubemap.

func (TextureCube) SetImageFile

func (t TextureCube) SetImageFile(file string, conv img.ImageConvert, index int) (TextureCube, error)

SetImageFile loads an image from a file. The index is the number of the image in the cubemap.

type VertexArray

type VertexArray struct {
	// contains filtered or unexported fields
}

an array of buffer data

func ArrayBuffer

func ArrayBuffer(data []float32, vertexSize int) *VertexArray

ArrayBuffer creates a new empty Vertex array with associated data. Size is the numer of size of each vertex in words.

func ElementArrayBuffer

func ElementArrayBuffer(data []uint32) *VertexArray

ElementArrayBuffer creates a new empty Vertex array with associated data.

func (*VertexArray) Draw

func (a *VertexArray) Draw(mode glbase.Enum, winding glbase.Enum)

Draw all of the elements in the array buffer or element array

func (*VertexArray) Enable

func (a *VertexArray) Enable()

Make buffer current

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL