SDL_CreateRenderer blocked when i use SDL_RENDERER_ACCELERAT

I want to render a movie clip(YUV format) in a window created by java swt, so i wrote a render function which accept a handle parameter,
my system is ubuntu 10.04 and i use gtk-2.0 lib to convert the handle.
when i use SDL_CreateRenderer(pwindow, -1, SDL_RENDERER_SOFTWARE), my function works, but the vedio quality is bad.
then i use SDL_CreateRenderer(pwindow, -1, SDL_RENDERER_ACCELERATED), it seems my function is blocked in SDL_CreateRenderer.
How can i use opengl accleration mode in my function? I hope anyone can give me a suggestion.

my code as below:

Code:

extern “C” int TW_init(int iHandle)
{
SDL_Init(SDL_INIT_EVERYTHING);

GtkWidget* pWidget = (GtkWidget*)((int)iHandle);
GdkWindow* pgdkWindow = pWidget->window;
Window x11id = GDK_WINDOW_XWINDOW(pgdkWindow);

SDL_Window *pwindow=NULL;
pwindow=SDL_CreateWindowFrom((void*)x11id);
if(!pwindow)
{
    printf("error when create window:%s\n", SDL_GetError());
    return 0;
}
printf("create window\n");

    SDL_RendererInfo info;
int num;

SDL_Renderer *prenderer=NULL;
printf("ready to create renderer\n");
prenderer=SDL_CreateRenderer(pwindow, -1, SDL_RENDERER_SOFTWARE);
if(!prenderer)
{
    SDL_DestroyWindow(pwindow);
    printf( "error when create renderer:%s\n", SDL_GetError());
    return 0;
}

/*other rendering code*/

return 0;

}

By blocked, you do mean SDL_CreateRenderer( …, SDL_RENDERER_ACCELERATED
); returns NULL? If so, what does SDL_GetError give you (looks like it
should print out).

If you mean that the program hangs on that command and doesn’t continue,
there are a few options:

  • Java could be hogging a system resource (unlikely)
  • SDL can’t create an OpenGL context on a gtk-imported window (presuming
    that the window manager either already has a context, or won’t create one
    if the window already has widgets on it?)
  • You found a bug

I have my suspicion that it’s the second option there. What is in the java
swt window? I don’t have much experience with C/SDL -> Java and window
management, so I don’t know how much I can personally help you debug this,
but if you can provide some more information, I’m sure someone on the
mailing list can give you more of a hand than I can.

Hope that points you in the right direction,
-AlexOn Wed, Aug 8, 2012 at 2:37 AM, hongbo <mahb94 at 126.com> wrote:

**
I want to render a movie clip(YUV format) in a window created by java swt,
so i wrote a render function which accept a handle parameter,
my system is ubuntu 10.04 and i use gtk-2.0 lib to convert the handle.
when i use SDL_CreateRenderer(pwindow, -1, SDL_RENDERER_SOFTWARE), my
function works, but the vedio quality is bad.
then i use SDL_CreateRenderer(pwindow, -1, SDL_RENDERER_ACCELERATED), it
seems my function is blocked in SDL_CreateRenderer.
How can i use opengl accleration mode in my function? I hope anyone can
give me a suggestion.

my code as below:

Code:

extern “C” int TW_init(int iHandle)
{
SDL_Init(SDL_INIT_EVERYTHING);

GtkWidget* pWidget = (GtkWidget*)((int)iHandle);
GdkWindow* pgdkWindow = pWidget->window;
Window x11id = GDK_WINDOW_XWINDOW(pgdkWindow);

SDL_Window *pwindow=NULL;
pwindow=SDL_CreateWindowFrom((void*)x11id);
if(!pwindow)
{
    printf("error when create window:%s\n", SDL_GetError());
    return 0;
}
printf("create window\n");

    SDL_RendererInfo info;
int num;

SDL_Renderer *prenderer=NULL;
printf("ready to create renderer\n");
prenderer=SDL_CreateRenderer(pwindow, -1, SDL_RENDERER_SOFTWARE);
if(!prenderer)
{
    SDL_DestroyWindow(pwindow);
    printf( "error when create renderer:%s\n", SDL_GetError());
    return 0;
}

/*other rendering code*/

return 0;

}


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

my program hangs on SDL_CREATERENDER . If it is the 2nd option, any suggestion?
Only SDL_RENDERER_SOFTWARE i can use now.