SDL_SURFACE from window handle (win32)

Instead of using SDL_SetVideoMode in order to create a screen (SDL_Surface),
is it possible to generate a SDL_Surface from a Window handle (Win32) ?
=>CreateWindow Top-Level Window => hWnd => create a SDL_SURFACE from hWnd,
and use it…

thank you
Paulo

I’ve been looking at this problem too.

I can’t help you directly with your question, but I would like to say
that I think it would be better to have an API that returns a window
handle for the surface so one could do this (Win32):

HWND main_window = CreateWindow(…);
SDL_Surface* disp_surf = SDL_DisplaySurface(…);
SetParent(SDL_GetNativeHandle(disp_surf), main_window);

Eddy

Paulo Vicentini wrote:> Instead of using SDL_SetVideoMode in order to create a screen

(SDL_Surface), is it possible to generate a SDL_Surface from a Window
handle (Win32) ?
=>CreateWindow Top-Level Window => hWnd => create a SDL_SURFACE from
hWnd, and use it…

thank you
Paulo



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

Actually, I think this would be better (Win32 example):

typedef SDL_NativeWindow HWND;
void SDL_SetParentWindow(SDL_Surface*, SDL_NativeWindow);

HWND main_window = CreateWindow(…);

disp_surf = SDL_DisplaySurface(…);
SDL_SetParentWindow(disp_surf, main_window);

Eddy

Edward Cullen wrote:> I’ve been looking at this problem too.

I can’t help you directly with your question, but I would like to say
that I think it would be better to have an API that returns a window
handle for the surface so one could do this (Win32):

HWND main_window = CreateWindow(…);
SDL_Surface* disp_surf = SDL_DisplaySurface(…);
SetParent(SDL_GetNativeHandle(disp_surf), main_window);

Eddy

Paulo Vicentini wrote:

Instead of using SDL_SetVideoMode in order to create a screen
(SDL_Surface), is it possible to generate a SDL_Surface from a Window
handle (Win32) ?
=>CreateWindow Top-Level Window => hWnd => create a SDL_SURFACE from
hWnd, and use it…

thank you
Paulo



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

isn’t the SDL_WINDOWID supposed to do just that?

we set the handle of our “main_window” in hex form or integer as value
of SDL_WINDOWID and SDL video will then use it to render its display
surface. e.g.

char tWndAddress[32];
sprintf(tWndAddress, "0x%p", main_window);
bFlag = SetEnvironmentVariable("SDL_WINDOWID", tWndAddress);

correct ?

in my “world” this works well when i use windib and not so well in
directx video driver (it could be my app and how it uses SDL - still
learning). the test program - testsprite - works mostly well, with
quirks (and i’ve not completed my analysis yet) with directx, fullscreen…

hope that helps.

kindest regards,
Sheshadri

Edward Cullen wrote:> Actually, I think this would be better (Win32 example):

typedef SDL_NativeWindow HWND;
void SDL_SetParentWindow(SDL_Surface*, SDL_NativeWindow);

HWND main_window = CreateWindow(…);

disp_surf = SDL_DisplaySurface(…);
SDL_SetParentWindow(disp_surf, main_window);

Eddy

Edward Cullen wrote:

I’ve been looking at this problem too.

I can’t help you directly with your question, but I would like to say
that I think it would be better to have an API that returns a window
handle for the surface so one could do this (Win32):

HWND main_window = CreateWindow(…);
SDL_Surface* disp_surf = SDL_DisplaySurface(…);
SetParent(SDL_GetNativeHandle(disp_surf), main_window);

Eddy

Paulo Vicentini wrote:

Instead of using SDL_SetVideoMode in order to create a screen
(SDL_Surface), is it possible to generate a SDL_Surface from a
Window handle (Win32) ?
=>CreateWindow Top-Level Window => hWnd => create a SDL_SURFACE
from hWnd, and use it…

thank you
Paulo



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

You are correct,

But SDL_WINDOWID is terrible hack - it should be possible to do it
without modifying the environment. It also isn’t conducive to working
with multiple windows.

Eddy

Sheshadri Mantha wrote:> isn’t the SDL_WINDOWID supposed to do just that?

we set the handle of our “main_window” in hex form or integer as value
of SDL_WINDOWID and SDL video will then use it to render its display
surface. e.g.

char tWndAddress[32];
sprintf(tWndAddress, “0x%p”, main_window);
bFlag = SetEnvironmentVariable(“SDL_WINDOWID”, tWndAddress);

correct ?

in my “world” this works well when i use windib and not so well in
directx video driver (it could be my app and how it uses SDL - still
learning). the test program - testsprite - works mostly well, with
quirks (and i’ve not completed my analysis yet) with directx, fullscreen…

hope that helps.

kindest regards,
Sheshadri

Edward Cullen wrote:

Actually, I think this would be better (Win32 example):

typedef SDL_NativeWindow HWND;
void SDL_SetParentWindow(SDL_Surface*, SDL_NativeWindow);

HWND main_window = CreateWindow(…);

disp_surf = SDL_DisplaySurface(…);
SDL_SetParentWindow(disp_surf, main_window);

Eddy

Edward Cullen wrote:

I’ve been looking at this problem too.

I can’t help you directly with your question, but I would like to say
that I think it would be better to have an API that returns a window
handle for the surface so one could do this (Win32):

HWND main_window = CreateWindow(…);
SDL_Surface* disp_surf = SDL_DisplaySurface(…);
SetParent(SDL_GetNativeHandle(disp_surf), main_window);

Eddy

Paulo Vicentini wrote:

Instead of using SDL_SetVideoMode in order to create a screen
(SDL_Surface), is it possible to generate a SDL_Surface from a
Window handle (Win32) ?
=>CreateWindow Top-Level Window => hWnd => create a SDL_SURFACE
from hWnd, and use it…

thank you
Paulo



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


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