tcod-rs icon indicating copy to clipboard operation
tcod-rs copied to clipboard

OSX White Screen on first game loop interaction / Infinite loop freezing

Open paezao opened this issue 9 years ago • 8 comments

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

paezao avatar May 17 '16 14:05 paezao

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.

zsparal avatar May 17 '16 14:05 zsparal

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

paezao avatar May 17 '16 16:05 paezao

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:

  1. Clone the repo
  2. cd tcod-rs/tcod_sys/libtcod
  3. make -f makefiles/makefile-osx
  4. this will produce shared libraries in the current directory (at least it does on Linux, your mileage may vary on OS X)
  5. create test.cpp here 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;
}
  1. Compile the program and link against the bundled library: clang++ -L . -ltcod -ltcodxx test.cpp -o test
  2. Copy terminal.png into this directory
  3. Run it with the bundled libtcod version: 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).

zsparal avatar May 17 '16 17:05 zsparal

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.

paezao avatar May 18 '16 10:05 paezao

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?

tomob avatar May 18 '16 11:05 tomob

Have you installed SDL1? I don't know why it would even start without it, but you could try running brew install sdl.

zsparal avatar May 18 '16 11:05 zsparal

> 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

paezao avatar May 18 '16 12:05 paezao

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.

zsparal avatar May 18 '16 14:05 zsparal