render

package
v0.0.0-...-03afc55 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2015 License: Apache-2.0 Imports: 25 Imported by: 8

Documentation

Index

Constants

View Source
const (
	AtlasSize = 1024
)

Variables

View Source
var (
	FOV = console.NewIntVar("r_fov", 90, console.Mutable, console.Serializable).Doc(`
r_fov controls the field of view of the camera. Measured
in degrees.
`)

	LightLevel, SkyOffset float32 = 0.8, 1.0
	ClearColour                   = struct{ R, G, B float32 }{
		122.0 / 255.0, 165.0 / 255.0, 247.0 / 255.0,
	}
)
View Source
var Camera = &ClientCamera{}

Camera is the main camera for the renderer

View Source
var DrawClouds = true

Functions

func AddIcon

func AddIcon(id string, pix image.Image)

func AllocateColumn

func AllocateColumn(x, z int)

AllocateColumn ensures the column's buffers are allocated.

func CloudData

func CloudData() []byte

func CreateProgram

func CreateProgram(vertex, fragment string) gl.Program

CreateProgram creates an OpenGL shader program from the passed shader sources. Panics if the shader is invalid.

func Draw

func Draw(width, height int, delta float64)

Draw draws a single frame

func DrawBox

func DrawBox(x1, y1, z1, x2, y2, z2 float64, r, g, b, a byte)

func FreeColumn

func FreeColumn(x, z int)

FreeColumn deallocates the column's buffers.

func FreeIcon

func FreeIcon(id string)

func FreeSkin

func FreeSkin(hash string)

func InitStruct

func InitStruct(inter interface{}, program gl.Program)

InitStruct loads the Uniform and Attribute fields of a struct with values from the program using the name from the 'gl' struct tag.

func LoadSkinBuffer

func LoadSkinBuffer()

func LoadTextures

func LoadTextures()

LoadTextures (re)loads all the block textures from the resource pack(s) TODO(Think) better error handling (if possible to recover?)

func RefSkin

func RefSkin(hash string)

func RefreshModels

func RefreshModels()

func SizeOfCharacter

func SizeOfCharacter(r rune) float64

Returns the size of the passed character in pixels.

func SizeOfString

func SizeOfString(str string) float64

Returns the size of the passed string in pixels.

func Start

func Start()

Start starts the renderer

func Sync

func Sync(f func())

Sync runs the passed function on the next frame on the same goroutine as the renderer.

func UIAddBytes

func UIAddBytes(data []byte)

Types

type ChunkBuffer

type ChunkBuffer struct {
	Rendered bool
	// contains filtered or unexported fields
}

ChunkBuffer is a renderable chunk section

func AllocateChunkBuffer

func AllocateChunkBuffer(x, y, z int) *ChunkBuffer

AllocateChunkBuffer allocates a chunk buffer and adds it to the render list.

func (*ChunkBuffer) Free

func (cb *ChunkBuffer) Free()

Free removes the buffer and frees related resources.

func (*ChunkBuffer) IsVisible

func (cb *ChunkBuffer) IsVisible(from, to direction.Type) bool

IsVisible returns whether the 'to' face is visible through 'from' face.

func (*ChunkBuffer) Upload

func (cb *ChunkBuffer) Upload(data []byte, indices int, cullBits uint64)

Upload uploads the passed vertex data to the buffer.

func (*ChunkBuffer) UploadTrans

func (cb *ChunkBuffer) UploadTrans(data []byte, indices int)

UploadTrans uploads the passed vertex data to the translucent buffer.

type ClientCamera

type ClientCamera struct {
	X, Y, Z    float64
	Yaw, Pitch float64
}

ClientCamera is a camera within the world

type Model

type Model struct {
	// For culling only
	X, Y, Z float32
	Radius  float32
	// Per a part matrix
	Matrix               []mgl32.Mat4
	Colors               [][4]float32
	BlockLight, SkyLight float32

	Verts []*ModelVertex
	// contains filtered or unexported fields
}

func NewModel

func NewModel(parts [][]*ModelVertex) *Model

func NewModelCollection

func NewModelCollection(parts [][]*ModelVertex, c *ModelCollection) *Model

func (*Model) Free

func (m *Model) Free()

func (*Model) Refresh

func (m *Model) Refresh()

type ModelCollection

type ModelCollection struct {
	// contains filtered or unexported fields
}
var (
	SunModels *ModelCollection
)

type ModelVertex

type ModelVertex struct {
	X, Y, Z            float32
	Texture            TextureInfo
	TextureX, TextureY float64
	R, G, B, A         byte
	// contains filtered or unexported fields
}

type TextureInfo

type TextureInfo interface {
	Atlas() int
	Rect() atlas.Rect
	Sub(x, y, w, h int) TextureInfo
}

TextureInfo returns information about a texture in an atlas

func CharacterTexture

func CharacterTexture(r rune) TextureInfo

CharacterTexture returns the TextureInfo for the passed rune or nil if one doesn't exist.

func GetTexture

func GetTexture(name string) TextureInfo

GetTexture returns the related TextureInfo for the requested texture. If the texture isn't found a placeholder is returned instead. The plugin prefix of 'minecraft:' is default

func Icon

func Icon(id string) TextureInfo

func RelativeTexture

func RelativeTexture(ti TextureInfo, w, h int) TextureInfo

func Skin

func Skin(hash string) TextureInfo

type UIElement

type UIElement struct {
	X, Y, W, H                 float64
	Layer                      int
	TX, TY, TW, TH             uint16
	TOffsetX, TOffsetY, TAtlas int16
	TSizeW, TSizeH             int16
	R, G, B, A                 byte
	Rotation                   float64
}

UIElement is a single element on the screen. It is a rectangle with a texture and a tint.

func NewUIElement

func NewUIElement(tex TextureInfo, x, y, width, height float64, tx, ty, tw, th float64) *UIElement

func (*UIElement) Bytes

func (u *UIElement) Bytes() []byte

type UIText

type UIText struct {
	Elements []*UIElement
	Width    float64
}

UIText is a collection of UI elements that make up a string of characters.

func NewUIText

func NewUIText(str string, x, y float64, rr, gg, bb int) UIText

DrawUIText draws a UIText element to the screen with the passed text at the location. The text may be tinted too

func NewUITextRotated

func NewUITextRotated(str string, x, y, sx, sy, rotation float64, rr, gg, bb int) UIText

DrawUITextRotated draws a UIText element to the screen with the passed text at the location. The text may be tinted, scaled and/or rotated too

func NewUITextScaled

func NewUITextScaled(str string, x, y, sx, sy float64, rr, gg, bb int) UIText

DrawUITextScaled draws a UIText element to the screen with the passed text at the location. The text may be tinted and/or scaled too

func (UIText) Alpha

func (u UIText) Alpha(a int)

Alpha changes the alpha of all theelements belonging to this UIText

func (UIText) Bytes

func (u UIText) Bytes() []byte

Directories

Path Synopsis
Package atlas provides a basic texture atlas
Package atlas provides a basic texture atlas
Package builder provides a simple way to create buffers to upload to the gpu
Package builder provides a simple way to create buffers to upload to the gpu
Package gl provides a more Go friendly OpenGL API
Package gl provides a more Go friendly OpenGL API
Package glsl handles glsl shaders and applies some preprocessing to them
Package glsl handles glsl shaders and applies some preprocessing to them

Jump to

Keyboard shortcuts

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