SDL_CreateWindowFrom and the SDL_WINDOW_OPENGL flag

Could we get the following minor changes added, to better support OpenGL on foreign windows?
Add to SDL_hints.h:
#define SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT??? "SDL_FOREIGN_WINDOW_OPENGL_SUPPORT"
Add to the bottom of WIN_CreateWindowFrom, at the end of the "if (hint) " block inside the “#if SDL_VIDEO_OPENGL_WGL” region:
??? ??? } else {
??? ??? ??? hint = SDL_GetHint(SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT);
??? ??? ??? if (hint)
??? ??? ??? ??? window->flags |= SDL_WINDOW_OPENGL;
??? ??? }
This provides a developer-definable override to say "yes, I really do want to use OpenGL rendering on this foreign window."
Mason

It might be possible to transparently check if the foreign window has
OpenGL support without a hint. Using the Win32 GetPixelFormat() and then
DescribePixelFormat(), I think you can recover the PIXELFORMATDESCRIPTOR
and check the flags for PFD_SUPPORT_OPENGL.

Jonny DOn Fri, Aug 21, 2015 at 8:45 AM, Mason Wheeler wrote:

Could we get the following minor changes added, to better support OpenGL
on foreign windows?

Add to SDL_hints.h:

#define SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT
"SDL_FOREIGN_WINDOW_OPENGL_SUPPORT"

Add to the bottom of WIN_CreateWindowFrom, at the end of the "if (hint) "
block inside the “#if SDL_VIDEO_OPENGL_WGL” region:

    } else {
        hint = SDL_GetHint(SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT);
        if (hint)
            window->flags |= SDL_WINDOW_OPENGL;
    }

This provides a developer-definable override to say “yes, I really do want
to use OpenGL rendering on this foreign window.”

Mason


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

That actually doesn’t seem particularly meaningful for determining whether or not the window supports OpenGL, because you can always set a new pixel format. The only really relevant thing is whether or not the system supports OpenGL.From: Jonathan Dearborn
To: Mason Wheeler <@Mason_Wheeler>; SDL Development List
Sent: Friday, August 21, 2015 12:02 PM
Subject: Re: [SDL] SDL_CreateWindowFrom and the SDL_WINDOW_OPENGL flag

It might be possible to transparently check if the foreign window has OpenGL support without a hint.? Using the Win32 GetPixelFormat() and then DescribePixelFormat(), I think you can recover the PIXELFORMATDESCRIPTOR and check the flags for PFD_SUPPORT_OPENGL.
Jonny D

On Fri, Aug 21, 2015 at 8:45 AM, Mason Wheeler <@Mason_Wheeler> wrote:

Could we get the following minor changes added, to better support OpenGL on foreign windows?
Add to SDL_hints.h:
#define SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT??? "SDL_FOREIGN_WINDOW_OPENGL_SUPPORT"
Add to the bottom of WIN_CreateWindowFrom, at the end of the "if (hint) " block inside the “#if SDL_VIDEO_OPENGL_WGL” region:
??? ??? } else {
??? ??? ??? hint = SDL_GetHint(SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT);
??? ??? ??? if (hint)
??? ??? ??? ??? window->flags |= SDL_WINDOW_OPENGL;
??? ??? }
This provides a developer-definable override to say "yes, I really do want to use OpenGL rendering on this foreign window."
Mason


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

As far as I understand, the pixel format is validated in
ChoosePixelFormat()/SetPixelFormat() and the actual flags supported are
returned in the last parameter. So if the system does not support OpenGL,
the returned format (which is the same as you get from
GetPixelFormat()/DescribePixelFormat()) will not have the
PFD_SUPPORT_OPENGL flag.

Jonny DOn Fri, Aug 21, 2015 at 2:17 PM, Mason Wheeler wrote:

That actually doesn’t seem particularly meaningful for determining whether
or not the window supports OpenGL, because you can always set a new pixel
format. The only really relevant thing is whether or not the system
supports OpenGL.


From: Jonathan Dearborn <@Jonathan_Dearborn>
To: Mason Wheeler ; SDL Development List <
sdl at lists.libsdl.org>
Sent: Friday, August 21, 2015 12:02 PM
Subject: Re: [SDL] SDL_CreateWindowFrom and the SDL_WINDOW_OPENGL flag

It might be possible to transparently check if the foreign window has
OpenGL support without a hint. Using the Win32 GetPixelFormat() and then
DescribePixelFormat(), I think you can recover the PIXELFORMATDESCRIPTOR
and check the flags for PFD_SUPPORT_OPENGL.

Jonny D

On Fri, Aug 21, 2015 at 8:45 AM, Mason Wheeler wrote:

Could we get the following minor changes added, to better support OpenGL
on foreign windows?

Add to SDL_hints.h:

#define SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT
"SDL_FOREIGN_WINDOW_OPENGL_SUPPORT"

Add to the bottom of WIN_CreateWindowFrom, at the end of the "if (hint) "
block inside the “#if SDL_VIDEO_OPENGL_WGL” region:

    } else {
        hint = SDL_GetHint(SDL_HINT_FOREIGN_WINDOW_OPENGL_SUPPORT);
        if (hint)
            window->flags |= SDL_WINDOW_OPENGL;
    }

This provides a developer-definable override to say “yes, I really do want
to use OpenGL rendering on this foreign window.”

Mason


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