EzDevInfo.com

libgdx

Desktop/Android/HTML5/iOS Java game development framework libgdx

Error at building model of new Gradle project for libgdx

I installed Gradle in eclipse and want to import a libgdx Gradle project. But when i click on "Build Model" button, i have an error at about 50% of the loading bar. Here is the problem :

> Plug-in: org.springsource.ide.eclipse.gradle.core Severity : error
> Message : org.eclipse.osgi.internal.framework.EquinoxConfiguration$1
> Exception Stack trace : java.lang.reflect.InvocationTargetException
>   at
> org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:92)
>   at
> org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
> Caused by: org.eclipse.core.runtime.CoreException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1    at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:284)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:633)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:654)
>   at
> org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
>   at
> org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:84)
>   ... 1 more Caused by: org.gradle.tooling.GradleConnectionException:
> Could not fetch model of type 'HierarchicalEclipseProject' using
> Gradle distribution
> 'http://services.gradle.org/distributions/gradle-1.11-all.zip'.   at
> org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
>   at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
>   at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
>   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source)     at
> org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
>   at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:48)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider.buildModel(GradleModelProvider.java:385)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:290)
>   ... 5 more Caused by:
> org.gradle.launcher.daemon.client.DaemonConnectionException: Could not
> dispatch a message to the daemon.     at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:57)
>   at
> org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:168)
>   at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:151)
>   at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
>   at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
>   at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
>   at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
>   at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
>   at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
>   at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:93)
>   at
> org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:133)
>   at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedModelProducer.produceModel(ModelBuilderBackedModelProducer.java:49)
>   at
> org.gradle.tooling.internal.consumer.connection.GradleBuildAdapterProducer.produceModel(GradleBuildAdapterProducer.java:42)
>   at
> org.gradle.tooling.internal.consumer.connection.BuildInvocationsAdapterProducer.produceModel(BuildInvocationsAdapterProducer.java:47)
>   at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection.run(ModelBuilderBackedConsumerConnection.java:55)
>   at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder$1.run(DefaultModelBuilder.java:59)
>   at
> org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
>   at
> org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
>   at
> org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
>   at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
>   at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
>   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source) Caused by:
> org.gradle.messaging.remote.internal.MessageIOException: Could not
> write message Build{id=67f4f73f-8d68-4e23-87c2-648a4fec30c8.1,
> currentDir=C:\applications\Eclipse} to '/127.0.0.1:1598'.     at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)
>   at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:51)
>   ... 23 more Caused by: java.io.NotSerializableException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.writeObject(Unknown Source)    at
> java.util.HashMap.internalWriteEntries(Unknown Source)    at
> java.util.HashMap.writeObject(Unknown Source)     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
> java.lang.reflect.Method.invoke(Unknown Source)   at
> java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)   at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.writeObject(Unknown Source)    at
> org.gradle.messaging.remote.internal.Message.send(Message.java:40)    at
> org.gradle.messaging.remote.internal.DefaultMessageSerializer$MessageWriter.write(DefaultMessageSerializer.java:62)
>   at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:112)
>   ... 24 more Root exception: org.eclipse.core.runtime.CoreException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1    at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:284)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:633)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:654)
>   at
> org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
>   at
> org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:84)
>   at
> org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
> Caused by: org.gradle.tooling.GradleConnectionException: Could not
> fetch model of type 'HierarchicalEclipseProject' using Gradle
> distribution
> 'http://services.gradle.org/distributions/gradle-1.11-all.zip'.   at
> org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
>   at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
>   at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
>   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source)     at
> org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
>   at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder.get(DefaultModelBuilder.java:48)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider.buildModel(GradleModelProvider.java:385)
>   at
> org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.ensureModels(GradleModelProvider.java:290)
>   ... 5 more Caused by:
> org.gradle.launcher.daemon.client.DaemonConnectionException: Could not
> dispatch a message to the daemon.     at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:57)
>   at
> org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:168)
>   at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:151)
>   at
> org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:74)
>   at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:42)
>   at
> org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:29)
>   at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:53)
>   at
> org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:30)
>   at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:106)
>   at
> org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:93)
>   at
> org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:133)
>   at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedModelProducer.produceModel(ModelBuilderBackedModelProducer.java:49)
>   at
> org.gradle.tooling.internal.consumer.connection.GradleBuildAdapterProducer.produceModel(GradleBuildAdapterProducer.java:42)
>   at
> org.gradle.tooling.internal.consumer.connection.BuildInvocationsAdapterProducer.produceModel(BuildInvocationsAdapterProducer.java:47)
>   at
> org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection.run(ModelBuilderBackedConsumerConnection.java:55)
>   at
> org.gradle.tooling.internal.consumer.DefaultModelBuilder$1.run(DefaultModelBuilder.java:59)
>   at
> org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:82)
>   at
> org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
>   at
> org.gradle.tooling.internal.consumer.connection.LoggingInitializerConsumerActionExecutor.run(LoggingInitializerConsumerActionExecutor.java:44)
>   at
> org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
>   at
> org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
>   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source) Caused by:
> org.gradle.messaging.remote.internal.MessageIOException: Could not
> write message Build{id=67f4f73f-8d68-4e23-87c2-648a4fec30c8.1,
> currentDir=C:\applications\Eclipse} to '/127.0.0.1:1598'.     at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:115)
>   at
> org.gradle.launcher.daemon.client.DaemonClientConnection.dispatch(DaemonClientConnection.java:51)
>   ... 23 more Caused by: java.io.NotSerializableException:
> org.eclipse.osgi.internal.framework.EquinoxConfiguration$1    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.writeObject(Unknown Source)    at
> java.util.HashMap.internalWriteEntries(Unknown Source)    at
> java.util.HashMap.writeObject(Unknown Source)     at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
> sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)   at
> java.lang.reflect.Method.invoke(Unknown Source)   at
> java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)   at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)     at
> java.io.ObjectOutputStream.writeSerialData(Unknown Source)    at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)    at
> java.io.ObjectOutputStream.writeObject0(Unknown Source)   at
> java.io.ObjectOutputStream.writeObject(Unknown Source)    at
> org.gradle.messaging.remote.internal.Message.send(Message.java:40)    at
> org.gradle.messaging.remote.internal.DefaultMessageSerializer$MessageWriter.write(DefaultMessageSerializer.java:62)
>   at
> org.gradle.messaging.remote.internal.inet.SocketConnection.dispatch(SocketConnection.java:112)
>   ... 24 more

Session data :

eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_20
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product

Any help will be appreciated


Source: (StackOverflow)

How get a String Width in Libgdx?

I wonder know how to get a Width of my String in pixels values

Thanks.


Source: (StackOverflow)

Advertisements

Actions of Actors in libgdx

I have made my Actor, but I am unclear on how to take advantage of the action and act methods. Outside of the basic Javadoc, I have not found a good tutorials on these methods.

Can anyone provide an example with comments for actions on actors?


Source: (StackOverflow)

In libgdx, how do I get input from the back button?

For my game, I'd like the Android back button to take you to the pause menu, instead of minimizing the game. From what I've googled, I know I need to call

Gdx.input.setCatchBackKey(true);

But how do I actually check for the button press? input.isKeyDown(Keys.BACK) doesn't seem to do anything.


Source: (StackOverflow)

(when adding jar) - Module "android" must not contain source root

I'm trying to add gdx-tools.jar to a libGDX project in IntelliJ. The result:

Module "android" must not contain source root ".../android/src". The root already belongs to module "android".

This is what I've tried:

project structure > libraries > new project library > java > select "gdx-tools.jar" >select module "desktop"

project structure > modules > select "desktop" > new > jars or directories > select "gdx-tools.jar" >

Ideas?


Source: (StackOverflow)

libgdx SpriteBatch render to texture

Is it possible to render to texture using SpriteBatch in libGdx (Java engine for Android/Desktop)? If so, how do it?

Basically I want to render everything to 320 x 240 region of 512 x 256 texture and than scale region to fit screen (in landscape mode). This way I want to eliminate artifacts which happen when I scale alpha blended textures independently. If there is any other way to remove such artifacts, please point them out :)

And is there any online documentation for libGdx?


Source: (StackOverflow)

slider always has default width

[UPDATE] I noticed that an invalidate() would be good but it didnt change something! So i put in the whole optionlayout with the creation of the table and the slider + labels. The backbutton is just a textbutton added to the end of the table. I know its a long code but i seems to be needed.

I created a slider like this as i know that the minwidth of the background is used for the slider width:

public OptionScreen(MainClass game) {
    super(game);
    preference = new PreferencesHelper();
    font = this.getDefaultFont(25);
    this.table = new Table();
    if (Config.DEBUG)
        this.table.debug();

    // add volumenlabel
    LabelStyle style = new LabelStyle(font, Color.WHITE);
    volumenLabel = new Label(Config.VOLUMEN_LABLE, style);
    table.add(volumenLabel).colspan(2);
    table.row();
    // add slider
    Skin skin = new Skin();
    skin.add("sliderbackground",
            this.game.manager.get("data/sliderbackground.png"));
    skin.add("sliderknob", this.game.manager.get("data/sliderknob.png"));

    SliderStyle sliderStyle = new SliderStyle();
    sliderStyle.background = skin.getDrawable("sliderbackground");
    sliderStyle.background.setMinWidth(600f);
    sliderStyle.knob = skin.getDrawable("sliderknob");

    volumenSlider = new Slider(0f, 1f, 0.1f, false, sliderStyle);
    volumenSlider.setValue(preference.getVolumen()); // load current volumen
    volumenSlider.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            volumeValue.setText(String.format("%.01f",
                    volumenSlider.getValue()));
            // sett the preference
            preference.setVolumen(volumenSlider.getValue());
        }
    });
    // add volslider to stage
    table.add(volumenSlider);
    volumenLabel.invalidate();

    // table
    style = new LabelStyle(font, Color.WHITE);
    // set current volumen
    volumeValue = new Label(
            String.format("%.01f", volumenSlider.getValue()), style);
    volumenLabel.setAlignment(2);
    table.add(volumeValue).width(50f);
    table.row();

    initBackButton();

    // init table
    table.setPosition(Config.VIRTUAL_VIEW_WIDTH / 2,
            Config.VIRTUAL_VIEW_HEIGHT / 2 - Config.BLOCK_SIZE * 10);

    // add a nice fadeIn to the whole table :)
    table.setColor(0, 0, 0, 0f);
    table.addAction(Actions.fadeIn(2f)); // alpha fade
    table.addAction(Actions.moveTo(Config.VIRTUAL_VIEW_WIDTH / 2,
            Config.VIRTUAL_VIEW_HEIGHT / 2, 2f)); // move to center of the
                                                    // screen
    // add to stage
    this.stage.addActor(table);
}

It's inside a table with no width or such. I already took a look if the width is sett and if the calculation for the prefWidth of the slider does take my 600.

Math.max(style.knob == null ? 0 : style.knob.getMinWidth(), style.background.getMinWidth())

this is the calculation for the width of the slider inside the Sliderclass. If i calculate that and log it, i get the 600.
Everything seems to me right but the slider is way to small for the 600 i sett.
Background and knobtextures are 24x24.
So i hope you guys can tell me what i am doing wrong. silder


Source: (StackOverflow)

Can't change font color in Libgdx

I'm trying to change the color of the font I use in my application. But whatever I try the font remains black. I made this font using Hiero font tool.

My code is something like this:

    SpriteBatch batch = new SpriteBatch();
    BitmapFont font = new BtimapFont( Gdx.files.internal(MainAssets.pathToAssets + "font/comic.fnt"), Gdx.files.internal(MainAssets.pathToAssets +  "font/comic.png"), false );

In render where I draw the font:

    batch.begin();
    font.setColor(1, 0, 0, 1);
    font.draw(batch, "Hello World!", 0, 0);
    batch.end();

I found a similar issue to mine but there was still no solution.

http://code.google.com/p/libgdx/issues/detail?id=370


Source: (StackOverflow)

Getting a directory file and the ClassLoader for a libGDX Android game

I have a libGDX game project for Android, and I want to execute a Groovy script in it.

To do so, I am examining this example code: https://github.com/melix/grooidshell-example

They managed to execute Groovy embed in Java on Android. Particularly GrooidShell.java (https://github.com/melix/grooidshell-example/blob/master/GroovyDroid/src/main/java/me/champeau/groovydroid/GrooidShell.java)

I have managed to implement most of the code in the Android launcher of the libGDX project. However, I cannot run it because I am missing two arguments:

public GrooidShell(File tmpDir, ClassLoader parent) {

The first one can be any directory. And the second one, I don't even know what is it for.

My question is, what is the ClassLoader and File arguments supposed to be? I need to get them and use them in the AndroidLauncher class of libGDX, which is like this:

public class AndroidLauncher extends AndroidApplication {
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new MyGdxGame(), config);
    }
}

Source: (StackOverflow)

WebGL and Chrome: high resolution makes for bad performance

I have an application created with LibGDX. I can run the application on the desktop and it runs at 90 fps @1080p.

On Firefox it runs at 40-50 fps @1080p (maximized window).

On Chrome it runs at 30 fps @1080p (maximized window).

However on Chrome, if I lower the resolution, the performance doubles (to 60fps). On Firefox this does not happen. What can be the cause of this?

I am using webkitRequestAnimationFrame.

As shown, I know my PC can handle the resolution fine.

Edit

I'm trying to apply the tips below, although they seem aimed at mobile GPUs mostly.

Source: https://wiki.mozilla.org/Platform/GFX/MobileGPUs#Memory_Bandwidth

Always call glClear immediately after glBindFramebuffer

See the Adreno 200 document, section 3.2.1: "it is imperative to (a) use clears when switching Frame Buffer Objects (FBOs) to avoid having the driver tries to save/restore GMEM contents, and (b) always clear the depth-buffer at the start of a frame."

That makes sense, so we should always do it. Concretely, this means that we should do a glClear after every glBindFramebuffer call, ideally right after it, or at least before any draw-call.

Framebuffer bindings are expensive

Changing the framebuffer binding forces immediately resolving the rendering of the current framebuffer. Therefore it is important to sort rendering to minimize framebuffer bindings. The Adreno 200 document, Section 3.2.4, has a useful explanation.

Edit

The above did not make a notable difference.

Edit

I have a feeling this problem arises due to the GLSL compiler. I don't have a lot of knowledge on the subject, but I believe GLSL for OpenGL ES is compiled to regular GLSL, with some browser specific code. It could be that Chrome compiles less than optimal and causes fragment shading to slow the program down at higher resolutions.

If someone has some tips on how to make sure that this compilation is optimalized, I could try that out and see if it fixes the problem.

Edit

The problem doesn't seem prevalent in Chrome on Windows with a Intel HD graphics 4000+ chipset. Chrome version: 40.0.2214.111 m. Low resolution: 45fps~. High resolution: 30 fps steady.

My original test case was with Chrome on Ubuntu with a GTX 650. Chrome version will be added later.

Edit

Version of Chrome which displays this problem: 40.0.2214.111 (64-bit) on Ubuntu on a GTX 650 graphics card.

Edit

On the same PC with GTX 650, under Windows 7, the same application runs at 60fps steady under Chrome. Since under Ubuntu the application compiled to Java runs fine at 90fps, I believe it can't be a Linux driver issue, but rather is an issue with the Linux version of Chrome.

Edit

I've sent a bugreport to Chrome about this.


Source: (StackOverflow)

Libgdx How to get a list of files in a directory?

So I am trying to get a list of files in a directory with a file handle.list() method but it returns an empty list even though there are files in the directory. What seems strange to me is that it does work on the device but it does not work on the desktop. I think I know what the problem is but I dont know how to solve it though. In the method description it says "On the desktop, an FileType.Internal handle to a directory on the classpath will return a zero length array.", but there is no other method than this so what do you guys think I can do?


Source: (StackOverflow)

How to display text with two-color background?

I need to create an app for android, where the 2-color text will be displayed on the 2-color background. See picture on the left. Then, the line should be moved with animation and result image should be like on the picture on the right.

I have the following questions:

  1. Should I use some 2d engine to do this? Or, will it be OK to use standard views? How to do it?
  2. How to draw the text like on the pictures?

pic1 --------- pic2


Source: (StackOverflow)

Drawing transparent ShapeRenderer in libgdx

I have a drawn a filled circle using ShapeRenderer and now I want to draw this circle as a transparent one. I am using the following code to do that: But the circle is not coming as transparent. Also, I checked th libgdx API and from the wiki, it says that, need to Create CameraStrategy. Has somebody faced similar issue ever before? If so, please give me some clues. Thanks in advance.

 Gdx.gl.glEnable(GL10.GL_BLEND);
      Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
      drawFilledCircle();
      Gdx.gl.glDisable(GL10.GL_BLEND);

private void drawFilledCircle(){

   shapeRenderer.setProjectionMatrix(camera.combined);
   shapeRenderer.begin(ShapeType.FilledCircle);
   shapeRenderer.setColor(new Color(0, 1, 0, 1));
   shapeRenderer.filledCircle(470, 45, 10);
   shapeRenderer.end();

}

Source: (StackOverflow)

Could not find class XXX referenced from method XXX.

I'm working on a libGDX project and I have a class called CheerVArachnids that has another inline class which is an event listener. When I run this project on the desktop it works fine. BUT when I run on my Android device, it can't find that inline class and I get the following error:

Could not find class 'com.bbj.cva.CheerVArachnids$PlaceUnitListener', referenced from method com.bbj.cva.CheerVArachnids.<init>

Here are the important parts of my class:

package com.bbj.cva;

public class CheerVArachnids implements ApplicationListener {

    class PlaceUnitListener implements EventSubscriber<PlaceUnitEvent> {

        @Override
        public void onEvent(PlaceUnitEvent event) 
        {   
            //
        }
    }

    public CheerVArachnids() {

        EventBus.subscribe(PlaceUnitEvent.class, new PlaceUnitListener());
        EventBus.subscribe(RemoveScreenObjectEvent.class,
                new RemoveScreenObjectListener());
    }
}

Any ideas why on Android, at runtime it can't find that inline class?


Source: (StackOverflow)

How to draw smooth text in libgdx?

I try to draw simple text in my android game on libgdx, but it's look sharp. How to make text look smooth in different resolutions? My Code:

private BitmapFont font;

font = new BitmapFont();

font.scale((ppuX*0.02f));

font.draw(spb, "Score:", width/2-ppuX*2f, height-0.5f*ppuY);

Source: (StackOverflow)