Forums > Dev

retrieve window handle from jit.window

August 18, 2007 | 8:40 pm

hello forum.

i am doing some preliminary research for a master’s thesis project.
very briefly, i would like to use a 3d engine dynamic library, inside a jitter-gl external.

from my initial research, i believe i have found the most straight forward way to do this. the rendering engine allows itself to be embedded in an external window, and have that window control it’s opengl context. i have seen examples of code which create sdl windows, wxwidgets windows, and qt windows, and forces the engine to render inside of them.

i am only interested at this stage in os x. example code found on a qt forum shows how to retrieve the window handle through an HIViewRef, which in turn calls HIViewGetWindow(). this gets passed to the rendering engine on initialization, and the engine creates an opengl context which renders to this window.

my question is, can anyone give me any information about how to retrieve a jit.window handle ID? do the jit.windows inherit from HIView or something else? is this kind of thing even possible (two gl render contexts rendering to a jit.window)?

many many thanks for anyone’s thoughts on these matters.
-rob


August 18, 2007 | 8:51 pm

Have a look at jit.gl.context.h. All of the structs and functions for
dealing with contexts are there.

wes

On 8/18/07, Robert Ramirez wrote:
>
> hello forum.
>
> i am doing some preliminary research for a master’s thesis project.
> very briefly, i would like to use a 3d engine dynamic library, inside a jitter-gl external.
>
> from my initial research, i believe i have found the most straight forward way to do this. the rendering engine allows itself to be embedded in an external window, and have that window control it’s opengl context. i have seen examples of code which create sdl windows, wxwidgets windows, and qt windows, and forces the engine to render inside of them.
>
> i am only interested at this stage in os x. example code found on a qt forum shows how to retrieve the window handle through an HIViewRef, which in turn calls HIViewGetWindow(). this gets passed to the rendering engine on initialization, and the engine creates an opengl context which renders to this window.
>
> my question is, can anyone give me any information about how to retrieve a jit.window handle ID? do the jit.windows inherit from HIView or something else? is this kind of thing even possible (two gl render contexts rendering to a jit.window)?
>
> many many thanks for anyone’s thoughts on these matters.
> -rob
>


August 18, 2007 | 8:56 pm

yeah, i was checking that out, but it just now occurred to me that the AGLDrawable might be what i need (was looking for something called window or view or whatever).

this seems to reference something called WindowPtr which lives in Quickdraw.h. methinks this might be what i need …

so, nothing jumps out at you right away that might prevent this from working?

thanks for the quick reply.

-rob


August 18, 2007 | 9:04 pm

I don’t want to say yes or no at this point because I’m sure there’s a
gotcha somewhere. It would definitely work if the engine could be
initialized with an already created context.

wes


August 18, 2007 | 9:32 pm

> It would definitely work if the engine could be initialized with an already created context.

yeah, that’s what i was hoping for, however i’m pretty sure that it wants to create and manage it’s own context.
it might be possible, however, with some modifications to the source code.

for now, i’m going to try and get the two contexts going in the jit.window and see what happens. still trying to find how to get this window handle…


August 19, 2007 | 3:03 am

just an update.

the following code all works and should do the trick for the rendering engine:

t_jit_gl_context jit_ctx = jit_gl_get_context();
if (jit_ctx) {
AGLDrawable myDrawable = (AGLDrawable) jit_ctx->drawable;
OpaqueWindowPtr* myWindow = (OpaqueWindowPtr*)myDrawable;
if(IsValidWindowPtr(myWindow))
{
ControlRef theContentView; // this is what i pass to the engine
if(GetRootControl(myWindow, &theContentView) == errNoRootControl)
post("error: no root control");
WindowClass outClass;
if(GetWindowClass(myWindow, &outClass) == noErr)
{
std::ostringstream strstrm;
UInt32 width((UInt32)outClass);
strstrm < < "window class: " << width;
post((char*)strstrm.str().c_str());
}
}
}


Viewing 6 posts - 1 through 6 (of 6 total)