Closed kikito closed 5 years ago
Googled a little bit more. It seems this might be a problem with libsdl.
I will try to recompile libsdl with that patch to see if that helps. But it will take me a while.
We only provide bundled sdl2 libs for windows, so your best bet would be to either update your package or recompile the library with the fix.
@kikito Did you get this working? I'm experiencing the same problem myself. I was working through the roguelike tutorial by @tomassedovic and I can't get anything to actually render.
I did think maybe it was the font I was using, so I tried switching to terminal.png and that just warped the window dimensions.
@ttracey93 no dice. Icculus has this thread on twitter listing things that Mojave broke on OpenGL (and thus SDL):
https://twitter.com/icculus/status/1054634481812992000
I would expect these issues to be fixed eventually in SDL. I digged in the SDL issues page and found this one:
https://bugzilla.libsdl.org/show_bug.cgi?id=4329
Which seems to point out that there might be some kind of bug in Mojave which might need to be "short-circuited" (by "creating all the contexts upfront" and "setting LATE_INIT
to zero). Or we could just wait for Apple to fix it, if it's indeed a bug in the OS.
In any case if you are using homebew, you can always try installing the latest SDL2 from the git repo with:
brew install sdl2 --HEAD
I have tried that one but my screen remains black. For the short term I have decided to let this rest for a while and start using rust+wasm, using the browser for rendering and interaction (no libtcod).
My friend is running into the same issue. I'm not versed on Rust or tcod specifically, but I ran into the same issue with an SDL2 project in C on Mojave. brew install sdl2 --HEAD
fixed it, but I had to do one additional thing in my C project:
// Pump events once and **then** set the window size, before the main loop
SDL_PumpEvents();
SDL_SetWindowSize(window, sf_window_width, sf_window_height);
Update: I'm installing Rust and my friend and I are going to see if we can resolve the issue, and if we can I'll see if we can rustle up a PR. Here's the link I referred to when I fixed the issue for myself. https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060
@rjungemann I'm running into this issue, is there a way to do SDL_PumpEvents
in Rust using this library? I'm very new, sorry if it's obvious.
I tried doing brew install sdl2 --HEAD
and it didn't seem to work:
λ ~/sandbox/rust/roguelike/ master* brew install sdl2 --HEAD
...
==> Downloading https://hg.libsdl.org/SDL/raw-diff/d274fa9731b1/build-scripts/ltmain.sh
######################################################################## 100.0%
==> Patching
==> Applying ltmain.sh
patching file build-scripts/ltmain.sh
Hunk #1 FAILED at 7404.
1 out of 1 hunk FAILED -- saving rejects to file build-scripts/ltmain.sh.rej
- Error: undefined method `shelljoin' for nil:NilClass
Please report this bug:
https://docs.brew.sh/Troubleshooting
/usr/local/Homebrew/Library/Homebrew/exceptions.rb:539:in `initialize'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:7:in `new'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:7:in `rewrite_child_error'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:84:in `block (3 levels) in safe_fork'
/usr/local/Homebrew/Library/Homebrew/utils.rb:402:in `ignore_interrupts'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:60:in `block (2 levels) in safe_fork'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:29:in `open'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:29:in `block in safe_fork'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
/usr/local/Homebrew/Library/Homebrew/utils/fork.rb:28:in `safe_fork'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:743:in `build'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:317:in `install'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:329:in `install_formula'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:259:in `block in install'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:257:in `each'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:257:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:89:in `<main>'
Weird. Try brew install sdl2 --build-bottle --bottle-arch=mojave
. Maybe something is broken in HEAD
. Possibly try installing the 2.0.9 binaries from https://www.libsdl.org/download-2.0.php as well.
If you take a look at my PR, I was able to add SDL_PumpEvents();
to the C code within the tcod-rs
project. Not sure about doing it from Rust-side. I might be able to dig in later. You should be able to point your Cargo.toml
at my branch, like:
[dependencies]
tcod = { git = "https://github.com/rjungemann/tcod-rs.git", branch = "fix-sdl2-rendering-mojave" }
λ ~/sandbox/rust/roguelike/ master* brew install sdl2 --build-bottle --bottle-arch=mojave
Error: Unrecognized architecture for --bottle-arch: mojave
So I downloaded SDL from the website and put it in /Library/Frameworks
Cargo.toml was:
[package]
name = "roguelike"
version = "0.1.0"
authors = ["Gage Peterson <justgage@gmail.com>"]
[dependencies]
# tcod = "0.12"
tcod = { git = "https://github.com/rjungemann/tcod-rs.git", branch = "fix-sdl-rendering-mojave" }
However pulling from your branch didn't seem to work:
λ ~/sandbox/rust/roguelike/ master* cargo run
Blocking waiting for file lock on the git checkouts
Updating git repository `https://github.com/rjungemann/tcod-rs.git`
error: failed to load source for a dependency on `tcod`
Caused by:
Unable to update https://github.com/rjungemann/tcod-rs.git?branch=fix-sdl-rendering-mojave
Caused by:
failed to find branch `fix-sdl-rendering-mojave`
Caused by:
cannot locate local branch 'fix-sdl-rendering-mojave'; class=Reference (4); code=NotFound (-3)
So then I just cloned your repo in the same folder and did this in my Cargo.toml
[package]
name = "roguelike"
version = "0.1.0"
authors = ["Gage Peterson <justgage@gmail.com>"]
[dependencies]
tcod = { path = "tcod-rs", version = "0.12" }
Now I get:
Package sdl2 was not found in the pkg-config search path
Full output
# NOTE: relevant bit near the bottom
λ ~/sandbox/rust/roguelike/ master* cargo run
Compiling tcod-sys v5.0.0 (/Users/justgage/sandbox/rust/roguelike/tcod-rs/tcod_sys)
error: failed to run custom build command for `tcod-sys v5.0.0 (/Users/justgage/sandbox/rust/roguelike/tcod-rs/tcod_sys)`
process didn't exit successfully: `/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-eaae9211c13a3e13/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-apple-darwin")
OPT_LEVEL = Some("0")
HOST = Some("x86_64-apple-darwin")
CC_x86_64-apple-darwin = None
CC_x86_64_apple_darwin = None
HOST_CC = None
CC = None
CFLAGS_x86_64-apple-darwin = None
CFLAGS_x86_64_apple_darwin = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("true")
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/adler32.o" "-c" "libtcod/src/zlib/adler32.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/crc32.o" "-c" "libtcod/src/zlib/crc32.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/deflate.o" "-c" "libtcod/src/zlib/deflate.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/infback.o" "-c" "libtcod/src/zlib/infback.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/inffast.o" "-c" "libtcod/src/zlib/inffast.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/inflate.o" "-c" "libtcod/src/zlib/inflate.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/inftrees.o" "-c" "libtcod/src/zlib/inftrees.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/trees.o" "-c" "libtcod/src/zlib/trees.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/zutil.o" "-c" "libtcod/src/zlib/zutil.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/compress.o" "-c" "libtcod/src/zlib/compress.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/uncompr.o" "-c" "libtcod/src/zlib/uncompr.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzclose.o" "-c" "libtcod/src/zlib/gzclose.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzlib.o" "-c" "libtcod/src/zlib/gzlib.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzread.o" "-c" "libtcod/src/zlib/gzread.c"
exit code: 0
running: "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-Wall" "-Wextra" "-w" "-o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzwrite.o" "-c" "libtcod/src/zlib/gzwrite.c"
exit code: 0
AR_x86_64-apple-darwin = None
AR_x86_64_apple_darwin = None
HOST_AR = None
AR = None
running: "ar" "crs" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libz.a" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/adler32.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/crc32.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/deflate.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/infback.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/inffast.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/inflate.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/inftrees.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/trees.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/zutil.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/compress.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/uncompr.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzclose.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzlib.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzread.o" "/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out/libtcod/src/zlib/gzwrite.o"
exit code: 0
cargo:rustc-link-lib=static=z
cargo:rustc-link-search=native=/Users/justgage/sandbox/rust/roguelike/target/debug/build/tcod-sys-15ca9978ce9abb56/out
--- stderr
- thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"sdl2\"` did not exit successfully: exit code: 1\n--- stderr\nPackage sdl2 was not found in the pkg-config search path.\nPerhaps you should add the directory containing `sdl2.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'sdl2\' found\n"', libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
I guess I'm just the master of weird errors...
Hm. brew edit sdl2
and replace the url
and sha256
lines near the top with:
url "https://libsdl.org/release/SDL2-2.0.9.tar.gz"
# sha256 "edc77c57308661d576e843344d8638e025a7818bff73f8fbfab09c3c5fd092ec"
And see if that works. 2.0.9 is latest stable.
If Homebrew is still giving you trouble, here's the associated Homebrew GitHub issue: https://github.com/Homebrew/homebrew-core/issues/33016
Update: Urgh sorry I had a typo on the branch name. The branch name is fix-sdl2-rendering-mojave
. Amended my previous comment.
Success!
I just did:
brew install sdl2
then used your cargo config from above:
[dependencies]
tcod = { git = "https://github.com/rjungemann/tcod-rs.git", branch = "fix-sdl2-rendering-mojave" }
Thanks so much @rjungemann!
Thanks! That'll be the default hot-fix for libtcod-rs on mac OS until I get around to update the repo to the latest libtcod I think (especially since I don't have a mac). I don't have much time but I'll see what I can do
Glad it worked. I remember reading that SDL2 2.0.8 had the new Metal renderer code in it but for some reason I recalled it not working for me. It is good to know that 2.0.8 will work for it.
Closing this down as it seems to be solved now. Thanks!
Hi,
I'm using (learning, really) tcod-rs on OSX.
Everything was working fine until I updated to Mojave. After that, all I see is an empty black screen.
I have tried
tcod-rs/examples/text.rs
too in order to discard problems in my code and I confirm that I also see a black screen when I run it.I have installed libtcod using
brew install libtcod
. Here's whatbrew
says about it: