gpt4 book ai didi

Raspberry Pi 上使用 JOGL 的 LibGDX - 运行时出错

转载 作者:行者123 更新时间:2023-12-02 07:04:14 25 4
gpt4 key购买 nike

我正在尝试使用 JOGL 后端 ( https://github.com/gouessej/libgdx/ ) 在 Raspberry Pi 2 上运行 LibGDX 桌面应用程序(一个仅显示图像的简单应用程序)。

在当前的libgdx版本中,JoglApplicationConfiguration是抽象的,有2个子类:JoglAwtApplicationConfiguration和JoglNewtApplicationConfiguration。

当我尝试使用 JoglAwtApplicationConfiguration 运行它时,出现错误:

 [java] glGetError 0x500
[java] glGetError 0x500
[java] JoglApplication: Couldn't initialize audio, disabling audio
[java] java.lang.ExceptionInInitializerError
[java] at com.badlogic.gdx.backends.jogamp.JoglApplicationBase.<init>(JoglApplicationBase.java:54)
[java] at com.badlogic.gdx.backends.jogamp.JoglNewtApplication.<init>(JoglNewtApplication.java:49)
[java] at com.mygdx.game.desktop.DesktopLauncher.main(DesktopLauncher.java:14)
[java] Caused by: com.jogamp.openal.ALException: Error opening default OpenAL device
[java] at com.jogamp.openal.util.ALut.alutInit(ALut.java:69)
[java] at com.badlogic.gdx.backends.jogamp.audio.OpenALAudio.<clinit>(OpenALAudio.java:41)
[java] ... 3 more
[java] AL lib: (EE) ALCplaybackOSS_open: Could not open /dev/dsp: Nie ma takiego pliku ani katalogu
[java] glGetError 0x500
[java] Exception in thread "main-Animator#00" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: com.jogamp.opengl.GLException: Caught NoSuchFieldError: gl on thread main-Animator#00
[java] at com.jogamp.opengl.util.DefaultAnimatorImpl.display(DefaultAnimatorImpl.java:61)
[java] at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:451)
[java] at com.jogamp.opengl.util.Animator$MainLoop.run(Animator.java:198)
[java] at java.lang.Thread.run(Thread.java:724)
[java] Caused by: com.jogamp.opengl.GLException: Caught NoSuchFieldError: gl on thread main-Animator#00
[java] at com.jogamp.opengl.GLException.newGLException(GLException.java:76)
[java] at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1311)
[java] at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1131)
[java] at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:680)
[java] at com.jogamp.opengl.util.DefaultAnimatorImpl.display(DefaultAnimatorImpl.java:54)
[java] ... 3 more
[java] Caused by: java.lang.NoSuchFieldError: gl
[java] at com.mygdx.game.MyGdxGame.render(MyGdxGame.java:21)
[java] at com.badlogic.gdx.backends.jogamp.JoglGraphicsBase.display(JoglGraphicsBase.java:164)
[java] at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:691)
[java] at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:673)
[java] at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:442)
[java] at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1277)
[java] ... 6 more
[java] EGLDisplayUtil.EGLDisplays: Shutdown (open: 1)
[java] EGLDisplayUtil: Open EGL Display Connections: 1
[java] EGLDisplayUtil: Open[0]: 0x1: EGLDisplayRef[0x1: refCnt 2]

使用 JoglNewtApplicationConfiguration 时出现其他错误:

 [java] glGetError 0x500
[java] glGetError 0x500
[java] JoglApplication: Couldn't initialize audio, disabling audio
[java] java.lang.ExceptionInInitializerError
[java] at com.badlogic.gdx.backends.jogamp.JoglApplicationBase.<init>(JoglApplicationBase.java:54)
[java] at com.badlogic.gdx.backends.jogamp.JoglAwtApplication.<init>(JoglAwtApplication.java:49)
[java] at com.mygdx.game.desktop.DesktopLauncher.main(DesktopLauncher.java:16)
[java] Caused by: com.jogamp.openal.ALException: Error opening default OpenAL device
[java] at com.jogamp.openal.util.ALut.alutInit(ALut.java:69)
[java] at com.badlogic.gdx.bacAL lib: (EE) ALCplaybackOSS_open: Could not open /dev/dsp: Nie ma takiego pliku ani katalogu
[java] kends.jogamp.audio.OpenALAudio.<clinit>(OpenALAudio.java:41)
[java] ... 3 more
[java] Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Creating window failed
[java] at com.badlogic.gdx.backends.jogamp.JoglAwtApplication.<init>(JoglAwtApplication.java:103)
[java] at com.mygdx.game.desktop.DesktopLauncher.main(DesktopLauncher.java:16)
[java] Caused by: java.lang.reflect.InvocationTargetException
[java] at java.awt.EventQueue.invokeAndWait(EventQueue.java:1272)
[java] at java.awt.EventQueue.invokeAndWait(EventQueue.java:1247)
[java] at com.badlogic.gdx.backends.jogamp.JoglAwtApplication.<init>(JoglAwtApplication.java:101)
[java] ... 1 more
[java] Caused by: java.lang.ClassCastException: com.jogamp.nativewindow.DefaultGraphicsConfiguration cannot be cast to com.jogamp.nativewindow.awt.AWTGraphicsConfiguration
[java] at com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1557)
[java] at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:615)
[java] at java.awt.Container.addNotify(Container.java:2769)
[java] at java.awt.Window.addNotify(Window.java:770)
[java] at java.awt.Frame.addNotify(Frame.java:487)
[java] at java.awt.Window.pack(Window.java:807)
[java] at com.badlogic.gdx.backends.jogamp.JoglAwtApplication$1.run(JoglAwtApplication.java:63)
[java] at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241)
[java] at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
[java] at java.awt.EventQueue.access$200(EventQueue.java:103)
[java] at java.awt.EventQueue$3.run(EventQueue.java:694)
[java] at java.awt.EventQueue$3.run(EventQueue.java:692)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
[java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
[java] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
[java] at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
[java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
[java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

使用两者,应用程序构建良好,但在我尝试运行它时出现错误。有人可以帮助我吗?

我的应用程序代码(使用 libgdx 生成器生成):

package com.mygdx.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;

@Override
public void create () {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}

@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
}

和启动器类:

package com.mygdx.game.desktop;

import com.badlogic.gdx.backends.jogamp.*;
import com.mygdx.game.MyGdxGame;

public class DesktopLauncher {
public static void main (String[] arg) {
JoglNewtApplicationConfiguration config = new JoglNewtApplicationConfiguration();
new JoglNewtApplication(new MyGdxGame(), config);
// OR:
//JoglAwtApplicationConfiguration config = new JoglAwtApplicationConfiguration();
//new JoglAwtApplication(new MyGdxGame(), config);
}
}

最佳答案

如果 OpenAL 初始化失败“AL lib:(EE)ALCplaybackOSS_open:无法打开/dev/dsp:没有这样的文件或目录”这源自 libopenal 声音库,找不到您的树莓派声卡那么你有三个选择:

A) 为 Pi 的声卡加载 OSS Linux 内核驱动

sudo modprobe snd_pcm_oss

B) 禁用 OpenAL soft oss 驱动程序:编辑/etc/openal/alsoft.conf并确保驱动程序列表包含-oss(它会禁用尝试使用不存在的dsp文件的OSS后端)

C) 最好的解决方案是 OpenAL-soft 项目可以检测到 OSS 后端不起作用并使用其 ALSA 后端重试,但是这样的解决方案需要有人协作并修补 OpenAL-soft 上游以使 OpenAl -在 Raspberry Pi 上开箱即用的软件:http://kcat.strangesoft.net/openal.html

关于Raspberry Pi 上使用 JOGL 的 LibGDX - 运行时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32691111/

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