goglbackend

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GLContext

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

GLContext is a context that contains all the shaders and buffers necessary for rendering

func NewGLContext

func NewGLContext() (*GLContext, error)

NewGLContext creates all the necessary GL resources, like shaders and buffers

type GoGLBackend

type GoGLBackend struct {
	*GLContext
	// contains filtered or unexported fields
}

GoGLBackend is a canvas backend using Go-GL

func New

func New(x, y, w, h int, ctx *GLContext) (*GoGLBackend, error)

New returns a new canvas backend. x, y, w, h define the target rectangle in the window. ctx is a GLContext created with NewGLContext, but can be nil for a default one. It makes sense to pass one in when using for example an onscreen and an offscreen backend using the same GL context.

func (*GoGLBackend) Activate

func (b *GoGLBackend) Activate()

Activate only needs to be called if there is other code also using the GL state

func (*GoGLBackend) AsImage

func (b *GoGLBackend) AsImage() backendbase.Image

AsImage returns nil, since this backend cannot be directly used as an image. Used internally

func (*GoGLBackend) CanUseAsImage

func (b *GoGLBackend) CanUseAsImage(b2 backendbase.Backend) bool

CanUseAsImage returns true if the given backend can be directly used by this backend to avoid a conversion. Used internally

func (*GoGLBackend) Clear

func (b *GoGLBackend) Clear(pts [4]backendbase.Vec)

func (*GoGLBackend) ClearClip

func (b *GoGLBackend) ClearClip()

func (*GoGLBackend) Clip

func (b *GoGLBackend) Clip(pts []backendbase.Vec)

func (*GoGLBackend) DrawImage

func (b *GoGLBackend) DrawImage(dimg backendbase.Image, sx, sy, sw, sh float64, pts [4]backendbase.Vec, alpha float64)

func (*GoGLBackend) Fill

func (b *GoGLBackend) Fill(style *backendbase.FillStyle, pts []backendbase.Vec, tf backendbase.Mat, canOverlap bool)

func (*GoGLBackend) FillImageMask

func (b *GoGLBackend) FillImageMask(style *backendbase.FillStyle, mask *image.Alpha, pts [4]backendbase.Vec)

func (*GoGLBackend) GetImageData

func (b *GoGLBackend) GetImageData(x, y, w, h int) *image.RGBA

GetImageData returns an RGBA image of the current image

func (*GoGLBackend) LoadImage

func (b *GoGLBackend) LoadImage(src image.Image) (backendbase.Image, error)

func (*GoGLBackend) LoadImagePattern

func (*GoGLBackend) LoadLinearGradient

func (b *GoGLBackend) LoadLinearGradient(data backendbase.Gradient) backendbase.LinearGradient

func (*GoGLBackend) LoadRadialGradient

func (b *GoGLBackend) LoadRadialGradient(data backendbase.Gradient) backendbase.RadialGradient

func (*GoGLBackend) PutImageData

func (b *GoGLBackend) PutImageData(img *image.RGBA, x, y int)

PutImageData puts the given image at the given x/y coordinates

func (*GoGLBackend) SetBounds

func (b *GoGLBackend) SetBounds(x, y, w, h int)

SetBounds updates the bounds of the canvas. This would usually be called for example when the window is resized

func (*GoGLBackend) Size

func (b *GoGLBackend) Size() (int, int)

Size returns the size of the window or offscreen texture

type GoGLBackendOffscreen

type GoGLBackendOffscreen struct {
	GoGLBackend

	TextureID uint32
	// contains filtered or unexported fields
}

GoGLBackendOffscreen is a canvas backend using an offscreen texture

func NewOffscreen

func NewOffscreen(w, h int, alpha bool, ctx *GLContext) (*GoGLBackendOffscreen, error)

NewOffscreen returns a new offscreen canvas backend. w, h define the size of the offscreen texture. ctx is a GLContext created with NewGLContext, but can be nil for a default one. It makes sense to pass one in when using for example an onscreen and an offscreen backend using the same GL context.

func (*GoGLBackendOffscreen) AsImage

func (b *GoGLBackendOffscreen) AsImage() backendbase.Image

AsImage returns an implementation of the Image interface that can be used to render this offscreen texture directly. Used internally

func (*GoGLBackendOffscreen) Delete

func (b *GoGLBackendOffscreen) Delete()

Delete deletes the offscreen texture. After calling this the backend can no longer be used

func (*GoGLBackendOffscreen) SetSize

func (b *GoGLBackendOffscreen) SetSize(w, h int)

SetSize updates the size of the offscreen texture

type Image

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

Image represents a loaded image that can be used in various drawing functions

func (*Image) Delete

func (img *Image) Delete()

Delete deletes the image from memory. Any draw calls with a deleted image will not do anything

func (*Image) Height

func (img *Image) Height() int

Height returns the height of the image

func (*Image) Replace

func (img *Image) Replace(src image.Image) error

Replace replaces the image with the new one

func (*Image) Size

func (img *Image) Size() (int, int)

Size returns the width and height of the image

func (*Image) Width

func (img *Image) Width() int

Width returns the width of the image

type ImagePattern

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

func (*ImagePattern) Delete

func (ip *ImagePattern) Delete()

func (*ImagePattern) Replace

func (ip *ImagePattern) Replace(data backendbase.ImagePatternData)

type LinearGradient

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

LinearGradient is a gradient with any number of stops and any number of colors. The gradient will be drawn such that each point on the gradient will correspond to a straight line

func (*LinearGradient) Delete

func (g *LinearGradient) Delete()

Delete explicitly deletes the gradient

func (*LinearGradient) Replace

func (lg *LinearGradient) Replace(data backendbase.Gradient)

type RadialGradient

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

RadialGradient is a gradient with any number of stops and any number of colors. The gradient will be drawn such that each point on the gradient will correspond to a circle

func (*RadialGradient) Delete

func (g *RadialGradient) Delete()

Delete explicitly deletes the gradient

func (*RadialGradient) Replace

func (rg *RadialGradient) Replace(data backendbase.Gradient)

Directories

Path Synopsis
Package gl implements Go bindings to OpenGL.
Package gl implements Go bindings to OpenGL.

Jump to

Keyboard shortcuts

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