Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 6
  ignore  |  Print  
  why are people trying to use Java2D to make games?  (Read 21303 times)
0 Members and 1 Guest are viewing this topic.
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Posted 2012-12-25 19:24:07 »

Why are so many people here trying to use Java2D to make games? The API is clunky, riddled with gotchas, and generally slow. You can make a nice game with it, but it's harder than it needs to be. I'm not mentioning this to push libgdx, I just think writing games in Java might be taken more ever so slightly more seriously if we do more to discourage using Java2D at all (java4k excluded of course).

Offline Mac70
« Reply #1 - Posted 2012-12-25 19:26:21 »

People are using it because most Java tutorials shows Java2d as example to graphics.

Check out my Devblog! Smiley
Online matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #2 - Posted 2012-12-25 19:29:38 »

I guess it's also not too easy for a newbe to set up jars and natives in their IDE's...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #3 - Posted 2012-12-25 19:36:18 »

I guess it's also not too easy for a newbe to set up jars and natives in their IDE's...

I take it you never tried libGDX?  Cheesy
Offline tyeeeee1
« Reply #4 - Posted 2012-12-25 19:45:15 »

Every single tutorial, excluding the few I've seen on this site, that I've read/looked at/referenced/etc... all showed how to use Java2D to do whatever I was trying to do. All these other things like Stick2D, LWJGL and whatever else there are seem to be a complete pain to use and figure out how to use when you first look at them.
Online matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #5 - Posted 2012-12-25 19:46:24 »

I guess it's also not too easy for a newbe to set up jars and natives in their IDE's...

I take it you never tried libGDX?  Cheesy

I do have ^^

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Mac70
« Reply #6 - Posted 2012-12-25 19:50:02 »

Every single tutorial, excluding the few I've seen on this site, that I've read/looked at/referenced/etc... all showed how to use Java2D to do whatever I was trying to do. All these other things like Stick2D, LWJGL and whatever else there are seem to be a complete pain to use and figure out how to use when you first look at them.

LWJGL is much easier than it seems for programming newbies, but it suffers from a lack of good tutorials.

Check out my Devblog! Smiley
Offline tyeeeee1
« Reply #7 - Posted 2012-12-25 20:02:14 »

Then we need to get some tutorials made for all of these non-Java2D thinggys.
Offline Cero
« Reply #8 - Posted 2012-12-25 20:10:17 »

basic reason is that there is a wealth of information about Java2D, and you end up naturally there, when learning java.
You get told OpenGL is way more complicated and libs like libgdx use OpenGL.
And what is a lib anyway and how do you use it ?

Libgdx has not as much documentation, example, blog entries and stuff as java2D, naturally
and much of libgdx tutorials and examples are actually outdated and do not work anymore - those should really be removed from the web btw.

I think it was davedes who suggested it: Someone should really write some code to make usage for libgdx "easier", to hide things like spritebatches and stuff

Offline Ultroman

JGO Knight


Medals: 24
Projects: 1


Snappin' at snizzes since '83


« Reply #9 - Posted 2012-12-25 20:13:21 »

While I do agree with you, I did learn a lot from using Java2D for my first 2 games. I would not have been able to understand the workings of libgdx, had I not been faced with many of the mathematical challenges, and the use of patterns, while using Java2D.

I don't think it's THAT difficult to work with Java2D, but it does force you to learn every little bit of the process, of getting a small game running even remotely smoothly. Libgdx, while a very helpful framework, does leave you without having to build your own game-structure, and lets you concentrate on the most creative pieces of the process.

I think some of you might've become too adept at game-programming, to see the small challenges newbies can run into. It is very frustrating to debug something, when you don't understand how it works. The kinds of problems you run into, only depends how much you know about programming and/or system-/data-structures.

- Jonas
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline HeroesGraveDev

JGO Kernel


Medals: 239
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #10 - Posted 2012-12-25 20:19:01 »

Every single tutorial, excluding the few I've seen on this site, that I've read/looked at/referenced/etc... all showed how to use Java2D to do whatever I was trying to do. All these other things like Stick2D, LWJGL and whatever else there are seem to be a complete pain to use and figure out how to use when you first look at them.

LWJGL is much easier than it seems for programming newbies, but it suffers from a lack of good tutorials.

And the fact that most of the tutorials requre you to have X library/API
Even if you use immediate mode you get about the same performance as Java2D. (okay, that's a guess, someone could confirm this?)
I'd say that once you know how to use it, it's easier to code than Java2D.
Especially setting up the canvas/display. Display.create() and a few matrix setups vs creating a jframe, a jpanel, a canvas, setting the size, double buffering, adding the components to their parents etc.

Back to the statement on tutorials all being for APIs, I am against this kind of thing. If someone wants help with one aspect of LWJGL, don't link them to an API/library with tons of other irrelevant stuff, give them source code specifically for the problem (if you have it) and tell them to go nuts. Most non-n00bs don't want to have to download a whole library just to solve one simple problem. They want to learn how something is done so they can develop their skills at programming.
[/rant]

Anyway, Java2D is not all that bad for simple 2d games. It's just when people start asking questions about how to do X with it when most people here use some OpenGL based library that the problem begins.

Offline davedes
« Reply #11 - Posted 2012-12-25 20:41:38 »

IMO most people who are encouraging the use of Java2D for newbies have not had very much experience with alternatives like LibGDX.

LibGDX is easy as pie to setup and includes a huge number of utilities to avoid reinventing the wheel. No need to worry about physics, tiled map loading, texture packing, bitmap font rendering, efficient sprite rendering, game loops, etc. Sound is obviously another huge bonus. A newb shouldn't have to worry about BufferStrategy or how to implement their own game loop -- 99% of them will just copy-paste loops, anyways -- instead, they should be focusing on essential gameplay programming. Once they get more comfortable, they can start learning about graphical programming and optimizations, including shaders, game loops, vertex buffers, and other more advanced concepts.

Even the concepts that you learn in Java2D -- i.e. CPU image processing to tint an image red, or using AlphaComposites to work with transparency -- do not transfer well to the OpenGL pipeline. This is why so many newbies coming from Java2D have issues like "Why is my 9041x52 texture not loading?" or "How can I modify the byte[] array of an OpenGL texture?" Another common mistake is trying to use polygons to make a circle/line, when really a texture region would be much more efficient.

Now that we're in 2012, the only reason to use Java2D is for Java4k.

With that said, the major drawback to LibGDX is that it introduces a few foreign concepts to newbies -- e.g. texture regions, color format, matrices, glBlendFunc, Framebuffer, etc. Slick did a good job at hiding those concepts (although, at the expense of performance/flexibility) which is why it appealed to newbies.


Quote
Back to the statement on tutorials all being for APIs, I am against this kind of thing. If someone wants help with one aspect of LWJGL, don't link them to an API/library with tons of other irrelevant stuff, give them source code specifically for the problem (if you have it) and tell them to go nuts.
This is simply not possible. Imagine the following, which is an extremely common question:

"How do I render a texture to the screen?"

In the programmable pipeline, you need shaders, matrices, VBOs, texture loaders, etc. If they don't understand any of those concepts, dumping thousands of lines of disorganized code is not going to help them. This is why the lwjgl-basics API exists -- because it's really the most minimal way to give a "code paste" to the above answer, using modern GL and OO practices.

Offline HeroesGraveDev

JGO Kernel


Medals: 239
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #12 - Posted 2012-12-25 21:14:05 »

IMO most people who are encouraging the use of Java2D for newbies have not had very much experience with alternatives like LibGDX.

LibGDX is easy as pie to setup and includes a huge number of utilities to avoid reinventing the wheel. No need to worry about physics, tiled map loading, texture packing, bitmap font rendering, efficient sprite rendering, game loops, etc. Sound is obviously another huge bonus. A newb shouldn't have to worry about BufferStrategy or how to implement their own game loop -- 99% of them will just copy-paste loops, anyways -- instead, they should be focusing on essential gameplay programming. Once they get more comfortable, they can start learning about graphical programming and optimizations, including shaders, game loops, vertex buffers, and other more advanced concepts.

Even the concepts that you learn in Java2D -- i.e. CPU image processing to tint an image red, or using AlphaComposites to work with transparency -- do not transfer well to the OpenGL pipeline. This is why so many newbies coming from Java2D have issues like "Why is my 20480x20480 texture not loading?" or "How can I modify the byte[] array of an OpenGL texture?" Or even something like rendering polygons to make a circle/line, when really a texture region would be much more efficient.

Now that we're in 2012, the only reason to use Java2D is for Java4k.

With that said, the major drawback to LibGDX is that it introduces a few foreign concepts to newbies -- e.g. texture regions, color format, matrices, glBlendFunc, Framebuffer, etc. Slick did a good job at hiding those concepts (although, at the expense of performance/flexibility) which is why it appealed to newbies.


Quote
Back to the statement on tutorials all being for APIs, I am against this kind of thing. If someone wants help with one aspect of LWJGL, don't link them to an API/library with tons of other irrelevant stuff, give them source code specifically for the problem (if you have it) and tell them to go nuts.
This is simply not possible. Imagine the following, which is an extremely common question:

"How do I render a texture to the screen?"

In the programmable pipeline, you need shaders, matrices, VBOs, texture loaders, etc. If they don't understand any of those concepts, dumping thousands of lines of disorganized code is not going to help them. This is why the lwjgl-basics API exists -- because it's really the most minimal way to give a "code paste" to the above answer, using modern GL.

Bold #1: Those are a case of not using Google.
Bold #2: Another case of not using Google.

Google is the answer. There is always someone who knows the answer other people don't, you just have to find them.
[hint-for-Riven]There should be a notice that shows before posting in Newbie & Debugging Questions that says "Have you Googled it first?"[/hint-for-Riven]

While your solutions are good for newbies, what about slightly more experienced programmers who want to actually learn how to do things instead of just blindly using other people's code?

Offline Regenuluz
« Reply #13 - Posted 2012-12-25 21:17:49 »

I might be one of the few who prefer this, but I prefer knowing why and how my code works, before moving on. So I enjoyed learning how to make game loops and the like in java2d.

I'm currently trying to learn some opengl with lwjgl, and to be honest, it's *A LOT* easier to start out with java2d. How many lines of code does it take to render a fricking square? 1 line in java2d, and too many in opengl.

And yes, more or less *all* tutorials on opengl out there doesn't work. I've seen more than 1 tutorial that uses indexes less than -1 and greater than 1 for vertex2f and the like, and when I've tried to use those snippets, they don't work, because that'll render it outside of the screen. No explanation of why though.. So, I've figured that 0,0 is the center of the screen(wtf? how does that make sense in a world where the upper left corner is 0,0?) and the indexes is percentages.. so 1 is clinging to the right side of the screen and -1 is the left.. Couldn't find any documentation on it though..

I haven't even gotten to rendering simple sprites to the screen yet, because that requires that I learn shaders and whatnot, just to render a picture...

So yeah, for a newbie, learning opengl right off the bat is the worst kind of idea anyone could get. However, if the amount of tutorials that are up to date, useful and organized grows a couple of thousand times, then *maybe* opengl will be something that's "easy" to learn..

Of course you'll still need to know of matrices etc. but that shouldn't be too big of a problem for anyone aspiring to becoming a programmer. (Seeing how important math is in the field of programming.)

That's just my 2 cents. Smiley
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 748
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #14 - Posted 2012-12-25 21:22:35 »

[hint-for-Riven]There should be a notice that shows before posting in Newbie & Debugging Questions that says "Have you Googled it first?"[/hint-for-Riven]
You like being patronized much?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline davedes
« Reply #15 - Posted 2012-12-25 21:25:09 »

Quote
I might be one of the few who prefer this, but I prefer knowing why and how my code works, before moving on. So I enjoyed learning how to make game loops and the like in java2d.

I'm currently trying to learn some opengl with lwjgl, and to be honest, it's *A LOT* easier to start out with java2d. How many lines of code does it take to render a fricking square? 1 line in java2d, and too many in opengl.
I don't get this "I don't like to use APIs, I want to write everything myself" attitude. Java2D is an API. Do you think Graphics.drawImage is a magical method that exists on all operating systems?

LWJGL is a thin wrapper on OpenGL -- it's not meant to make your life easier when rendering a 2D sprite. That's why LibGDX, Slick, lwjgl-basics, etc. exist.

I dare you to compare a bare-bones Java2D (active rendering) sprite rendering example to a Slick/LibGDX/etc sprite rendering example, and then tell me that the Java2D example is easier for newbies to understand or requires less code. Roll Eyes

Offline Regenuluz
« Reply #16 - Posted 2012-12-25 21:46:53 »

A quick google for "lwjgl sprite rendering" let me to http://www.cokeandcode.com/info/tut2d-4.html and looking at the code under "LWJLGL Sprite" I see an exceptional lot of lines, vs. g.drawImage(sprite, x, y, null);

So yeah.... Smiley
Offline HeroesGraveDev

JGO Kernel


Medals: 239
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #17 - Posted 2012-12-25 22:00:53 »

There is no point arguing this.

People do what they want.  Pointing Best answer so far.

Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #18 - Posted 2012-12-25 22:13:44 »

Why argue about rape, people do what they want.

Why have elections, people do what they want.

Why do we need police, people do what they want.
Offline HeroesGraveDev

JGO Kernel


Medals: 239
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #19 - Posted 2012-12-25 22:16:18 »

Why argue about rape, people do what they want.

Why have elections, people do what they want.

Why do we need police, people do what they want.

The question was WHY people use Java2D, not whether people should use it.

Offline Cero
« Reply #20 - Posted 2012-12-25 22:50:08 »

A quick google for "lwjgl sprite rendering" let me to http://www.cokeandcode.com/info/tut2d-4.html and looking at the code under "LWJLGL Sprite" I see an exceptional lot of lines, vs. g.drawImage(sprite, x, y, null);

So yeah.... Smiley

case and point. that tutorial link makes me sigh big time...

Offline davedes
« Reply #21 - Posted 2012-12-25 22:53:14 »

A quick google for "lwjgl sprite rendering" let me to http://www.cokeandcode.com/info/tut2d-4.html and looking at the code under "LWJLGL Sprite" I see an exceptional lot of lines, vs. g.drawImage(sprite, x, y, null);

So yeah.... Smiley
LWJGL is not an image rendering API, it's a thin OpenGL wrapper.

If you're a newb, going straight to LWJGL is indeed daft. That's why LibGDX, Slick, lwjgl-basics, and others exist -- these APIs, like Java2D, give us a high-level means of drawing sprites.

This comparison has come up before. Java2D vs LibGDX vs Slick.

LibGDX/Slick2D is easier to use, easier to understand, and easier to work with. It also performs better and includes a wealth of other game-related utilities, as I've mentioned before. Why on earth would anybody still choose Java2D?

Offline Regenuluz
« Reply #22 - Posted 2012-12-25 22:59:20 »

And where/what is lwjgl-basics? A google search for "lwjgl-basics" just returns links to a site that shows how to use lwjgl.jar, and not some specific thing that should make my life easier. Smiley
Offline HeroesGraveDev

JGO Kernel


Medals: 239
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #23 - Posted 2012-12-25 23:04:55 »

Why on earth would anybody still choose Java2D?

Because people have a free will.
If they want to use Java2D, they will. You can't change that, and if they don't want to change, there's no point trying to convince them otherwise (haven't seen anyone who actually wants to stick with Java2D yet, but just saying  Wink)

This whole topic is a pointless argument.

Offline davedes
« Reply #24 - Posted 2012-12-25 23:07:55 »

Regenuluz - My own minimal LWJGL-based API and tutorials, focusing on the programmable pipeline (e.g. "modern" GL).

The idea is to replace SlickUtil as the go-to LWJGL utility library.

API:
https://github.com/mattdesl/lwjgl-basics

Tutorials:
https://github.com/mattdesl/lwjgl-basics/wiki

Offline tyeeeee1
« Reply #25 - Posted 2012-12-25 23:54:33 »

From what I've read in this thread all I think that I've learned is that some of these libraries (I think that's what they're called) just shorten the amount of code you need to write something and therefore make it easier and faster to do whatever you're doing. Since I'm still a total noob and haven't even tried using any of the libraries, could someone explain how they're so much better from Java2D?
I'm pretty much going on guesswork here but I'm assuming LWJGL, Stick2D and all of the others were written in Java which would mean that you could most likely do everything that they do with Java2D or something like that?

*This post is based on a lot of guessing.
Offline Mac70
« Reply #26 - Posted 2012-12-25 23:58:27 »

Speed. There is a big difference between Java2d and LWJGL, LWJGL is several times faster than Java2d.

Java2d is using software to do rendering, while LWJGL is using hardware.

Check out my Devblog! Smiley
Online matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #27 - Posted 2012-12-26 00:00:44 »

It's pretty much a fact that Java2D is not anywhere near as fast as libGDX / Slick2D / lwjgl-basics or pure lwjgl with deprecated immediate rendering.

Java2D does not really give you sound... You can't count that, because the API is the biggest crap, from what I've heard.

And finally the ammount of code you need to write to get a window you can draw onto is much bigger than for lwjgl ... (But I would say lwjgl's windowing api is not really good OOP (but you all already know what I say Wink ))

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Online matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #28 - Posted 2012-12-26 00:02:57 »

Java2d is using software to do rendering, while LWJGL is using hardware.

Uh... not really.

Java2D does use software rendering SOMETIMES. Only when it needs to.
When it's on windows it mostly uses DirectX, and on linux and everywhere else it uses OpenGL.

The problem is that Java2D gives you so much possibilities (for example simply modifying a BufferedImage only by changing values in a pixel
int[]
array) that it's not possible to do this with "optimized" OpenGL, or simply has to simulate it in software...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline tyeeeee1
« Reply #29 - Posted 2012-12-26 00:09:05 »

*Still posting based on guessing stuff.

I'm still assuming that LWJGL and the others are coded in Java so; If LWJGL and the others are coded in Java and we're coding programs and that in Java, can't we just (although it's probably a waste of time and totally stupid to do it) do everythign that LWJGL and the others do manually using the default Java libraries and stuff?

Another question I have is, why isn't Java2D being updated to increase speed and that since it's already been done with non-default libraries and stuff?
Pages: [1] 2 3 ... 6
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (15 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!