gfx

package
v0.0.0-...-8a6b8bc Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Window  *Window
	Program *Program
	// contains filtered or unexported fields
}

Context is a context for doing opengl graphics

func NewContext

func NewContext(done chan struct{},
	windowConfig *WindowConfig, shaderConfigs []*ShaderConfig) (*Context, error)

NewContext creates a new opengl context

func (*Context) AddTextureObject

func (c *Context) AddTextureObject(cfg *TextureConfig) (*TextureObject, error)

AddTextureObject creates a new TextureObject by first creating a PixelBufferObject that will be used to store the texture. The PBO can be updated by calling TextureObject.Update() which will read the current state of cfg.Image.

func (*Context) AddVertexArrayObject

func (c *Context) AddVertexArrayObject(cfg *VAOConfig) error

AddVertexArrayObject creates a VAO from a VertexBufferObject (todo implement that type)

func (*Context) Draw

func (c *Context) Draw()

Draw draws every VAO that's attached to the context.

func (*Context) EventLoop

func (c *Context) EventLoop(render func(*Context))

EventLoop clears the current framebuffer and executes render in a loop until the underlying glfw window tells it to stop. Calls glfw.Terminate when finished.

func (*Context) GetAttributeLocation

func (c *Context) GetAttributeLocation(name string) uint32

GetAttributeLocation returns the location of an attribute with context's program.

func (*Context) GetUniformLocation

func (c *Context) GetUniformLocation(uname string) int32

GetUniformLocation returns the location of a uniform within the context's program.

func (*Context) NewVertexArrayObject

func (c *Context) NewVertexArrayObject(cfg *VAOConfig) (*VertexArrayObject, error)

NewVertexArrayObject creates a VertexArrayObject

func (*Context) Terminate

func (c *Context) Terminate()

Terminate ends the glfw session

type Program

type Program struct {
	ProgramID uint32
	Shaders   []*Shader
}

Program represents an OpenGL program.

func NewProgram

func NewProgram() (*Program, error)

NewProgram creates a new Program

func (*Program) AttachShader

func (p *Program) AttachShader(cfg *ShaderConfig) error

AttachShader attaches a shader from source to a program, defering compilation so that calls can be chained together and finished with a call to Link()

func (p *Program) Link() error

Link links the program and retrieves all variable locations

type Shader

type Shader struct {
	ShaderID           uint32
	UniformLocations   map[string]int32
	AttributeLocations map[string]int32
	// contains filtered or unexported fields
}

Shader represents a shader with attached attribute pointers.

func NewShader

func NewShader(cfg *ShaderConfig) (*Shader, error)

NewShader loads and compiles a new shader, but does not attach it to a program.

type ShaderConfig

type ShaderConfig struct {
	Source         string
	Typ            ShaderType
	AttributeNames []string
	UniformNames   []string
}

ShaderConfig is used to create new shaders

type ShaderType

type ShaderType int

ShaderType tells NewShader what type of shader it's creating.

const (
	VertexShaderType ShaderType = iota
	FragmentShaderType
)

Types of shaders

type TextureConfig

type TextureConfig struct {
	Image       *image.RGBA
	UniformName string
	Mode        int32
}

TextureConfig is a configuration for creating a new TextureObject

type TextureObject

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

TextureObject represents a texture that is

func (*TextureObject) Update

func (t *TextureObject) Update(img *image.RGBA)

type VAOConfig

type VAOConfig struct {
	Vertices   []float32
	VertAttr   string
	TexAttr    string
	Stride     int32
	Size       int
	GLDrawType uint32
	OnDraw     func(ctx *Context) bool
}

VAOConfig represents a configuration for creating a new VAO. OnDraw is a function that returns true if the VAO should be drawn, but can also be used to set uniforms.

type VertexArrayObject

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

VertexArrayObject points to a vertex buffer that has already been loaded into grpahics memory.

func (*VertexArrayObject) Draw

func (v *VertexArrayObject) Draw(ctx *Context)

Draw draws a VertexArrayObject to the current frame buffer

type Window

type Window struct {
	Config     *WindowConfig
	GlfwWindow *glfw.Window
}

Window represents a wrapped glfw window object.

func NewWindow

func NewWindow(cfg *WindowConfig) (*Window, error)

NewWindow initializes a new window object with glfw.

type WindowConfig

type WindowConfig struct {
	Width  int
	Height int
	Title  string
}

WindowConfig contains a new window configuration

Directories

Path Synopsis
examples
texture
Renders a textured spinning cube using GLFW 3 and OpenGL 4.1 core forward-compatible profile.
Renders a textured spinning cube using GLFW 3 and OpenGL 4.1 core forward-compatible profile.

Jump to

Keyboard shortcuts

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