graphicscommand

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package graphicscommand represents a low layer for graphics using OpenGL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlushCommands

func FlushCommands(graphicsDriver graphicsdriver.Graphics) error

FlushCommands flushes the command queue.

func InitializeGraphicsDriverState added in v2.2.0

func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error)

InitializeGraphicsDriverState initialize the current graphics driver state.

func LogImagesInfo added in v2.2.0

func LogImagesInfo(images []*Image)

func MaxImageSize added in v2.1.0

func MaxImageSize(graphicsDriver graphicsdriver.Graphics) int

MaxImageSize returns the maximum size of an image.

func ResetGraphicsDriverState

func ResetGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error)

ResetGraphicsDriverState resets the current graphics driver state. If the graphics driver doesn't have an API to reset, ResetGraphicsDriverState does nothing.

func SetRenderingThread added in v2.3.0

func SetRenderingThread(thread Thread)

SetRenderingThread must be called from the rendering thread where e.g. OpenGL works.

TODO: Create thread in this package instead of setting it externally.

Types

type Image

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

Image represents an image that is implemented with OpenGL.

func NewImage

func NewImage(width, height int) *Image

NewImage returns a new image.

Note that the image is not initialized yet.

func NewScreenFramebufferImage

func NewScreenFramebufferImage(width, height int) *Image

func (*Image) Dispose

func (i *Image) Dispose()

func (*Image) DrawTriangles

func (i *Image) DrawTriangles(srcs [graphics.ShaderImageNum]*Image, offsets [graphics.ShaderImageNum - 1][2]float32, vertices []float32, indices []uint16, clr affine.ColorM, mode graphicsdriver.CompositeMode, filter graphicsdriver.Filter, address graphicsdriver.Address, dstRegion, srcRegion graphicsdriver.Region, shader *Shader, uniforms [][]float32, evenOdd bool)

DrawTriangles draws triangles with the given image.

The vertex floats are:

0: Destination X in pixels
1: Destination Y in pixels
2: Source X in texels
3: Source Y in texels
4: Color R [0.0-1.0]
5: Color G
6: Color B
7: Color Y

src and shader are exclusive and only either is non-nil.

The elements that index is in between 2 and 7 are used for the source images. The source image is 1) src argument if non-nil, or 2) an image value in the uniform variables if it exists. If there are multiple images in the uniform variables, the smallest ID's value is adopted.

If the source image is not specified, i.e., src is nil and there is no image in the uniform variables, the elements for the source image are not used.

func (*Image) Dump

func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackbg bool, rect image.Rectangle) error

Dump dumps the image to the specified path. In the path, '*' is replaced with the image's ID.

If blackbg is true, any alpha values in the dumped image will be 255.

This is for testing usage.

func (*Image) InternalSize

func (i *Image) InternalSize() (int, int)

func (*Image) IsInvalidated

func (i *Image) IsInvalidated() bool

func (*Image) ReadPixels added in v2.3.0

func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, buf []byte) error

ReadPixels reads the image's pixels. ReadPixels returns an error when an error happens in the graphics driver.

func (*Image) ReplacePixels

func (i *Image) ReplacePixels(pixels []byte, mask []byte, x, y, width, height int)

type Shader

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

func NewShader

func NewShader(ir *shaderir.Program) *Shader

func (*Shader) Dispose

func (s *Shader) Dispose()

type Thread added in v2.1.0

type Thread interface {
	Call(f func())
}

Jump to

Keyboard shortcuts

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