# SDL2 - Can't see the Window

**URL:** <https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835>\
**Category:** SDL Development\
**Created:** [March 5, 2019, 9:12pm UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835 "2019-03-05T21:12:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kotrunga](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/kotrunga/32/3391_2.png) [@kotrunga](https://discourse.libsdl.org/u/kotrunga)\
**Post date:** [March 5, 2019, 9:12pm UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/1 "2019-03-05T21:12:51Z")

</div>

Hi all,

Running into a problem with SDL2- when I make a window, I can’t see it! I’m running the latest version of Mac OS X.

I’m trying to follow the Lazy Foo tutorials [here](http://lazyfoo.net/tutorials/SDL/index.php)

I’ve also read the docs for SDL\_CreateWindow [here](https://wiki.libsdl.org/SDL_CreateWindow?highlight=%28%5CbCategoryAPI%5Cb%29%7C%28SDLFunctionTemplate%29)

I’ve tried the Lazy Foo tutorials for Mac OS X using Xcode, as well as building SDL2 myself (following the Linux tutorials) and running it. I’ve also tried the code from the SDL\_CreateWindow docs page.

I have no problems compiling. It compiles fine. When I run it, whether with ./01\_hello\_SDL or hitting the play button in XCode, I can see that something runs (the spinning wheel comes up in the GUI for Xcode or in the top right of terminal when running with ./filename). However, I don’t _see_ any window or image popup.

What am I doing wrong?

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![kotrunga](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/kotrunga/32/3391_2.png) [@kotrunga](https://discourse.libsdl.org/u/kotrunga)\
**Post date:** [March 6, 2019, 10:49pm UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/2 "2019-03-06T22:49:40Z")

</div>

Ok, I found the issue. The window wouldn’t show up on OS X unless I had an event loop going (prior I had an SDL\_Delay call).

Now I’m curious- why do I need the event loop? Why isn’t the SDL\_Delay sufficient?

(LazyFoo gives an example of the event loop on [this](http://lazyfoo.net/tutorials/SDL/03_event_driven_programming/index.php) page.)

---

<div class="post-metadata">

**Author:** ![viking](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/viking/32/3916_2.png) [@viking](https://discourse.libsdl.org/u/viking)\
**Post date:** [December 14, 2019, 10:39pm UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/3 "2019-12-14T22:39:29Z")

</div>

@kotrunga I had this issue as well, did you learn why?  
thanks!

---

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [December 15, 2019, 7:08am UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/4 "2019-12-15T07:08:52Z")

</div>

There’s some window sizing and state change stuff that MacOS puts on the event queue that most likely needs to get consumed and removed from the event queue before the OS considers the window “finished” and shows it, or something along that line.

A quick little test app with SDL 2.0.10 run on MacOS 10.15.1 shows that there were 5 events waiting in the queue right after the window was created: SDL\_WINDOWEVENT\_FOCUS\_GAINED, SDL\_WINDOWEVENT\_ENTER, SDL\_MOUSEMOTION, SDL\_WINDOWEVENT\_SHOWN, SDL\_WINDOWEVENT\_EXPOSED.

In a normal game or app, this isn’t a problem since you’re going to set up an event queue anyway.

---

<div class="post-metadata">

**Author:** ![viking](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/viking/32/3916_2.png) [@viking](https://discourse.libsdl.org/u/viking)\
**Post date:** [December 15, 2019, 7:26am UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/5 "2019-12-15T07:26:26Z")

</div>

Thanks for explaining , got a bit confused why the problem occurred. Always good to know why things happen.

Yes I agree with that the event loop will most likely be added in most cases.

---

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [December 15, 2019, 7:28am UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/6 "2019-12-15T07:28:10Z")

</div>

If memory serves, this wasn’t _always_ the case on MacOS, which is why older tutorials don’t mention it.

---

<div class="post-metadata">

**Author:** ![viking](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/viking/32/3916_2.png) [@viking](https://discourse.libsdl.org/u/viking)\
**Post date:** [December 16, 2019, 9:40am UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/7 "2019-12-16T09:40:15Z")

</div>

I think you are correct, I used a little bit of SDL2 in my university studies and I can’t recall that this happed back then 😃

---

<div class="post-metadata">

**Author:** ![kotrunga](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/kotrunga/32/3391_2.png) [@kotrunga](https://discourse.libsdl.org/u/kotrunga)\
**Post date:** [December 16, 2019, 3:20pm UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/8 "2019-12-16T15:20:28Z")

</div>

@sjr thanks for helping @viking and me!

---

<div class="post-metadata">

**Author:** ![sjr](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sjr/32/5749_2.png) [@sjr](https://discourse.libsdl.org/u/sjr)\
**Post date:** [December 18, 2019, 4:53am UTC](https://discourse.libsdl.org/t/sdl2-cant-see-the-window/25835/9 "2019-12-18T04:53:56Z")

</div>

No problem! Glad to help.
