Example #1
0
func CreateLines() *Lines {
	l := &Lines{
		Lines:    make([]Line, 0, 0),
		Material: assets.GetMaterialCached("lines"),
		Width:    10.0,
		vao:      render.CreateVertexArray(),
		vbo:      render.CreateVertexBuffer(),
	}
	l.Compute()
	return l
}
Example #2
0
func NewImageQuadAt(mat *render.Material, x, y, w, h, z float32) *ImageQuad {
	q := &ImageQuad{
		Material:    mat,
		TopLeft:     ImageVertex{X: x, Y: y + h, Z: z, Tx: 0, Ty: 0},
		TopRight:    ImageVertex{X: x + w, Y: y + h, Z: z, Tx: 1, Ty: 0},
		BottomLeft:  ImageVertex{X: x, Y: y, Z: z, Tx: 0, Ty: 1},
		BottomRight: ImageVertex{X: x + w, Y: y, Z: z, Tx: 1, Ty: 1},
		vao:         render.CreateVertexArray(),
		vbo:         render.CreateVertexBuffer(),
	}
	q.compute()
	return q
}
Example #3
0
func NewChunk(parentObject *engine.Object, size int, ts *Tileset) *Chunk {
	chk := &Chunk{
		Size:    size,
		Tileset: ts,
		Data:    make([]*Voxel, size*size*size),

		vao: render.CreateVertexArray(),
		vbo: render.CreateVertexBuffer(),
	}

	chk.ComponentBase = engine.NewComponent(parentObject, chk)
	return chk
}
Example #4
0
func NewQuad(mat *render.Material, color render.Color, w, h, z float32) *Quad {
	q := &Quad{
		Material:    mat,
		TopLeft:     ColorVertex{X: 0, Y: h, Z: z, Color: color},
		TopRight:    ColorVertex{X: w, Y: h, Z: z, Color: color},
		BottomLeft:  ColorVertex{X: 0, Y: 0, Z: z, Color: color},
		BottomRight: ColorVertex{X: w, Y: 0, Z: z, Color: color},
		segments:    5,
		border:      0,

		vao: render.CreateVertexArray(),
		vbo: render.CreateVertexBuffer(),
	}
	q.compute()
	return q
}