render

package module
v0.0.0-...-f07c3fd Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: MIT Imports: 10 Imported by: 0

README

render

OpenGL convenience structs for Go

Godoc Build Status Go Report Card

Dependencies

  • Golang:
    • Requires 1.6+ binaries are required with the GOPATH environment variable specified and $GOPATH/bin in your PATH.
  • go-gl/gl:
    • A cgo compiler (typically gcc).
    • On Ubuntu/Debian-based systems, the libgl1-mesa-dev package.

Installation

glide get github.com/kbirk/render

Documentation

Index

Constants

View Source
const (
	// DefaultWrapS is the default wrap S parameter.
	DefaultWrapS = gl.CLAMP_TO_EDGE
	// DefaultWrapT is the default wrap T parameter.
	DefaultWrapT = gl.CLAMP_TO_EDGE
	// DefaultMinFilter is the default min filter parameter.
	DefaultMinFilter = gl.NEAREST
	// DefaultMagFilter is the default mag filter parameter.
	DefaultMagFilter = gl.NEAREST
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributePointer

type AttributePointer struct {
	Index      uint32
	Size       int32
	Type       uint32
	ByteStride int32
	ByteOffset int
}

AttributePointer represents a vertex attribute pointer.

type Command

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

Command represents a render command.

func (*Command) Execute

func (c *Command) Execute(shader *Shader) error

Execute executes the render command.

func (*Command) Renderable

func (c *Command) Renderable(renderable *Renderable)

Renderable sets a renderable to be drawn.

func (*Command) Texture

func (c *Command) Texture(location uint32, texture *Texture)

Texture sets a texture to be bound.

func (*Command) Uniform

func (c *Command) Uniform(name string, value interface{})

Uniform sets a uniform to be buffered.

type FrameBuffer

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

FrameBuffer represents a framebuffer object

func NewFrameBuffer

func NewFrameBuffer() *FrameBuffer

NewFrameBuffer instantiates and returns a new framebuffer instance.

func (*FrameBuffer) AttachTexture

func (f *FrameBuffer) AttachTexture(attachment uint32, texture *Texture) error

AttachTexture attaches the provided texture to the provided attachment id.

func (*FrameBuffer) Bind

func (f *FrameBuffer) Bind()

Bind binds the framebuffer object.

func (*FrameBuffer) BindForDraw

func (f *FrameBuffer) BindForDraw()

BindForDraw binds the framebuffer object for drawing.

func (*FrameBuffer) BindForRead

func (f *FrameBuffer) BindForRead()

BindForRead binds the framebuffer object for reading.

func (*FrameBuffer) Destroy

func (f *FrameBuffer) Destroy()

Destroy deallocates the framebuffer object.

func (*FrameBuffer) Resize

func (f *FrameBuffer) Resize(width uint32, height uint32)

Resize will resize all attached textures.

func (*FrameBuffer) SetDrawBuffers

func (f *FrameBuffer) SetDrawBuffers(buffers []uint32)

SetDrawBuffers sets the draw buffers for the framebuffer object.

func (*FrameBuffer) Texture

func (f *FrameBuffer) Texture(attachment uint32) (*Texture, bool)

Texture returns the texture for the provided attachment id.

func (*FrameBuffer) Unbind

func (f *FrameBuffer) Unbind()

Unbind unbinds the framebuffer object.

func (*FrameBuffer) UnbindForDraw

func (f *FrameBuffer) UnbindForDraw()

UnbindForDraw unbinds the framebuffer object for drawing.

func (*FrameBuffer) UnbindForRead

func (f *FrameBuffer) UnbindForRead()

UnbindForRead unbinds the framebuffer object for reading.

type IndexBuffer

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

IndexBuffer represents an indexbuffer.

func (*IndexBuffer) Bind

func (i *IndexBuffer) Bind()

Bind binds the indexbuffer.

func (*IndexBuffer) BufferUint16

func (i *IndexBuffer) BufferUint16(data []uint16)

BufferUint16 allocates uint16 buffer data.

func (*IndexBuffer) BufferUint32

func (i *IndexBuffer) BufferUint32(data []uint32)

BufferUint32 allocates uint32 buffer data.

func (*IndexBuffer) BufferUint8

func (i *IndexBuffer) BufferUint8(data []uint8)

BufferUint8 allocates uint8 buffer data.

func (*IndexBuffer) Destroy

func (i *IndexBuffer) Destroy()

Destroy deallocates the indexbuffer.

func (*IndexBuffer) Draw

func (i *IndexBuffer) Draw(mode uint32, count int32, typ uint32, byteOffset int)

Draw renders the indexbuffer.

func (*IndexBuffer) DrawInstanced

func (i *IndexBuffer) DrawInstanced(mode uint32, count int32, typ uint32, byteOffset int, primcount int32)

DrawInstanced renders multiple instances of the indexbuffer.

func (*IndexBuffer) Unbind

func (i *IndexBuffer) Unbind()

Unbind unbinds the indexbuffer.

type Renderable

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

Renderable represents a renderable object.

func (*Renderable) Bind

func (r *Renderable) Bind()

Bind binds the renderable.

func (*Renderable) Destroy

func (r *Renderable) Destroy()

Destroy deallocates the renderable.

func (*Renderable) Draw

func (r *Renderable) Draw()

Draw renders the renderable.

func (*Renderable) SetDrawArrays

func (r *Renderable) SetDrawArrays(mode uint32, first int32, count int32)

SetDrawArrays sets the params to render the underlying vertexbuffer.

func (*Renderable) SetDrawArraysInstanced

func (r *Renderable) SetDrawArraysInstanced(mode uint32, first int32, count int32, primcount int32)

SetDrawArraysInstanced sets the instancing params to render the underlying vertexbuffer.

func (*Renderable) SetDrawElements

func (r *Renderable) SetDrawElements(mode uint32, count int32, typ uint32, byteOffset int)

SetDrawElements sets the instancing params to render the underlying vertexbuffer.

func (*Renderable) SetDrawElementsInstanced

func (r *Renderable) SetDrawElementsInstanced(mode uint32, count int32, typ uint32, byteOffset int, primcount int32)

SetDrawElementsInstanced sets the params to render the underlying vertexbuffer.

func (*Renderable) SetIndexBuffer

func (r *Renderable) SetIndexBuffer(ib *IndexBuffer)

SetIndexBuffer sets the indexbuffer of the renderable.

func (*Renderable) SetInstancedAttributes

func (r *Renderable) SetInstancedAttributes(instancedIndices []uint32)

SetInstancedAttributes flags provided attributes for instancing.

func (*Renderable) SetPointer

func (r *Renderable) SetPointer(index uint32, pointer *AttributePointer)

SetPointer sets a vertex attribute pointer of the renderable.

func (*Renderable) SetVertexBuffer

func (r *Renderable) SetVertexBuffer(vb *VertexBuffer)

SetVertexBuffer sets the vertexbuffer of the renderable.

func (*Renderable) Unbind

func (r *Renderable) Unbind()

Unbind ubinds the renderable.

func (*Renderable) Upload

func (r *Renderable) Upload()

Upload allocates the renderable to the GPU.

type Shader

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

Shader represents a shader program.

func NewVertFragShader

func NewVertFragShader(vert, frag string) (*Shader, error)

NewVertFragShader instantiates a new shader object.

func (*Shader) AttachShader

func (s *Shader) AttachShader(shader uint32)

AttachShader attaches a shader object to the program.

func (*Shader) CreateShader

func (s *Shader) CreateShader(source string, typ uint32) (uint32, error)

CreateShader creates an individual shader object.

func (*Shader) Destroy

func (s *Shader) Destroy()

Destroy deallocates the shader program.

func (*Shader) LinkProgram

func (s *Shader) LinkProgram() error

LinkProgram links the shader program.

func (*Shader) SetUniform

func (s *Shader) SetUniform(name string, arg interface{}) error

SetUniform buffers one or more uniforms.

func (*Shader) SetUniform1f

func (s *Shader) SetUniform1f(location int32, arg interface{}) error

SetUniform1f buffers a float32 by value.

func (*Shader) SetUniform1fv

func (s *Shader) SetUniform1fv(location int32, count int32, arg interface{}) error

SetUniform1fv buffers one or more float32 by address.

func (*Shader) SetUniform1i

func (s *Shader) SetUniform1i(location int32, arg interface{}) error

SetUniform1i buffers a int32 by value.

func (*Shader) SetUniform1iv

func (s *Shader) SetUniform1iv(location int32, count int32, arg interface{}) error

SetUniform1iv buffers one or more int32 by address.

func (*Shader) SetUniform1ui

func (s *Shader) SetUniform1ui(location int32, arg interface{}) error

SetUniform1ui buffers an uint32 by value.

func (*Shader) SetUniform1uiv

func (s *Shader) SetUniform1uiv(location int32, count int32, arg interface{}) error

SetUniform1uiv buffers one or more uint32 by address.

func (*Shader) SetUniform2fv

func (s *Shader) SetUniform2fv(location int32, count int32, arg interface{}) error

SetUniform2fv buffers one or more 2-component float32 by address.

func (*Shader) SetUniform3fv

func (s *Shader) SetUniform3fv(location int32, count int32, arg interface{}) error

SetUniform3fv buffers one or more 3-component float32 by address.

func (*Shader) SetUniform4fv

func (s *Shader) SetUniform4fv(location int32, count int32, arg interface{}) error

SetUniform4fv buffers one or more 4-component float32 by address.

func (*Shader) SetUniformMatrix3fv

func (s *Shader) SetUniformMatrix3fv(location int32, count int32, arg interface{}) error

SetUniformMatrix3fv buffers one or more 9-component float32 by address.

func (*Shader) SetUniformMatrix4fv

func (s *Shader) SetUniformMatrix4fv(location int32, count int32, arg interface{}) error

SetUniformMatrix4fv buffers one or more 16-component float32 by address.

func (*Shader) UniformBlockDescriptors

func (s *Shader) UniformBlockDescriptors() map[string]*UniformBlockDescriptor

UniformBlockDescriptors returns the map of uniform block descriptors.

func (*Shader) UniformDescriptors

func (s *Shader) UniformDescriptors() map[string]*UniformDescriptor

UniformDescriptors returns the map of uniform descriptors.

func (*Shader) Use

func (s *Shader) Use()

Use activates the shader.

type Technique

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

Technique represents a render technique.

func NewTechnique

func NewTechnique() *Technique

NewTechnique instantiates and returns a new technique instance.

func (*Technique) BlendFunc

func (t *Technique) BlendFunc(sfactor uint32, dfactor uint32)

BlendFunc sets the blend func for the technique.

func (*Technique) ClearColor

func (t *Technique) ClearColor(r, g, b, a float32)

ClearColor sets the clear color for the frame.

func (*Technique) CullFace

func (t *Technique) CullFace(mode uint32)

CullFace sets the cull face mode for the technique.

func (*Technique) DepthFunc

func (t *Technique) DepthFunc(xfunc uint32)

DepthFunc sets the depth mask for the technique.

func (*Technique) DepthMask

func (t *Technique) DepthMask(flag bool)

DepthMask sets the depth mask for the technique.

func (*Technique) Draw

func (t *Technique) Draw(commands []*Command) error

Draw renders all commands using the technique.

func (*Technique) Enable

func (t *Technique) Enable(enable uint32)

Enable enables the rendering states for the technique.

func (*Technique) Shader

func (t *Technique) Shader(shader *Shader)

Shader sets the shader for the technique.

func (*Technique) Viewport

func (t *Technique) Viewport(viewport *Viewport)

Viewport sets the viewport for the technique.

type Texture

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

Texture represents a 2D texture object.

func LoadRGBATexture

func LoadRGBATexture(filename string) (*Texture, error)

LoadRGBATexture loads an image file into an RGBA texture.

func NewRGBATexture

func NewRGBATexture(rgba []uint8, width uint32, height uint32, params *TextureParams) *Texture

NewRGBATexture returns a new RGBA texture.

func (*Texture) Bind

func (t *Texture) Bind(location uint32)

Bind activates the provided texture unit and binds the texture.

func (*Texture) Destroy

func (t *Texture) Destroy()

Destroy deallocates the texture buffer.

func (*Texture) Height

func (t *Texture) Height() uint32

Height returns the height of the texture.

func (*Texture) ID

func (t *Texture) ID() uint32

ID returns the ID of the texture.

func (*Texture) Resize

func (t *Texture) Resize(width uint32, height uint32)

Resize will resize the texture, removing it's current buffer.

func (*Texture) Unbind

func (t *Texture) Unbind()

Unbind will unbind the texture.

func (*Texture) Width

func (t *Texture) Width() uint32

Width returns the width of the texture.

type TextureParams

type TextureParams struct {
	WrapS     int32
	WrapT     int32
	MinFilter int32
	MagFilter int32
}

TextureParams represents parameters for a 2D texture object.

type UniformBlockDescriptor

type UniformBlockDescriptor struct {
	Name      string
	Index     uint32
	Size      int32
	Offsets   map[string]int32
	Alignment int32
}

UniformBlockDescriptor represents a shader uniform blocks attributes.

func (*UniformBlockDescriptor) AlignedSize

func (u *UniformBlockDescriptor) AlignedSize() int32

AlignedSize returns the aligned block size of the uniform block.

func (*UniformBlockDescriptor) Offset

func (u *UniformBlockDescriptor) Offset(name string) (int32, error)

Offset returns the offset of the uniform block.

func (*UniformBlockDescriptor) UnAlignedSize

func (u *UniformBlockDescriptor) UnAlignedSize() int32

UnAlignedSize returns the unaligned block size of the uniform block.

type UniformDescriptor

type UniformDescriptor struct {
	Name     string
	Type     uint32
	Count    int32
	Location int32
}

UniformDescriptor represents a single shader uniforms attributes.

type VertexBuffer

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

VertexBuffer represents a vertexbuffer.

func (*VertexBuffer) AllocateBuffer

func (v *VertexBuffer) AllocateBuffer(numBytes int)

AllocateBuffer allocates the size of the underlying buffer.

func (*VertexBuffer) Bind

func (v *VertexBuffer) Bind()

Bind binds the vertexbuffer.

func (*VertexBuffer) BufferFloat32

func (v *VertexBuffer) BufferFloat32(data []float32)

BufferFloat32 buffers a float32 slice.

func (*VertexBuffer) BufferSubFloat32

func (v *VertexBuffer) BufferSubFloat32(data []float32, offset int)

BufferSubFloat32 buffers a float32 slice into a portion of the underlying buffer.

func (*VertexBuffer) Destroy

func (v *VertexBuffer) Destroy()

Destroy deallocates the vertexbuffer.

func (*VertexBuffer) Draw

func (v *VertexBuffer) Draw(mode uint32, first int32, count int32)

Draw renders the vertexbuffer.

func (*VertexBuffer) DrawInstanced

func (v *VertexBuffer) DrawInstanced(mode uint32, first int32, count int32, primcount int32)

DrawInstanced renders multiple instances of the vertexbuffer.

func (*VertexBuffer) Unbind

func (v *VertexBuffer) Unbind()

Unbind unbinds the vertexbuffer.

type Viewport

type Viewport struct {
	X      int32
	Y      int32
	Width  int32
	Height int32
}

Viewport represents a viewport.

func (*Viewport) Equals

func (v *Viewport) Equals(other *Viewport) bool

Equals returns true if the viewports are equal.

Jump to

Keyboard shortcuts

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