0
\$\begingroup\$

1) When I test my game on desktop it is 100% fine. When I test it on my Nexus 7 physical device, it is the same except the backgrounds have no color. For example my splash screen has a greenish background, On desktop this is visible, on android it's just a white background.

Splash screen:

@Override
public void render(float delta) {
    manager.update(delta);
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    backgroud.begin(ShapeType.FilledRectangle);
    backgroud.setColor(147, 112, 219, .4f);
    backgroud.filledRect(0, 0, Gdx.graphics.getWidth(),
            Gdx.graphics.getHeight());

    backgroud.end();
    batch.begin();

    leftLogo.draw(batch);

    batch.end();

}

2) When running my game on an Android emulator, it just shows up as a blank black screen on so far 5+ different emulators. What does this usually mean? No errors anywhere.

I also have cfg.useGL20=true;

\$\endgroup\$
1
\$\begingroup\$

Have you tried a newer version of LibGDX? Support for GL 1 was removed a while ago so it seems that you're using an old version. It might fix the problem. If that doesn't work, can you show the rest of your code?

Edit: Oh, and maybe change GL10.GL_COLOR_BUFFER_BIT to GL20.GL_COLOR_BUFFER_BIT

Edit2: Okay, I noticed a few other things you can try. First, I think that the buffer bit part has to go before glClearColor(), not after. Second, when setting the color of backgroud you might try it with an alpha value of 1.0 and not 0.4, not sure why you would want to do that since you clear the screen beforehand so it won't be see through anyway.

Edit3: Last thing: you forgot to set the camera of the batch(es) it seems. Create a class variable "private OrthographicCamera camera;" in your class, and in the create function initialize it with "camera = new OrthographicCamera()". Paste this line afterwards: "camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());". What this does is it initializes a camera and sets the bottom left of the screen to (0,0). Now you just have to initialize the batch before calling batch.begin(). Paste this before batch.begin(): "batch.setProjectionMatrix(camera.combined);" Take a look in the docs at the pages about cameras and spritebatches for more information. Also, I think you also have to do this for the backgroud variable, but you can probably figure that out yourself ;-)

\$\endgroup\$
  • \$\begingroup\$ thanks, I switched things up and I am not sure exactly what fixed it but now I am getting color on my android :). At first when I set it to gl20 it didn't change anything but after a few tries it did so I assume it worked \$\endgroup\$ – gallly Apr 20 '14 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.