2
\$\begingroup\$

I'm making an app with SDL2. I've gotten everything to work so far, including SDL_TTF. When I run my program in a normal window, everything works great!

However, now I'm trying to add fullscreen functionality... and I've run into the problem. On fullscreen mode ONLY, the program APPEARS to look fine at first, however, one of my functions (A text rendering function) causes problems. On fullscreen, this function momentarily removes or "flickers" the image behind it, revealing the previous image underneath. Why would this function cause an error on fullscreen vs. regular window sizing? I assume it's some kind of strange sizing issue...

void drawDialog(const char* content) {
//Draws a dialog box with set text
TTF_Font* font = TTF_OpenFont("assets/times.ttf", 30);
SDL_Color textColor = { 255, 255, 255 };
SDL_Surface* message = TTF_RenderText_Solid(font, content, textColor);
SDL_Texture* dialogTex;
SDL_Rect destRect;

destRect.x = 50;
destRect.y = 730;

destRect.w = 300;
destRect.h = 30;

dialogTex = SDL_CreateTextureFromSurface(renderer, message);
SDL_FreeSurface(message);
SDL_RenderCopy(renderer, dialogTex, NULL, &destRect);
SDL_RenderPresent(renderer);

}

Any help would be super! Thanks!

\$\endgroup\$
12
  • \$\begingroup\$ Do you have VSYNC on/off, and does toggling that make a difference? \$\endgroup\$
    – user35344
    Nov 16, 2017 at 6:35
  • \$\begingroup\$ Can you describe what 'momentarily' means? I'm not familiar with SDL, but one possible cause could be z-fighting of some of the planes due to the backbuffer not being cleared appropriately. Of course also check if the driver is causing this. \$\endgroup\$
    – StarShine
    Nov 16, 2017 at 15:06
  • \$\begingroup\$ @Tyyppi_77 I don't know what VSYNC is! What is it and how/where do I toggle it? \$\endgroup\$ Nov 16, 2017 at 16:24
  • \$\begingroup\$ Pass SDL_RENDERER_PRESENTVSYNC to SDL_CreateRenderer to enable it, and omit it to disable it. \$\endgroup\$
    – user35344
    Nov 16, 2017 at 16:29
  • \$\begingroup\$ @Tyyppi_77 Well, I just enabled it. Nothing changed. \$\endgroup\$ Nov 16, 2017 at 20:40

1 Answer 1

0
\$\begingroup\$

I fixed it! Before, when I created the window in the main function, I passed SDL_WINDOW_FULLSCREEN to the window creation. However, the other mode of fullscreen is SDL_WINDOW_FULLSCREEN_DESKTOP which creates a "fake" fullscreen appearance by sizing the window to the screen size. This works perfectly!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Good find, I would not consider this a tue fix, but I can imagine you can do your thing and move on. Could you build a minimal sample and notify the SDL developers of the issue? \$\endgroup\$
    – StarShine
    Nov 21, 2017 at 21:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .