|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: GP: Java, DirectX, and hwnd's
The newest versions of Java with just in time compilers and even the new "Hot Spot" technology are not that slow. And, in the kind of set up you are talking about the graphics and other time critical parts of the game would all take place in native machine code so that would be just as fast as if you called them from C++ or asm. In other words, the speed of Java is not an serious issue. I've done quite a bit of work with JNI and after a little confusion it isn't hard to use. What you need to do is define an API that creates a full screen window, something like Game.CreateWindow(); The version of this that you write for Windows would call the Win32 APIs that create a full screen window. Also, the initializer method for Game would call a native initialization routine that does all the set up. And so on. Sounds like a very good project. I would love to see a cross platform game API for Java. Before you start it though take a look at the Java2D, Java3D, and JavaSound APIs. These are all well suited to doing games. Java3D is designed with games in mind and includes 3D sound rendering. The only thing that seems to be missing a good interface to Joysticks and other controllers. The hooks are there, but there's nothing on 'em. Bob P. Atool Varma wrote: > > Hello, > > I'm attempting to write a simple 2D graphics library to be used > for gaming purposes. I dislike how disorganized and unmanageable C/C++ > code can be, but at the same time, it's the only high-level language that > is fairly portable and can give me direct access to hardware resources. > On the other hand, Java's a language that's much more organized and easy > to code in, but it's pretty slow and you can't access hardware directly. > So I thought about the possibility of using the Java Native Interface with > platform-specific C code to create this gaming library--the C code can be > used for hardware access (routing abstract function calls to DirectX, > Xlib, Allegro, etc) as well as any speed-critical code, and the Java can > be used to code the game logic, as a sort of scripting engine. > > I found an article on Gamasutra that talks about the issues > involved in doing something like this... There seem to be two routes to > take with this idea: making a Java application that interfaces with a > shared library (a DLL, in the case of Windows) for native code, or making > a C/C++ application that launches a Java Virtual Machine as an embedded > system. From a conceptual standpoint, the Java app would seem to be the > most flexible way to go, for a number of reasons that I won't explain > right now, but my main problem with this on the Windows platform is the > issue of window handles (HWND's). In a native win32 app, the WinMain() > function is always passed a window handle by the operating system. For > DirectX to operate in full-screen mode, it needs to call a function > that sets the cooperative level (SetCooperativeLevel()); that function > requires a non-null window handle as a parameter. Because JNI is > completely platform-independent, there's no way for me to get any kind of > window handle here (e.g., I can't use the AWT or Swing to get one). > > Is there any Windows API call that can give me such a window > handle, or can it only be given to a native win32 app? If not, I guess > I'll have to make a win32 app that launches an embedded JVM. If I > end up making it a Java application, I hope I don't run into this > kind of problem on another platform. Thanks for your input, and if > you've ever done any work with JNI and would like to give me any tips, it > would be very helpful too. > > Atul > > P.S. -- No, I'm not using MS J++'s interface to COM to access DirectX... > For one thing, I don't have J++, and I'd also like to make this as > cross-platform as possible, which MS is not well-known for. > > ================================================================= > To SUBSCRIBE or UNSUBSCRIBE please visit > http://gameprogrammer.com/mailinglist.html ================================================================= To SUBSCRIBE or UNSUBSCRIBE please visit http://gameprogrammer.com/mailinglist.html
|
|