gfx

package
v0.0.0-...-7296e18 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

The gfx Pacakge is used largly to simplify OpenGL calls and to manage state of transformations. Anything meant to be drawn to screen will come from this pacakge.

Index

Constants

View Source
const (
	LINE DrawMode = iota
	FILL

	//texture wrap
	WRAP_CLAMP           WrapMode = 0x812F
	WRAP_REPEAT          WrapMode = 0x2901
	WRAP_MIRRORED_REPEAT WrapMode = 0x8370

	//texture filter
	FILTER_NONE    FilterMode = 0
	FILTER_NEAREST FilterMode = 0x2600
	FILTER_LINEAR  FilterMode = 0x2601

	//opengl blending constants
	// Alpha blending (normal). The alpha of what's drawn determines its opacity.
	BLENDMODE_ALPHA BlendMode = iota
	// The pixel colors of what's drawn are multiplied with the pixel colors
	// already on the screen (darkening them). The alpha of drawn objects is
	// multiplied with the alpha of the screen rather than determining how much
	// the colors on the screen are affected.
	BLENDMODE_MULTIPLICATIVE
	BLENDMODE_PREMULTIPLIED
	// The pixel colors of what's drawn are subtracted from the pixel colors
	// already on the screen. The alpha of the screen is not modified.
	BLENDMODE_SUBTRACTIVE
	// The pixel colors of what's drawn are added to the pixel colors already on
	// the screen. The alpha of the screen is not modified.
	BLENDMODE_ADDITIVE
	// screen blending
	BLENDMODE_SCREEN
	// The colors of what's drawn completely replace what was on the screen, with
	// no additional blending.
	BLENDMODE_REPLACE

	//stencil actions
	STENCIL_REPLACE        StencilAction = 0x1E01
	STENCIL_INCREMENT      StencilAction = 0x1E02
	STENCIL_DECREMENT      StencilAction = 0x1E03
	STENCIL_INCREMENT_WRAP StencilAction = 0x8507
	STENCIL_DECREMENT_WRAP StencilAction = 0x8508
	STENCIL_INVERT         StencilAction = 0x150A

	// stenicl test modes
	COMPARE_GREATER  CompareMode = 0x0201
	COMPARE_EQUAL    CompareMode = 0x0202
	COMPARE_GEQUAL   CompareMode = 0x0203
	COMPARE_LESS     CompareMode = 0x0204
	COMPARE_NOTEQUAL CompareMode = 0x0205
	COMPARE_LEQUAL   CompareMode = 0x0206
	COMPARE_ALWAYS   CompareMode = 0x0207

	// treat adjacent segments with angles between their directions <5 degree as straight
	LINES_PARALLEL_EPS float32 = 0.05

	//line styles for overdraw
	LINE_ROUGH LineStyle = iota
	LINE_SMOOTH

	//line joins for nicer corners
	LINE_JOIN_NONE LineJoin = iota
	LINE_JOIN_MITER
	LINE_JOIN_BEVEL

	//uniform types for shaders
	UNIFORM_FLOAT UniformType = iota
	UNIFORM_INT
	UNIFORM_BOOL
	UNIFORM_SAMPLER
	UNIFORM_UNKNOWN

	UNIFORM_BASE UniformType = iota
	UNIFORM_VEC
	UNIFORM_MAT

	//mesh draw modes
	// DRAWMODE_POINTS will draw a point at every point provided
	DRAWMODE_POINTS MeshDrawMode = 0x0000
	// DRAWMODE_TRIANGLES will connect the points in triangles
	DRAWMODE_TRIANGLES MeshDrawMode = 0x0004
	// DRAWMODE_STRIP will connect the points in a triangle strip, reusing points.
	DRAWMODE_STRIP MeshDrawMode = 0x0005
	// DRAWMODE_FAN will fan out from a start point
	DRAWMODE_FAN MeshDrawMode = 0x0006

	//mesh and spritebatch usage
	USAGE_STREAM  Usage = 0x88E0
	USAGE_STATIC  Usage = 0x88E4
	USAGE_DYNAMIC Usage = 0x88E8

	// upper limit of particles that can be created
	MAX_PARTICLES = math.MaxInt32 / 4

	//particle distrobution
	DISTRIBUTION_NONE ParticleDistribution = iota
	DISTRIBUTION_UNIFORM
	DISTRIBUTION_NORMAL

	//particle insertion
	INSERT_MODE_TOP ParticleInsertion = iota
	INSERT_MODE_BOTTOM
	INSERT_MODE_RANDOM

	// text align
	ALIGN_CENTER AlignMode = iota
	ALIGN_LEFT
	ALIGN_RIGHT
	ALIGN_JUSTIFY
)

Variables

This section is empty.

Functions

func Arc

func Arc(mode DrawMode, x, y, radius, angle1, angle2 float32)

Arc will draw a part of a circle at the point x, y with the radius provied. The arc will start at angle1 (radians) and end at angle2 (radians) The drawmode specifies either a fill or line draw

func Arcp

func Arcp(mode DrawMode, x, y, radius, angle1, angle2 float32, points int)

Arcp is like Arc except that you can define how many points you want to generate the arc. If it is lower it will look jagged. If it is higher it will hit performace. The drawmode specifies either a fill or line draw

func Circle

func Circle(mode DrawMode, x, y, radius float32)

Circle will draw a circle at x, y with a radius as specified. The drawmode specifies either a fill or line draw

func Circlep

func Circlep(mode DrawMode, x, y, radius float32, points int)

Circlep will draw a circle at x, y with a radius as specified. points specifies how many points should be generated in the arc. If it is lower it will look jagged. If it is higher it will hit performace. The drawmode specifies either a fill or line draw

func Clear

func Clear(r, g, b, a float32)

Clear will clear everything already rendered to the screen and set is all to the r, g, b, a provided.

func ClearC

func ClearC(c *Color)

Clear will clear everything already rendered to the screen and set is all to the *Color provided.

func ClearScissor

func ClearScissor()

ClearScissor will disable all set scissors.

func ClearStencilTest

func ClearStencilTest()

ClearStencilTest stops the stencil test from operating

func CreateGlObjectGroup

func CreateGlObjectGroup(group string)

CreateGlObjectGroup will create a scope for all new gl object that will be instantiated. This is useful when for example when you are loading a stage/level that will be unloaded later. You would create the group before loading the items and call ReleaseGlObjectGroup when you unload the level. This allows for a bit of memory management.

func CurrentGlObjectGroup

func CurrentGlObjectGroup() string

CurrentGlObjectGroup will get the name of the current GLObjectGroup. If you have not set one it will return the default group.

func DeInit

func DeInit()

Deinit will do the clean up for the context.

func Draw

func Draw(drawable Drawable, args ...float32)

Draw calls draw on any drawable object with the inputs Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func Drawq

func Drawq(drawable QuadDrawable, quad *Quad, args ...float32)

Drawq will draw any object that can have a quad applied to it Inputs are as follows quad is the quad to crop the texture x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func Ellipse

func Ellipse(mode DrawMode, x, y, radiusx, radiusy float32)

Ellipse will draw a circle at x, y with a radius as specified. radiusx and radiusy will specify how much the width will be along those axis If it is lower it will look jagged. If it is higher it will hit performace. The drawmode specifies either a fill or line draw

func Ellipsep

func Ellipsep(mode DrawMode, x, y, radiusx, radiusy float32, points int)

Ellipsep will draw a circle at x, y with a radius as specified. radiusx and radiusy will specify how much the width will be along those axis points specifies how many points should be generated in the arc. If it is lower it will look jagged. If it is higher it will hit performace. The drawmode specifies either a fill or line draw

func GetBackgroundColor

func GetBackgroundColor() (r, g, b, a float32)

GetBackgroundColor gets the background color.

func GetHeight

func GetHeight() float32

GetHeight will return the height of the rendering context.

func GetLineWidth

func GetLineWidth() float32

GetLineWidth will return the current line width. Default line width is 1

func GetPointSize

func GetPointSize() float32

GetPointSize will return the current point size

func GetScissor

func GetScissor() (x, y, w, h int32)

GetScissor will return the current scissor rectangle

func GetViewport

func GetViewport() []int32

GetViewport will return the x, y, w, h of the opengl viewport. This is interfaced directly with opengl and used by the framework. Only use this if you know what you are doing

func GetWidth

func GetWidth() float32

GetWidth will return the width of the rendering context.

func HasFramebufferSRGB

func HasFramebufferSRGB() bool

HasFramebufferSRGB will return true if standard RGB color space is suporrted on this system. Only supported on non ES environments.

func InitContext

func InitContext(w, h int32)

InitContext will initiate the opengl context with a viewport in the size of w x h. This is generally called from the game loop and wont generally need to be called unless you are rolling your own game loop.

func IntersectScissor

func IntersectScissor(x, y, width, height int32)

IntersectScissor sets the scissor to the rectangle created by the intersection of the specified rectangle with the existing scissor. If no scissor is active yet, it behaves like SetScissor. The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including Clear. The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...).

func IsActive

func IsActive() bool

IsActive will return true of the context has been initialized and the window is open.

func IsCreated

func IsCreated() bool

IsCreated checks if the opengl context has be initialized.

func IsWireframe

func IsWireframe() bool

IsWireframe will return true if wirefame is current enabled. Wireframe is only available in non ES enviroments.

func Line

func Line(args ...float32)

Line is a short form of Polyline so you can enter your params not in an array

func NewScreenshot

func NewScreenshot() image.Image

NewScreenshot will take a screenshot of the screen and convert it to an image.Image

func Origin

func Origin()

Origin will reset all translations and transformations back to defaults. This function is always used to reverse any previous calls to Rotate, Scale, Shear or Translate.

func Points

func Points(coords ...float32)

Point will draw a point on the screen at x, y position. The size of the point is dependant on the point size set with SetPointSize.

func PolyLine

func PolyLine(coords []float32)

PolyLine will draw a line with an array in the form of x1, y1, x2, y2, x3, y3, ..... xn, yn

func Polygon

func Polygon(mode DrawMode, coords []float32)

Polygon will draw a closed polygon with an array in the form of x1, y1, x2, y2, x3, y3, ..... xn, yn The drawmode specifies either a fill or line draw

func Pop

func Pop()

Pop pops the current coordinate transformation from the transformation stack. This function is always used to reverse a previous push operation. It returns the current transformation state to what it was before the last preceding push.

func Present

func Present()

Preset is used at the end of the game loop to swap the frame buffers and display the next rendered frame. This is normally used by the game loop and should not be used unless rolling your own game loop.

func Print

func Print(fs string, argv ...float32)

func Printc

func Printc(strs []string, colors []*Color, argv ...float32)

func Printf

func Printf(fs string, wrapLimit float32, align AlignMode, argv ...float32)

func Printfc

func Printfc(strs []string, colors []*Color, wrapLimit float32, align AlignMode, argv ...float32)

func Push

func Push()

Push copies and pushes the current coordinate transformation to the transformation stack. This function is always used to prepare for a corresponding pop operation later. It stores the current coordinate transformation state into the transformation stack and keeps it active. Later changes to the transformation can be undone by using the pop operation, which returns the coordinate transform to the state it was in before calling push.

func Rect

func Rect(mode DrawMode, x, y, width, height float32)

Rect draws a rectangle with the top left corner at x, y with the specified width and height The drawmode specifies either a fill or line draw

func ReleaseGlObjectGroup

func ReleaseGlObjectGroup(group string)

ReleaseGlObjectGroup will release all the gl objects in the group with the group name.

func Rotate

func Rotate(angle float32)

Rotate rotates the coordinate system in two dimensions. Calling this function affects all future drawing operations by rotating the coordinate system around the origin by the given amount of radians. This change lasts until drawing completes

func Scale

func Scale(args ...float32)

Scale scales the coordinate system in two dimensions. By default the coordinate system / in amore corresponds to the display pixels in horizontal and vertical directions one-to-one, and the x-axis increases towards the right while the y-axis increases downwards. Scaling the coordinate system changes this relation. After scaling by sx and sy, all coordinates are treated as if they were multiplied by sx and sy. Every result of a drawing operation is also correspondingly scaled, so scaling by (2, 2) for example would mean making everything twice as large in both x- and y-directions. Scaling by a negative value flips the coordinate system in the corresponding direction, which also means everything will be drawn flipped or upside down, or both. Scaling by zero is not a useful operation. Scale and translate are not commutative operations, therefore, calling them in different orders will change the outcome. Scaling lasts until drawing completes

func SetActive

func SetActive(enable bool)

SetActive will enable or disable the rendering of the the game. Mainly this is used by the framework to disable rendering when not in view.

func SetBackgroundColor

func SetBackgroundColor(r, g, b, a float32)

SetBackgroundColor sets the background color.

func SetBackgroundColorC

func SetBackgroundColorC(c *Color)

SetBackgroundColorC sets the background color.

func SetBlendMode

func SetBlendMode(mode BlendMode)

SetBlendMode sets the blending mode. Blending modes are different ways to do color blending. See BlendMode constants to see how they operate.

func SetCanvas

func SetCanvas(canvases ...*Canvas) error

SetCanvas will set the render target to a specified Canvas. All drawing operations until the next SetCanvas call will be redirected to the Canvas and not shown on the screen. Call with a no params to enable drawing to screen again.

func SetColor

func SetColor(r, g, b, a float32)

SetColor will sets the color used for drawing.

func SetColorC

func SetColorC(c *Color)

SetColorC will sets the color used for drawing.

func SetColorMask

func SetColorMask(mask ColorMask)

SetColorMask will set a mask for each r, g, b, and alpha component.

func SetDefaultFilter

func SetDefaultFilter(min, mag FilterMode, anisotropy float32)

SetDefaultFilter sets the default scaling filters used with Images, Canvases, and Fonts.

func SetDefaultFilterF

func SetDefaultFilterF(f Filter)

SetDefaultFilterF sets the default scaling filters used with Images, Canvases, and Fonts.

func SetDefaultMipmapFilter

func SetDefaultMipmapFilter(filter FilterMode, sharpness float32)

func SetFont

func SetFont(font *Font)

SetFont will set a font for the next print call

func SetLineJoin

func SetLineJoin(join LineJoin)

SetLineJoin will change how each line joins. options are None, Bevel or Miter.

func SetLineStyle

func SetLineStyle(style LineStyle)

SetLineStyle will set the line style either smooth (overdraw) or rough.

func SetLineWidth

func SetLineWidth(width float32)

SetLineWidth changes the width in pixels that the lines will render when using Line or PolyLine

func SetPointSize

func SetPointSize(size float32)

SetPointSize will set the size of points drawn by Point

func SetScissor

func SetScissor(args ...int32)

SetScissor Sets or disables scissor. The scissor limits the drawing area to a specified rectangle. This affects all graphics calls, including Clear. The dimensions of the scissor is unaffected by graphical transformations (translate, scale, ...). if no arguments are given it will disable the scissor. if x, y, w, h are given it will enable the scissor

func SetShader

func SetShader(shader *Shader)

SetShader sets or resets a Shader as the current pixel effect or vertex shaders. All drawing operations until the next SetShader will be drawn using the Shader object specified.

func SetStencilTest

func SetStencilTest(compare CompareMode, value int32)

SetStencilTest configures or disables stencil testing. When stencil testing is enabled, the geometry of everything that is drawn afterward will be clipped/stencilled out based on a comparison between the arguments of this function and the stencil value of each pixel that the geometry touches. The stencil values of pixels are affected via Stencil/StencilEXT.

func SetViewport

func SetViewport(x, y, w, h int32)

SetViewport will set the viewport to x, y, w, h. This is interfaced directly with opengl and used by the framework. Only use this if you know what you are doing

func SetViewportSize

func SetViewportSize(w, h int32)

SetViewportSize will set the viewport to 0, 0, w, h. This is interfaced directly with opengl and used by the framework. Only use this if you know what you are doing

func SetWireframe

func SetWireframe(enable bool)

SetWireframe sets whether wireframe lines will be used when drawing.

func Shear

func Shear(args ...float32)

Shear shears the coordinate system.

func Stencil

func Stencil(stencil_func func())

Stencil draws geometry as a stencil. The geometry drawn by the supplied function sets invisible stencil values of pixels, instead of setting pixel colors. The stencil values of pixels can act like a mask / stencil - SetStencilTest can be used afterward to determine how further rendering is affected by the stencil values in each pixel. Each Canvas has its own per-pixel stencil values. Stencil values are within the range of [0, 255]. This stencil has the defaults of StencilAction: STENCIL_REPLACE, value: 1, keepvalues: true

func StencilExt

func StencilExt(stencil_func func(), action StencilAction, value int32, keepvalues bool)

StencilExt operates like stencil but with access to change the stencil action, value, and keepvalues.

action: How to modify any stencil values of pixels that are touched by what's drawn in the stencil function.

value: The new stencil value to use for pixels if the "replace" stencil action is used. Has no effect with other stencil actions. Must be between 0 and 255.

keepvalues: True to preserve old stencil values of pixels, false to re-set every pixel's stencil value to 0 before executing the stencil function. Clear will also re-set all stencil values.

func Translate

func Translate(x, y float32)

Translate will translate the rendering origin to the point x, y. When this function is called with two numbers, dx, and dy, all the following drawing operations take effect as if their x and y coordinates were x+dx and y+dy. Scale and translate are not commutative operations, therefore, calling them in different orders will change the outcome. This change lasts until drawing completes or else a Pop reverts to a previous graphics state. Translating using whole numbers will prevent tearing/blurring of images and fonts draw after translating.

Types

type AlignMode

type AlignMode int

AlignMode is the normal text align, center, left and right

type BlendMode

type BlendMode int

BlendMode specifies different ways to do color blending.

type Canvas

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

Canvas is an off-screen render target.

func GetCanvas

func GetCanvas() []*Canvas

GetCanvas returns the currently bound canvases

func NewCanvas

func NewCanvas(width, height int32) *Canvas

NewCanvas creates a pointer to a new canvas with the privided width and height

func (*Canvas) NewImageData

func (canvas *Canvas) NewImageData(x, y, w, h int32) (image.Image, error)

NewImageData will create an image from the canvas data. It will return an error only if the dimensions given are invalid

func (*Canvas) Release

func (canvas *Canvas) Release()

Release will release all the gl objects associates with the canvas and clean up the memory

type Color

type Color [4]float32

Color represents an rgba color

func GetBackgroundColorC

func GetBackgroundColorC() *Color

GetBackgroundColorC gets the background color.

func GetColor

func GetColor() *Color

GetColor returns the current drawing color.

func NewColor

func NewColor(r, g, b, a float32) *Color

NewColor will take the values r, g, b, a in the range from 0 to 255 and return a pointer to the new color

func (*Color) Add

func (color *Color) Add(c *Color) *Color

Add will add one color to another and return the resulting color

func (*Color) Darken

func (color *Color) Darken(percent float32) *Color

Darken will darken the color by the percent given

func (*Color) Div

func (color *Color) Div(s float32) *Color

Div will divide one color from another and return the resulting color

func (*Color) Lighten

func (color *Color) Lighten(percent float32) *Color

Lighten will lighten the color by the percent given

func (*Color) Mul

func (color *Color) Mul(s float32) *Color

Mul will multiply one color to another and return the resulting color

func (*Color) Sub

func (color *Color) Sub(c *Color) *Color

Sub will subtract one color from another and return the resulting color

type ColorMask

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

ColorMask contains an rgba color mask

func GetColorMask

func GetColorMask() ColorMask

GetColorMask will return the current color mask

type CompareMode

type CompareMode uint32

CompareMode defines different types of per-pixel stencil test comparisons. The pixels of an object will be drawn if the comparison succeeds, for each pixel that the object touches.

func GetStencilTest

func GetStencilTest() (CompareMode, int32)

GetStencilTest will return the current compare mode and the stencil test value.

type DrawMode

type DrawMode int

DrawMode is used to specify line or fill draws on primitives

type Drawable

type Drawable interface {
	Draw(args ...float32)
}

Drawable interface defines all objects that can be drawn. Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

type Filter

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

Filter is a representation of texture filtering that contains both min and mag filter modes

func GetDefaultFilter

func GetDefaultFilter() Filter

GetDefaultFilterF returns the scaling filters used with Images, Canvases, and Fonts.

type FilterMode

type FilterMode int

FilterMode is used for setting texture/image/canvas filters

func GetDefaultMipmapFilter

func GetDefaultMipmapFilter() (filter FilterMode, sharpness float32)

type Font

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

Font is a rasterized font data

func GetFont

func GetFont() *Font

GetFont will return the currenly bound font or the frameworks font if none has be bound.

func NewFont

func NewFont(filename string, font_size float32) *Font

NewFont rasterizes a ttf font and returns a pointer to a new Font

func NewImageFont

func NewImageFont(filename, glyph_hints string) *Font

NewImageFont rasterizes an image using the glyph_hints. The glyph_hints should list all characters in the image. The characters should all have equal width and height. Using the glyph_hints, the image is split up into equal rectangles for rasterization. The function will return a pointer to a new Font

func (*Font) GetAscent

func (font *Font) GetAscent() int

GetAscent gets the height of the font from the baseline

func (*Font) GetBaseline

func (font *Font) GetBaseline() int

GetBaseline returns the position of the base line.

func (*Font) GetDescent

func (font *Font) GetDescent() int

GetDescent gets the height of the font below the base line

func (*Font) GetFilter

func (font *Font) GetFilter() Filter

GetFilter will return the filter of the font

func (*Font) GetHeight

func (font *Font) GetHeight() float32

GetHeight will get the height of the font.

func (*Font) GetLineHeight

func (font *Font) GetLineHeight() float32

GetLineHeight will return the current line height of the font

func (*Font) GetWidth

func (font *Font) GetWidth(text string) float32

GetWidth will get the width of a given string after rendering.

func (*Font) GetWrap

func (font *Font) GetWrap(text string, wrapLimit float32) (float32, []string)

GetWrap will split a string given a wrap limit. It will return the max width of the longest string and it will return the string split into the strings that are smaller than the wrap limit.

func (*Font) HasGlyph

func (font *Font) HasGlyph(g rune) bool

HasGlyph checks if this font has a character for the given rune

func (*Font) HasGlyphs

func (font *Font) HasGlyphs(text string) bool

HasGlyphs will check every glyph in the string and return if it has a character for each character

func (*Font) Release

func (font *Font) Release()

Release will release all the gl objects associates with the canvas and clean up the memory

func (*Font) SetFallbacks

func (font *Font) SetFallbacks(fallbacks ...*Font)

SetFallbacks will add extra fonts in case some characters are not available in this font. If the character is not available it will be rendered with one of the fallback characters

func (*Font) SetFilter

func (font *Font) SetFilter(min, mag FilterMode) error

SetFilter sets the filtering on the font.

func (*Font) SetLineHeight

func (font *Font) SetLineHeight(height float32)

SetLineHeight sets the height between lines

type Image

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

Image is an image that is drawable to the screen

func NewImage

func NewImage(path string) (*Image, error)

NewImage will create a new texture for this image and return the *Image. If the file does not exist or cannot be decoded it will return an error.

func NewMipmappedImage

func NewMipmappedImage(path string) *Image

NewMipmappedImage is like NewImage but the image is mipmapped

func (*Image) Drawv

func (img *Image) Drawv(vertices []float32)

Drawv will take raw verticies so that you can draw the image on a polygon, specifying the image coords.

type LineJoin

type LineJoin int

LineJoin specifies how each lines are joined together

func GetLineJoin

func GetLineJoin() LineJoin

GetLineJoin will return the current line join. Default line join is miter.

type LineStyle

type LineStyle int

LineStyle specifies if the line drawing is smooth or rough

func GetLineStyle

func GetLineStyle() LineStyle

GetLineStyle will return the current line style. Default line style is smooth

type Mesh

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

Mesh is a collection of points that a texture can be applied to.

func NewMesh

func NewMesh(verticies []float32, size int) (*Mesh, error)

NewMesh will generate a mesh with the verticies and it with a max size of the size provided. MeshDrawMode is default to DRAWMODE_FAN and Usage is USAGE_DYNAMIC

func NewMeshExt

func NewMeshExt(vertices []float32, size int, mode MeshDrawMode, usage Usage) (*Mesh, error)

NewMeshExt is like NewMesh but with access to setting the MeshDrawMode and Usage.

func (*Mesh) ClearDrawRange

func (mesh *Mesh) ClearDrawRange()

ClearDrawRange will reset the draw range if you want to draw the whole mesh again.

func (*Mesh) ClearTexture

func (mesh *Mesh) ClearTexture()

ClearTexture will unbind the texture of the mesh

func (*Mesh) ClearVertexMap

func (mesh *Mesh) ClearVertexMap()

ClearVertexMap disabled the vertex map and re-enabled drawing the whole mesh again.

func (*Mesh) Draw

func (mesh *Mesh) Draw(args ...float32)

Draw satisfies the Drawable interface. Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func (*Mesh) Flush

func (mesh *Mesh) Flush()

Flush immediately sends all modified vertex data in the Mesh to the graphics card. Normally it isn't necessary to call this method as Draw(mesh, ...) will do it automatically if needed, but explicitly using Flush gives more control over when the work happens. If this method is used, it generally shouldn't be called more than once (at most) between draw(mesh, ...) calls.

func (*Mesh) GetDrawMode

func (mesh *Mesh) GetDrawMode() MeshDrawMode

GetDrawMode will return the current draw mode for the mesh

func (*Mesh) GetDrawRange

func (mesh *Mesh) GetDrawRange() (int, int)

GetDrawRange will return the min, max range set on the mesh. If no range is set the range will return -1, -1

func (*Mesh) GetTexture

func (mesh *Mesh) GetTexture() iTexture

GetTexture will return an interface iTexture if there is a texture bound, and nil if there isnt

func (*Mesh) GetVertex

func (mesh *Mesh) GetVertex(vertindex int) ([]float32, error)

GetVertex will return all the data for that vertex at the given index.

func (*Mesh) GetVertexCount

func (mesh *Mesh) GetVertexCount() int

GetVertexCount will return how many vertexes there are in the provided data.

func (*Mesh) GetVertexFormat

func (mesh *Mesh) GetVertexFormat() (vertex, text, color bool)

GetVertexFormat will return true for each attribute that is enabled.

func (*Mesh) GetVertexMap

func (mesh *Mesh) GetVertexMap() []uint32

GetVertexMap returns the currently set vertex map and an empty slice if there is not one set.

func (*Mesh) GetVertexStride

func (mesh *Mesh) GetVertexStride() int

GetVertexStride will return the number of components in each vertex. i.e. x, y, u, v, r, g, b, a

func (*Mesh) SetDrawMode

func (mesh *Mesh) SetDrawMode(mode MeshDrawMode)

SetDrawMode sets the MeshDrawMode. Please see the constant definitions for explanation.

func (*Mesh) SetDrawRange

func (mesh *Mesh) SetDrawRange(min, max int) error

SetDrawRange will set a range in the points to draw. This is useful if you only need to render a portion of the mesh.

func (*Mesh) SetTexture

func (mesh *Mesh) SetTexture(text iTexture)

SetTexture will apply a texture to the mesh. This will go a lot better if uv coords were provided to the mesh.

func (*Mesh) SetVertex

func (mesh *Mesh) SetVertex(vertindex int, data []float32) error

SetVertex will replace vertex data at the specified index. The index specifies the point and not the index in the array provided to the mesh.

func (*Mesh) SetVertexMap

func (mesh *Mesh) SetVertexMap(vertex_map []uint32)

SetVertexMap will allow to set indexes of verticies that should be drawn.

func (*Mesh) SetVertices

func (mesh *Mesh) SetVertices(startindex int, data []float32) error

SetVertices is like SetVertex but will do more than one point

type MeshDrawMode

type MeshDrawMode uint32

MeshDrawMode specifies the tesselation of the mesh points

type ParticleDistribution

type ParticleDistribution int

ParticleDistribution specifies which direction particle will be send in when spawned

type ParticleInsertion

type ParticleInsertion int

ParticleInsertion specifies which level a particle will be inserted on spawn.

type ParticleSystem

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

ParticleSystem generates and emits particles at set speeds and rotations.

func NewParticleSystem

func NewParticleSystem(texture iTexture, size int) *ParticleSystem

NewParticleSystem will create a new system where the texture given (generally an image) will be how each particle is represented and the size is the maximum number of particles displayed at a time.

func (*ParticleSystem) Draw

func (system *ParticleSystem) Draw(args ...float32)

Draw satisfies the Drawable interface. Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func (*ParticleSystem) Emit

func (system *ParticleSystem) Emit(num int)

Emit will emits a burst of particles from the particle emitter.

func (*ParticleSystem) GetAreaSpreadDistribution

func (system *ParticleSystem) GetAreaSpreadDistribution() ParticleDistribution

GetAreaSpreadDistrobution will return the particle distrobution of the system.

func (*ParticleSystem) GetAreaSpreadParameters

func (system *ParticleSystem) GetAreaSpreadParameters() (float32, float32)

GetAreaSpreadParameters will return the maximum spawn distance from the emitter for uniform distribution, or the standard deviation for normal distribution.

func (*ParticleSystem) GetBufferSize

func (system *ParticleSystem) GetBufferSize() int

GetBufferSize returns the maximum number of particles the system can create simultaneously.

func (*ParticleSystem) GetColor

func (system *ParticleSystem) GetColor() []*Color

GetColor will return all the colors set for each pixel. See Set color as to why this is an array

func (*ParticleSystem) GetCount

func (system *ParticleSystem) GetCount() int

GetCount will return the count of currently active particles

func (*ParticleSystem) GetDirection

func (system *ParticleSystem) GetDirection() float32

GetDirection will return the direction in radians that the particles will be emitted in.

func (*ParticleSystem) GetEmissionRate

func (system *ParticleSystem) GetEmissionRate() float32

GetEmissionRate will return the rate in which particles are generated by the system.

func (*ParticleSystem) GetEmitterLifetime

func (system *ParticleSystem) GetEmitterLifetime() float32

GetEmitterLifetime will return the lifetime of the system in seconds. Default lifetime on a system is -1

func (*ParticleSystem) GetInsertMode

func (system *ParticleSystem) GetInsertMode() ParticleInsertion

GetInsertMode will return the current ParticleInsertion of the system.

func (*ParticleSystem) GetLinearAcceleration

func (system *ParticleSystem) GetLinearAcceleration() (xmin, ymin, xmax, ymax float32)

GetLinearAcceleration will return the min and max ranges od linear acceleration on each particle.

func (*ParticleSystem) GetLinearDamping

func (system *ParticleSystem) GetLinearDamping() (min, max float32)

GetLinearDamping returns the range min, max of linear deceleration for particles.

func (*ParticleSystem) GetOffset

func (system *ParticleSystem) GetOffset() (x, y float32)

GetOffset will return the offset that each particle rotates at

func (*ParticleSystem) GetParticleLifetime

func (system *ParticleSystem) GetParticleLifetime() (float32, float32)

GetParticleLifetime will return the range, min, max, life time in seconds that each particle will have when they are emitted.

func (*ParticleSystem) GetPosition

func (system *ParticleSystem) GetPosition() (float32, float32)

GetPosition returns the position of the system.

func (*ParticleSystem) GetQuads

func (system *ParticleSystem) GetQuads() []Quad

GetQuads will return the quads that are to be used by the system.

func (*ParticleSystem) GetRadialAcceleration

func (system *ParticleSystem) GetRadialAcceleration() (min, max float32)

GetRadialAcceleration will return the range min, max of the radial acceleration on each particle.

func (*ParticleSystem) GetRotation

func (system *ParticleSystem) GetRotation() (min, max float32)

GetRotation will return the rotation range min, max for the texture

func (*ParticleSystem) GetSizeVariation

func (system *ParticleSystem) GetSizeVariation() float32

GetSizeVariation will return the set variation of sizes.

func (*ParticleSystem) GetSizes

func (system *ParticleSystem) GetSizes() []float32

GetSizes will return all the sizes set for each particle.

func (*ParticleSystem) GetSpeed

func (system *ParticleSystem) GetSpeed() (float32, float32)

GetSpeed will return the min, max range of speeds that the particles will be emitted in.

func (*ParticleSystem) GetSpin

func (system *ParticleSystem) GetSpin() (start, end float32)

GetSpin returns the range min, max spin (radians per second).

func (*ParticleSystem) GetSpinVariation

func (system *ParticleSystem) GetSpinVariation() float32

GetSpinVariation returns the variation in spin of the particles

func (*ParticleSystem) GetSpread

func (system *ParticleSystem) GetSpread() float32

GetSpread returns the spread in radians that the particle are emitted in.

func (*ParticleSystem) GetTangentialAcceleration

func (system *ParticleSystem) GetTangentialAcceleration() (min, max float32)

GetTangentialAcceleration will return the range min, max of the tangential acceleration on each particle.

func (*ParticleSystem) GetTexture

func (system *ParticleSystem) GetTexture() iTexture

GetTexture will return the texture currently being used by this particle system.

func (*ParticleSystem) HasRelativeRotation

func (system *ParticleSystem) HasRelativeRotation() bool

GetRelativeRotation returns whether particle angles and rotations are relative to their velocities. If enabled, particles are aligned to the angle of their velocities and rotate relative to that angle.

func (*ParticleSystem) IsActive

func (system *ParticleSystem) IsActive() bool

IsActive will return if the system is activly emitting particles

func (*ParticleSystem) IsEmpty

func (system *ParticleSystem) IsEmpty() bool

IsEmpty will return true if there are no active particles

func (*ParticleSystem) IsFull

func (system *ParticleSystem) IsFull() bool

IsFull will return true if the number of active particles has reached the max buffer size

func (*ParticleSystem) IsPaused

func (system *ParticleSystem) IsPaused() bool

IsPaused will return true if the system has been paused

func (*ParticleSystem) IsStopped

func (system *ParticleSystem) IsStopped() bool

IsStopped will return if the system is not active or has reached the end of its life time.

func (*ParticleSystem) MoveTo

func (system *ParticleSystem) MoveTo(x, y float32)

MoveTo moves the position of the emitter. This results in smoother particle spawning behaviour than if SetPosition is used every frame.

func (*ParticleSystem) Pause

func (system *ParticleSystem) Pause()

Pause will deactivate a system and stop emitting particles.

func (*ParticleSystem) Release

func (system *ParticleSystem) Release()

Release will release all the gl objects associates with the system and clean up the memory

func (*ParticleSystem) SetAreaSpread

func (system *ParticleSystem) SetAreaSpread(distribution ParticleDistribution, x, y float32)

SetAreaSpread sets area-based spawn parameters for the particles. Newly created particles will spawn in an area around the emitter based on the parameters to this function. x and y are the maximum spawn distance from the center of the emitter

func (*ParticleSystem) SetBufferSize

func (system *ParticleSystem) SetBufferSize(size int)

SetBufferSize resizes the maximum amount of particles the system can create simultaneously.

func (*ParticleSystem) SetColor

func (system *ParticleSystem) SetColor(newColors ...*Color)

SetColor sets a series of colors to apply to the particle sprite. The particle system will interpolate between each color evenly over the particle's lifetime.

func (*ParticleSystem) SetDirection

func (system *ParticleSystem) SetDirection(direction float32)

SetDirection sets the direction in radians the particles will be emitted in.

func (*ParticleSystem) SetEmissionRate

func (system *ParticleSystem) SetEmissionRate(rate float32)

SetEmissionRate will set the rate in which particles are generated by the system. you will the system seems to pause if your rate is high and your buffer size is low because it will reach the max size very quickly.

func (*ParticleSystem) SetEmitterLifetime

func (system *ParticleSystem) SetEmitterLifetime(life float32)

SetEmitterLifetime will set how long the system should continue to emit particles in seconds. If -1 then it emits particles forever.

func (*ParticleSystem) SetInsertMode

func (system *ParticleSystem) SetInsertMode(mode ParticleInsertion)

SetInsertMode will set the ParticleInsertion on the system and if the particles will appear on top, bottom, or randomly in the stack.

func (*ParticleSystem) SetLinearAcceleration

func (system *ParticleSystem) SetLinearAcceleration(xmin, ymin, xmax, ymax float32)

SetLinearAcceleration Sets a linear acceleration along the x and y axes, for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax.

func (*ParticleSystem) SetLinearDamping

func (system *ParticleSystem) SetLinearDamping(min, max float32)

SetLinearDamping sets the range of linear damping (constant deceleration) for particles.

func (*ParticleSystem) SetOffset

func (system *ParticleSystem) SetOffset(x, y float32)

SetOffset set the offset position which the particle sprite is rotated around. If this function is not used, the particles rotate around their center.

func (*ParticleSystem) SetParticleLifetime

func (system *ParticleSystem) SetParticleLifetime(min, max float32)

SetParticleLifetime will set how long in seconds each particle is to remain on screen before being destroys and a new particle emitted.

func (*ParticleSystem) SetPosition

func (system *ParticleSystem) SetPosition(x, y float32)

SetPosition sets the position the system will be rendered at. By using MoveTo the system can take into account the movement of the system when emitting particles. This is why you can use the system position insteam of drawing at this position.

func (*ParticleSystem) SetQuads

func (system *ParticleSystem) SetQuads(newQuads ...Quad)

SetQuads sets a series of Quads to use for the particle sprites. Particles will choose a Quad from the list based on the particle's current lifetime, allowing for the use of animated sprite sheets with ParticleSystems. If no quads are passed in it will clear the quads and use the whole texture again

func (*ParticleSystem) SetRadialAcceleration

func (system *ParticleSystem) SetRadialAcceleration(min, max float32)

SetRadialAcceleration Sets a radial acceleration along the x and y axes, for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax.

func (*ParticleSystem) SetRelativeRotation

func (system *ParticleSystem) SetRelativeRotation(enable bool)

SetRelativeRotation sets whether particle angles and rotations are relative to their velocities. If enabled, particles are aligned to the angle of their velocities and rotate relative to that angle.

func (*ParticleSystem) SetRotation

func (system *ParticleSystem) SetRotation(min, max float32)

SetRotation sets a range min, max initial angle of the texture in radians.

func (*ParticleSystem) SetSize

func (system *ParticleSystem) SetSize(size ...float32)

SetSize sets the size of the particles in pixels over its lifetime. If only one is provided it will stay that size, if multiple are give it will interpolate between the sizes over time. A max of 8 sizes

func (*ParticleSystem) SetSizeVariation

func (system *ParticleSystem) SetSizeVariation(variation float32)

SetSizeVariation sets the amount of size variation when the particle is emitted.

func (*ParticleSystem) SetSpeed

func (system *ParticleSystem) SetSpeed(min, max float32)

SetSpeed will set a range of speeds that the particles will be emitted in.

func (*ParticleSystem) SetSpin

func (system *ParticleSystem) SetSpin(start, end float32)

SetSpin sets the range min, max spin (radians per second).

func (*ParticleSystem) SetSpinVariation

func (system *ParticleSystem) SetSpinVariation(variation float32)

SetSpinVariation sets the amount of spin variation (0 meaning no variation and 1 meaning full variation between start and end).

func (*ParticleSystem) SetSpread

func (system *ParticleSystem) SetSpread(spread float32)

SetSpread sets the spread in radian from the direction being emitted.

func (*ParticleSystem) SetTangentialAcceleration

func (system *ParticleSystem) SetTangentialAcceleration(min, max float32)

SetTangentialAcceleration sets a tangential acceleration along the x and y axes, for particles. Every particle created will accelerate along the x and y axes between xmin,ymin and xmax,ymax.

func (*ParticleSystem) SetTexture

func (system *ParticleSystem) SetTexture(tex iTexture)

SetTexture will change the texture for the particles being inserted into the system.

func (*ParticleSystem) Start

func (system *ParticleSystem) Start()

Start will activate a stopped system.

func (*ParticleSystem) Stop

func (system *ParticleSystem) Stop()

Stop will deactivate a system, stop emitting particles and restart the life of the system.

func (*ParticleSystem) Update

func (system *ParticleSystem) Update(dt float32)

Update should be called from the amore update function with the delta time, this updates the position, color and rotation of all the particles.

type Quad

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

Quad is essentially a crop of an image/texture

func NewQuad

func NewQuad(x, y, w, h, sw, sh int32) *Quad

New Quad will generate a new *Quad with the dimensions given x, y are position on the texture w, h are the size of the quad sw, sh are references on how large the texture is. image.GetWidth(), image.GetHeight()

func (*Quad) GetHeight

func (quad *Quad) GetHeight() float32

GetHeight gets the height of the quad

func (*Quad) GetViewport

func (quad *Quad) GetViewport() (x, y, w, h int32)

GetViewport gets the current viewport of this Quad.

func (*Quad) GetWidth

func (quad *Quad) GetWidth() float32

GetWidth gets the width of the quad

func (*Quad) SetViewport

func (quad *Quad) SetViewport(x, y, w, h int32)

SetViewport sets the texture coordinates according to a viewport.

type QuadDrawable

type QuadDrawable interface {
	Drawq(quad *Quad, args ...float32)
}

QuadDrawable interface defines all objects that can be drawn with a quad. Inputs are as follows quad is the quad to crop the texture x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

type RandomGenerator

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

func (*RandomGenerator) GetSeed

func (generator *RandomGenerator) GetSeed() int64

func (*RandomGenerator) Rand

func (generator *RandomGenerator) Rand() float32

func (*RandomGenerator) RandMax

func (generator *RandomGenerator) RandMax(max float32) float32

func (*RandomGenerator) RandRange

func (generator *RandomGenerator) RandRange(min, max float32) float32

func (*RandomGenerator) RandomNormal

func (generator *RandomGenerator) RandomNormal(stddev float32) float32

Box–Muller transform

func (*RandomGenerator) SetSeed

func (generator *RandomGenerator) SetSeed(seed int64)

type Shader

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

func NewShader

func NewShader(paths ...string) *Shader

func (*Shader) Release

func (shader *Shader) Release()

func (*Shader) SendFloat

func (shader *Shader) SendFloat(name string, values ...float32) error

func (*Shader) SendInt

func (shader *Shader) SendInt(name string, values ...int32) error

func (*Shader) SendMat2

func (shader *Shader) SendMat2(name string, mat mgl32.Mat2) error

func (*Shader) SendMat3

func (shader *Shader) SendMat3(name string, mat mgl32.Mat3) error

func (*Shader) SendMat4

func (shader *Shader) SendMat4(name string, mat mgl32.Mat4) error

func (*Shader) SendTexture

func (shader *Shader) SendTexture(name string, texture iTexture) error

type SpriteBatch

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

SpriteBatch is a collection of images/quads/textures all drawn with a single draw call

func NewSpriteBatch

func NewSpriteBatch(text iTexture, size int) *SpriteBatch

NewSpriteBatch will generate a new batch with the size provided and bind the texture to it.

func NewSpriteBatchExt

func NewSpriteBatchExt(texture iTexture, size int, usage Usage) *SpriteBatch

NewSpriteBatchExt is like NewSpriteBatch but allows you to set the usage.

func (*SpriteBatch) Add

func (sprite_batch *SpriteBatch) Add(args ...float32) error

Add adds a sprite to the batch. Sprites are drawn in the order they are added. x, y The position to draw the object r rotation of the object sx, sy scale of the object ox, oy offset of the object kx, ky shear of the object

func (*SpriteBatch) Addq

func (sprite_batch *SpriteBatch) Addq(quad *Quad, args ...float32) error

Adds a Quad to the batch. This is very useful for something like a tilemap.

func (*SpriteBatch) Clear

func (sprite_batch *SpriteBatch) Clear()

Clear will remove all the sprites from the batch

func (*SpriteBatch) ClearColor

func (sprite_batch *SpriteBatch) ClearColor()

ClearColor will reset the color back to white

func (*SpriteBatch) ClearDrawRange

func (sprite_batch *SpriteBatch) ClearDrawRange()

ClearDrawRange will reset the draw range if you want to draw the whole batch again.

func (*SpriteBatch) Draw

func (sprite_batch *SpriteBatch) Draw(args ...float32)

Draw satisfies the Drawable interface. Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func (*SpriteBatch) GetBufferSize

func (sprite_batch *SpriteBatch) GetBufferSize() int

GetBufferSize will return the limit of sprites you can add to this batch.

func (*SpriteBatch) GetColor

func (sprite_batch *SpriteBatch) GetColor() *Color

GetColor will return the currently used color.

func (*SpriteBatch) GetCount

func (sprite_batch *SpriteBatch) GetCount() int

GetCount will return the amount of sprites already added to the batch

func (*SpriteBatch) GetDrawRange

func (sprite_batch *SpriteBatch) GetDrawRange() (int, int)

GetDrawRange will return the min, max range set on the batch. If no range is set the range will return -1, -1

func (*SpriteBatch) GetTexture

func (sprite_batch *SpriteBatch) GetTexture() iTexture

GetTexture will return the currently bound texture of this sprite batch.

func (*SpriteBatch) Release

func (sprite_batch *SpriteBatch) Release()

Release cleans up the gl object associates with the sprite batch. This should only be done when discarding this object.

func (*SpriteBatch) Set

func (sprite_batch *SpriteBatch) Set(index int, args ...float32) error

Set changes a sprite in the batch with the same arguments as add

func (*SpriteBatch) SetBufferSize

func (sprite_batch *SpriteBatch) SetBufferSize(newsize int) error

SetBufferSize will resize the buffer, change the limit of sprites you can add to this batch.

func (*SpriteBatch) SetColor

func (sprite_batch *SpriteBatch) SetColor(color *Color)

SetColor will set the color that will be used for the next add or set operations.

func (*SpriteBatch) SetDrawRange

func (sprite_batch *SpriteBatch) SetDrawRange(min, max int) error

SetDrawRange will set a range in the points to draw. This is useful if you only need to render a portion of the batch.

func (*SpriteBatch) SetTexture

func (sprite_batch *SpriteBatch) SetTexture(newtexture iTexture)

SetTexture will change the texture of the batch to a new one

func (*SpriteBatch) Setq

func (sprite_batch *SpriteBatch) Setq(index int, quad *Quad, args ...float32) error

Set changes a sprite in the batch with the same arguments as addq

type StencilAction

type StencilAction uint32

StencilAction is how a stencil function modifies the stencil values of pixels it touches.

type Text

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

func NewColorText

func NewColorText(font *Font, strs []string, colors []*Color) (*Text, error)

func NewColorTextExt

func NewColorTextExt(font *Font, strs []string, colors []*Color, wrap_limit float32, align AlignMode) (*Text, error)

func NewText

func NewText(font *Font, text string) (*Text, error)

func NewTextExt

func NewTextExt(font *Font, text string, wrap_limit float32, align AlignMode) (*Text, error)

func (*Text) Draw

func (text *Text) Draw(args ...float32)

Draw satisfies the Drawable interface. Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func (*Text) GetDimensions

func (text *Text) GetDimensions() (float32, float32)

func (*Text) GetFont

func (text *Text) GetFont() *Font

func (*Text) GetHeight

func (text *Text) GetHeight() float32

func (*Text) GetWidth

func (text *Text) GetWidth() float32

func (*Text) Release

func (text *Text) Release()

func (*Text) Set

func (text *Text) Set(t string)

func (*Text) SetFont

func (text *Text) SetFont(f *Font)

func (*Text) Setc

func (text *Text) Setc(strs []string, colors []*Color)

type Texture

type Texture struct {
	Width, Height int32
	// contains filtered or unexported fields
}

Texture is a struct to wrap the opengl texture object

func (*Texture) Draw

func (texture *Texture) Draw(args ...float32)

Draw satisfies the Drawable interface. Inputs are as follows x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func (*Texture) Drawq

func (texture *Texture) Drawq(quad *Quad, args ...float32)

Drawq satisfies the QuadDrawable interface. Inputs are as follows quad is the quad to crop the texture x, y, r, sx, sy, ox, oy, kx, ky x, y are position r is rotation sx, sy is the scale, if sy is not given sy will equal sx ox, oy are offset kx, ky are the shear. If ky is not given ky will equal kx

func (*Texture) GetDimensions

func (texture *Texture) GetDimensions() (int32, int32)

GetDimensions will return the width and height of the texture.

func (*Texture) GetFilter

func (texture *Texture) GetFilter() Filter

GetFilter will return the filter set on this texture.

func (*Texture) GetHeight

func (texture *Texture) GetHeight() int32

GetHeight will return the height of the texture.

func (*Texture) GetWidth

func (texture *Texture) GetWidth() int32

GetWidth will return the width of the texture.

func (*Texture) GetWrap

func (texture *Texture) GetWrap() Wrap

GetWrap will return the wrapping for how the texture behaves on a plane that is larger than itself

func (*Texture) Release

func (texture *Texture) Release()

Release will release the texture data and clean up the memory

func (*Texture) SetFilter

func (texture *Texture) SetFilter(min, mag FilterMode) error

SetFilter will set the min, mag filters for the texture filtering.

func (*Texture) SetMipmapSharpness

func (texture *Texture) SetMipmapSharpness(sharpness float32)

func (*Texture) SetWrap

func (texture *Texture) SetWrap(wrap_s, wrap_t WrapMode)

SetWrap will set how the texture behaves when applies to a plane that is larger than itself.

type UniformType

type UniformType int

UniformType is the data type of a uniform

type Usage

type Usage uint32

Usage is used for sprite batch usage, and specifies if it is static, dynamic, or stream

type Wrap

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

Wrap is a representation of texture rapping containing both s and t wrap

type WrapMode

type WrapMode int

WrapMode is used for setting texture/image/canvas wrap

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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