lwjgl

Determine mouse button release in LWJGL

只谈情不闲聊 提交于 2019-12-11 06:31:41
问题 I have a program in LWJGL where I have a series of buttons. I'm trying to use Mouse.getEventButton() and Mouse.getEventButtonState() in order to figure out when the mouse is released , but neither seem to be working. After adding a few print statements for debugging, it seems that getEventButton() always returns 0 regardless of what the mouse is doing, and getEventButtonState() always returns false. All other mouse methods I've used so far have behaved normally. Any idea what might be going

Error on OpenGL texture delete

删除回忆录丶 提交于 2019-12-11 05:56:17
问题 I'm working on a game and I have run into a problem where my OpenGL code wont delete a texture when I tell it to free every thing on shutdown, here is the exception: Exception in thread "main" java.lang.NullPointerException at org.lwjgl.opengl.GL11.glDeleteTextures(GL11.java:732) at com.magicalrealmsofherith.OpenGL.releaseAll(OpenGL.java:29) at com.magicalrealmsofherith.client.MRoH.stop(MRoH.java:100) at com.magicalrealmsofherith.client.MRoH.run(MRoH.java:60) at java.lang.Thread.run(Unknown

Doing a matrix multiplication in reverse

泪湿孤枕 提交于 2019-12-11 03:53:37
问题 Follow-up for: Calculating world coordinates from camera coordinates I'm multiplying a 2D vector with a transformation matrix (OpenGL's model-view matrix) to get world coordinates from my camera coordinates. I do this calculation like this: private Vector2f toWorldCoordinates(Vector2f position) { glPushMatrix(); glScalef(this.zoom, this.zoom, 1); glTranslatef(this.position.x, this.position.y, 0); glRotatef(ROTATION, 0, 0, 1); ByteBuffer m = ByteBuffer.allocateDirect(64); m.order(ByteOrder

Java LWJGL OpenGL convert 3d point to 2d point

谁说胖子不能爱 提交于 2019-12-11 03:24:24
问题 I'm trying to convert a 3d point in OpenGL to a 2d point on screen to render a healthbar for a little game I'm writing. However, I'm having some trouble retrieving the x coordinate of where to draw the healthbar. Basically, the healthbar must appear to be above a player, but must always have the same width/height relative to the screen. I tweaked a snippet of code I found from the accepted answer at Convert a 3D location to a 2D on-screen point. (XYZ => XY) and I now have this public static

Problems with single-tap and press-and-hold with LWJGL

我与影子孤独终老i 提交于 2019-12-11 02:55:19
问题 I've been researching a way to use LWJGL for my input system. I'm having problems detecting if it is a single-press or a press-and-hold. The event fires twice when I tap, instead of just once. while(Keyboard.next()) { if(Keyboard.getEventKeyState()) { if(Keyboard.isRepeatEvent()) { //Key held. doAction(Keyboard.getEventKey(), true, false); } else { //Key pressed doAction(Keyboard.getEventKey(), false, false); } } else { //Fired when key is released. doAction(Keyboard.getEventKey(), false,

run java from terminal that depend on external libraries

老子叫甜甜 提交于 2019-12-11 02:28:49
问题 I've read around a lot but haven't been able to find a solution yet. I'm using lwjgl , it needs 2 jars and a native library to run: lwjgl.jar , lwjgl_util.jar and the natives library. I've tried this in every way i could think of, anyway, I'm trying with a command like this at the moment: java - Djava.library.path="libs/natives/" -cp libs/jars/lwjgl.jar:libs/jars/lwjgl_util.jar DisplayTest.class but in every way i try, i get: Exception in thread "main" java.lang.NoClassDefFoundError:

Caching in Java Applets

丶灬走出姿态 提交于 2019-12-11 02:26:40
问题 What approaches are available for caching within a Java applet? I gather that the .jar that makes up the applet will be cached by most browsers. Will this be the case for any dependent .jars used by the applet? If the applet loads resources from a remote URL at runtime, is it correct to assume that this will not be cached by the browser? If it is not cached by the browser, would one be able to implement caching by writing to local storage? 回答1: Will this be the case for any dependent .jars

LWJGL3: Overloaded glBufferData methods

为君一笑 提交于 2019-12-10 21:41:47
问题 I am using LWJGL to call OpenGL functions. The method org.lwjgl.opengl.GL15#glBufferData() calls the equivalent OpenGL method. It has several overloaded variants in LWJGL, and the most used I've seen is with FloatBuffer , like this for a simple triangle (other unrelated OpenGL calls omitted): float[] triangle = new float[]{ 0.0f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f }; FloatBuffer buf = BufferUtils.createFloatBuffer(triangle.length); buf.put(triangle).flip(); int vbo =

Opening a LWJGL window from a SWT app on Mac

雨燕双飞 提交于 2019-12-10 20:02:00
问题 I have a SWT app that opens a OpenGL window (using the LWJGL library) after a button is pressed. It is supposed to close it's main SWT window and open a new one with an OpenGL context. Works fine on Windows. On Mac, I get this error: 2010-03-05 02:28:25.315 java[1315:a07] [Java CocoaComponent compatibility mode]: Enabled 2010-03-05 02:28:25.316 java[1315:a07] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000 2010-03-05 02:28:25.317 java[1315:a07] Apple AWT Startup

Put a LWJGL java app in a jpanel or canvas

耗尽温柔 提交于 2019-12-10 19:43:10
问题 With the new update to lwjgl 3 the class Display does not exists, i've searched everywhere but i can't find anything on how to put all my lwjgl app in a jpanel or in a canvas or anything like. I already thought to use an opengl gui like twl but it would make all more difficult and i don't need it, so my question is how to put the lwjgl app in a jpanel or in a canvas. Thanks, it would save my life. 回答1: Unfortunately, there currently isn't any support for using LWJGL3 with Swing. Support for