platform specific window handle?

View: New views
5 Messages — Rating Filter:   Alert me  

platform specific window handle?

by Chris Marshall-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've been looking into the possibility
of embedding freeglut opengl windows
into other applications or GUI libraries.

Typically, one needs a platform specific
handle to the window in order to manage
handling events and passing events down
to the embedded window.

Is the a way to request a native window
handle from FreeGLUT (e.g. X11 window
or a win32 handle)?  I'm not sure on what
the specific details would be but I would
prefer to avoid breaking the FreeGLUT
abstraction layer to solve the problem.

For example, I could modify and build my
own copy of FreeGLUT with the needed hooks.

Cheers,
Chris Marshall

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

Re: platform specific window handle?

by John Tsiombikas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 24, 2009 at 02:51:26PM -0400, Chris Marshall wrote:

> I've been looking into the possibility
> of embedding freeglut opengl windows
> into other applications or GUI libraries.
>
> Typically, one needs a platform specific
> handle to the window in order to manage
> handling events and passing events down
> to the embedded window.
>
> Is the a way to request a native window
> handle from FreeGLUT (e.g. X11 window
> or a win32 handle)?  I'm not sure on what
> the specific details would be but I would
> prefer to avoid breaking the FreeGLUT
> abstraction layer to solve the problem.
>
> For example, I could modify and build my
> own copy of FreeGLUT with the needed hooks.

The SFG_Context struct in freeglut_internal.h contains an
SFG_WindowHandleType variable which is a Window on X11 and a HWND on
windows. That is in turn included in the SFG_Window struct. A list of
windows is kept in the SFG_Structure (see fgStructure in
freeglut_structure.c).

So, there it is, you can easily modify your own copy to do that.

As far as adding that facility to freeglut, I already mentioned in this
list some time ago that I think it would be very useful to include a
function in the freeglut API to retreive window-system specific
variables. However most people here seemed to dissagree, because it
might encourage people to write platform-specific code.

--
John Tsiombikas
http://nuclear.sdf-eu.org/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

Re: platform specific window handle?

by John F. Fay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Chris,

         Since the purpose of "freeglut" is exactly to shield the
application from getting a "platform-specific" anything, I'm not sure
how we could have it return a native window handle while remaining
true to its purpose.

                 - John


At 01:51 PM 10/24/2009, you wrote:

>I've been looking into the possibility
>of embedding freeglut opengl windows
>into other applications or GUI libraries.
>
>Typically, one needs a platform specific
>handle to the window in order to manage
>handling events and passing events down
>to the embedded window.
>
>Is the a way to request a native window
>handle from FreeGLUT (e.g. X11 window
>or a win32 handle)?  I'm not sure on what
>the specific details would be but I would
>prefer to avoid breaking the FreeGLUT
>abstraction layer to solve the problem.
>
>For example, I could modify and build my
>own copy of FreeGLUT with the needed hooks.
>
>Cheers,
>Chris Marshall
>
>------------------------------------------------------------------------------
>Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>is the only developer event you need to attend this year. Jumpstart your
>developing skills, take BlackBerry mobile applications to market and stay
>ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>http://p.sf.net/sfu/devconference
>_______________________________________________
>Freeglut-developer mailing list
>Freeglut-developer@...
>https://lists.sourceforge.net/lists/listinfo/freeglut-developer


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

Re: platform specific window handle?

by Chris Marshall-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John F. Fay wrote:
>
>          Since the purpose of "freeglut" is exactly to shield the
> application from getting a "platform-specific" anything, I'm not sure
> how we could have it return a native window handle while remaining
> true to its purpose.

Well, given that FreeGLUT is a GLUT replacement
and from the GLUT description at
http://www.opengl.org/resources/libraries/glut/

   GLUT (pronounced like the glut in gluttony)
   is the OpenGL Utility Toolkit, a window
   system independent toolkit for writing
   OpenGL programs...

with the key phrase being "window system
independent", my thought was there are two
ways to achieve that:

   (1) have absolutely no access to window
       system dependent anything from the
       GLUT level,
or
   (2) have *exactly* the same interface
       across all window systems (such as a
       pointer to a native object).

At any rate, the problem seems to boil down
to making a GLUT window with a non-GLUT
parent window.  Maybe this is not a good
idea, but I guess I'm trying to address
interoperability where GLUT or FreeGLUT
can only *ever* be a top level application
window and extending that to embedding the
window within another application.

--Chris

>
>
> At 01:51 PM 10/24/2009, you wrote:
>
>> I've been looking into the possibility
>> of embedding freeglut opengl windows
>> into other applications or GUI libraries.
>>
>> Typically, one needs a platform specific
>> handle to the window in order to manage
>> handling events and passing events down
>> to the embedded window.
>>
>> Is the a way to request a native window
>> handle from FreeGLUT (e.g. X11 window
>> or a win32 handle)?  I'm not sure on what
>> the specific details would be but I would
>> prefer to avoid breaking the FreeGLUT
>> abstraction layer to solve the problem.
>>
>> For example, I could modify and build my
>> own copy of FreeGLUT with the needed hooks.
>>
>> Cheers,
>> Chris Marshall

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer

Re: platform specific window handle?

by John Tsiombikas-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 24, 2009 at 10:26:56PM -0400, Chris Marshall wrote:

>
> Well, given that FreeGLUT is a GLUT replacement
> and from the GLUT description at
> http://www.opengl.org/resources/libraries/glut/
>
>    GLUT (pronounced like the glut in gluttony)
>    is the OpenGL Utility Toolkit, a window
>    system independent toolkit for writing
>    OpenGL programs...
>
> with the key phrase being "window system
> independent", my thought was there are two
> ways to achieve that:
>
>    (1) have absolutely no access to window
>        system dependent anything from the
>        GLUT level,
> or
>    (2) have *exactly* the same interface
>        across all window systems (such as a
>        pointer to a native object).

Just one pointer to a native object might be sufficient for windows
(HWND), but on other systems you need more data. Under X11 for instance
you need at least the Display pointer along with the Window.

The best way to go if one would want to expose the underlying window
system to the user, I guess would be to return a void* to "something"
that can be a structure containing Display* and Window under X11, and
HWND or possibly also HINSTANCE under windows, etc.

A cleaner interface could be something like:

void glutGetWM(int what, void *buf);

with the first argument being GLUT_DISPLAY, GLUT_WINDOW, GLUT_GLCONTEXT,
etc. Copying the appropriate data in each case to the buffer pointed by
the second argument. Of course on win32 for instance
glutGetWM(GLUT_DISPLAY, ...) would be a no-op, and so on.

--
John Tsiombikas
http://nuclear.sdf-eu.org/

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Freeglut-developer mailing list
Freeglut-developer@...
https://lists.sourceforge.net/lists/listinfo/freeglut-developer