Skip to content

Commit

Permalink
Updates according to the latest Go and libs versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsf committed Oct 4, 2011
1 parent 13107fa commit b5cbfef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
13 changes: 7 additions & 6 deletions font.go
Expand Up @@ -16,12 +16,13 @@ func uploadTexture_NRGBA32(img *image.NRGBA) gl.Texture {
data := make([]uint8, b.Max.X * b.Max.Y * 4)
for y := 0; y < b.Max.Y; y++ {
for x := 0; x < b.Max.X; x++ {
p := &img.Pix[y * img.Stride + x]
p := img.At(x, y)
offset := y * b.Max.X * 4 + x * 4
data[offset+0] = p.R;
data[offset+1] = p.G;
data[offset+2] = p.B;
data[offset+3] = p.A;
r, g, b, a := p.RGBA()
data[offset+0] = uint8(r)
data[offset+1] = uint8(g)
data[offset+2] = uint8(b)
data[offset+3] = uint8(a)
}
}

Expand All @@ -32,7 +33,7 @@ func uploadTexture_NRGBA32(img *image.NRGBA) gl.Texture {
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, b.Max.X, b.Max.Y, 0, gl.RGBA, data)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, b.Max.X, b.Max.Y, 0, gl.RGBA, gl.UNSIGNED_BYTE, data)

if gl.GetError() != gl.NO_ERROR {
id.Delete()
Expand Down
18 changes: 12 additions & 6 deletions gotris.go
Expand Up @@ -725,14 +725,20 @@ func main() {
lastTime := sdl.GetTicks()

running := true
e := new(sdl.Event)
for running {
for e.Poll() {
switch e.Type {
case sdl.QUIT:
for {
event := sdl.PollEvent()
if event == nil {
break
}

switch e := event.(type) {
case *sdl.QuitEvent:
running = false
case sdl.KEYDOWN:
running = gs.HandleKey(e.Keyboard().Keysym.Sym)
case *sdl.KeyboardEvent:
if e.Type == sdl.KEYDOWN {
running = gs.HandleKey(e.Keysym.Sym)
}
}
}

Expand Down

0 comments on commit b5cbfef

Please sign in to comment.