Skip to content

Commit 1c3e930

Browse files
authored
Merge pull request #4 from dusk125/atlas-ext
2 parents a6e31f9 + 0ded3b1 commit 1c3e930

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

ext/atlas/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Atlas Extension
2+
3+
This is a simple example of the texture atlas extension.

ext/atlas/hiking.png

67.8 KB
Loading

ext/atlas/main.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"github.com/gopxl/pixel/v2"
5+
"github.com/gopxl/pixel/v2/backends/opengl"
6+
"github.com/gopxl/pixel/v2/ext/atlas"
7+
"golang.org/x/image/colornames"
8+
)
9+
10+
var (
11+
Atlas atlas.Atlas
12+
group = Atlas.MakeGroup()
13+
hiking = group.AddFile("hiking.png")
14+
gopher = Atlas.AddFile("thegopherproject.png")
15+
)
16+
17+
func run() {
18+
cfg := opengl.WindowConfig{
19+
Title: "Atlas example",
20+
Bounds: pixel.R(0, 0, 1024, 768),
21+
}
22+
win, err := opengl.NewWindow(cfg)
23+
if err != nil {
24+
panic(err)
25+
}
26+
defer win.Destroy()
27+
28+
Atlas.Pack()
29+
30+
for !win.Closed() {
31+
if win.JustPressed(pixel.KeyEscape) {
32+
win.SetClosed(true)
33+
}
34+
35+
win.Clear(colornames.Skyblue)
36+
37+
hiking.Draw(win, pixel.IM.Moved(win.Bounds().Center()))
38+
gopher.Draw(win, pixel.IM.Moved(win.Bounds().Center()))
39+
40+
win.Update()
41+
}
42+
}
43+
44+
func main() {
45+
opengl.Run(run)
46+
}

ext/atlas/thegopherproject.png

26.8 KB
Loading

0 commit comments

Comments
 (0)