The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_CreateWindowFrom and the SDL_WINDOW_OPENGL flag
Mason Wheeler
Guest

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_CreateWindowFrom and the SDL_WINDOW_OPENGL flag
Jonny D


Joined: 12 Sep 2009
Posts: 932
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:
Quote:
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_CreateWindowFrom and the SDL_WINDOW_OPENGL flag
Mason Wheeler
Guest

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; 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 wrote:
Quote:



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 http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_CreateWindowFrom and the SDL_WINDOW_OPENGL flag
Jonny D


Joined: 12 Sep 2009
Posts: 932
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 D




On Fri, Aug 21, 2015 at 2:17 PM, Mason Wheeler wrote:
Quote:
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; 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 wrote:
Quote:



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