veandco / go-sdl2-examples Goto Github PK
View Code? Open in Web Editor NEWThis is where all go-sdl2 examples are stored
This is where all go-sdl2 examples are stored
Hi veandco,
When I run the recording-audio.go file I get this error message:
C:\Users*****\AppData\Local\Temp\go-build233611566\b001_cgo_main.o:/tmp/go-build/cgo-generated-wrappers:2: undefined reference to `OnAudio'
collect2.exe: error: ld returned 1 exit status
Can you help me with this?
Thanks
GNK03
Sorry, I copy pasted the file and for whatever reason there was an empty line every second line. Between "//export OnAudio" and "func OnAudio(userdata unsafe.Pointer, _stream *C.Uint8, _length C.int) {" can't be an empty line. This caused the error.
here is a program you can use to test:
(needs bell.wav in the dir)
package main
import (
"log"
"github.com/veandco/go-sdl2/mix"
"github.com/veandco/go-sdl2/sdl"
)
const (
sampleHz = 48000
)
func main() {
if err := sdl.Init(sdl.INIT_AUDIO); err != nil {
log.Println(err)
return
}
defer sdl.Quit()
spec := &sdl.AudioSpec{
Freq: sampleHz,
Format: sdl.AUDIO_U8,
Channels: 2,
Samples: sampleHz,
}
if err := sdl.OpenAudio(spec, nil); err != nil {
log.Println(err)
return
}
defer sdl.CloseAudio()
mix.Init(mix.INIT_MP3)
sdl.PauseAudio(false)
chunk, err := mix.LoadWAV("./bell.wav")
if err != nil {
log.Println(err)
return
}
defer chunk.Free()
chunk.Play(0, 0)
sdl.Delay(500) // play audio for long enough to understand whether it works
sdl.CloseAudio()
}
When trying to compile examples/keyboard-input/keyboard-input.go, I get the following error:
This is due to a change following the commit "examples: updated to remove pointer in event switch cases" where "*sdl.QuitEvent" was replaced by "sdl.QuitEvent" in the switch statement.
If I put back the dereferencing operator '*', the code compiles.
There must be a good reason for the change in the commit. Could you explain the rationale please? Thank you in advance !
If that matters, I am using go1.22.2 linux/amd64
I have a problem with the cursor, it also occurs in the render example provided. The problem is if I move my mouse to the created window, it becomes unresponding.
I am running the examples on MacOS Mojave and the window never appears even though the app icon shows the app is running in the task bar. If I call
sdl.PollEvent()
or sdl.PumpEvents()
just before the sdl.Delay(2000)
line, then the window displays just fine. This happens for all of the examples that do not use an event loop.
Hi,
when i try to install gfx package with "go get github.com/veandco/go-sdl2/gfx"
C:/Program Files/mingw-w64/x86_64-7.3.0-posix-seh-rt_v5-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2_gfx
collect2.exe: error: ld returned 1 exit status
I've downloaded SDL2_gfx-1.0.1 and tried to compile it with Visual Studio but i get several error's, i guess it's because of the arch.
Is there any precompiled or successful compilation of the SDL2_gfx lib for x64 ?
Thanks in advance,
Sam
When it comes to Event, most of code in examples look like this:
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch t := event.(type) {
...
}
}
Why the event (a interface) should be written = sdl.PollEvent()
twice?
I've been trying to adapt audio/audio.go
to pass toneHz, sampleHz, dPhase into SineWave, but I have no clue how it should be done
How to use go-sdl2-examples\examples\android
examples on Windows platform. Is how to compile SDL2 on Windows10 platform
to APK file
.
The original README
was for Linux
, I don't know how to put it in Windows10
.
Thank you!
CMD: go run main.go is an main.exe
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.