OSX White Screen on first game loop interaction / Infinite loop freezing
Hello,
Im having trouble in OSX. It shows a white screen and then renders correctly but only if I use root.wait_for_keypress(true);
If I don't use root.wait_for_keypress(true); then it just freezes and doesn't even show the window.
White screen screenshot: https://screencloud.net/v/uYLD
Does it hang in the Rust or C part of the library? On a related note: does it work using C or C++ and the bundled libtcod version?
Also, could you provide a minimal repro (or your whole project if it's open source) so I can try and reproduce it under Linux?
EDIT: can you try cloning this repo and running cargo run --example samples to see if our example works for you? That might also be a good place to start.
Hello @Gustorn, thanks for replying 👍
It seems that the infinite loop is hanging it.. Im not sure though if its Rust or C. The libtcod I compiled has samples that work correctly but Im not sure about the bundled version. How can I check that?
tcod-rs samples also show the white screen.
This is my current code -> https://gist.github.com/paezao/0babb33796b588dbd3d812bde6b3e5ec
Unfortunately it just works on Linux, so this will probably be difficult to debug (unless someone with OSX shows up).
As for checking the bundled version:
- Clone the repo
cd tcod-rs/tcod_sys/libtcodmake -f makefiles/makefile-osx- this will produce shared libraries in the current directory (at least it does on Linux, your mileage may vary on OS X)
- create
test.cpphere with the following contents:
#include "include/libtcod.hpp"
int main() {
TCODConsole::initRoot(80, 60, "Test", false);
while (!TCODConsole::isWindowClosed()) {
TCODSystem::checkForEvent(TCOD_EVENT_KEY_PRESS, NULL, NULL);
TCODConsole::root->clear();
TCODConsole::root->putChar(40, 30, '@');
TCODConsole::flush();
}
return 0;
}
- Compile the program and link against the bundled library:
clang++ -L . -ltcod -ltcodxx test.cpp -o test - Copy
terminal.pnginto this directory - Run it with the bundled
libtcodversion:DYLD_LIBRARY_PATH=. ./test
If this works then the problem is on our end: either a tcod-sys buildscript error or something else. If not then it's on the libtcod side, which will be much harder to debug.
What you can also try is using a different renderer, by doing something like this:
let mut root = Root::initializer()
.font("arial10x10.png", FontLayout::Tcod)
.font_type(FontType::Greyscale)
.size(SCREEN_WIDTH, SCREEN_HEIGHT)
.title("Roguerust")
.renderer(Renderer::GLSL) // or Renderer::OpenGL
.init();
Try both alternative renderers and see if any of them works (Renderer::SDL is the default one, you don't have to check that).
Hello @Gustorn,
This example also does flash the screen with white. It seems to be a problem with libtcod then.
It does work correctly with Renderer::OpenGL and Renderer::GLSL. Interesting.
It seems to work on my Mac.
> sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.5
BuildVersion: 14F1713
> rustc -V
rustc 1.8.0 (db2939409 2016-04-11)
> sdl2-config --version
2.0.3
> sdl-config --version
1.2.15
@paezao Does the C++ example works for you with a different renderer?
Have you installed SDL1? I don't know why it would even start without it, but you could try running brew install sdl.
> sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.2
BuildVersion: 15C50
> rustc -V
rustc 1.10.0-nightly (5ebe41835 2016-05-15)
> sdl2-config --version
2.0.4
> sdl-config --version
1.2.15
I'm out of ideas. As far as I can tell OSX is not even officially supported by libtcod (at least it doesn't mention it anywhere), so I don't even know where to look for more info. I'd recommend just using one of the other renderers.