You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NoiseTorch/vendor/github.com/go-gl/glfw/v3.3/glfw/util.go

39 lines
573 B
Go

package glfw
//#include <stdlib.h>
//#define GLFW_INCLUDE_NONE
//#include "glfw/include/GLFW/glfw3.h"
import "C"
import (
"reflect"
"unsafe"
)
func glfwbool(b C.int) bool {
if b == C.int(True) {
return true
}
return false
}
func bytes(origin []byte) (pointer *uint8, free func()) {
n := len(origin)
if n == 0 {
return nil, func() {}
}
data := C.malloc(C.size_t(n))
dataSlice := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(data),
Len: n,
Cap: n,
}))
copy(dataSlice, origin)
return &dataSlice[0], func() { C.free(data) }
}