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

the import com.badlogic.gdx.graphics.gl10 cannot be resolved(导入 com.badlogic.gdx.graphics.gl10 无法解析)
本文介绍了导入 com.badlogic.gdx.graphics.gl10 无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我不知道为什么,但这是我的第二个 libgdx 项目,它不起作用,我的 mainactivity 文件如下:

I dont know why but this is my second libgdx project and it does not work, my mainactivity file is as follows:

    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);
    }
}

而我的其他 java 文件看起来像这样

and my other java file looks like this

   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() {
    }
}

问题是当它声明要导入 gl10 和在主要活动中,cfg.useGL20 - true;

The problem is the line when it states to import the gl10 and in the main activity, cfg.useGL20 - true;

任何帮助将不胜感激

推荐答案

您可能正在使用最新版本的 Libgdx,例如 1.0.0(请在将来包含该版本).OpenGL 1.x 支持已于 2014 年 3 月 2 日从 Libgdx 中移除.

You are probably using a recent version of Libgdx, like 1.0.0 (please include the version in future). OpenGL 1.x support was removed from Libgdx on March 2, 2014.

GL20 替换 GL10 类(大部分相同)并删除 useGL20 配置标志.

Replace the GL10 class with GL20 (most of it is the same) and remove the useGL20 config flag.

这篇关于导入 com.badlogic.gdx.graphics.gl10 无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Show padding zeros using DecimalFormat(使用 DecimalFormat 显示填充零)
Java decimal formatting using String.format?(使用 String.format 的 Java 十进制格式?)
Sprintf equivalent in Java(Java 中的 Sprintf 等价物)
StAX XML formatting in Java(Java 中的 StAX XML 格式)
Java - format double value as dollar amount(Java - 将双值格式化为美元金额)
Java printf using variable field size?(Java printf使用可变字段大小?)