gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:43:14 27 4
gpt4 key购买 nike

我不知道为什么,但这是我的第二个 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);
}
}

我的另一个 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() {
}
}

问题出在声明导入 gl10 和主要 Activity 中的行,cfg.useGL20 - true;

任何帮助将不胜感激

最佳答案

您可能使用的是最新版本的 Libgdx,例如 1.0.0(请包括以后的版本)。 OpenGL 1.x support was removed from Libgdx 2014 年 3 月 2 日。

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

关于java - 无法解析导入 com.badlogic.gdx.graphics.gl10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23691868/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com