Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
paezao opened this issue May 17, 2016 · 8 comments
Open

Comments

@paezao
Copy link

paezao commented May 17, 2016

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

@zsparal
Copy link
Collaborator

zsparal commented May 17, 2016

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.

@paezao
Copy link
Author

paezao commented May 17, 2016

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

@zsparal
Copy link
Collaborator

zsparal commented May 17, 2016

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).

@paezao
Copy link
Author

paezao commented May 18, 2016

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.

@tomob
Copy link
Contributor

tomob commented May 18, 2016

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?

@zsparal
Copy link
Collaborator

zsparal commented May 18, 2016

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

@paezao
Copy link
Author

paezao commented May 18, 2016

> 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

@zsparal
Copy link
Collaborator

zsparal commented May 18, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants