[java] A very general question

Started by
5 comments, last by Antheus 12 years, 6 months ago
So I am fairly familiar with Java at this point, and started to create a title screen for a game. I wanted the title screen to have a "blur in" effect, so I did some internet reading and figured out how to achieve a good blur on an image. However, the calculations required to blur an image are evidently so complex (or just so numerous) that when I try to seamlessly blur the image in (by blurring the image to a lesser and lesser extreme over time), there is tremendous lag. My question is actually not even related specifically to this, but it's a good example of what I want to avoid.

My question is this: I was looking at books on java image processing techniques (I'd ultimately like to make a very flashy 2D game), but will this kind of literature even be relevant to real time image processing? In other words, I don't want to end up with a book that gives me all of these great image processing algorithms that are completely useless in an animated context because of the "costliness" of applying them in rapid succession.

I've also looked at a few introductory books on java game creation, but these are extremely uninspiring as they generally focus on very UN-flashy games. (Not to mention, the image processing techniques that Killer Game Programming In Java discussed didn't even work...I guess it's just too old or something...or there are some unusual complications that are too far over my head at this point.)

I understand that ANY information is better than none at all, but if there's a more direct route to my goal, I'd like to pursue that instead.

As a side note, I'm a computer science major at the sophomore level, and I still feel so helpless to accomplish these kinds of things...grrr, it's frustrating. But, I will be taking computer graphics next semester, so I'm hoping that breaks the seal for me.

One more thing: any book recommendations on java sound processing would be appreciated too. I'd like to be able to do some flashy things with the sound scape as much as I would with the images. Thanks for any feedback.
Advertisement

My question is this: I was looking at books on java image processing techniques (I'd ultimately like to make a very flashy 2D game), but will this kind of literature even be relevant to real time image processing? In other words, I don't want to end up with a book that gives me all of these great image processing algorithms that are completely useless in an animated context because of the "costliness" of applying them in rapid succession.

Algorithms are math, they aren't related to language. So they are universally relevant.

Some of them are indeed expensive, which is why GPUs were invented.

I've also looked at a few introductory books on java game creation, but these are extremely uninspiring as they generally focus on very UN-flashy games. (Not to mention, the image processing techniques that Killer Game Programming In Java discussed didn't even work...I guess it's just too old or something...or there are some unusual complications that are too far over my head at this point.)[/quote]
JDK suffers from many problems for such tasks, the biggest being that both Sun and Oracle never cared about and many years ago effectively abandoned any client-side development. They deprecated Swing and AWT in favor of JavaFX, then a year later abandoned that as well.

While Java2D set direction for hardware accelerate or at least low overhead rendering, it was never developed to a point of being universally available. Between insisting to use unsuitable design and poor driver support, it's just pain. The worst part is that you never know which operation will be emulated on which system. So something that works well on some machines will be unusable on others.

About the only semi-reliable way to get consistent graphic performance is to use OpenGL bindings, which means very low level graphics programming.

Java is now owned by Oracle which has zero interest, market or users in anything even remotely desktop or media oriented, so they lack both, interest and competence to deliver anything in that area.

One more thing: any book recommendations on java sound processing would be appreciated too.[/quote]
Sound processing... is nonexistant in Java. All media frameworks in general were abandoned years ago. It's barely doable, but you'll be on your own.


JVM is flexible and powerful, but since Sun traditionally showed so little support even developers that were interested gave up, meaning there is next to ongoing activity in above. While some continue to use it, the platform itself isn't supportive. So if you have a very good case to use JVM for such tasks (distribution, target audience, market) it can be done. But if just experimenting, expect a lot of wasted effort fighting the platform that could be better spent dealing with actual solutions.

These days, given the direction, C#/.net is where it's at, especially anything media related. And since you're student, you can get entire stack for free for 3 years or so.
Very helpful reply, thanks. I was at first considering OpenGL, but I figured it might be too far above my level at this point in time. However, judging from what you just said, it sounds like my best bet is to just suck it up and start trying to get into it. I'm not extremely familiar with C#, but for some reason, I feel like I should avoid it. I guess it almost seems like a "special interest" language to me, whereas C++ and Java are all over the professional domain. I definitely want to avoid XNA, because, as I understand it, there's quite a bit of overhead, so I wouldn't really be learning the ins and outs of game development if I were to use it. I would just be learning to use someone else's prefabricated tools; and then, when those tools became outdated or irrelevant for whatever reason, I would be outta luck, because I had never done anything from scratch.

Any recommendations on a really good starting book for OpenGL? I looked on Amazon.com for some, but I didn't really find one where the reviews were unanimously positive (not that I expected to). I would prefer a book that sets you up to do some truly exciting things (rather than snake and pong), without assuming its reader is already a technical expert (maybe it's delusional to hope for a book like that though). Oh, and most importantly, a book that is CURRENT. Nothing is more disappointing than to be teased by a great demo program that turns out to be using deprecated code. I've taken all the calculus, as well as linear algebra, so the math shouldn't be an issue. As for C++, I'm learning it right now in my data structures class, so I'm not extremely comfortable with it, but I know the fundamentals.

And thanks again for the informative response.
This book is great for Sound: ISBN: 978-1-59273-005-6

Developing Games in Java.

As said above, opengl is probably better if you want more functionality and speed in the long run.
Thanks for the book recommendation. It seems I ended up eating my words right after I typed them though. I said I wanted to avoid XNA, but in all my frustration, I started playing with it, and it was way too gratifying. It's so easy to make something happen. Probably gonna search the XNA forums to find out what the limitations are...although, kinda seems like there would be almost none, because even if the framework didn't provide you with some functionality you needed, you ARE programming in C#, so I would think you could always add your own lower level functions to the framework as needed. Anyway, thanks for the replies, guys.
I remember JavaFX was just starting to come into play when I moved to C#/.NET, but I don't think Swing is deprecated? That's like Microsoft doing away with WInForms...but I haven't been around the java block in a while, especially since Oracle took over Sun.

Anyways, doing any sort of image filtering (blur) on the CPU with -any- language (managed, native, what have you) is going to be slow. This is where GPU's step in, and especially, shaders where you're able to create a blur filter in a shading language and use render-to-texture functionality to filter your image. So if you're using C++ or Java or C# you have to resign yourself to using D3D/OGL or the many wrappers/frameworks/engines that use them (e.g. XNA is a framework that sits ontop of D3D).

There are some good OGL bindings (LWJGL comes to mind) and java engines (jMonkey, Ardor3D - jMonkey 3 has gone completely shader-based now though) of doing quality, even "flashy" graphics using Java. But of course, learning graphics programming is best when you get your hands dirty and go low level - this doesn't necessarily mean to use OGL with C++, but not to use an engine or framework which hides a lot of complexity (after all, that's their purpose in making things easier for you).

As for XNA, it's a great framework - the content pipeline makes it easy getting setup with assets right off the back and overall its a pretty clean API. You do lose flexibility since the actual graphics API is hidden, since the goals of XNA is to run on multiple devices (PC, Phone, Xbox) so the developers made an effort to create a streamlined API that can cover each device. That's not an easy task and such a generalized causes specifics to be lost. Quite a bit of XNA does map nicely to the graphics API though - mostly D3D10+ style and not D3D9 (especially with XNA 4.0, and the reason for that is pretty clear - although XNA still uses D3D9), but its still going to be more effective learning D3D by using it directly. A good library to do that and still work with C# would be SlimDX (a very good D3D wrapper in my opinion). As with any managed language, there's going to be a slight runtime overhead than writing pure native code, but in my opinion I'm far more productive in C# than C/C++ and its easier to rapidly prototype and make changes. In the end though, you can still make quality games or apps with XNA (or SlimDX) (there's actually quite a few successful XNA games out there), and even in java, so don't feel that if you're not using C++/OGL you can't make something decent, especially as a solo or student programmer. These days, a great deal of making "flashy" graphics solidly rely on your shaders, which are GPU programs, and totally indifferent to if you use C#, Java, or C/C++.

I remember JavaFX was just starting to come into play when I moved to C#/.NET, but I don't think Swing is deprecated?


There was Swing2 project, an attempt to fix the AWT/Swing legacy mess along with some really crucial issues and bugs. Swing2 was cancelled in favor of JavaFX. When asked if fixes will be coming to Swing, the answer was there are no plans and that JavaFX is now the preferred way of developing applications, Swing development was frozen. JavaFX dies. Swing is still frozen.

For all practical purposes, it's deprecated. There is no development track, no fixes, no improvements. So we're looking at 5 years of some crucial usability issues not being even acknowledged.

And with competition from .Net, iOS, Flash, Swing just cannot compete with what is provided out of box and natively by all major platforms. And with Win8 and iOS as full vertical stacks and touch interfaces, it's simply unusable. The word competitive doesn't even come into play. When Metro and WPF are fully DX10 based, Swing struggles with hardware accelerated blits. When shaders and concurrency are almost first-class class citizens in OSes, Swing passes Java-based events through about 20 compatibility layers to software rendering pipeline in a single thread.

It would take a ground-up rewrite and redesign of entire Java-based UIs just to reach parity these days. Unfortunately, while both MS and Apple managed just that, Sun has proven unable to do so and Oracle won't. They were unable and unwilling to make any kind of concession, so if there was a Java card that didn't support some feature, it was not added in favor of compatibility, holding back the entire framework. As history has shown, this is the wrong move. The times have changed enough so that hard cuts are preferred.

That's like Microsoft doing away with WInForms...[/quote]JEE is WinForms. Swing has been something like FoxPro. Some people used it for lack of alternatives in hope of improving.

This topic is closed to new replies.

Advertisement