Documentation ¶
Overview ¶
Package graphicscommand represents a low layer for graphics using OpenGL.
Index ¶
- Constants
- func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir string) (string, error)
- func FlushCommands(graphicsDriver graphicsdriver.Graphics, endFrame bool) error
- func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error)
- func LogImagesInfo(images []*Image)
- func LoopRenderThread(ctx context.Context)
- func MaxImageSize(graphicsDriver graphicsdriver.Graphics) int
- func ResetGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error)
- func SetOSThreadAsRenderThread()
- func SetVsyncEnabled(enabled bool, graphicsDriver graphicsdriver.Graphics)
- func Terminate()
- type Image
- func (i *Image) Dispose()
- func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, ...)
- func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackbg bool, ...) (string, error)
- func (i *Image) InternalSize() (int, int)
- func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, args []graphicsdriver.PixelsArgs) error
- func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangle)
- type Shader
Constants ¶
const ( // MaxVertexCount is the maximum number of vertices for one draw call. // // On 64bit architectures, this value is 2^32-1, as the index type is uint32. // This value cannot be exactly 2^32 especially with WebGL 2, as 2^32th vertex is not rendered correctly. // See https://registry.khronos.org/webgl/specs/latest/2.0/#5.18 . // // On 32bit architectures, this value is an adjusted number so that maxVertexFloatCount doesn't overflow int. MaxVertexCount = is64bit*math.MaxUint32 + is32bit*(math.MaxInt32/graphics.VertexFloatCount) )
Variables ¶
This section is empty.
Functions ¶
func DumpImages ¶ added in v2.5.0
func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir string) (string, error)
DumpImages dumps all the current images to the specified directory.
This is for testing usage.
func FlushCommands ¶
func FlushCommands(graphicsDriver graphicsdriver.Graphics, endFrame bool) error
FlushCommands flushes the command queue and present the screen if needed. If endFrame is true, the current screen might be used to present.
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 LoopRenderThread ¶ added in v2.7.0
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 SetOSThreadAsRenderThread ¶ added in v2.7.0
func SetOSThreadAsRenderThread()
SetOSThreadAsRenderThread sets an OS thread as rendering thread e.g. for OpenGL.
func SetVsyncEnabled ¶ added in v2.7.0
func SetVsyncEnabled(enabled bool, graphicsDriver graphicsdriver.Graphics)
Types ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents an image that is implemented with OpenGL.
func (*Image) DrawTriangles ¶
func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *Shader, uniforms []uint32, fillRule graphicsdriver.FillRule)
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) InternalSize ¶
func (*Image) ReadPixels ¶ added in v2.3.0
func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, args []graphicsdriver.PixelsArgs) error
ReadPixels reads the image's pixels. ReadPixels returns an error when an error happens in the graphics driver.
func (*Image) WritePixels ¶ added in v2.4.0
func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangle)