Documentation ¶
Index ¶
- Constants
- Variables
- func AddIcon(id string, pix image.Image)
- func AllocateColumn(x, z int)
- func CloudData() []byte
- func CreateProgram(vertex, fragment string) gl.Program
- func Draw(width, height int, delta float64)
- func DrawBox(x1, y1, z1, x2, y2, z2 float64, r, g, b, a byte)
- func FreeColumn(x, z int)
- func FreeIcon(id string)
- func FreeSkin(hash string)
- func InitStruct(inter interface{}, program gl.Program)
- func LoadSkinBuffer()
- func LoadTextures()
- func RefSkin(hash string)
- func RefreshModels()
- func SizeOfCharacter(r rune) float64
- func SizeOfString(str string) float64
- func Start()
- func Sync(f func())
- func UIAddBytes(data []byte)
- type ChunkBuffer
- type ClientCamera
- type Model
- type ModelCollection
- type ModelVertex
- type TextureInfo
- type UIElement
- type UIText
Constants ¶
const (
AtlasSize = 1024
)
Variables ¶
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, } )
var Camera = &ClientCamera{}
Camera is the main camera for the renderer
var DrawClouds = true
Functions ¶
func AllocateColumn ¶
func AllocateColumn(x, z int)
AllocateColumn ensures the column's buffers are allocated.
func CreateProgram ¶
CreateProgram creates an OpenGL shader program from the passed shader sources. Panics if the shader is invalid.
func InitStruct ¶
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 RefreshModels ¶
func RefreshModels()
func SizeOfCharacter ¶
Returns the size of the passed character in pixels.
func SizeOfString ¶
Returns the size of the passed string in pixels.
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 ¶
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
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
type UIText ¶
UIText is a collection of UI elements that make up a string of characters.
func NewUIText ¶
DrawUIText draws a UIText element to the screen with the passed text at the location. The text may be tinted too
func NewUITextRotated ¶
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 ¶
DrawUITextScaled draws a UIText element to the screen with the passed text at the location. The text may be tinted and/or scaled too
Source Files ¶
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 |