The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL2: SDL_Delay() makes the window bar hidden on El Capitan
Feng


Joined: 13 Jun 2016
Posts: 1
Env:
    SDL 2.0.4;
    OS X El Capitan 10.11.5 (15F34);
    clang 7.3


After calling the SDL_Delay(), the window bar is hidden and a white bar is shown instead.
I'm not sure if this is a feature or bug. Or I missed something?

Thank you!

Here is my code:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <SDL2/SDL.h>

const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

int main(int argc, const char *argv[])
{
  if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
  {
    printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
  }
  bool quit = false;
  SDL_Event event;
  SDL_Window* window = NULL;
  window = SDL_CreateWindow("Test SDL", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
  SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

  SDL_SetRenderDrawColor(renderer, 255, 254, 255, 255 );
  SDL_RenderClear(renderer);

  SDL_RenderPresent(renderer);
  SDL_Delay(5000); // window bar is hidden, a white blank bar is shown instead.

  while (!quit) // window bar is shown right now.
  {
    SDL_WaitEvent(&event);
    switch (event.type)
    {
      case SDL_QUIT:
        quit = true;
        break;
    }
  }


  SDL_DestroyRenderer(renderer);
  SDL_DestroyWindow(window);

   SDL_Quit();
  return 0;
}

[/img]
marius


Joined: 19 Jul 2016
Posts: 1
I have the exact same problem! And I saw it reported on a number of other websites. There are also other variants of this issue, almost all on OS X El Capitan.
Does someone here know whether it is a (un)known bug or a normal behaviour inherent to the OS X platform? I’m curious about this. Thank you very much Very Happy
rrohrer


Joined: 07 Aug 2016
Posts: 2
Location: Seattle, WA, USA
Hey, I don't know if you figured this out (it's been a while since this post was made), but the issue is that the message pump isn't getting drained.

Previous versions of SDL2 / OS X seemed to handle this differently.

Code:

// replace this:
SDL_Delay(1000);

// with this:
for (int i = 0; i < 1000; ++i)
{
    SDL_PumpEvents();
    SDL_Delay(1);
}


I know it's a lame work around, but it fixes the issue of the white / hidden window bar.