banthar / go-sdl Goto Github PK
View Code? Open in Web Editor NEWGo bindings for SDL
Go bindings for SDL
or did I miss something?
go get github.com/banthar/Go-SDL/sdl
exec: "pkg-config": executable file not found in $PATH
on a mac
Hi,
This's the list of stuff I found missing in the library. There're just the ones I bumped into though, I haven't made a real check.
SDL_INIT_TIMER definition is missing
RenderUTF8() is missing in SDL_ttf
make[1]: Entering directory `/home/Chris/Go-SDL/sdl'
CGOPKGPATH= cgo -- sdl.go
touch _obj/_cgo_run
8g -o _go_.8 constants.go structs.8.go _obj/sdl.cgo1.go _obj/_cgo_gotypes.go
sdl.go:70[_obj/sdl.cgo1.go:73]: invalid operation: uintptr(count) * 4 (mismatched types uintptr and int)
make[1]: *** [_go_.8] Error 1
make[1]: Leaving directory `/home/Chris/Go-SDL/sdl'
make: *** [all] Error 2
End of make output:
CGOPKGPATH= cgo -- `pkg-config --cflags sdl` sdl.go 8g -o _go_.8 constants.go structs.8.go sdl.cgo1.go _cgo_gotypes.go 8c -FVw -I"/home/henry/src/go/pkg/linux_386" _cgo_defun.c _cgo_defun.c:16 function args not checked: gostring _cgo_defun.c:16 incompatible types: "STRUCT String" and "INT" for op "AS" _cgo_defun.c:23 function args not checked: cmalloc _cgo_defun.c:23 incompatible types: "IND CHAR" and "INT" for op "AS" _cgo_defun.c:24 function args not checked: mcpy _cgo_defun.c:35 function args not checked: cgocall _cgo_defun.c:44 function args not checked: cgocall _cgo_defun.c:53 function args not checked: cgocall _cgo_defun.c:62 function args not checked: cgocall _cgo_defun.c:71 function args not checked: cgocall
[etc]
The current event handling functions pass around a copy of a 24-bytes struct for each call, which should be avoided.
In sdl/sdl.go, the method *Surface.Unlock should call SDL_UnlockSurface instead of SDL_Flip, which it currently does.
-Ostsol
Here (Arch Linux), I don't have goinstall
, so I did:
go get github.com/banthar/Go-SDL/{sdl,ttf,gfx,mixer}
(The test program works fine.)
Well I have to build a program using SDL and Golang on Windows. This is what just happened when I ran "go get github.com/banthar/sdl" in Git Bash.
$ go get github.com/banthar/Go-SDL/sdl
Package sdl was not found in the pkg-config search path.
Perhaps you should add the directory containing `sdl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sdl' found
C:\TDM-GCC-32\bin\pkg-config.exe: exit status 1
Unfortunately I googled and found that "pkg-config" is unavailable on Windows. And the SDL don't provide a file named "sdl.pc". Maybe your library is just available on other platforms?
http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_75.html#SEC75
or at least the built in mix processors:
Mix_SetPanning
Mix_SetDistance
Mix_SetPosition
Mix_SetReverseStereo
I got following errors with the weekly go version:
sdl.go:482[_obj/sdl.cgo1.go:485]: undefined: os.O_CREAT
sdl.go:484[_obj/sdl.cgo1.go:487]: undefined: os.O_CREAT
sdl.go:488[_obj/sdl.cgo1.go:491]: undefined: os.O_CREAT
sdl.go:490[_obj/sdl.cgo1.go:493]: undefined: os.O_CREAT
If I changed "os.O_CREAT" to "os.O_CREATE" then it compiles.
Best regards
erwura
With latest stable go one can not build Go-SDL
Just cloned the source (rev 8309d2a) and tried to build, but it fails immediatelly with following output:
gomake -C sdl
make[1]: Entering directory /home/v0idexp/Builds/Go-SDL/sdl' 6g -o _go_.6 constants.go structs.6.go _obj/sdl.cgo1.go _obj/_cgo_gotypes.go sdl.go:4[_obj/sdl.cgo1.go:7]: can't find import: errors make[1]: *** [_go_.6] Error 1 make[1]: Leaving directory
/home/v0idexp/Builds/Go-SDL/sdl'
make: *** [all] Error 2
Doing a $ go run test.go
gives the following output:
2013-09-21 23:06:54.233 test[81015:303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow on line 259'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8834fb06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff87ae23f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8834f8dc +[NSException raise:format:] + 204
3 AppKit 0x00007fff90c54b49 _NSCreateWindowWithOpaqueShape2 + 655
4 AppKit 0x00007fff90c53340 -[NSWindow _commonAwake] + 2002
5 AppKit 0x00007fff90c11d82 -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 1763
6 AppKit 0x00007fff90c10ecf -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1568
7 AppKit 0x00007fff90c1089f -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
8 libSDL-1.2.0.dylib 0x0000000000211a8d -[SDL_QuartzWindow initWithContentRect:styleMask:backing:defer:] + 279
9 libSDL-1.2.0.dylib 0x000000000020f49b QZ_SetVideoMode + 1409
10 libSDL-1.2.0.dylib 0x0000000000206789 SDL_SetVideoMode + 907
11 test 0x0000000000077349 _cgo_0b5699797723_Cfunc_SDL_SetVideoMode + 28
12 test 0x000000000002287f runtime.asmcgocall + 95
)
libc++abi.dylib: terminate called throwing an exception
SIGABRT: abort
PC=0x7fff87f07212
signal arrived during cgo execution
github.com/banthar/Go-SDL/sdl._Cfunc_SDL_SetVideoMode(0x1e000000280, 0x1000000020, 0x0)
github.com/banthar/Go-SDL/sdl/_obj/_cgo_defun.c:669 +0x2f
github.com/banthar/Go-SDL/sdl.SetVideoMode(0x280, 0x1e0, 0x20, 0x10, 0x0, ...)
github.com/banthar/Go-SDL/sdl/_obj/_cgo_gotypes.go:451 +0x44
main.main()
/Users/agis/dev/chip-8/src/github.com/banthar/Go-SDL/test/test.go:58 +0x15d
goroutine 2 [syscall]:
rax 0x0
rbx 0x6
rcx 0x7fff5fbfe1b8
rdx 0x0
rdi 0x303
rsi 0x6
rbp 0x7fff5fbfe1e0
rsp 0x7fff5fbfe1b8
r8 0x7fff76c84278
r9 0x7fff5fbfe1c0
r10 0x20000000
r11 0x206
r12 0x7fff5fbfe340
r13 0xf
r14 0x7fff76c85180
r15 0x7fff5fbfe220
rip 0x7fff87f07212
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
exit status 2
I've installed sdl using brew and then Xquartz.
this repository seems to be unactive for two years, and there are 74 forks, but i don't know which to choose. Which is best?
Go-SDL/ttf does not build successfully on Go 1.0.1.
$ go get -u github.com/banthar/Go-SDL/ttf
# github.com/banthar/Go-SDL/ttf
1: error: 'TTF_GetFontHinting' undeclared (first use in this function)
1: note: each undeclared identifier is reported only once for each function it appears in
1: error: 'TTF_SetFontHinting' undeclared (first use in this function)
1: error: 'TTF_GetFontOutline' undeclared (first use in this function)
1: error: 'TTF_SetFontOutline' undeclared (first use in this function)
Making Go-SDL/ttf:
~/go/src/github.com/banthar/Go-SDL/ttf$ make
Makefile:5: /usr/lib/go/src/Make.inc: No such file or directory
Makefile:22: /usr/lib/go/src/Make.pkg: No such file or directory
make: *** No rule to make target `/usr/lib/go/src/Make.pkg'. Stop.
When I run the GO-SDL test on OSX 10.6.6 I get a lot of errors about leaking objects due to no autorelease pool being in place, and then a crash trying to create the window.
Model Name: MacBook Pro
Model Identifier: MacBookPro6,2
Processor Name: Intel Core i7
Processor Speed: 2.8 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache (per core): 256 KB
L3 Cache: 4 MB
Memory: 8 GB
Processor Interconnect Speed: 4.8 GT/s
Boot ROM Version: MBP61.0057.B0C
SMC Version (system): 1.58f16
Sudden Motion Sensor:
State: Enabled
System Version: Mac OS X 10.6.6 (10J567)
Kernel Version: Darwin 10.6.0
Boot Volume: Mac HD
Boot Mode: Normal
Secure Virtual Memory: Enabled
64-bit Kernel and Extensions: No
Time since boot: 15:54
Version: 4.0 (4A251a)
Location: /Xcode4
Applications:
Xcode: 4.0 (92)
Instruments: 3.0 (3524)
Dashcode: 3.0.2 (333)
SDKs:
Mac OS X:
10.5: (9L31a)
10.6: (4A251a)
iPhone OS:
4.2: (8C134)
iPhone Simulator:
3.2: (7W367a)
4.0: (8A400)
4.1: (8B117)
4.2: (8C134)
bluehex@macbook:~/contrib/Go-SDL/test$ ./test
2011-04-03 13:08:02.529 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x401c4f0 of class NSCFNumber autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.531 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x4300000 of class NSCFNumber autoreleased with no pool in place - just leaking
# <<about 75 more lines of 'autoreleased with no pool in place - just leaking' warnings>>
2011-04-03 13:08:02.685 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x260b9c0 of class NSTrackingArea autoreleased with no pool in place - just leaking
Sun Apr 3 13:08:02 macbook test[85928] <Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
Sun Apr 3 13:08:02 macbook test[85928] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
2011-04-03 13:08:02.685 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430d9f0 of class NSTrackingArea autoreleased with no pool in place - just leaking
Sun Apr 3 13:08:02 macbook test[85928] <Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection
Sun Apr 3 13:08:02 macbook test[85928] <Error>: kCGErrorInvalidConnection: CGSNewWindowWithOpaqueShape: Invalid connection
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430e620 of class NSCFString autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430dd90 of class NSException autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430e820 of class _NSCallStackArray autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.686 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430e8d0 of class _NSCallStackArray autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.687 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430ea00 of class NSCFString autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.687 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x4806a00 of class NSCFString autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.687 test[85928:903] *** __NSAutoreleaseNoPool(): Object 0x430ea70 of class NSConcreteMutableData autoreleased with no pool in place - just leaking
2011-04-03 13:08:02.688 test[85928:903] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1002) creating CGSWindow'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff875167b4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff83de90f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff875165d7 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff87516564 +[NSException raise:format:] + 148
4 AppKit 0x00007fff84416ee2 _NSCreateWindowWithOpaqueShape2 + 473
5 AppKit 0x00007fff843ab489 -[NSWindow _commonAwake] + 1214
6 AppKit 0x00007fff843a816e -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 1501
7 AppKit 0x00007fff843a6dfa -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1396
8 AppKit 0x00007fff843a6883 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
9 libSDL-1.2.0.dylib 0x000000000218bc0d -[SDL_QuartzWindow initWithContentRect:styleMask:backing:defer:] + 285
10 libSDL-1.2.0.dylib 0x00000000021890e4 QZ_SetVideoMode + 1076
11 libSDL-1.2.0.dylib 0x000000000218025f SDL_SetVideoMode + 527
12 test 0x00000000000175aa 0x0 + 95658
13 test 0x0000000000003c2d 0x0 + 15405
)
terminate called after throwing an instance of 'NSException'
SIGABRT: abort
pc: 0x7fff82e3f616
goroutine 1 [3]:
runtime.entersyscall+0x28 /Users/bluehex/go/src/pkg/runtime/proc.c:617
runtime.entersyscall()
runtime.cgocall+0xb1 /Users/bluehex/go/src/pkg/runtime/cgocall.c:42
runtime.cgocall(0x1758e, 0x2386e10, 0x2386e18, 0x162a0)
sdl._Cfunc_SDL_SetVideoMode+0x2f /Users/bluehex/contrib/Go-SDL/sdl/_obj/_cgo_defun.c:387
sdl._Cfunc_SDL_SetVideoMode(0x1e000000280, 0x1000000020)
sdl.SetVideoMode+0x3b /Users/bluehex/contrib/Go-SDL/sdl/_obj/sdl.cgo1.go:-803
sdl.SetVideoMode(0x1e000000280, 0x1000000020, 0xf800000000, 0xf840001280, 0x8863, ...)
main.main+0x157 /Users/bluehex/contrib/Go-SDL/test/test.go:58
main.main()
runtime.mainstart+0xf /Users/bluehex/go/src/pkg/runtime/amd64/asm.s:77
runtime.mainstart()
runtime.goexit /Users/bluehex/go/src/pkg/runtime/proc.c:150
runtime.goexit()
----- goroutine created by -----
_rt0_amd64+0x8e /Users/bluehex/go/src/pkg/runtime/amd64/asm.s:64
rax 0x0
rbx 0x7fff704da2d8
rcx 0x7fff5fbfede8
rdx 0x0
rdi 0x14fa8
rsi 0x6
rbp 0x7fff5fbfee00
rsp 0x7fff5fbfede8
r8 0x7fff704dda40
r9 0x63
r10 0x7fff82e3b656
r11 0x206
r12 0x7fff8759bb09
r13 0x0
r14 0x2
r15 0x0
rip 0x7fff82e3f616
rflags 0x206
cs 0x2f
fs 0x10
gs 0x48
Wrong project, please close.
Compare the C struct with the Go one, they're entirely different.
The correct struct might be:
type VideoInfo struct {
HW_available uint32 "Flag: Can you create hardware surfaces?"
WM_available uint32 "Flag: Can you talk to a window manager?"
UnusedBits1, UnusedBits2 uint32
Blit_hw uint32 "Flag: Accelerated blits HW --> HW"
Blit_hw_CC uint32 "Flag: Accelerated blits with Colorkey"
Blit_hw_A uint32 "Flag: Accelerated blits with Alpha"
Blit_sw uint32 "Flag: Accelerated blits SW --> HW"
Blit_sw_CC uint32 "Flag: Accelerated blits with Colorkey"
Blit_sw_A uint32 "Flag: Accelerated blits with Alpha"
Blit_fill uint32 "Flag: Accelerated color fill"
UnusedBits3 uint32
Video_mem uint32 "The total amount of video memory (in K)"
Vfmt *PixelFormat "Value: The format of the video surface"
Current_w int "Value: The current video mode width"
Current_H int "Value: The current video mode height"
}
Just so I don't forget, there are a couple more, but that's what I needed right now:
// Returns ActiveEvent or nil if event has other type
func (event *Event) Active() *ActiveEvent {
if event.Type == ACTIVEEVENT {
return (*ActiveEvent)(cast(event))
}
return nil
}
// Returns ResizeEvent or nil if event has other type
func (event *Event) Resize() *ResizeEvent {
if event.Type == VIDEORESIZE {
return (*ResizeEvent)(cast(event))
}
return nil
}
Go-SDL compiles without a hitch (after installing SDL with brew) and so does the test program, but it crashes instantly with tons of output. See here:
Any plans to wrap them? They can be very useful at times.
For instance, it'd be great to have IMG_Load_RW (to display an image I deflate into memory) --with IMG_Load, I am forced to write a copy of it on filesystem first.
The output of calling make:
gomake -C sdl
make[1]: Entering directory `/root/Go-SDL/sdl'
make[1]: Leaving directory `/root/Go-SDL/sdl'
gomake -C ttf
make[1]: Entering directory `/root/Go-SDL/ttf'
CGOPKGPATH=sdl cgo -- ttf.go
Package SDL_ttf was not found in the pkg-config search path.
Perhaps you should add the directory containing `SDL_ttf.pc'
to the PKG_CONFIG_PATH environment variable
No package 'SDL_ttf' found
ttf.go: bad #cgo option pkg-config: pkg-config failed
make[1]: *** [_obj/_cgo_run] Error 2
make[1]: Leaving directory `/root/Go-SDL/ttf'
make: *** [all] Error 2
I do have libsdl-ttf-dev installed.
I do not have the file SDL_ttf.pc anywhere on my only hard drive.
I do not know why it's happening to me.
Hi sorry if this is my fault, but I guess it might help someone else looking here.
I followed the new readme (and the old one) and I have had quite a few issues. I now have it down to one.
My go version is compatible with weekly.2011-12-14 (i know because I installed this version)
I have all the SDL parts and they all work with other languages
GOPATH=/home/me/gocode
GOROOT=/home/me/go
PATH=$PATH:/home/me/go/bin
When I run goinstall github.com/banthar/Go-SDL/sdl
I get some permission denied error (not too sure why meh)
so I run sudo -E goinstall github.com/banthar/Go-SDL/sdl
and get
/bin/bash: === cd /home/me/gocode/src/github.com/banthar/Go-SDL/sdl; bash gomake -f- install
8g -I "/home/me/go/pkg/linux_386" -I "/home/me/gocode/pkg/linux_386" -p github.com/banthar/Go-SDL/sdl -o go.8 constants.go structs_386.go _obj/sdl.cgo1.go _obj/_cgo_gotypes.go
_obj/_cgo_gotypes.go:13: undefined: os.Error
_obj/_cgo_gotypes.go:13: undefined: os.Errno
make: *** [go.8] Error 1
--- exit status 2
goinstall: github.com/banthar/Go-SDL/sdl: install: running bash: exit status 2
Just not too sure what this error means
Thanks
Thranriel
Every time I press a key in the SDL test "unknown key" is printed. The test prints out the mouse information just fine, though.
I'm using SDL version 1.2.13 on Linux (Ubuntu Karmic, kernel 2.6.31-15)
A couple of the automatically generated constants have int type, this causes issues because some of them overflow int when combined and SetVideoMode only takes uint32.
I suggest we identify all possible flags for that function and type them properly.
Building Go-SDL fails consistently on my machine. Even after updating Go to the latest release and making sure all requirements are met (sdl libs).
The following are the errors I get when make hits the sdl package:
sdl.go:49[sdl.cgo1.go:51]: VideoInfo redeclared in this block previous declaration at constants.6.go:397
sdl.go:66[sdl.cgo1.go:68]: undefined: internalVideoInfo
After some digging, I found that the problem is in the auto-generation of the constant.6.go file.
The internalVideoInfo struct is supposed to be generated in this file, but it is only present in the constants.8.go file. Not in the constants.6.go file (which is my arch).
the 6.go file contains a (duplicate) 'VideoInfo' struct:
type VideoInfo struct {
Pad0 [2]byte
UnusedBits3 uint16
Video_mem uint32
Vfmt *PixelFormat
Current_w int32
Current_h int32
}
Where it should be having:
type internalVideoInfo struct {
Flags uint32
Video_mem uint32
Vfmt *PixelFormat
Current_w int32
Current_h int32
}
Manually replacing it fixes the problem and the build works as intended, but I thought I'd mention it here so it can be addressed.
Even when enabling unicode translation with sdl.EnableUNICODE(1) the Unicode field is always zero. It works fine using C SDL. This is on a 32 bit machine so hopefully nothing odd is going on.
I can fix this by changing the struct to:
type Keysym struct {
Scancode uint8
Pad0 [3]byte
Sym byte
Mod byte
Pad1 [5]byte
Unicode uint16
}
This inserts some more padding before the Unicode field. I can't really explain why this is needed but it seems it ends up on these bytes. At least for me.
cEvent() causes panic with panic: reflect.Value.UnsafeAddr of unaddressable value.
. One can simply try pushing a UserEvent to get this.
Riddle me this: http://pastebin.com/Jc5wEdwu
I ran gofix over all source files (wouldn't even get that far without it) and went through all makefiles, removed the pkg-config stuff and added -Ia:/mingw/msys/1.0/include to CFLAGS and -La:/mingw/msys/1.0/lib to LDFLAGS.
I have not made any further changes. Any idea what the issue could be?
Please specify a license for your project so users will know the terms they are allow to use and redistribute Go-SDL.
If you simply don't want to be inconvenienced by adding license headers to the tops of your files, I have a small utility for handling that here: https://github.com/gtalent/Liccor
On my Mac OS X 10.6 system the ttf module does not get compiled because there is a space between -L and the path specification in the Makefile for LDFLAGS. Removing the space fixed the problem for me.
Hi,
This isn't really a feature request, nor a bug, but in case you wanted to know, here's the SDL example for Go-SDL, packaged separately for Arch Linux. It includes an application shortcut and could possibly be used as an example for packaging other games and applications that are using Go-SDL.
https://aur.archlinux.org/packages.php?ID=62108
Best regards,
Alexander Rødseth
I've got an issue trying to compile the package with latest Go release:
andrea@ganimoide:~/src/Go-SDL$ make
make -C sdl install
make[1]: ingresso nella directory «/home/andrea/src/Go-SDL/sdl»
CGOPKGPATH= /home/andrea/bin/cgo `pkg-config --cflags sdl` sdl.go
flag provided but not defined: -D_GNU_SOURCE
usage: cgo [compiler options] file.go ...
make[1]: *** [_cgo_defun.c] Errore 2
make[1]: uscita dalla directory «/home/andrea/src/Go-SDL/sdl»
make: *** [install] Errore 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.