无法正确使用LWJGL,代码给出错误(Can't use LWJGL correctly, code giving errors)

编程入门 行业动态 更新时间:2024-10-20 03:15:30
无法正确使用LWJGL,代码给出错误(Can't use LWJGL correctly, code giving errors)

我正在尝试运行此代码,用于查看是否正确设置了内容:

package simpleslickgame; import java.util.logging.Level; import java.util.logging.Logger; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; public class SimpleSlickGame extends BasicGame { public SimpleSlickGame(String gamename) { super(gamename); } @Override public void init(GameContainer gc) throws SlickException {} @Override public void update(GameContainer gc, int i) throws SlickException {} @Override public void render(GameContainer gc, Graphics g) throws SlickException { g.drawString("Howdy!", 10, 10); } public static void main(String[] args) { try { AppGameContainer appgc; appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game")); appgc.setDisplayMode(640, 480, false); appgc.start(); } catch (SlickException ex) { Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex); } } }

我所做的所有谷歌搜索都让我一遍又一遍地检查本地人,我很确定我做得对。当我去这个项目的构建路径中的库时,JRE系统库和Slick2D都说原生图书馆的位置:... / windows / x64。我只是尝试了... / windows,我尝试过没有原生位置的JRE。我按照两个不同的教程来说明如何做到这一点我尝试运行这个简单的代码时不断出错。有什么帮助吗?

I'm trying to run this code that is used to see if things were setup properly:

package simpleslickgame; import java.util.logging.Level; import java.util.logging.Logger; import org.newdawn.slick.AppGameContainer; import org.newdawn.slick.BasicGame; import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.SlickException; public class SimpleSlickGame extends BasicGame { public SimpleSlickGame(String gamename) { super(gamename); } @Override public void init(GameContainer gc) throws SlickException {} @Override public void update(GameContainer gc, int i) throws SlickException {} @Override public void render(GameContainer gc, Graphics g) throws SlickException { g.drawString("Howdy!", 10, 10); } public static void main(String[] args) { try { AppGameContainer appgc; appgc = new AppGameContainer(new SimpleSlickGame("Simple Slick Game")); appgc.setDisplayMode(640, 480, false); appgc.start(); } catch (SlickException ex) { Logger.getLogger(SimpleSlickGame.class.getName()).log(Level.SEVERE, null, ex); } } }

All of the Googling I've done has led me to checking the natives over and over and I"m pretty sure I've done it right. When I go to the libraries in this project's build path, JRE System library and Slick2D both say Native library location: .../windows/x64. I've tried just .../windows, and I've tried it with the JRE not having a native location. I followed two different tutorials on how to do this and I keep getting errors trying to run this simple code. Any help?

最满意答案

基本上你需要的是将slick.jar和lwjgl.jar添加到你的构建路径,然后右键单击你的项目>>打开属性>>点击Java Build Path >>打开Libraries选项卡>>展开JRE系统库>>点击Native库位置>>编辑>>外部文件夹>>在硬盘上找到.. \ lwjgl-2.9.0 \ native \ windows文件夹>>选择它>>你就完成了

g.drawString("Howdy!", 10, 10);

我只是将这个字符串移动到其他位置,因为它显示在FPS计数器上:)

编辑:

你可以使用.. \ slick \ lib \ natives-windows.jar中的原生代码。

用WinRAR或其他东西打开它并解压缩到一个文件夹,然后将该文件夹设置为您的本机库位置

basically what you need is to add slick.jar and lwjgl.jar to your build path and then right click your project >> open properties >> click on Java Build Path >> open Libraries tab >> expand JRE System Library >> click Native library location >> edit >> External Folder >> find ..\lwjgl-2.9.0\native\windows folder on your hard drive >> select it >> and you're done

g.drawString("Howdy!", 10, 10);

I would just move this string to some other location, cause it's showing over the FPS counter :)

EDIT:

you can use the natives from ..\slick\lib\natives-windows.jar.

open it with WinRAR or something and extract to a folder, then just set that folder to be your Native library location

更多推荐

本文发布于:2023-08-05 21:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1439296.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确   错误   代码   LWJGL   errors

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!