Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
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  
  Using libgdx for multiple platforms?  (Read 3167 times)
0 Members and 1 Guest are viewing this topic.
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Posted 2012-12-29 20:22:28 »

I have never used this engine or any multiple platform engine, So I am just curious If i wrote a code that changed the game screen when i clicked in a certain area on the game (on computer version) would I have to write something different to get this to work on an android version of the app? I have never used an engine really before so I am not sure about this. And where would a good place to learn libgdx be?

Offline davedes
« Reply #1 - Posted 2012-12-29 20:27:31 »

Things like screen size (small Android devices vs desktop monitors), input (finger touch vs. mouse and keyboard), data storage (class-path on desktop/Android vs not on HTML) and so forth will obviously need to be taken into consideration. With that said, most of your code should be application independent, as long as you are being smart about things.

(For example, instead of using absolute UI positions and sizes which won't work on multiple resolutions, you might use layouts and resizable content.)

But if you are new to programming and gamedev, then I would suggest learning by writing several games for a single platform (e.g. desktop) before you try writing a multi-platform game.

Plenty of resources on LibGDX if you google it:
http://libgdx.badlogicgames.com/documentation.html

Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #2 - Posted 2012-12-29 20:29:14 »

In comparison, I'd say that libgdx is the only possible solution for having 99% of your code being able to be executed on all platforms: PC, Android, iOS (unsure) and html5.

If you do it right, of course.

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 wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #3 - Posted 2012-12-29 20:29:24 »

Thanks for the advice but im not that new to java or gamedev I have made a pc and android game before. And im not sure if your aware but libgdx supports multiple platforms so I wasnt sure if I was the one who had to do this porting or libgdx offered some help

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 132
Projects: 4
Exp: 3 years



« Reply #4 - Posted 2012-12-29 21:49:53 »

I'd say 99% of everyone on this forum is aware of libGDX's abilities.

Overall:

from http://steigert.blogspot.com.au/2012/02/1-libgdx-tutorial-introduction.html
Offline Phibedy

Senior Member


Medals: 8



« Reply #5 - Posted 2012-12-29 23:19:54 »

I started gamedev with java2d, why? All tuts are about java2d. After that I tried myself at jogl, I soon realized that most of the tuts are deprecated, that's why I switched to lwjgl. With some help of the forum I got familiar with it, the community is absolutely noobfriendly  Grin
Now I am using libgdx for android, it's really worth it. If you use libgdx u get access to some really beginnerfriendly functions. The filesystem/rendering is completely platform independent. Furthermore I enjoy box2d, the "physics engine" I wrote by my self wasn't that accurate.
Lastly I don't like the android sdk that much, I prefere libgdx  Smiley
best regards
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #6 - Posted 2012-12-30 00:58:58 »

how did u learn libgdx? i really want to start using it but im not sure how. this wont be my first game, i haev coded my own android game and made a pc game using slick2d and another pc without an engine. so im not too much of a newb lol

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #7 - Posted 2012-12-30 01:01:44 »

I know some of you might say google this, but im curious of what you guys have used to learn using libgdx for android and what has and hasnt been sucessful for you

Offline pitbuller
« Reply #8 - Posted 2012-12-30 02:04:08 »

I know some of you might say google this, but im curious of what you guys have used to learn using libgdx for android and what has and hasnt been sucessful for you

This is quite good http://code.google.com/p/libgdx/wiki/SimpleApp
Other parts of the wiki was also quite helpfull. Google is king after that.
Offline ReBirth
« Reply #9 - Posted 2012-12-30 02:08:11 »

Try and error by myself, and hit google (mostly user wiki) when something wrong.

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

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #10 - Posted 2012-12-30 03:38:00 »

Yes, with libgdx you can port to Windows, Linux, Mac, Android, iOS (yes!) & HTML5.  Grin

Have a look at the demos too. superjumper for example has been ported to all platforms that I listed above:
https://github.com/libgdx/libgdx/tree/master/demos/superjumper

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #11 - Posted 2012-12-30 04:37:13 »

Thanks alot guys I really appreciate this. !

Offline Phibedy

Senior Member


Medals: 8



« Reply #12 - Posted 2012-12-30 11:31:49 »

Most of the time I google my errors, but there are a lot of deprecated, outdated, "you shouldn't programm like that", let them call "tutorials" out there. After I can't find any good solution I post it in the newbie-section -> There's always a good guy/woman(haven't recognised one jet but don't want to discriminate them), who likes to help me  Grin
There's a leack of good up-to-date java tuts.
1. That's my favorite: http://code.google.com/p/libgdx/wiki/SimpleApp
2. Of course the api is quite helpfull: http://libgdx.badlogicgames.com/nightlies/docs/api/
3. That's about box2d: http://www.iforce2d.net/b2dtut/forces (it's in C++ but you will get it)
4. The java-gaming.org community Smiley
best regards
Offline Danny02
« Reply #13 - Posted 2012-12-30 12:41:35 »

quick question about libgdx cross-compilation, is there are blog post or wiki page which lists all the things one must think of when cross-compiling to another platform.

Like what classes are forbidden to use and how to use libraries and so on.
Offline Cero
« Reply #14 - Posted 2012-12-30 15:45:39 »

quick question about libgdx cross-compilation, is there are blog post or wiki page which lists all the things one must think of when cross-compiling to another platform.

Like what classes are forbidden to use and how to use libraries and so on.

not that I know of, generally you really have only a few things to think about.
IF you want to do direct opengl calls, I think it is best to use "Gdx.graphics.getGLCommon()" instead of "Gdx.graphics.getGL10()" for example - I THINK.

ehm... in applet you cannot use FileHandle.list() - for obvious reasons. However I made this mistake a couple of times, since I would have a folder and load everything in it...

I cant really think of anything else... the HTML 5 port has some more stuff you cannot use, like System.nanoTime(), but upon convert/compiling it will tell you when a line cannot be used.

Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #15 - Posted 2012-12-30 16:35:23 »

since I have not learned opengl yet would it be beneficial to me to do so before using libgdx?

Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 132
Projects: 4
Exp: 3 years



« Reply #16 - Posted 2012-12-30 16:37:48 »

Not necessarily, you can always call opengl commands through libGDX anyways, and the learning curve of opengl might be too steep.
Offline davedes
« Reply #17 - Posted 2012-12-30 16:50:35 »

Quote from: Cero link=topic=28274.msg256619#msg256619
IF you want to do direct opengl calls, I think it is best to use "Gdx.graphics.getGLCommon()" instead of "Gdx.graphics.getGL10()" for example - I THINK.
It works like tihs:

If your app uses GL20 (e.g. it was specified in application config or is required by the platform you're distributing to) then Gdx.gl20 will be non-null, and Gdx.gl10 will be null.

For apps that don't have "useGL20=true", then Gdx.gl20 will be null, and Gdx.gl10 will be non-null.

Gdx.gl (or Gdx.graphics.getGLCommon) should never return null.

For example, the following is standard practice:
1  
2  
3  
4  
5  
if (Gdx.graphics.isGL20Available()) {
    Gdx.gl20.glXXX
} else {
    Gdx.gl10.glXXX
}

Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #18 - Posted 2012-12-30 17:27:58 »

Side-question @davedes:
What if I have a
OrthographicCamera
set up, and I want to use
camera.apply(Gdx.gl10);
?
It wants to have a GL10, but I can't feed him one, if I only have a gl20 available...

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline davedes
« Reply #19 - Posted 2012-12-30 19:55:16 »

"Apply" sets up fixed-function matrices to the specified camera's projection and view matrix:
1  
2  
3  
4  
5  
6  
   public void apply (GL10 gl) {
      gl.glMatrixMode(GL10.GL_PROJECTION);
      gl.glLoadMatrixf(projection.val, 0);
      gl.glMatrixMode(GL10.GL_MODELVIEW);
      gl.glLoadMatrixf(view.val, 0);
   }


So the equivalent in GL20 would be to send a projection and/or modelview matrix to your shader. Typically it might look like:
1  
2  
3  
shader.begin();
shader.setUniformMatrix("u_projView", camera.combined); //combined matrix
shader.end();


If you use SpriteBatch and Stage for 2D rendering, you shouldn't need to call apply() or setUniformMatrix(). Smiley

Offline badlogicgames
« Reply #20 - Posted 2012-12-30 19:56:19 »

As per the Javadocs, that method of OrthographicCamera is only applicable in a GLES 1.x environment. With GLES 2.0 you'd submit the camera matrices to your shader.

To ensure your app works across all platforms, try to stick to what libgdx provides. This includes things like file i/o (use Gdx.app.files), networking (Gdx.app.net) and so on. The reason is that Android, HTML5 and iOS do not support all classes in the JRE. That's why we provide replacements which are sometimes even a bit better than their JRE equivalents in terms of say memory consumption and GC friendliness.

In terms of OpenGL ES, you can chose between 1.x (fixed function) or 2.0 (shaders). The higher level classes like SpriteBatch, BitmapFont and so on are all agnostic about which version you use. If you only issue OpenGL ES commands via the GLCommon interface (Gdx.gl) and leave the rest to the higher level classes, you will not run into any issues. If you want more control, you'll have to special case your rendering depending on what's available on the system. The gdx-invaders example in the repo demonstrates this. It has one renderer for OpenGL ES 1.x and another one for 2.0. Again, this is only necessary if you want to get your hands dirty with low-level OpenGL ES yourself.

TL;DR: use what libgdx provides, stay away from JRE classes if you target HTML5.

http://www.badlogicgames.com - musings on Android and Java game development
Offline ReBirth
« Reply #21 - Posted 2012-12-31 03:30:22 »

The only JRE class that I use is only Math, just to abs and round >.>

Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #22 - Posted 2012-12-31 06:17:15 »

Also if you go with Libgdx and want to convert to html5, there are certain things you can't do in html5
This is as of no fault of libgdx, but of the google GWT, you can't use certain things for GWT. The most specific example is Reflection. Although its usually half decent to rewrite code to not use it.

"Experience is what you get when you did not get what you wanted"
Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #23 - Posted 2012-12-31 15:57:19 »

"Apply" sets up fixed-function matrices to the specified camera's projection and view matrix:
1  
2  
3  
4  
5  
6  
   public void apply (GL10 gl) {
      gl.glMatrixMode(GL10.GL_PROJECTION);
      gl.glLoadMatrixf(projection.val, 0);
      gl.glMatrixMode(GL10.GL_MODELVIEW);
      gl.glLoadMatrixf(view.val, 0);
   }


So the equivalent in GL20 would be to send a projection and/or modelview matrix to your shader. Typically it might look like:
1  
2  
3  
shader.begin();
shader.setUniformMatrix("u_projView", camera.combined); //combined matrix
shader.end();


If you use SpriteBatch and Stage for 2D rendering, you shouldn't need to call apply() or setUniformMatrix(). Smiley

Uh oh... okey... I was using
Box2DDebugRenderer
, so giving
cam.combined
to
renderer.render(world, cam.combined);
was enough.

Thanks Smiley

more off-topic stuff: Having guys hanging out at #libgdx irc would be pretty cool, since I often have quick questions, but can't get an answer anywhere... And using a forum topic is sometimes too much. (And sometimes I want a really quick answer, instant message is often pretty good).

Sorry for posting so much off-topic...

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

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #24 - Posted 2012-12-31 17:20:30 »

Try #libgdx on FreeNode. Usually some ~60 people in there.

Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #25 - Posted 2012-12-31 17:24:38 »

Try #libgdx on FreeNode. Usually some ~60 people in there.
Wth... I think I have a serious brain damage Cheesy

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
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.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (103 views)
2014-09-10 06:39:09

Tekkerue (51 views)
2014-09-09 02:24:56
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!