mirror of
https://github.com/bloeys/physx-go.git
synced 2025-12-29 07:58:20 +00:00
Wrap some foundation+pvd classes
This commit is contained in:
21
main.go
21
main.go
@ -1,8 +1,23 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/bloeys/physx-go/pgo"
|
import (
|
||||||
|
"github.com/bloeys/physx-go/pgo"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
pgo.Test()
|
f := pgo.CreateFoundation()
|
||||||
println("Hey!!")
|
defer f.Release()
|
||||||
|
println("foundation:", f)
|
||||||
|
|
||||||
|
pvd := pgo.CreatePvd(f)
|
||||||
|
// defer pvd.Release()
|
||||||
|
println("Pvd:", pvd)
|
||||||
|
|
||||||
|
pvdTr := pgo.DefaultPvdSocketTransportCreate("127.0.0.1", 9876, 500)
|
||||||
|
// defer pvdTr.Release()
|
||||||
|
println("Pvd transport:", pvdTr)
|
||||||
|
|
||||||
|
// for {
|
||||||
|
// time.Sleep(1 / 60 * time.Second)
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
64
pgo/pgo.go
64
pgo/pgo.go
@ -8,13 +8,65 @@ package pgo
|
|||||||
#include <stdlib.h> //Needed for C.free
|
#include <stdlib.h> //Needed for C.free
|
||||||
|
|
||||||
//Functions
|
//Functions
|
||||||
struct CPxFoundation* NewCPxFoundation();
|
struct CPxFoundation* CPxCreateFoundation();
|
||||||
void FreeCPxFoundation(struct CPxFoundation*);
|
void CPxFoundation_release(struct CPxFoundation*);
|
||||||
|
|
||||||
|
struct CPxPvd* CPxCreatePvd(struct CPxFoundation*);
|
||||||
|
void CPxPvd_release(struct CPxPvd*);
|
||||||
|
|
||||||
|
struct CPxPvdTransport* CPxDefaultPvdSocketTransportCreate(const char* address, int port, int timeoutMillis);
|
||||||
|
void CPxPvdTransport_release(struct CPxPvdTransport* cppt);
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
func Test() {
|
type Foundation struct {
|
||||||
x := C.NewCPxFoundation()
|
cFoundation *C.struct_CPxFoundation
|
||||||
println("Result:", x)
|
}
|
||||||
C.FreeCPxFoundation(x)
|
|
||||||
|
func (f *Foundation) Release() {
|
||||||
|
C.CPxFoundation_release(f.cFoundation)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateFoundation() *Foundation {
|
||||||
|
|
||||||
|
f := &Foundation{}
|
||||||
|
f.cFoundation = C.CPxCreateFoundation()
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
type Pvd struct {
|
||||||
|
cPvd *C.struct_CPxPvd
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pvd) Release() {
|
||||||
|
C.CPxPvd_release(p.cPvd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreatePvd(f *Foundation) *Pvd {
|
||||||
|
|
||||||
|
p := &Pvd{}
|
||||||
|
p.cPvd = C.CPxCreatePvd(f.cFoundation)
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
type PvdTransport struct {
|
||||||
|
cPvdTr *C.struct_CPxPvdTransport
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PvdTransport) Release() {
|
||||||
|
C.CPxPvdTransport_release(p.cPvdTr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultPvdSocketTransportCreate(host string, port, timeoutMillis int) *PvdTransport {
|
||||||
|
|
||||||
|
hostCStr := C.CString(host)
|
||||||
|
defer C.free(unsafe.Pointer(hostCStr))
|
||||||
|
|
||||||
|
p := &PvdTransport{}
|
||||||
|
p.cPvdTr = C.CPxDefaultPvdSocketTransportCreate(hostCStr, C.int(port), C.int(timeoutMillis))
|
||||||
|
|
||||||
|
return p
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,8 +9,8 @@ extern "C" {
|
|||||||
void* obj;
|
void* obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
CPxAPI CSTRUCT CPxFoundation* NewCPxFoundation();
|
CPxAPI CSTRUCT CPxFoundation* CPxCreateFoundation();
|
||||||
CPxAPI void FreeCPxFoundation(CSTRUCT CPxFoundation* cpf);
|
CPxAPI void CPxFoundation_release(CSTRUCT CPxFoundation* cpf);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
20
pgo/physx-c/CPxPvd.h
Executable file
20
pgo/physx-c/CPxPvd.h
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef __CPxPvd_H__
|
||||||
|
#define __CPxPvd_H__
|
||||||
|
|
||||||
|
#include "CPxFoundation.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
struct CPxPvd
|
||||||
|
{
|
||||||
|
void* obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
CPxAPI CSTRUCT CPxPvd* CPxCreatePvd(CSTRUCT CPxFoundation*);
|
||||||
|
CPxAPI void CPxPvd_release(CSTRUCT CPxPvd* cpp);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
18
pgo/physx-c/CPxPvdTransport.h
Executable file
18
pgo/physx-c/CPxPvdTransport.h
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __CPxPvdTransport_H__
|
||||||
|
#define __CPxPvdTransport_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
struct CPxPvdTransport
|
||||||
|
{
|
||||||
|
void* obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
CPxAPI CSTRUCT CPxPvdTransport* CPxDefaultPvdSocketTransportCreate(const char* address, int port, int timeoutMillis);
|
||||||
|
CPxAPI void CPxPvdTransport_release(CSTRUCT CPxPvdTransport* cppt);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,3 +1,4 @@
|
|||||||
#define CPxAPI
|
#define CPxAPI
|
||||||
#define CSTRUCT struct
|
#define CSTRUCT struct
|
||||||
#include <CPxFoundation.h>
|
#include <CPxFoundation.h>
|
||||||
|
#include <CPxPvd.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user