use cgo and newest libprojectm

This commit is contained in:
filifa 2024-08-22 19:50:06 -05:00
parent 1905515311
commit 908d12ccc9
1 changed files with 20 additions and 1 deletions

21
main.go
View File

@ -2,6 +2,13 @@ package main
import "github.com/veandco/go-sdl2/sdl" import "github.com/veandco/go-sdl2/sdl"
/*
#cgo CFLAGS: -I/home/nick/Downloads/include
#cgo LDFLAGS: -L/home/nick/.local/lib -lprojectM-4
#include "projectM-4/projectM.h"
*/
import "C"
func main() { func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil { if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err) panic(err)
@ -9,12 +16,24 @@ func main() {
defer sdl.Quit() defer sdl.Quit()
window, err := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, window, err := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
800, 600, sdl.WINDOW_SHOWN) 800, 600, sdl.WINDOW_OPENGL)
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer window.Destroy() defer window.Destroy()
context, err := window.GLCreateContext()
if err != nil {
panic(err)
}
defer sdl.GLDeleteContext(context)
handle := C.projectm_create()
if (handle == nil) {
panic("nil")
}
defer C.projectm_destroy(handle)
surface, err := window.GetSurface() surface, err := window.GetSurface()
if err != nil { if err != nil {
panic(err) panic(err)