Skip to content

Commit 889be5f

Browse files
committed
examples: Update examples to build with latest API
Signed-off-by: Lilis Iskandar <[email protected]>
1 parent ae9169a commit 889be5f

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

examples/events/events.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
var winTitle string = "Go-SDL2 Events"
12-
var winWidth, winHeight int = 800, 600
12+
var winWidth, winHeight int32 = 800, 600
1313
var joysticks [16]*sdl.Joystick
1414

1515
func run() int {

examples/gfx/gfx.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"fmt"
55
"os"
66

7-
"github.com/veandco/go-sdl2/sdl"
87
"github.com/veandco/go-sdl2/gfx"
8+
"github.com/veandco/go-sdl2/sdl"
99
)
1010

1111
var winTitle string = "SDL2 GFX"
12-
var winWidth, winHeight int = 800, 600
12+
var winWidth, winHeight int32 = 800, 600
1313

1414
func run() int {
1515
var window *sdl.Window
@@ -44,7 +44,7 @@ func run() int {
4444
vy[2] = int16(winHeight * 2 / 3)
4545
gfx.FilledPolygonColor(renderer, vx, vy, sdl.Color{0, 0, 255, 255})
4646

47-
gfx.CharacterColor(renderer, winWidth - 16, 16, 'X', sdl.Color{255, 0, 0, 255})
47+
gfx.CharacterColor(renderer, winWidth-16, 16, 'X', sdl.Color{255, 0, 0, 255})
4848
gfx.StringColor(renderer, 16, 16, "GFX Demo", sdl.Color{0, 255, 0, 255})
4949

5050
renderer.Present()

examples/messagebox/messagebox.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import (
88

99
func main() {
1010
buttons := []sdl.MessageBoxButtonData{
11-
{ 0, 0, "no" },
12-
{ sdl.MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "yes" },
13-
{ sdl.MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "cancel" },
11+
{0, 0, "no"},
12+
{sdl.MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "yes"},
13+
{sdl.MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "cancel"},
1414
}
1515

1616
colorScheme := sdl.MessageBoxColorScheme{
1717
Colors: [5]sdl.MessageBoxColor{
18-
sdl.MessageBoxColor{ 255, 0, 0 },
19-
sdl.MessageBoxColor{ 0, 255, 0 },
20-
sdl.MessageBoxColor{ 255, 255, 0 },
21-
sdl.MessageBoxColor{ 0, 0, 255 },
22-
sdl.MessageBoxColor{ 255, 0, 255 },
18+
sdl.MessageBoxColor{255, 0, 0},
19+
sdl.MessageBoxColor{0, 255, 0},
20+
sdl.MessageBoxColor{255, 255, 0},
21+
sdl.MessageBoxColor{0, 0, 255},
22+
sdl.MessageBoxColor{255, 0, 255},
2323
},
2424
}
2525

@@ -35,7 +35,7 @@ func main() {
3535

3636
var buttonid int32
3737
var err error
38-
if err, buttonid = sdl.ShowMessageBox(&messageboxdata); err != nil {
38+
if buttonid, err = sdl.ShowMessageBox(&messageboxdata); err != nil {
3939
fmt.Println("error displaying message box")
4040
return
4141
}

examples/opengl/opengl.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func main() {
1212
var winTitle string = "Go-SDL2 + Go-GL"
13-
var winWidth, winHeight int = 800, 600
13+
var winWidth, winHeight int32 = 800, 600
1414
var window *sdl.Window
1515
var context sdl.GLContext
1616
var event sdl.Event
@@ -32,11 +32,11 @@ func main() {
3232
panic(err)
3333
}
3434
defer window.Destroy()
35-
context, err = sdl.GL_CreateContext(window)
35+
context, err = sdl.GLCreateContext(window)
3636
if err != nil {
3737
panic(err)
3838
}
39-
defer sdl.GL_DeleteContext(context)
39+
defer sdl.GLDeleteContext(context)
4040

4141
gl.Enable(gl.DEPTH_TEST)
4242
gl.ClearColor(0.2, 0.2, 0.3, 1.0)
@@ -55,7 +55,7 @@ func main() {
5555
}
5656
}
5757
drawgl()
58-
sdl.GL_SwapWindow(window)
58+
sdl.GLSwapWindow(window)
5959
}
6060
}
6161

examples/opengl3/opengl3.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ func main() {
7171
panic(err)
7272
}
7373
defer window.Destroy()
74-
context, err = sdl.GL_CreateContext(window)
74+
context, err = sdl.GLCreateContext(window)
7575
if err != nil {
7676
panic(err)
7777
}
78-
defer sdl.GL_DeleteContext(context)
78+
defer sdl.GLDeleteContext(context)
7979

8080
gl.Init()
8181
gl.Viewport(0, 0, gl.Sizei(winWidth), gl.Sizei(winHeight))
@@ -136,7 +136,7 @@ func main() {
136136
}
137137
}
138138
drawgl()
139-
sdl.GL_SwapWindow(window)
139+
sdl.GLSwapWindow(window)
140140
}
141141
}
142142

examples/render/render.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
var winTitle string = "Go-SDL2 Render"
12-
var winWidth, winHeight int = 800, 600
12+
var winWidth, winHeight int32 = 800, 600
1313

1414
func run() int {
1515
var window *sdl.Window

examples/text/text.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
var winTitle string = "Text"
12-
var winWidth, winHeight int = 800, 600
12+
var winWidth, winHeight int32 = 800, 600
1313

1414
func run() int {
1515
var window *sdl.Window

examples/texture/texture.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
var winTitle string = "Go-SDL2 Texture"
12-
var winWidth, winHeight int = 800, 600
12+
var winWidth, winHeight int32 = 800, 600
1313
var imageName string = "../../assets/test.bmp"
1414

1515
func run() int {

examples/texture_png/texture_png.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ package main
44

55
import (
66
"fmt"
7-
"github.com/veandco/go-sdl2/sdl"
87
"github.com/veandco/go-sdl2/img"
8+
"github.com/veandco/go-sdl2/sdl"
99
"os"
1010
)
1111

1212
var winTitle string = "Go-SDL2 Texture"
13-
var winWidth, winHeight int = 800, 600
13+
var winWidth, winHeight int32 = 800, 600
1414
var imageName string = "../../assets/test.png"
1515

1616
func run() int {

0 commit comments

Comments
 (0)