mirror of
https://github.com/bloeys/assimp-go.git
synced 2025-12-29 08:28:20 +00:00
Update to 5.1.6+use dll+update readme
This commit is contained in:
24
README.md
24
README.md
@ -34,8 +34,8 @@ Then simply clone and use `go run .`
|
|||||||
|
|
||||||
> Note: that it might take a while to run the first time because of downloading/compiling dependencies.
|
> Note: that it might take a while to run the first time because of downloading/compiling dependencies.
|
||||||
|
|
||||||
`assimp-go` statically links AssImp using platform dependent libraries.
|
`assimp-go` dynamically links (e.g. through a DLL) AssImp using platform dependent libraries, which are made available with the GitHub releases.
|
||||||
Currently only `Windows` libraries are available, but more should be easy to add by statically compiling assimp on the wanted platform. (Make a PR if you can help us get those binaries!)
|
Currently only `Windows` libraries are available, but more should be easy to add by compiling AssImp on the wanted platform. (Make a PR if you can help us get those binaries!)
|
||||||
|
|
||||||
### Getting Started
|
### Getting Started
|
||||||
|
|
||||||
@ -84,30 +84,28 @@ While `asig` functions should NOT be called on a Scene (or its objects) after th
|
|||||||
|
|
||||||
## Developing assimp-go
|
## Developing assimp-go
|
||||||
|
|
||||||
We link against static assimp libraries that are built for each platform and added to the `asig/libs` package.
|
We link against assimp libraries that are built for each platform and the `*.a` files are added to the `asig/libs` package.
|
||||||
Depending on the platform we select one of them and link against it when doing `go build`.
|
Depending on the platform we select one of them and link against it when doing `go build`.
|
||||||
|
|
||||||
The general steps are:
|
The general steps are:
|
||||||
|
|
||||||
- Copy assimp includes into `asig/assimp`
|
* Copy assimp includes into `asig/assimp`
|
||||||
- Copy `zlib.h`, `zconf.h` and `irrXML.h` into `asig/zlib` and `asig/irrxml` respectively.
|
* Copy `zlib.h`, `zconf.h` and `irrXML.h` into `asig/zlib` and `asig/irrxml` respectively.
|
||||||
- Copy static libraries into `asig/libs`
|
* Copy static libraries and DLL import libraries into `asig/libs`
|
||||||
- Generate the wrappers using `swig -go -c++ -intgosize 64 asig/asig.i`
|
|
||||||
- Add `#cgo LDFLAGS: -L ./staticLibs -l zlibstatic -l IrrXML -l assimp` at the top of the 'C' import in `asig.go`
|
|
||||||
|
|
||||||
> Note: When dealing with static libraries the compiler will probably (e.g. MinGW does this) ignore `lib` suffixes and `.a`/`.lib` suffixes.
|
> Note: When dealing with libraries the compiler will probably (e.g. MinGW does this) ignore `lib` prefixes and `.a`/`.lib` suffixes.
|
||||||
So if your lib name is `libassimp.a` you need to pass it to CGO as `-l assimp`, otherwise you will get an error about library not found.
|
So if your lib name is `libassimp.a` you need to pass it to CGO as `-l assimp`, otherwise you will get an error about library not found.
|
||||||
|
|
||||||
For platform specific steps:
|
For platform specific steps:
|
||||||
|
|
||||||
**Windows**:
|
**Windows**:
|
||||||
|
|
||||||
> Note: You must compile with the same C/C++ compiler you use with Go (e.g. if you use MinGW with Go, then compile assimp with MinGW by sepcifying the correct `-G` option)
|
> Note: You must compile with the same C/C++ compiler you use with Go (e.g. if you use MinGW with Go, then compile assimp with MinGW by specifying the correct `-G` option to cMake)
|
||||||
---
|
---
|
||||||
> Note: If you get compilation errors with things like `File too big` or `can't write 166 bytes to section` then cmake isn't detecting you are using MinGW, so add this flag `-D CMAKE_COMPILER_IS_MINGW=TRUE`
|
> Note: If you get compilation errors with things like `File too big` or `can't write 166 bytes to section` then cmake isn't detecting you are using MinGW, so add this flag `-D CMAKE_COMPILER_IS_MINGW=TRUE`
|
||||||
|
|
||||||
Now assuming you are using MinGW on windows:
|
Now assuming you are using MinGW on windows:
|
||||||
|
|
||||||
- Clone wanted release of assimp and run `cmake CMakeLists.txt -D BUILD_SHARED_LIBS=OFF -D ASSIMP_BUILD_ZLIB=ON -D ASSIMP_BUILD_ASSIMP_TOOLS=OFF -D ASSIMP_BUILD_TESTS=OFF -G "MinGW Makefiles"` in the root folder
|
* Clone wanted release of assimp and run `cmake CMakeLists.txt -D ASSIMP_BUILD_ASSIMP_TOOLS=OFF -G "MinGW Makefiles"` in the root folder
|
||||||
- Run `cmake --build . --parallel 6`
|
* Run `cmake --build . --parallel 6`
|
||||||
- Copy the generated `*.lib` (or `*.a`) files into `asig/lib`
|
* Copy the generated `*.lib` (or `*.a`) files from the `lib` folder and into `asig/lib`, and copy the generated dll from AssImp `bin` folder into the root of `assimp-go`.
|
||||||
|
|||||||
@ -4,15 +4,8 @@ package asig
|
|||||||
#cgo CFLAGS: -I .
|
#cgo CFLAGS: -I .
|
||||||
#cgo LDFLAGS: -L ./libs -l assimp_windows_amd64 -l IrrXML_windows_amd64 -l zlib_windows_amd64
|
#cgo LDFLAGS: -L ./libs -l assimp_windows_amd64 -l IrrXML_windows_amd64 -l zlib_windows_amd64
|
||||||
|
|
||||||
|
#include <wrap.cxx>
|
||||||
#include <stdlib.h> //Needed for C.free
|
#include <stdlib.h> //Needed for C.free
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
|
|
||||||
//Functions
|
|
||||||
struct aiScene* aiImportFile(const char* pFile, unsigned int pFlags);
|
|
||||||
void aiReleaseImport(const struct aiScene* pScene);
|
|
||||||
const char* aiGetErrorString();
|
|
||||||
unsigned int aiGetMaterialTextureCount(const struct aiMaterial* pMat, enum aiTextureType type);
|
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
|
|||||||
Binary file not shown.
2
go.mod
2
go.mod
@ -2,4 +2,4 @@ module github.com/bloeys/assimp-go
|
|||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require github.com/bloeys/gglm v0.2.6
|
require github.com/bloeys/gglm v0.3.1
|
||||||
|
|||||||
2
go.sum
2
go.sum
@ -1,2 +1,4 @@
|
|||||||
github.com/bloeys/gglm v0.2.6 h1:+6m+GZuabU9GRhtEfqz7NS3fewO1xMcjJEenKVPRosM=
|
github.com/bloeys/gglm v0.2.6 h1:+6m+GZuabU9GRhtEfqz7NS3fewO1xMcjJEenKVPRosM=
|
||||||
github.com/bloeys/gglm v0.2.6/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
|
github.com/bloeys/gglm v0.2.6/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
|
||||||
|
github.com/bloeys/gglm v0.3.1 h1:Sy9upW7SBsBfDXrSmEhid3aQ+7J7itej+upwcxOnPMQ=
|
||||||
|
github.com/bloeys/gglm v0.3.1/go.mod h1:qwJQ0WzV191wAMwlGicbfbChbKoSedMk7gFFX6GnyOk=
|
||||||
|
|||||||
2
main.go
2
main.go
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
scene, release, err := asig.ImportFile("obj2.fbx", asig.PostProcessTriangulate|asig.PostProcessJoinIdenticalVertices)
|
scene, release, err := asig.ImportFile("obj.obj", asig.PostProcessTriangulate|asig.PostProcessJoinIdenticalVertices)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user