Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Java Swing and native windows  (Read 1240 times)
0 Members and 1 Guest are viewing this topic.
Offline elias

JGO Ninja
***

Posts: 638



« on: 2003-09-10 04:04:28 »

Hi,

I'm posting this here because the Mac OS X proficient dudes most probably sit here anyway....

My problem lies in the creation of an LWJGL native window under Mac OS X. Now, if I just create the window, it appears, but behaves wrongly. That is, it cannot be highlighted or moved, and no application icon or system menu appears for the program.

Now, if I create and dispose a swing window just before creating the LWJGL native window, everything is fine, and a java icon appears along with a default system menu. So, How does java register itself with Mac OS X to be a "GUI" app thereby getting the special treatment I need?

- elias

Offline cfmdobbie

JGO Wizard
****

Posts: 1257


Who, me?


« Reply #1 on: 2003-09-10 06:10:49 »

Don't know anything about it, but until someone comes along with a real answer, this may help out:

http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL/chap4/chapter_4_section_2.html#//apple_ref/doc/uid/TP30000163/CJECBHJE

It looks like a simple open-a-Cocoa-window-and-get-OpenGL-to-draw tutorial.  Even if it's not what you're after it may give you an idea of where to start.

Hellomynameis Charlie Dobbie.
Offline elias

JGO Ninja
***

Posts: 638



« Reply #2 on: 2003-09-10 06:17:33 »

Unfortunately all those programs will behave correctly when placed in a Mac application bundle (as Project Builder will do correctly), but not when the code is brought into a JNI library :/

- elias

Games published by our own members! Go get 'em!
Offline elias

JGO Ninja
***

Posts: 638



« Reply #3 on: 2003-09-10 06:46:09 »

This call before init()ing the LWJGL window is enough:

Toolkit.getDefaultToolkit();

So initializing the toolkit is enough to trigger the "I'm a graphical application" voodoo.

Anybody knows if the java for mac source is available? :-D

- elias

Offline cfmdobbie

JGO Wizard
****

Posts: 1257


Who, me?


« Reply #4 on: 2003-09-10 08:12:13 »

Well, here's what SWT does on MacOSX-Carbon:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_CreateNewWindow
      (JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jintArray arg3)
{
      Rect _arg2, *lparg2=NULL;
      jint *lparg3=NULL;
      jint rc;

      DEBUG_CALL("CreateNewWindow\n")

      if (arg2) lparg2 = getRectFields(env, arg2, &_arg2);
      if (arg3) lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL);
      rc = (jint)CreateNewWindow((WindowClass)arg0, (WindowAttributes)arg1, (const Rect *)lparg2, (WindowRef *)lparg3);
      if (arg2) setRectFields(env, arg2, lparg2);
      if (arg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
      return rc;
}


CreateNewWindow appears to be documented here:

http://developer.apple.com/documentation/Carbon/Reference/Window_Manager/wind_mgr_ref/function_group_6.html#//apple_ref/c/func/CreateNewWindow

And useful links from there (sorry for the long links) are "Window Attribute Constants":

http://developer.apple.com/documentation/Carbon/Reference/Window_Manager/wind_mgr_ref/constant_1.html#//apple_ref/doc/uid/TP30000176/C006478

and "Window Attributes":

http://developer.apple.com/documentation/Carbon/Reference/Window_Manager/wind_mgr_ref/constant_2.html#//apple_ref/doc/uid/TP30000176/C015461

Are you passing the right flags to the CreateNewWindow function?


If you get no joy from any of that, you might want to look at how wxWindows does it:

http://www.wxwindows.org/

Hellomynameis Charlie Dobbie.
Offline elias

JGO Ninja
***

Posts: 638



« Reply #5 on: 2003-09-10 08:21:32 »

I've got a rather good understanding of the Mac API from surfing the developer connection for hours trying to locate the problem. So the window creation code is ok I guess. Also, the problem is that the window alters it's behaviour depending on the launch conditions.

But diggin' in SWT is a good one. Hope I'll find the right stuff in there.

- elias

Offline elias

JGO Ninja
***

Posts: 638



« Reply #6 on: 2003-09-10 10:18:27 »

SWT apps apparantly have the same problem(!). Except Eclipse because it's packaged in a special way. I merely want to emulate the capability of the vm to enable GUI mode on demand (you can't demand that LWJGL apps be packaged in a native Mac bundle).

- elias

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.401 seconds with 21 queries.