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
Migrating from SDL 1.2 to SDL2
AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Since the previous thread i opened gone wild, i opened a new thread about migrating software from SDL version 1 to SDL version 2.

I have now a problem related to SDL_ACTIVEEVENT.
If i understood correctly, it's now changed to SDL_WINDOWEVENT.

Consider now the following:

Code:

SDL_Event event;

case SDL_ACTIVEEVENT:
      if (event.active.state & SDL_APPINPUTFOCUS && !event.active.gain) {
           DEBUG.LOG("Lost input focus\n");
           ...
          ...
       ]



now event.active.state and event.active.gain doesn't exist anymore.

How can i change this?

Thank you very much
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
SDL_WINDOWEVENT_ENTER and LEAVE may be what you are after
AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Thank you for the reply.

Now it's the SDL_UpdateRects turn.

What if this function was previously used to update specific screen portions?
There's an equivalent in SDL2?
AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Anyone?
Migrating from SDL 1.2 to SDL2
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
Looks like SDL_UpdateWindowSurfaceRects might do what you want.  When in doubt, just browse the wiki.  You can see all the functions alphabetically and just search the page with Ctrl/Cmd+F with things that might make sense, in this case, I did that with 'Rects'.

On Thu, May 12, 2016 at 10:02 AM, AmigaBlitter wrote:
Quote:
Anyone?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Thank you, i can't find any specific example for SDL2. Documentation hard to find around.

Hope that specific tutorial for migration pops out around.
AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Migration guide is a bit vague on this:

"That's right, if you've been using SDL_UpdateRect() or SDL_Flip() to get your bits to the screen, the render API uses SDL_RenderPresent(). "
Migrating from SDL 1.2 to SDL2
Jonny D


Joined: 12 Sep 2009
Posts: 932
It depends on your porting strategy.  If you're using SDL_GetWindowSurface(), then use SDL_UpdateWindowSurfaceRects().  Otherwise, using hardware SDL_Renderer, there is no analogous function; you are expected to refresh the whole screen all at once with SDL_RenderPresent().

Jonny D




On Thu, May 12, 2016 at 10:59 AM, AmigaBlitter wrote:
Quote:
Migration guide is a bit vague on this:

"That's right, if you've been using SDL_UpdateRect() or SDL_Flip() to get your bits to the screen, the render API uses SDL_RenderPresent(). "


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Thank you for the info.
AmigaBlitter


Joined: 14 Feb 2016
Posts: 16
Hello again,

can anyone help me in creating a routine to find a screen mode with specific mode or pixel format?

in SDL1 the routine is as follow:

Code:


static long find_screen_modes (struct SDL_PixelFormat *vfmt, SDL_Rect *mode_list, int mode_list_size)
{
    long count = 0;
    SDL_Rect **modes = SDL_ListModes (vfmt, SDL_FULLSCREEN | SDL_HWSURFACE);

    if (modes != 0 && modes != (SDL_Rect**)-1) {
   unsigned int i;
   int w = -1;
   int h = -1;

   /* Filter list of modes SDL gave us and ignore duplicates */
   for (i = 0; modes[i] && count < mode_list_size; i++) {
       if (modes[i]->w != w || modes[i]->h != h) {
      mode_list[count].w = w = modes[i]->w;
      mode_list[count].h = h = modes[i]->h;
      count++;

      write_log ("SDLGFX: Found screenmode: %dx%d.\n", w, h);
       }
   }
    } else
   count = (long) modes;

    return count;
}


i have some difficulty to create an SDL2 version of this function