chunqian / go-raylib

go-raylib is a simple and easy-to-use library to enjoy videogames programming
zlib License
44 stars 3 forks source link

Different result in go and C function: LoadFontEx #10

Closed vladimirschuka closed 3 years ago

vladimirschuka commented 3 years ago

Hi I'm struggling with text output and almost gave up.

And As I see main problem is function : LoadFontEx

It works in C, I took an example about text and have such string : Font fontTtf = LoadFontEx("Ubuntu-Regular.ttf", 256, 0, 2048); in the log output:


INFO: FILEIO: [Ubuntu-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 3] Texture created successfully (16384x16384 - 1 mipmaps)

in Go I have such string: font := rl.LoadFontEx("Ubuntu-Regular.ttf", 256, &s, 2048) and in the logs :

INFO: FILEIO: [Ubuntu-Regular.ttf] File loaded successfully
INFO: TEXTURE: [ID 3] Texture created successfully (512x512 - 1 mipmaps)

and of course there is no any output in the window of go version. And all works perfect with C version.

I'm writing here because I see project looks alive and maybe some one has solution.

OS: MacOS 11 arm64

Go: 1.16.3

go-raylib: v0.0.0-20210424023010-5a21bdadf8d6

chunqian commented 3 years ago

I take the time to look at this issue

chunqian commented 3 years ago

@vladimirschuka image No problems found on my macbook pro OS: MacOS 10.14.6 Intel i7

Can you give me the raylib c version commit you compared?

chunqian commented 3 years ago

@vladimirschuka image Also tested on the M1 version of the macbook air, no problem I used examples font_loading to test

vladimirschuka commented 3 years ago

Thank you. Strange, I felt that it sounds silly, I installed raylib from homebrew brew info raylib

raylib: stable 3.5.0 (bottled), HEAD
Simple and easy-to-use library to learn videogames programming
https://www.raylib.com/
/opt/homebrew/Cellar/raylib/3.5.0 (18 files, 2.8MB) *
  Poured from bottle on 2021-04-25 at 23:46:22
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/raylib.rb

and commit which I used :

github.com/chunqian/go-raylib v0.0.0-20210424023010-5a21bdadf8d6

Could you please give me a hint where I should look, to fix my problem.

Thanks a lot

chunqian commented 3 years ago

Can you post the full code? Or clone my project and run examples text font_loading

makew0rld commented 3 years ago

@vladimirschuka by the way, you shouldn't need to install raylib from homebrew. It comes with this library, so just running go get github.com/chunqian/go-raylib@master will install it where it needs to be for Go.

chunqian commented 3 years ago

go get github.com/chunqian/go-raylib@master is not the latest commit use go get -u github.com/chunqian/go-raylib The full process and full code will be more helpful

vladimirschuka commented 3 years ago

Thank you guys. I found a problem, I took example from another repository and now I understood that important 2 things, what i missed: 1)

func init() {
    runtime.LockOSThread()
}

2) font := rl.LoadFontEx("Ubuntu-Regular.ttf", 32, nil, 2048) before it was font := rl.LoadFontEx("Ubuntu-Regular.ttf", 32, &s, 2048) where &s is &int32(0)