Skip to main content
gamedev.net
🔒 Locked

[java] JNI and windows

Started by Tree Penguin 6 replies 850+ views
Original Post
Tree Penguin
Tree Penguin
Hi, i am writing an application containing both complicated GUI and complicated OpenGL rendering. When i heard about JNI i decided to do the GUI part in Java and the rendering in C++ (instead of all C++). I have just one problem: how do integrate the rendering window (which is probably a c++ one unless there's a way of using Java Canvas objects in c++ code)? Is there an 'official' way to do this? If not, how can i make sure the rendering window (would be the client area of a window in c++) stays at the right position and doesn't overlap my app's toolboxes and isn't overlapped by my app's mainframe? Is it positioned and or arranged according to the awt component that called for it's creation (guess not but you'll never know)? Thanks for any help!
JDev
JDev
Have you heard of the JOGL project, it's opengl's binding to Java. It may be a little on the slow side for real-time 3D graphical games, but it renders just fine for small stuff. Otherwise, I would suggest moving your gui stuff to QT (never used it personally, but I've heard from people who use it it's awesome and cross-platform).
Tree Penguin
Tree Penguin
Well, it's not only the rendering that i want in c++, also a giant heap of algorithms that are much slower in java and are already done using c++. And besides, c++ is still my best language, i am only interested in Java for it's easy GUI programming and i am really not interested in switching completely to it, i'd rather switch to full c++.
Tree Penguin
Tree Penguin
Thanks! Exactly what i was looking for.
Tree Penguin
Tree Penguin
Do i get this right:

To import a function from a dll you declare the function in the .java source file using the native keyword and you load that dll using the loadLibrary function, jni loads the native library which exports these functions (i guess it looks inside the app's directory first just as native programs) and the imported functions work, or did i miss something?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.