[API Migrate]How to get pixelformat of Window/Surface of "SDL_PixelFormat" type in SDL2.0

Hi all,

I am upgrading the FFPlay which is the part of FFMPEG project to base the
new SDL2.0.

There are some common need, such as:
"
SDL_PixelFormat format = ???
fgcolor = SDL_MapRGB(&format, a, b, (a + b) / 2);

            fill_rectangle(screen,
                        s->xpos, s->height-y, 1, 1,
                        fgcolor, 0);

"
How to get the PixelFormat, i try to work it out in this way:
"
static SDL_Window *screen;

const SDL_PixelFormat *format = screen->surface->format;
"
but the compiler complains like:
"
jni/…/jni/SDL2-2.0.1/ffplay/ffplay.c:921:51: error: dereferencing pointer
to incomplete type
"
whatever member in SDL_Window i can to access directly there’s a compile
error like above.

So my question is:

  1. Is my above usage wrong?
  2. If 1) true, then what’s the right way to retrieve the
    SDL_Window/SDL_Surface’s PixelFomat(of SDL_PixelFormat type)?

Best regards,
faywong

Unlike SDL_Surface from SDL 1.2, SDL_Window uses functions to retrieve the
member info you’re used to. Here’s one of those functions:
http://wiki.libsdl.org/SDL_GetWindowSize

For the rest, see here:
http://wiki.libsdl.org/CategoryVideo

Jonny DOn Mon, Oct 28, 2013 at 9:01 PM, fei wang wrote:

Hi all,

I am upgrading the FFPlay which is the part of FFMPEG project to base the
new SDL2.0.

There are some common need, such as:
"
SDL_PixelFormat format = ???
fgcolor = SDL_MapRGB(&format, a, b, (a + b) / 2);

            fill_rectangle(screen,
                        s->xpos, s->height-y, 1, 1,
                        fgcolor, 0);

"
How to get the PixelFormat, i try to work it out in this way:
"
static SDL_Window *screen;

const SDL_PixelFormat *format = screen->surface->format;
"
but the compiler complains like:
"
jni/…/jni/SDL2-2.0.1/ffplay/ffplay.c:921:51: error: dereferencing pointer
to incomplete type
"
whatever member in SDL_Window i can to access directly there’s a compile
error like above.

So my question is:

  1. Is my above usage wrong?
  2. If 1) true, then what’s the right way to retrieve the
    SDL_Window/SDL_Surface’s PixelFomat(of SDL_PixelFormat type)?

Best regards,
faywong


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

Hi Jonny,

Before sending out the former email I noticed:

Uint32 SDL_GetWindowPixelFormat(SDL_Window* window)

from the wiki page and i tried to use it, but the result of it is of
Uint32, i don’t know how to convert it to a format of "SDL_PixelFormat"
type so as to hook with SDL_MapRGB(…)

Can you help me about it?

Many thanks in advance.

Best regards,
faywong

2013/10/29 Jonathan Dearborn > Unlike SDL_Surface from SDL 1.2, SDL_Window uses functions to retrieve the

member info you’re used to. Here’s one of those functions:
http://wiki.libsdl.org/SDL_GetWindowSize

For the rest, see here:
http://wiki.libsdl.org/CategoryVideo

Jonny D

On Mon, Oct 28, 2013 at 9:01 PM, fei wang <@fei_wang> wrote:

Hi all,

I am upgrading the FFPlay which is the part of FFMPEG project to base the
new SDL2.0.

There are some common need, such as:
"
SDL_PixelFormat format = ???
fgcolor = SDL_MapRGB(&format, a, b, (a + b) / 2);

            fill_rectangle(screen,
                        s->xpos, s->height-y, 1, 1,
                        fgcolor, 0);

"
How to get the PixelFormat, i try to work it out in this way:
"
static SDL_Window *screen;

const SDL_PixelFormat *format = screen->surface->format;
"
but the compiler complains like:
"
jni/…/jni/SDL2-2.0.1/ffplay/ffplay.c:921:51: error: dereferencing
pointer to incomplete type
"
whatever member in SDL_Window i can to access directly there’s a compile
error like above.

So my question is:

  1. Is my above usage wrong?
  2. If 1) true, then what’s the right way to retrieve the
    SDL_Window/SDL_Surface’s PixelFomat(of SDL_PixelFormat type)?

Best regards,
faywong


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


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

from the wiki page and i tried to use it, but the result of it is of
Uint32, i don’t know how to convert it to a format of "SDL_PixelFormat"
type so as to hook with SDL_MapRGB(…)

SDL_AllocFormat()

–ryan.

Hi Ryan,

It’s so kind of you. Many many thanks.

Best regards,
faywong

2013/10/29 Ryan C. Gordon >

from the wiki page and i tried to use it, but the result of it is of

Uint32, i don’t know how to convert it to a format of "SDL_PixelFormat"
type so as to hook with SDL_MapRGB(…)

SDL_AllocFormat()

–ryan.

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

Are you using the SDL_Renderer API or are you still using an SDL_Surface
and copying that to the screen? The new SDL_Renderer API would
use SDL_SetRenderDrawColor() and SDL_RenderFillRect() instead of
SDL_MapRGB() and SDL_FillRect().

Jonny DOn Mon, Oct 28, 2013 at 10:27 PM, fei wang wrote:

Hi Jonny,

Before sending out the former email I noticed:

Uint32 SDL_GetWindowPixelFormat(SDL_Window* window)

from the wiki page and i tried to use it, but the result of it is of
Uint32, i don’t know how to convert it to a format of "SDL_PixelFormat"
type so as to hook with SDL_MapRGB(…)

Can you help me about it?

Many thanks in advance.

Best regards,
faywong

2013/10/29 Jonathan Dearborn <@Jonathan_Dearborn>

Unlike SDL_Surface from SDL 1.2, SDL_Window uses functions to retrieve
the member info you’re used to. Here’s one of those functions:
http://wiki.libsdl.org/SDL_GetWindowSize

For the rest, see here:
http://wiki.libsdl.org/CategoryVideo

Jonny D

On Mon, Oct 28, 2013 at 9:01 PM, fei wang wrote:

Hi all,

I am upgrading the FFPlay which is the part of FFMPEG project to base
the new SDL2.0.

There are some common need, such as:
"
SDL_PixelFormat format = ???
fgcolor = SDL_MapRGB(&format, a, b, (a + b) / 2);

            fill_rectangle(screen,
                        s->xpos, s->height-y, 1, 1,
                        fgcolor, 0);

"
How to get the PixelFormat, i try to work it out in this way:
"
static SDL_Window *screen;

const SDL_PixelFormat *format = screen->surface->format;
"
but the compiler complains like:
"
jni/…/jni/SDL2-2.0.1/ffplay/ffplay.c:921:51: error: dereferencing
pointer to incomplete type
"
whatever member in SDL_Window i can to access directly there’s a compile
error like above.

So my question is:

  1. Is my above usage wrong?
  2. If 1) true, then what’s the right way to retrieve the
    SDL_Window/SDL_Surface’s PixelFomat(of SDL_PixelFormat type)?

Best regards,
faywong


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


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


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