Documentation ¶
Index ¶
- func CastBool(value bool) (cast int)
- func ConvertCTypes[RET, SRC any](src SRC) RET
- func Ptr(data interface{}) unsafe.Pointer
- func PtrToByteSlice(p unsafe.Pointer) []byte
- func PtrToUint16Slice(p unsafe.Pointer) []uint16
- func Wrap[CTYPE any, self any](in WrappableType[CTYPE, self]) (cPtr *CTYPE, finisher func())
- func WrapBool[RESULT ~bool](goValue *bool) (wrapped *RESULT, finisher func())
- func WrapNumberPtr[CTYPE Number, GOTYPE Number](goValue *GOTYPE) (wrapped *CTYPE, finisher func())
- func WrapString[RET ~int8](value string) (wrapped *RET, finisher func())
- func WrapStringList[RET ~int8](value []string) (wrapped **RET, finisher func())
- func WrapVoidPtr(value unsafe.Pointer) (wrapped unsafe.Pointer, finisher func())
- type Number
- type StringBuffer
- type Vector
- type WrappableType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertCTypes ¶
func ConvertCTypes[RET, SRC any](src SRC) RET
ConvertCTypes intendedd use is to convert packageA.C.MyType to packageB.C.MyType. make sure your types are identical C types before using it. THIS IS HIGHLY UNSAFE AND NOT RECOMMENDED TO USE OUTSIDE CIMGUI. It just forces pointer/type reinterpretation with unsafe.Pointer.
func Ptr ¶
Ptr takes a slice or pointer (to a singular scalar value or the first element of an array or slice) and returns its GL-compatible address.
For example:
var data []uint8 ... gl.TexImage2D(gl.TEXTURE_2D, ..., gl.UNSIGNED_BYTE, gl.Ptr(&data[0]))
func PtrToByteSlice ¶
func PtrToUint16Slice ¶
func Wrap ¶
func Wrap[CTYPE any, self any](in WrappableType[CTYPE, self]) (cPtr *CTYPE, finisher func())
Wrap takes a variable of one of the types defined in this file and returns a pointer to its C equivalend as well as a "finisher" func. This finisher func should be called after doing any operations on C pointer in order to apply the changes back to the original GO variable.
func WrapBool ¶
WrapBool converts a Go bool pointer to a C bool pointer. Default value of RESULT should be C.bool
func WrapNumberPtr ¶
WrapNumberPtr is a generic method to convert GOTYPE (int32/float32 e.t.c.) into CTYPE (c_int/c_float e.t.c.)
func WrapString ¶
WrapString converts Go string to C char* Default value of RET is C.char
func WrapStringList ¶
WrapStringList converts Go string slice to C char** Default value of RET is C.char
Types ¶
type Number ¶
type Number interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 }
Number is a generic type for Go/C types that can be used as a number. It could be anything that you can convert to that type (e.g. C.int is a Number, because it can be directly converted to int)
type StringBuffer ¶
type StringBuffer struct {
// contains filtered or unexported fields
}
func NewStringBuffer ¶
func NewStringBuffer(initialValue string) *StringBuffer
func (*StringBuffer) Free ¶
func (buf *StringBuffer) Free()
func (*StringBuffer) Ptr ¶
func (buf *StringBuffer) Ptr() unsafe.Pointer
func (*StringBuffer) ResizeTo ¶
func (buf *StringBuffer) ResizeTo(requestedSize int)
func (*StringBuffer) Size ¶
func (buf *StringBuffer) Size() int
func (*StringBuffer) ToGo ¶
func (buf *StringBuffer) ToGo() string
type Vector ¶
type Vector[T any] struct { Size int Capacity int Data T // contains filtered or unexported fields }
func NewVectorFromC ¶
type WrappableType ¶
type WrappableType[CTYPE any, self any] interface { // ToC converts self into CTYPE ToC() CTYPE // FromC force-converts taken any to CTYPE, converts it into self, // applies to receiver and returns it. FromC(unsafe.Pointer) self }
WrappableType represents a GO type that can be converted into a C value and back - into a GO value. CTYPE represents the equivalent C type of self. self is the type WrappableType applies to - TODO - figure out if it can be ommited :-) intentional values: - CTYPE is e.g. C.ImVec2, C.ImColor e.t.c. - self is a pointer type (e.g. *Vec2, Color)