简体   繁体   English

Windows上我的java(libGDX)应用程序中没有图像的黑屏

[英]Black screen without images in my java (libGDX) application on Windows

I got a java (libGDX) application. 我有一个java(libGDX)应用程序。 My app is loading images (sprites) from an assets folder. 我的应用程序正在从资源文件夹加载图像(精灵)。 When i am launching my app on Linux - everything is working fine, but when i am launching jar on Windows - i see only black screen - without images. 当我在Linux上启动我的应用程序时 - 一切正常,但是当我在Windows上启动jar时 - 我只看到黑屏 - 没有图像。 Could you please help me to solve this problem. 你能帮我解决这个问题吗? I have no ideas what can go wrong, and why this is happening. 我不知道会出现什么问题,以及为什么会这样。 I saw - my assets - are in the jar. 我看到 - 我的资产 - 在罐子里。

  1. Could you provide us with some code examples so we can see what you are doing? 你能给我们提供一些代码示例,以便我们看到你在做什么吗? (eg loading images, files, etc.) (例如加载图像,文件等)

  2. Try executing the jar from the cmd / shell (java -jar ) so you will see if there are any exceptions thrown. 尝试从cmd / shell(java -jar)执行jar,这样你就可以看到是否抛出任何异常。 Most likely there is an exception thrown but you cannot see it because you dont have a console window. 最有可能抛出一个异常,但你看不到它,因为你没有控制台窗口。 If there is an exception thrown, please post the stack trace in your question so we can analize it. 如果抛出异常,请在您的问题中发布堆栈跟踪,以便我们对其进行分析。

  3. How are you building the jar? 你是怎么建造这个罐子的? Make sure you are builing the jar correctly.(gradlew desktop:dist) 确保你正确地建造了罐子。(gradlew desktop:dist)

  4. Are you using any java file input output methods(eg File)? 您使用的是任何java文件输入输出方法(例如File)吗? These wont work correctly with libgdx core module in jar. 这些与jar中的libgdx核心模块无法正常工作。 Libgdx handles the files by its own way, so make sure you are reading / writing to files using libgdx's file handling system( Check it out here ) Libgdx以自己的方式处理文件,因此请确保使用libgdx的文件处理系统读取/写入文件( 在此处查看

  5. What is your graphics card? 你的显卡是什么? Libgdx has a bug where the default shader doesnt work on some AMD cards because some older opengl versions dont seem to be supported for some reason. Libgdx有一个错误,默认着色器在某些AMD卡上不起作用,因为某些旧的opengl版本似乎不支持某些原因。 This bug has not been resolved yet, but the admin has provided us a solution. 此错误尚未解决,但管理员已为我们提供了解决方案。 So if you get a stack trace, when running from command prompt or shell, saying sth like "...error compiling shader ... blah blah blah ... Implicit version 110 not supported by GL3 ..." then Check this thread in libgdx issues page . 因此,如果你得到一个堆栈跟踪,当从命令提示符或shell运行时,说......“错误编译着色器...等等等等...... GL3不支持隐式版本110 ...”然后检查此线程在libgdx问题页面中 The admin xoppa provided a solution which seems to work well for all: admin xoppa提供了一个似乎适合所有人的解决方案:

Could you try to add the following code to your desktop starter. 您可以尝试将以下代码添加到桌面启动器中。

config.useGL30 = true; ShaderProgram.prependVertexCode = "#version 140\\n#define varying out\\n#define attribute in\\n"; ShaderProgram.prependFragmentCode = "#version 140\\n#define varying in\\n#define texture2D texture\\n#define gl_FragColor fragColor\\nout vec4 fragColor;\\n";

This answer can be found in the thread I provided. 这个答案可以在我提供的主题中找到。

I hope I helped and im sorry for bad english and bad code formatting. 我希望我帮助并且对不起英语和错误的代码格式化表示抱歉。

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

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