简体   繁体   English

导入com.badlogic.gdx.graphics.gl10无法解析

[英]the import com.badlogic.gdx.graphics.gl10 cannot be resolved

I dont know why but this is my second libgdx project and it does not work, my mainactivity file is as follows: 我不知道为什么,但这是我的第二个libgdx项目,它不起作用,我的mainactivity文件如下:

    package com.me.rarster;

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;

public class MainActivity extends AndroidApplication {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
        cfg.useGL20 = true;

        initialize(new rarstertech(), cfg);
    }
}

and my other java file looks like this 而我的其他java文件看起来像这样

   package com.me.rarster;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class rarstertech implements ApplicationListener {
    private OrthographicCamera camera;
    private SpriteBatch batch;
    private Texture texture;
    private Sprite sprite;

    @Override
    public void create() {      
        float w = Gdx.graphics.getWidth();
        float h = Gdx.graphics.getHeight();

        camera = new OrthographicCamera(1, h/w);
        batch = new SpriteBatch();

        texture = new Texture(Gdx.files.internal("data/libgdx.png"));
        texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);

        sprite = new Sprite(region);
        sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
        sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
        sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
    }

    @Override
    public void dispose() {
        batch.dispose();
        texture.dispose();
    }

    @Override
    public void render() {      
        Gdx.gl.glClearColor(1, 1, 1, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

        batch.setProjectionMatrix(camera.combined);
        batch.begin();
        sprite.draw(batch);
        batch.end();
    }

    @Override
    public void resize(int width, int height) {
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }
}

The problem is the line when it states to import the gl10 and in the main activity, cfg.useGL20 - true; 问题是当它声明导入gl10时的行,并且在主要活动中,cfg.useGL20 - true;

any help would be appreciated 任何帮助,将不胜感激

You are probably using a recent version of Libgdx, like 1.0.0 (please include the version in future). 您可能正在使用最新版本的Libgdx,例如1.0.0(请在将来包含该版本)。 OpenGL 1.x support was removed from Libgdx on March 2, 2014. OpenGL 1.x支持已于 2014年3月2日从Libgdx中删除

Replace the GL10 class with GL20 (most of it is the same) and remove the useGL20 config flag. GL20替换GL10类(大部分是相同的)并删除useGL20配置标志。

The use of libgdx-0.9.9 made it work for me. 使用libgdx-0.9.9使它对我有用。 You can get it here: http://libgdx.badlogicgames.com/releases/ 你可以在这里得到它: http//libgdx.badlogicgames.com/releases/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM