Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (122)
games submitted by our members
Games in WIP (577)
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  
  lwjgl and 2D?  (Read 2440 times)
0 Members and 1 Guest are viewing this topic.
Offline Remeer

Junior Newbie





« Posted 2013-01-16 21:14:34 »

I'm making a minecraftlike 2D game that uses tiles, world generation, alot of other fun stuff.
Got a 'demo' of my game to work. Generates a png using Perlin Noise and it reads off the pixels for the basic map(I will need to change that later as a simple png won't be able to hold the whole map I need later). Also uses basic entities and player functions such as a inventory and world interaction.


Anyway, I am having some serious performance problems pop up. Now, I've been ALL of my 2D processing/drawing by using what Java already has. No extra libraries at all.
I have roughly 10 layers of image processing my game has to go though. Particles, entities, player, world, second world layer, UI, UI second layer. You get the idea.
Someone told me that I should use lwjgl or something simular, because the way I have coded it makes it so the CPU does pretty much all of the work drawing everything, which is harsh. And lwjgl or something that uses OpenGL uses the video card to do that processing and would run faster.

So, mind you, I am ALL self-taught. So, sorry for the stupid question, or if I even got the details wrong but;
Is this true? If so, where can I look into how to use lwjgl or something simular in a 2D game?
Everything I find comes up with 3D, either my google-fu needs some work, or lwjgl is strictly for 3D.
I'm not exactly sure where to look because I have no experience using libraries.


Thanks for your time!
Offline princec

JGO Kernel


Medals: 409
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #1 - Posted 2013-01-16 21:18:16 »

LWJGL is OpenGL; OpenGL is general purpose computer graphics. It does 3D obviously, but 2D is just a special case of 3D.

Cas Smiley

Offline Sparky83
« Reply #2 - Posted 2013-01-16 21:36:28 »

For a start, this is a nice tutorial: http://www.youtube.com/playlist?list=PL19F2453814E0E315

Especially there is a tutorial called "Minecraft 2D". *g*

If you understood german I would have another tutorial for you.
http://wiki.delphigl.com/index.php/Tutorial_2D
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #3 - Posted 2013-01-16 22:05:09 »

LWJGL is just a thin wrapper around OpenGL. This means you can achieve some great performance, but you will need to write a lot of "boilerplate" to get things going. This is simply because OpenGL is rather "low level" and verbose to set up, and doesn't include convenient utilities for 2D games.

This is why it's generally recommended to use a higher level library like LibGDX. It includes a game loop, sprite, font and GUI rendering, Box2D integration, etc.

If you're keen to "reinvent the wheel" using just LWJGL, see here:
https://github.com/mattdesl/lwjgl-basics/wiki

Offline Remeer

Junior Newbie





« Reply #4 - Posted 2013-01-16 22:22:58 »

For a start, this is a nice tutorial: http://www.youtube.com/playlist?list=PL19F2453814E0E315

Especially there is a tutorial called "Minecraft 2D". *g*

If you understood german I would have another tutorial for you.
The youtube tutorials seem like they should help quite a bit. Thanks a ton!
And nah, sorry, English only. I know, I'm lame. :C

LWJGL is just a thin wrapper around OpenGL. This means you can achieve some great performance, but you will need to write a lot of "boilerplate" to get things going. This is simply because OpenGL is rather "low level" and verbose to set up, and doesn't include convenient utilities for 2D games.

This is why it's generally recommended to use a higher level library like LibGDX. It includes a game loop, sprite, font and GUI rendering, Box2D integration, etc.

If you're keen to "reinvent the wheel" using just LWJGL, see here:
https://github.com/mattdesl/lwjgl-basics/wiki
I'll probably just learn how Lwjgl works and 'reinvent the wheel'. I like having complete control over my Engine. Which is why I made the game as far as I did without using any libraries or tools.
I will however keep LibGDX in mind, in case I can't quite get the ball rolling on my own.

Thanks so much for the help so far. With the YT tutorials I should be able to learn quite a bit.
Offline Sparky83
« Reply #5 - Posted 2013-01-16 22:32:47 »

And nah, sorry, English only. I know, I'm lame. :C
Not at all, maybe I am. *g* No, I just know this good tutorial and wanted to ask, you never know.
Offline davedes
« Reply #6 - Posted 2013-01-17 17:22:13 »

IMO if you are going to spend the time to learn "low level OpenGL" you may as well learn modern OpenGL. TheCodingUniverse's tutorials use deprecated techniques (immediate mode), don't explain fundamental concepts (like texture coordinates), and rely on the old/dead SlickUtil library for texture loading.

Offline Sparky83
« Reply #7 - Posted 2013-01-17 19:25:06 »

@davedes: your right to say that, I should have added some more information to my post. This is what I meant with "for a start". Still I think that starting off with CodingUniverse is ok with that in mind. I did it the same way and it was ok for beginning. But of course there might be a better way to do it. Anyway it is a subjective opinion and everyone should decide for themselves.
It also depends on what you already know...

And I think that one should always use several sources at once to get an overview of what ways and techniques exist to achieve certain things with OpenGL. I like your tutorial btw.
Offline pitbuller
« Reply #8 - Posted 2013-01-17 20:13:02 »

LibGdx would suit your purposes extreme well. Efficient 2d sprite batcher build in and lot of target platforms to pick.
Offline greenOwl

Junior Duke


Medals: 1


from Germany


« Reply #9 - Posted 2013-01-17 20:42:54 »

A really detailed and well written modern OpenGL tutorial:
http://www.arcsynthesis.org/gltut/index.html

The client code is written in C but its really easy to port to java because most of the lwjgl methods resemble the calls in the tutorial.
I've learned OpenGL with that tutorial (and the orange book for shaders) and I think learing modern techniques like VertexArrayObjects and indexed VertexBufferObjects is really the only way to do it "properly".


elfeck
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sparky83
« Reply #10 - Posted 2013-01-17 21:42:49 »

I've learned OpenGL with that tutorial (and the orange book for shaders) and I think learing modern techniques like VertexArrayObjects and indexed VertexBufferObjects is really the only way to do it "properly".
I agree, because I did learn VAOs and VBOs too. But I wouldn't say that learning immediate mode first destroys your capabilities to do it the right way after that. And I don't think that it is a waste of time to do so. IMO it is good to start with small steps.
Offline ra4king

JGO Kernel


Medals: 353
Projects: 3
Exp: 5 years


I'm the King!


« Reply #11 - Posted 2013-01-17 22:27:01 »

A really detailed and well written modern OpenGL tutorial:
http://www.arcsynthesis.org/gltut/index.html

The client code is written in C but its really easy to port to java because most of the lwjgl methods resemble the calls in the tutorial.
I've learned OpenGL with that tutorial (and the orange book for shaders) and I think learing modern techniques like VertexArrayObjects and indexed VertexBufferObjects is really the only way to do it "properly".
And here are the LWJGL ports in case you don't want to waste your life understanding terribly coded C++ Tongue

Offline davedes
« Reply #12 - Posted 2013-01-17 23:00:35 »

@davedes: your right to say that, I should have added some more information to my post. This is what I meant with "for a start". Still I think that starting off with CodingUniverse is ok with that in mind. I did it the same way and it was ok for beginning. But of course there might be a better way to do it. Anyway it is a subjective opinion and everyone should decide for themselves.
It also depends on what you already know...

And I think that one should always use several sources at once to get an overview of what ways and techniques exist to achieve certain things with OpenGL. I like your tutorial btw.
Suit yourself. Keep in mind, I was once in the same boat. Starting with immediate mode and SlickUtil mostly led me to learning poor practices, and not fully understanding the GL pipeline.

Offline StumpyStrust
« Reply #13 - Posted 2013-01-18 05:09:45 »

I normally would disagree with davedes because I think if you have a good set of tutorials you can start with immediate mode and then go to modern with a better understanding but most tutorials are trash.

I have yet to do a whole lot of complete 3.0+ stuff because I CAN'T do it on my laptop which technically supports it.  Angry Angry Angry  I also would say that shaders have a huge learning curve in any learning direction so it is better to start early. Due to lack of understanding, I at first thought that they would just *magically* speed things up based on all the crap I read on the web.

Offline theagentd
« Reply #14 - Posted 2013-01-18 07:19:20 »

I normally would disagree with davedes because I think if you have a good set of tutorials you can start with immediate mode and then go to modern with a better understanding but most tutorials are trash.

I have yet to do a whole lot of complete 3.0+ stuff because I CAN'T do it on my laptop which technically supports it.  Angry Angry Angry  I also would say that shaders have a huge learning curve in any learning direction so it is better to start early. Due to lack of understanding, I at first thought that they would just *magically* speed things up based on all the crap I read on the web.
I agree to some extent that immediate mode is better to start with. There's much less that can go wrong, while when using OGL 3+ you can mess up the shaders, the VBOs, the VAOs, the glEnables, etc. It's a lot easier to just get something on the screen with earlier OGL versions, so it's better to start there so you get a grip of how OpenGL works. However, I'd say that you should deyou finitely start using OGL 3 as soon as possible, but I guess that also depends on how interested you actually are in graphics.

Myomyomyo.
Offline davedes
« Reply #15 - Posted 2013-01-18 07:20:14 »

Yeah, it's a shame OpenGL tutorials and documentation are so scattered. Most use old and deprecated techniques, or don't explain essential concepts. And those that use modern GL (like ArcSynthesis or open.gl) won't be compatible with < GL 3.3.

There is so much junk on the web that most GL newbies end up copy-pasting a lot of things they don't need without fully understanding what they are doing (and it tends to bite them in the ass later).

This is why I suggested LibGDX unless you are really keen to "reinvent the wheel," in which case don't expect an easy road ahead. Smiley

Also keep in mind, you can learn OpenGL concepts like shaders, vertex attributes, textures, matrices, etc. when using a high-level library like LibGDX. In fact, it may be easier to learn these concepts with LibGDX than having to deal with all the horrifying LWJGL boilerplate.

Offline Sparky83
« Reply #16 - Posted 2013-01-18 07:21:32 »

Suit yourself. Keep in mind, I was once in the same boat. Starting with immediate mode and SlickUtil mostly led me to learning poor practices, and not fully understanding the GL pipeline.
I didn't want to post again, having said what I think, but I'd like to reply to that. Smiley

Currently I am learning OpenGL with this and that. Especially "Real-Time Rendering" is the one that helps me understand the hardware and how it works. So with that I have no trouble at all. I wouldn't rely on online sources alone anyway. This is what I learned at university. Sure, there are some gems. But mostly it is not half as good as a real book.
I wouldn't say that skipping immediate mode is a bad idea either. So "suit yourself" might just be the best advice. *g*

I might add that I like real books. I mean three dimensional objects, you know. Not eBooks. Many students here don't understand that.
Offline princec

JGO Kernel


Medals: 409
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #17 - Posted 2013-01-18 10:08:01 »

Thing is, learning all the "horrifying" LWJGL boilerplate means you end up with people who understand how things work know how to fix problems instead of going "bwaaaaaa all my sprites are white" or "getting a blank screen" or "how do I do <some crazy effect>" etc.

You can't build cars without knowing how all the parts work and what they are supposed to do. And we are building cars here. Not just sticking body kits on them.

Cas Smiley

Offline Cero
« Reply #18 - Posted 2013-01-18 14:43:46 »

Thing is, learning all the "horrifying" LWJGL boilerplate means you end up with people who understand how things work know how to fix problems instead of going "bwaaaaaa all my sprites are white" or "getting a blank screen" or "how do I do <some crazy effect>" etc.

You can't build cars without knowing how all the parts work and what they are supposed to do. And we are building cars here. Not just sticking body kits on them.

There is of course a limit to that for normal game dev people who arent graphics programmers; I dont solder on my mainboard if its not working, I just replace it - I have basic understanding, but I can't really fix it.

Especially if you are working alone having to program gameplay, sound, graphics, managing inputs, read files, load stuff, make music, make sounds, make graphics, write story, design levels - its a tall order to be expected to learn opengl extensively...

Compartmentalizing is a good thing of course - if you have someone who is skilled at or interested in graphics programming, team up
and get artists while you're at it =D

I kinda recommend what I did, which is, just try to make the game as you imagine.
When you do that, you naturally come to limits and problems which you can only overcome by absorbing the needed knowledge - so you're not just learning opengl, you are learning how to solve your problem in specific and how and why it works.

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.

TehJavaDev (32 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (58 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
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!