Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Swing vs Lwjgl  (Read 3735 times)
0 Members and 1 Guest are viewing this topic.
Offline TimeSlip

Junior Newbie





« Posted 2012-10-20 00:00:34 »

Hello,

I'm fairly new to java game development. All the games I've dabbled with so far were in swing. I'm guessing that for a number of reasons, swing isn't a very good environment for proper game development.

I've heard there are problems with rotating images and speed. Also, I suspect that handling resolution will be problematic, as the types of graphics swing can handle don't scale well. (Please correct me if I'm wrong) One thing I do like about swing is the components. Are these problems bypassed/easier to cope with using the lwjgl?

I'd really like to keep working on games in java, as I have an intermediate grasp on the language itself. The game I'm working on will use simple 2D graphics, and basic animation. Animation is causing me the most trouble at present. Does Lwgjl sound like a good library for me to use? I'd like something with good documentation and maybe some examples (which LWJGL seems to have)

Thanks for your help!
Offline sproingie

JGO Kernel


Medals: 202



« Reply #1 - Posted 2012-10-20 00:06:53 »

LWJGL has neither UI components nor animation at all.  It's strictly a java API for OpenGL, OpenAL, OpenCL, plus some input libraries for mouse/keyboard/controllers.  You're going to find it an awfully tedious low-level affair for what you're describing, unless you try something on top of it such as LibGDX (highly recommended around here).
Offline TimeSlip

Junior Newbie





« Reply #2 - Posted 2012-10-20 00:11:37 »

Thanks sproingie. I'll look LibGDX up!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 138
Projects: 4
Exp: 3 years



« Reply #3 - Posted 2012-10-20 02:17:37 »

We need a site bot that instantly replies "LibGDX is the answer" when it finds the words "new", "library", "unsure", "what", etc.
Offline ReBirth
« Reply #4 - Posted 2012-10-20 02:24:34 »

No need that if it's still on JGO, I'll do that.

Offline HeroesGraveDev

JGO Kernel


Medals: 294
Projects: 11
Exp: 3 years


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


« Reply #5 - Posted 2012-10-20 08:06:29 »

I have something against high-level libraries. I only started using LWJGL when I went into 3D development. Of course I then realised how efficient it was and now I can develop just as fast as when I used Java2D.

Even then, I only use a tiny fraction of the classes in the library.

The second library I used was Kryonet, because I can't manage to make a stable network by myself. Grin
Even then I was reluctant, but it turned out that the API features I needed were few and easy to use.

However, I still refuse to use libGDX until I have interest in HTML5 games (which I could make without libGDX) or get an Android phone/tablet.

Why? In the amount of time it could take me to work out how to use something, I could implement it myself without all the other junk.

Libraries are only required for these things:

Input from controls
Output to screen
I/O for other things

Anything else is not worth it.

IMO: only use libraries when
1: You NEED them or
2: They are better where the default java libraries are lacking
3: They have documentation/a wide range of tutorials.

Use LWJGL if possible. Only libGDX/Slick2D if you can't learn quickly enough.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #6 - Posted 2012-10-20 08:19:13 »

Most libraries are by definition better where the default library is lacking, otherwise they wouldn't have much reason to exist.  The dirty little secret is that no one else will ever care about how macho you are for reinventing everything from scratch.
Offline HeroesGraveDev

JGO Kernel


Medals: 294
Projects: 11
Exp: 3 years


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


« Reply #7 - Posted 2012-10-20 08:41:31 »

Collsion detection libraries do what default libraries don't but it's better to make your own physics as it helps you learn. And you don't get a whole load of methods for working out whether a duodecagon collided with a semisphere etc.

Oh, and output to the screen AND speakers is what I should have put (see my previous post)(I couldn't be bothered editing)

Offline 65K
« Reply #8 - Posted 2012-10-20 09:20:29 »

However, I still refuse to use libGDX until I have interest in HTML5 games (which I could make without libGDX) or get an Android phone/tablet.

Why? In the amount of time it could take me to work out how to use something, I could implement it myself without all the other junk.
Highly unlikely, except you need many months to learn libGDX ...
There is a big gap quality wise from hacking something together and having a matured software stack to rely upon.
In the world of professional business software no sane mind would first write a new database, OR mapper and web framework before starting to care about the real customers needs.

Offline HeroesGraveDev

JGO Kernel


Medals: 294
Projects: 11
Exp: 3 years


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


« Reply #9 - Posted 2012-10-20 19:35:24 »

I was only referring to libGDX, not all libraries.

In the case of libGDX, if I need to use something, it is best if I understand how it works to avoid having mysterious glitches that slow my progress. Once I understand how it works, I should be able to implement it myself, whether I need to look up free-to-use code then type out the parts I need, or whether it is just a matter of maths and complicated drawings.

Example: converting an image to a texture. I googled it, read it, understood what it does, implemented it myself and now I am free from bulky libraries AND I know how to convert images to textures (without destroying/'seriously editing' them).

However if I find that using a library is more efficient than reinventing the wheel, I would use the library.

Anyway, who buys a whole car just to get the wheel? (Oh yeah! metaphor)

On topic:

LWJGL: If you understand maths and how to fix errors in the native code
Slick2D: If you want the advantages of LWJGL while still coding like Java2D or if you want to slowly move from Java2D to LWJGL.
LibGDX: If you want to be able to make games for HTML5/Android(/iOS yet?) have lots of time, like reading and asking questions.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StumpyStrust
« Reply #10 - Posted 2012-10-20 20:05:01 »

hmm....I would say that you can do most basic things in java2D and still keep things fast. (don't worry too much about rotation as long as you don't have 2k+ objects rotating.)

LWJGL is not an engine it is JUST bindings to opengl. What you are looking for is what everyone here said, libgdx/slick2D

I am with Heroes a little. I think you should start with trying to write a game engine in LWJGL just so you can begin to understand what higher level engines do under the covers. You do not need to create an other libgdx just get your head around what is going on. After that, libgdx will seem like godsend.

I have never had to fix errors in native code for LWJGL.

You can get going rather quickly with libgdx. Hard part is setting everything up.

PS:
I had looked at how to draw text using opengl, and looked again, and did one of these O.o, then grabbed slick-util and was a happy camper....well for the most part. (do not like have to unbind textures and reset glColor after drawing stuff...think it should be done in the lib but w/e)

Offline TimeSlip

Junior Newbie





« Reply #11 - Posted 2012-10-20 22:51:31 »

Thanks for all the pointers. Had a go with slick 2d today. Spent 90% of the time getting it set up, but made one of the tutorial games in the remaining 10%. Kinda like it.

How would you rate slick vs libgdx?

Offline StumpyStrust
« Reply #12 - Posted 2012-10-20 22:54:03 »

slick is easier but libgdx is much faster 2-3x. libgdx will also let you do android and html5 which is nice.

Offline TimeSlip

Junior Newbie





« Reply #13 - Posted 2012-10-20 23:07:37 »

Thanks. Will get stuck into slick for a few weeks and take it from there!
Offline davedes
« Reply #14 - Posted 2012-10-20 23:11:37 »

Quote
slick is easier but libgdx is much faster 2-3x
This isn't really true. If you use Slick's drawEmbedded or vertex array renderer you'll get comparable speeds with minimal changes to your code. The difference is that the nature of LibGDX's SpriteBatch encourages users to think about batching and OpenGL concepts (like flushing a batch before changing blend function, and the implication that will have if you plan to use many different blend funcs per frame), whereas newbies using Slick may not think about those things since they are hidden and/or abstracted away.

The main things with Slick vs LibGDX:
  • Slick is buggy, and not likely to be fixed anytime soon
  • Slick is no longer maintained
  • Slick's setup requires pulling from git; it's not nearly as easy as LibGDX (especially considering LibGDX's setup tool)
  • Slick is outdated, and uses old school OpenGL techniques
  • Slick's library was not well designed. It has a lot of kludgey code that has developed over the years from various sources who clearly have varying levels of experience with API design.
  • Slick's tools (PackULike, Particle Editor) are buggy and/or limited. LibGDX's tools are much more complete and still growing.
  • LibGDX is much more flexible and allows you to get down to the nitty gritty OpenGL without everything blowing up.
  • LibGDX has a stronger community of professional and semi-professional game developers, whereas 99% of Slick's community is still on chapter 1 of Learning Java.
  • LibGDX's UI is more complete than Slick, and arguably better in some respects than the complexities of TWL
  • LibGDX ports to Android, HTML5, iOS
  • LibGDX supports 3D and its 3D API will only continue to grow in the future
  • LibGDX's API often uses JNI for increased performance, e.g. Pixmap rendering, image decoding, Matrix math, etc.
  • and many countless other benefits of LibGDX....

Here is the real question: Are you too lazy to learn simple concepts like matrices, orthographic projection and what a framebuffer is? Then go with Slick2D. Do you want a stable and solid game development platform with a booming community? Then go with LibGDX.

EDIT:
Quote
do not like have to unbind textures and reset glColor after drawing stuff...think it should be done in the lib but w/e
There is no such thing as "unbinding textures" in OpenGL. Texture unit zero can hold data and be bound just like any other. You shouldn't need to disable texturing, either, unless you plan to render something without textures. Not sure what you're on about, or what you think Slick should do differently...

Offline StumpyStrust
« Reply #15 - Posted 2012-10-21 00:12:23 »

Not unbinding I was wrong. Binding 0 so no texture is used. And I am talking about the slick you can download with LWJGL that gives things like Texture loading and text rendering. I am not disabling texturing.

I know that if you do not bind 0 before rendering, it will use the last bound texture. And if you want transparent text or different colored text that you need to call glColor4f(1,1,1,1) after rendering as it will not reset the color back. I may be using an old version that has this but w/e it works.

Last time I checked matrices, orthographic projection, and what a framebuffer is not simple. Maybe for someone such as yourself who has been programming for years, but for those who have been coding for less than a year or who have yet to embark on the linear mathematics train, it is very very complicated. Sure it is not too horribly hard to learn compared to all the other complex things out there, but it is by no means simple.

Offline HeroesGraveDev

JGO Kernel


Medals: 294
Projects: 11
Exp: 3 years


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


« Reply #16 - Posted 2012-10-21 00:30:24 »

hmm....I would say that you can do most basic things in java2D and still keep things fast. (don't worry too much about rotation as long as you don't have 2k+ objects rotating.)

LWJGL is not an engine it is JUST bindings to opengl. What you are looking for is what everyone here said, libgdx/slick2D

I am with Heroes a little. I think you should start with trying to write a game engine in LWJGL just so you can begin to understand what higher level engines do under the covers. You do not need to create an other libgdx just get your head around what is going on. After that, libgdx will seem like godsend.

I have never had to fix errors in native code for LWJGL.

You can get going rather quickly with libgdx. Hard part is setting everything up.

PS:
I had looked at how to draw text using opengl, and looked again, and did one of these O.o, then grabbed slick-util and was a happy camper....well for the most part. (do not like have to unbind textures and reset glColor after drawing stuff...think it should be done in the lib but w/e)
Not fixing errors in native code, working out what caused them in java and fixing the java code.

It happens when you set up VBOs wrong  Undecided

Offline davedes
« Reply #17 - Posted 2012-10-21 08:22:20 »

Not unbinding I was wrong. Binding 0 so no texture is used. And I am talking about the slick you can download with LWJGL that gives things like Texture loading and text rendering. I am not disabling texturing.

I know that if you do not bind 0 before rendering, it will use the last bound texture. And if you want transparent text or different colored text that you need to call glColor4f(1,1,1,1) after rendering as it will not reset the color back. I may be using an old version that has this but w/e it works.
Why should Slick reset the color for you? GL is a state-based API -- if you set something, expect it to remain that way until you set it again. Having Slick reset colours for every draw call would result in a lot of redundant driver calls.

If you want transparent or coloured text you simply specify a color for the filter parameter to drawString, and the colour will be bound for you. If you don't specify a colour, white will be bound.

Quote
Last time I checked matrices, orthographic projection, and what a framebuffer is not simple. Maybe for someone such as yourself who has been programming for years, but for those who have been coding for less than a year or who have yet to embark on the linear mathematics train, it is very very complicated. Sure it is not too horribly hard to learn compared to all the other complex things out there, but it is by no means simple.
Agreed that somebody very new to Java may have a harder time with LibGDX than Slick. Ideally somebody will write a LibGDX extension that makes it more "Slick-like" (i.e. aimed at beginners in Java and game dev) and abstracts concepts like blend functions and frame buffers.

Offline pitbuller
« Reply #18 - Posted 2012-10-21 14:04:10 »

I was only referring to libGDX, not all libraries.

In the case of libGDX, if I need to use something, it is best if I understand how it works to avoid having mysterious glitches that slow my progress. Once I understand how it works, I should be able to implement it myself, whether I need to look up free-to-use code then type out the parts I need, or whether it is just a matter of maths and complicated drawings.

Example: converting an image to a texture. I googled it, read it, understood what it does, implemented it myself and now I am free from bulky libraries AND I know how to convert images to textures (without destroying/'seriously editing' them).

However if I find that using a library is more efficient than reinventing the wheel, I would use the library.

Anyway, who buys a whole car just to get the wheel? (Oh yeah! metaphor)

On topic:

LWJGL: If you understand maths and how to fix errors in the native code
Slick2D: If you want the advantages of LWJGL while still coding like Java2D or if you want to slowly move from Java2D to LWJGL.
LibGDX: If you want to be able to make games for HTML5/Android(/iOS yet?) have lots of time, like reading and asking questions.

There is nothing that force you to use any libgdx high level functionality. Just code against opengl wrapper and you get multiplatform support for free. Only price that you pay is 1-2MB library that you don't use. This is hardly a problem nowadays. Also tested, robust and efficient utility classes make you much more productive. Just using stuff like textures, mesh, shadersProgram and mathUtils make perfect sense.

Learning curve for libgdx is easier than for lwjgl. not harder for similar usage.
Pages: [1]
  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.

SHC (22 views)
2014-11-25 12:00:59

SHC (20 views)
2014-11-25 11:53:45

Norakomi (18 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (67 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!