Skip to content

Commit 4ebcc92

Browse files
committed
sdl: Change types of coordinate and size variables and parameters from int to int32
Signed-off-by: Lilis Iskandar <[email protected]>
1 parent 6e5c884 commit 4ebcc92

File tree

7 files changed

+55
-55
lines changed

7 files changed

+55
-55
lines changed

sdl/joystick.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (joy *Joystick) GetHat(hat int) byte {
151151

152152
// GetBall returns the ball axis change since the last poll.
153153
// (https://wiki.libsdl.org/SDL_JoystickGetBall)
154-
func (joy *Joystick) GetBall(ball int, dx, dy *int) int {
154+
func (joy *Joystick) GetBall(ball int, dx, dy *int32) int {
155155
_dx := (*C.int)(unsafe.Pointer(dx))
156156
_dy := (*C.int)(unsafe.Pointer(dy))
157157
return (int)(C.SDL_JoystickGetBall(joy.cptr(), C.int(ball), _dx, _dy))

sdl/mouse.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ func GetMouseFocus() *Window {
6868

6969
// GetMouseState returns the current state of the mouse.
7070
// (https://wiki.libsdl.org/SDL_GetMouseState)
71-
func GetMouseState() (x, y int, state uint32) {
71+
func GetMouseState() (x, y int32, state uint32) {
7272
var _x, _y C.int
7373
_state := uint32(C.SDL_GetMouseState(&_x, &_y))
74-
return int(_x), int(_y), _state
74+
return int32(_x), int32(_y), _state
7575
}
7676

7777
// GetRelativeMouseState returns the relative state of the mouse.
7878
// (https://wiki.libsdl.org/SDL_GetRelativeMouseState)
79-
func GetRelativeMouseState() (x, y int, state uint32) {
79+
func GetRelativeMouseState() (x, y int32, state uint32) {
8080
var _x, _y C.int
8181
_state := uint32(C.SDL_GetRelativeMouseState(&_x, &_y))
82-
return int(_x), int(_y), _state
82+
return int32(_x), int32(_y), _state
8383
}
8484

8585
// WarpMouseInWindow moves the mouse to the given position within the window.
8686
// (https://wiki.libsdl.org/SDL_WarpMouseInWindow)
87-
func (window *Window) WarpMouseInWindow(x, y int) {
87+
func (window *Window) WarpMouseInWindow(x, y int32) {
8888
C.SDL_WarpMouseInWindow(window.cptr(), C.int(x), C.int(y))
8989
}
9090

@@ -102,15 +102,15 @@ func GetRelativeMouseMode() bool {
102102

103103
// CreateCursor creates a cursor using the specified bitmap data and mask (in MSB format).
104104
// (https://wiki.libsdl.org/SDL_CreateCursor)
105-
func CreateCursor(data, mask *uint8, w, h, hotX, hotY int) *Cursor {
105+
func CreateCursor(data, mask *uint8, w, h, hotX, hotY int32) *Cursor {
106106
_data := (*C.Uint8)(unsafe.Pointer(data))
107107
_mask := (*C.Uint8)(unsafe.Pointer(mask))
108108
return (*Cursor)(C.SDL_CreateCursor(_data, _mask, C.int(w), C.int(h), C.int(hotX), C.int(hotY)))
109109
}
110110

111111
// CreateColorCursor creates a color cursor.
112112
// (https://wiki.libsdl.org/SDL_CreateColorCursor)
113-
func CreateColorCursor(surface *Surface, hotX, hotY int) *Cursor {
113+
func CreateColorCursor(surface *Surface, hotX, hotY int32) *Cursor {
114114
return (*Cursor)(C.SDL_CreateColorCursor(surface.cptr(), C.int(hotX), C.int(hotY)))
115115
}
116116

sdl/rect.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@ func computeOutCode(rect *Rect, x, y int32) int {
274274

275275
// IntersectLine calculates the intersection of a rectangle and a line segment.
276276
// (https://wiki.libsdl.org/SDL_IntersectRectAndLine)
277-
func (a *Rect) IntersectLine(X1, Y1, X2, Y2 *int) bool {
277+
func (a *Rect) IntersectLine(X1, Y1, X2, Y2 *int32) bool {
278278
if a.Empty() {
279279
return false
280280
}
281281

282-
x1 := int32(*X1)
283-
y1 := int32(*Y1)
284-
x2 := int32(*X2)
285-
y2 := int32(*Y2)
282+
x1 := *X1
283+
y1 := *Y1
284+
x2 := *X2
285+
y2 := *Y2
286286
rectX1 := a.X
287287
rectY1 := a.Y
288288
rectX2 := a.X + a.W - 1
@@ -303,14 +303,14 @@ func (a *Rect) IntersectLine(X1, Y1, X2, Y2 *int) bool {
303303
// Check if the line is horizontal
304304
if y1 == y2 {
305305
if x1 < rectX1 {
306-
*X1 = int(rectX1)
306+
*X1 = rectX1
307307
} else if x1 > rectX2 {
308-
*X1 = int(rectX2)
308+
*X1 = rectX2
309309
}
310310
if x2 < rectX1 {
311-
*X2 = int(rectX1)
311+
*X2 = rectX1
312312
} else if x2 > rectX2 {
313-
*X2 = int(rectX2)
313+
*X2 = rectX2
314314
}
315315

316316
return true
@@ -319,14 +319,14 @@ func (a *Rect) IntersectLine(X1, Y1, X2, Y2 *int) bool {
319319
// Check if the line is vertical
320320
if x1 == x2 {
321321
if y1 < rectY1 {
322-
*Y1 = int(rectY1)
322+
*Y1 = rectY1
323323
} else if y1 > rectY2 {
324-
*Y1 = int(rectY2)
324+
*Y1 = rectY2
325325
}
326326
if y2 < rectY1 {
327-
*Y2 = int(rectY1)
327+
*Y2 = rectY1
328328
} else if y2 > rectY2 {
329-
*Y2 = int(rectY2)
329+
*Y2 = rectY2
330330
}
331331

332332
return true
@@ -381,10 +381,10 @@ func (a *Rect) IntersectLine(X1, Y1, X2, Y2 *int) bool {
381381
}
382382
}
383383

384-
*X1 = int(x1)
385-
*Y1 = int(y1)
386-
*X2 = int(x2)
387-
*Y2 = int(y2)
384+
*X1 = x1
385+
*Y1 = y1
386+
*X2 = x2
387+
*Y2 = y2
388388

389389
return true
390390
}

sdl/rect_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ func TestIntersectLines(t *testing.T) {
116116

117117
var tests = []struct {
118118
want bool
119-
in struct{ x1, y1, x2, y2 int }
120-
out struct{ x1, y1, x2, y2 int }
119+
in struct{ x1, y1, x2, y2 int32 }
120+
out struct{ x1, y1, x2, y2 int32 }
121121
r *Rect
122122
}{
123123
{want: false,
124-
in: struct{ x1, y1, x2, y2 int }{15, 15, 25, 25},
125-
out: struct{ x1, y1, x2, y2 int }{15, 15, 25, 25},
124+
in: struct{ x1, y1, x2, y2 int32 }{15, 15, 25, 25},
125+
out: struct{ x1, y1, x2, y2 int32 }{15, 15, 25, 25},
126126
r: &Rect{X: 0, Y: 0, W: 10, H: 10}},
127127
{want: true,
128-
in: struct{ x1, y1, x2, y2 int }{-1, -1, 11, 11},
129-
out: struct{ x1, y1, x2, y2 int }{0, 0, 9, 9},
128+
in: struct{ x1, y1, x2, y2 int32 }{-1, -1, 11, 11},
129+
out: struct{ x1, y1, x2, y2 int32 }{0, 0, 9, 9},
130130
r: &Rect{X: 0, Y: 0, W: 10, H: 10}}}
131131

132132
for _, test := range tests {

sdl/render.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func GetRenderDriverInfo(index int, info *RendererInfo) int {
109109

110110
// CreateWindowAndRenderer returns a new window and default renderer.
111111
// (https://wiki.libsdl.org/SDL_CreateWindowAndRenderer)
112-
func CreateWindowAndRenderer(w, h int, flags uint32) (*Window, *Renderer, error) {
112+
func CreateWindowAndRenderer(w, h int32, flags uint32) (*Window, *Renderer, error) {
113113
var window *C.SDL_Window
114114
var renderer *C.SDL_Renderer
115115
ret := C.SDL_CreateWindowAndRenderer(C.int(w), C.int(h), C.Uint32(flags), &window, &renderer)
@@ -168,7 +168,7 @@ func (renderer *Renderer) GetInfo() (RendererInfo, error) {
168168

169169
// GetOutputSize returns the output size in pixels of a rendering context.
170170
// (https://wiki.libsdl.org/SDL_GetRendererOutputSize)
171-
func (renderer *Renderer) GetOutputSize() (w, h int, err error) {
171+
func (renderer *Renderer) GetOutputSize() (w, h int32, err error) {
172172
_w := (*C.int)(unsafe.Pointer(&w))
173173
_h := (*C.int)(unsafe.Pointer(&h))
174174
_ret := C.SDL_GetRendererOutputSize(renderer.cptr(), _w, _h)
@@ -180,7 +180,7 @@ func (renderer *Renderer) GetOutputSize() (w, h int, err error) {
180180

181181
// CreateTexture returns a new texture for a rendering context.
182182
// (https://wiki.libsdl.org/SDL_CreateTexture)
183-
func (renderer *Renderer) CreateTexture(format uint32, access int, w int, h int) (*Texture, error) {
183+
func (renderer *Renderer) CreateTexture(format uint32, access int, w, h int32) (*Texture, error) {
184184
_format := C.Uint32(format)
185185
_access := C.int(access)
186186
_w := C.int(w)
@@ -362,7 +362,7 @@ func (renderer *Renderer) GetRenderTarget() *Texture {
362362

363363
// SetLogicalSize sets a device independent resolution for rendering.
364364
// (https://wiki.libsdl.org/SDL_RenderSetLogicalSize)
365-
func (renderer *Renderer) SetLogicalSize(w int, h int) error {
365+
func (renderer *Renderer) SetLogicalSize(w, h int32) error {
366366
_ret := C.SDL_RenderSetLogicalSize(renderer.cptr(), C.int(w), C.int(h))
367367
if _ret < 0 {
368368
return GetError()
@@ -372,7 +372,7 @@ func (renderer *Renderer) SetLogicalSize(w int, h int) error {
372372

373373
// GetLogicalSize returns device independent resolution for rendering.
374374
// (https://wiki.libsdl.org/SDL_RenderGetLogicalSize)
375-
func (renderer *Renderer) GetLogicalSize() (w, h int) {
375+
func (renderer *Renderer) GetLogicalSize() (w, h int32) {
376376
_w := (*C.int)(unsafe.Pointer(&w))
377377
_h := (*C.int)(unsafe.Pointer(&h))
378378
C.SDL_RenderGetLogicalSize(renderer.cptr(), _w, _h)
@@ -506,7 +506,7 @@ func (renderer *Renderer) Clear() error {
506506

507507
// DrawPoint draws a point on the current rendering target.
508508
// (https://wiki.libsdl.org/SDL_RenderDrawPoint)
509-
func (renderer *Renderer) DrawPoint(x, y int) error {
509+
func (renderer *Renderer) DrawPoint(x, y int32) error {
510510
_ret := C.SDL_RenderDrawPoint(renderer.cptr(), C.int(x), C.int(y))
511511
if _ret < 0 {
512512
return GetError()
@@ -526,7 +526,7 @@ func (renderer *Renderer) DrawPoints(points []Point) error {
526526

527527
// DrawLine draws a line on the current rendering target.
528528
// (https://wiki.libsdl.org/SDL_RenderDrawLine)
529-
func (renderer *Renderer) DrawLine(x1, y1, x2, y2 int) error {
529+
func (renderer *Renderer) DrawLine(x1, y1, x2, y2 int32) error {
530530
_x1 := C.int(x1)
531531
_y1 := C.int(y1)
532532
_x2 := C.int(x2)

sdl/surface.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func CreateRGBSurface(flags uint32, width, height, depth int32, Rmask, Gmask, Bm
6363

6464
// CreateRGBSurfaceFrom allocate a new RGB surface with existing pixel data.
6565
// (https://wiki.libsdl.org/SDL_CreateRGBSurfaceFrom)
66-
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
66+
func CreateRGBSurfaceFrom(pixels unsafe.Pointer, width, height int32, depth, pitch int, Rmask, Gmask, Bmask, Amask uint32) (*Surface, error) {
6767
surface := (*Surface)(unsafe.Pointer(C.SDL_CreateRGBSurfaceFrom(
6868
pixels,
6969
C.int(width),
@@ -261,7 +261,7 @@ func (surface *Surface) ConvertFormat(pixelFormat uint32, flags uint32) (*Surfac
261261

262262
// ConvertPixels copies a block of pixels of one format to another format.
263263
// (https://wiki.libsdl.org/SDL_ConvertPixels)
264-
func ConvertPixels(width, height int, srcFormat uint32, src unsafe.Pointer, srcPitch int,
264+
func ConvertPixels(width, height int32, srcFormat uint32, src unsafe.Pointer, srcPitch int,
265265
dstFormat uint32, dst unsafe.Pointer, dstPitch int) error {
266266
if C.SDL_ConvertPixels(C.int(width), C.int(height), C.Uint32(srcFormat), src, C.int(srcPitch), C.Uint32(dstFormat), dst, C.int(dstPitch)) != 0 {
267267
return GetError()

sdl/video.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func (window *Window) GetPixelFormat() (uint32, error) {
378378

379379
// CreateWindow creates a window with the specified position, dimensions, and flags.
380380
// (https://wiki.libsdl.org/SDL_CreateWindow)
381-
func CreateWindow(title string, x int, y int, w int, h int, flags uint32) (*Window, error) {
381+
func CreateWindow(title string, x, y, w, h int32, flags uint32) (*Window, error) {
382382
_title := C.CString(title)
383383
var _window = C.SDL_CreateWindow(_title, C.int(x), C.int(y), C.int(w), C.int(h), C.Uint32(flags))
384384
if _window == nil {
@@ -460,16 +460,16 @@ func (window *Window) GetData(name string) unsafe.Pointer {
460460

461461
// SetPosition sets the position of the window.
462462
// (https://wiki.libsdl.org/SDL_SetWindowPosition)
463-
func (window *Window) SetPosition(x int, y int) {
463+
func (window *Window) SetPosition(x, y int32) {
464464
C.SDL_SetWindowPosition(window.cptr(), C.int(x), C.int(y))
465465
}
466466

467467
// GetPosition returns the position of the window.
468468
// (https://wiki.libsdl.org/SDL_GetWindowPosition)
469-
func (window *Window) GetPosition() (x, y int) {
469+
func (window *Window) GetPosition() (x, y int32) {
470470
var _x, _y C.int
471471
C.SDL_GetWindowPosition(window.cptr(), &_x, &_y)
472-
return int(_x), int(_y)
472+
return int32(_x), int32(_y)
473473
}
474474

475475
// SetResizable sets the user-resizable state of the window.
@@ -484,44 +484,44 @@ func (window *Window) SetResizable(resizable bool) {
484484

485485
// SetSize sets the size of the window's client area.
486486
// (https://wiki.libsdl.org/SDL_SetWindowSize)
487-
func (window *Window) SetSize(w int, h int) {
487+
func (window *Window) SetSize(w, h int32) {
488488
C.SDL_SetWindowSize(window.cptr(), C.int(w), C.int(h))
489489
}
490490

491491
// GetSize returns the size of the window's client area.
492492
// (https://wiki.libsdl.org/SDL_GetWindowSize)
493-
func (window *Window) GetSize() (w, h int) {
493+
func (window *Window) GetSize() (w, h int32) {
494494
var _w, _h C.int
495495
C.SDL_GetWindowSize(window.cptr(), &_w, &_h)
496-
return int(_w), int(_h)
496+
return int32(_w), int32(_h)
497497
}
498498

499499
// SetMinimumSize sets the minimum size of the window's client area.
500500
// (https://wiki.libsdl.org/SDL_SetWindowMinimumSize)
501-
func (window *Window) SetMinimumSize(minW int, minH int) {
501+
func (window *Window) SetMinimumSize(minW, minH int32) {
502502
C.SDL_SetWindowMinimumSize(window.cptr(), C.int(minW), C.int(minH))
503503
}
504504

505505
// GetMinimumSize returns the minimum size of the window's client area.
506506
// (https://wiki.libsdl.org/SDL_GetWindowMinimumSize)
507-
func (window *Window) GetMinimumSize() (w, h int) {
507+
func (window *Window) GetMinimumSize() (w, h int32) {
508508
var _w, _h C.int
509509
C.SDL_GetWindowMinimumSize(window.cptr(), &_w, &_h)
510-
return int(_w), int(_h)
510+
return int32(_w), int32(_h)
511511
}
512512

513513
// SetMaximumSize sets the maximum size of the window's client area.
514514
// (https://wiki.libsdl.org/SDL_SetWindowMaximumSize)
515-
func (window *Window) SetMaximumSize(maxW int, maxH int) {
515+
func (window *Window) SetMaximumSize(maxW, maxH int32) {
516516
C.SDL_SetWindowMaximumSize(window.cptr(), C.int(maxW), C.int(maxH))
517517
}
518518

519519
// GetMaximumSize returns the maximum size of the window's client area.
520520
// (https://wiki.libsdl.org/SDL_GetWindowMaximumSize)
521-
func (window *Window) GetMaximumSize() (w, h int) {
521+
func (window *Window) GetMaximumSize() (w, h int32) {
522522
var _w, _h C.int
523523
C.SDL_GetWindowMaximumSize(window.cptr(), &_w, &_h)
524-
return int(_w), int(_h)
524+
return int32(_w), int32(_h)
525525
}
526526

527527
// SetBordered sets the border state of the window.
@@ -822,10 +822,10 @@ func GLGetSwapInterval() (int, error) {
822822

823823
// GLGetDrawableSize returns the size of a window's underlying drawable in pixels (for use with glViewport).
824824
// (https://wiki.libsdl.org/SDL_GL_GetDrawableSize)
825-
func GLGetDrawableSize(window *Window) (w, h int) {
825+
func GLGetDrawableSize(window *Window) (w, h int32) {
826826
var _w, _h C.int
827827
C.SDL_GL_GetDrawableSize(window.cptr(), &_w, &_h)
828-
return int(_w), int(_h)
828+
return int32(_w), int32(_h)
829829
}
830830

831831
// GLSwapWindow updates a window with OpenGL rendering.

0 commit comments

Comments
 (0)