Permalink
Browse files

Updates according to the latest Go and libs versions.

  • Loading branch information...
1 parent 13107fa commit b5cbfef1f430da04dbf1422d7817224150ee10b0 @nsf committed Oct 4, 2011
Showing with 19 additions and 12 deletions.
  1. +7 −6 font.go
  2. +12 −6 gotris.go
View
@@ -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)
}
}
@@ -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()
View
@@ -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)
+ }
}
}

0 comments on commit b5cbfef

Please sign in to comment.