read stdin
This commit is contained in:
parent
a9a6211521
commit
c709e012bf
14
main.go
14
main.go
|
@ -10,6 +10,8 @@ import "github.com/veandco/go-sdl2/sdl"
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,6 +42,8 @@ func main() {
|
||||||
|
|
||||||
C.projectm_set_window_size(handle, 800, 600)
|
C.projectm_set_window_size(handle, 800, 600)
|
||||||
|
|
||||||
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
running := true
|
running := true
|
||||||
for running {
|
for running {
|
||||||
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
|
||||||
|
@ -51,6 +55,16 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
audioData := make([]byte, 4096)
|
||||||
|
n, err := reader.Read(audioData)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr := C.CBytes(audioData)
|
||||||
|
|
||||||
|
C.projectm_pcm_add_float(handle, (*C.float)(ptr), C.uint(n / C.sizeof_float), C.PROJECTM_STEREO)
|
||||||
|
|
||||||
C.projectm_opengl_render_frame(handle)
|
C.projectm_opengl_render_frame(handle)
|
||||||
window.GLSwap()
|
window.GLSwap()
|
||||||
time.Sleep(1 / 60 * time.Second)
|
time.Sleep(1 / 60 * time.Second)
|
||||||
|
|
Loading…
Reference in New Issue