milkbucket/main.go

59 lines
1.1 KiB
Go
Raw Normal View History

2024-08-20 02:53:48 +00:00
package main
import "github.com/veandco/go-sdl2/sdl"
2024-08-23 00:50:06 +00:00
/*
#cgo CFLAGS: -I/home/nick/Downloads/include
#cgo LDFLAGS: -L/home/nick/.local/lib -lprojectM-4
#include "projectM-4/projectM.h"
*/
import "C"
2024-08-23 01:08:28 +00:00
import (
"time"
)
2024-08-20 02:53:48 +00:00
func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
window, err := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
2024-08-23 00:50:06 +00:00
800, 600, sdl.WINDOW_OPENGL)
2024-08-20 02:53:48 +00:00
if err != nil {
panic(err)
}
defer window.Destroy()
2024-08-23 00:50:06 +00:00
context, err := window.GLCreateContext()
if err != nil {
panic(err)
}
defer sdl.GLDeleteContext(context)
handle := C.projectm_create()
2024-08-23 01:08:28 +00:00
if handle == nil {
2024-08-23 00:50:06 +00:00
panic("nil")
}
defer C.projectm_destroy(handle)
2024-08-23 00:54:02 +00:00
C.projectm_set_window_size(handle, 800, 600)
2024-08-20 02:53:48 +00:00
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch event.(type) {
case *sdl.QuitEvent:
println("Quit")
running = false
break
}
}
2024-08-23 01:08:28 +00:00
C.projectm_opengl_render_frame(handle)
window.GLSwap()
time.Sleep(1 / 60 * time.Second)
2024-08-20 02:53:48 +00:00
}
}