Migrating from SDL 1.2 to SDL2

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

SDL_WINDOWEVENT_ENTER and LEAVE may be what you are after

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?

Anyone?

Looks like SDL_UpdateWindowSurfaceRects
https://wiki.libsdl.org/SDL_UpdateWindowSurfaceRects?highlight=(\bCategoryVideo\b)|(CategoryEnum)|(CategoryStruct)
might do what you want. When in doubt, just browse the wiki. You can see all
the functions alphabetically https://wiki.libsdl.org/CategoryAPI 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:

Anyone?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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.

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

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 DOn Thu, May 12, 2016 at 10:59 AM, AmigaBlitter wrote:

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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thank you for the info.

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