lwjgl

GLSL shader: Interpolate between more than two textures

本秂侑毒 提交于 2019-12-20 10:56:03
问题 I've implemented a heightmap in OpenGL. For now it is just a sine/cosine curved terrain. At the moment I am interpolating between the white "ice" and the darker "stone" texture. This is done like this: color = mix(texture2D(ice_layer_tex, texcoord), texture2D(stone_layer_tex, texcoord), (vertex.y + amplitude) / (amplitude * 2)) The result: It works fine, but what could I do if I want to add more textures, for example a grass texture, so that the interpolation order is "ice, stone, grass"? I

How do I work with “delta” in Slick2D/LWJGL or game programming in general?

本秂侑毒 提交于 2019-12-20 04:30:10
问题 All I know is that delta relates somehow to adapting to different frame rates, but I'm not sure exactly what it stands for and how to use it in the math that calculates speeds and what not. Where is delta declared? initialized? How is it used? How are its values (min,max) set? 回答1: It's the number of milliseconds between frames. Rather than trying to build your game on a fixed number of milliseconds between frames, you want to alter your game to move/update/adjust each element/sprite/AI based

Free Flight Camera - strange rotation around X-axis

喜你入骨 提交于 2019-12-20 04:23:19
问题 So I nearly implemented a free-flight camera using vectors and something like gluLookAt. The movement in all 4 directions and rotation around the Y-axis work fine. For the rotation around the Y-axis I calculate the vector between the eye and center vector and then rotate it with the rotation matrix like this: Vector temp = vecmath.vector(center.x() - eye.x(), center.y() - eye.y(), center.z() - eye.z()); float vecX = (temp.x()*(float) Math.cos(-turnSpeed)) + (temp.z()* (float)Math.sin(

Java bitmap font: blitting 1-bit image with different colors

给你一囗甜甜゛ 提交于 2019-12-19 19:40:26
问题 I'd like to implement a simple bitmap font drawing in Java AWT-based application. Application draws on a Graphics object, where I'd like to implement a simple algorithm: 1) Load a file (probably using ImageIO.read(new File(fileName)) ), which is 1-bit PNG that looks something like that: I.e. it's 16*16 (or 16*many, if I'd like to support Unicode) matrix of 8*8 characters. Black corresponds to background color, white corresponds to foreground. 2) Draw strings character-by-character, blitting

How to get OpenGL context into my current thread, opengl context not found

自作多情 提交于 2019-12-19 10:29:13
问题 I'm working on a world editor for fun and using Java and JLWGL. Everything is working so far. Now I tried creating a window where I can add e.g. a terrain or a new model to use. Problem is, when I try to create the terrain from my main it is created and shown, but when I try to call it by an button eventlistener I get the error: No OpenGL context found in the current thread. I basically know why I get the error. My frame which I use to get the input and click the button has no opengl context.

Pointers - decreasing memory consumption

不问归期 提交于 2019-12-19 10:18:09
问题 I have been writing a Minecraft replica for OpenGL practice (as many do I guess), however after writing the basic rendering API I noticed the real Minecraft uses a lot or memory - around 800MB! I can fully understand why this is with all the blocks it has to remember along with mobs and probably terrain data for the generator...I asked myself "This block is exactly the same as that block..can they be in the code?" and remembered C++ has pointers, so I have attempted to do the same in Java the

LWJGL Display class can't be found

▼魔方 西西 提交于 2019-12-19 07:30:10
问题 I have installed LWJGL into a Java project, and I can't import the Display class. import org.lwjgl.opengl.display; Gives a cannot be resolved error. DisplayMode and other classes are also missing. I can not find any of them in the broswer. 回答1: The old utility classes like Display, Keyboard, Mouse etc. have been removed in LWJGL3. The libary now uses GLFW for window management, which is more complicated but said to have better performance and more features. Like with OpenGL methods, all glfw

(Libgdx 1.6.1) BitmapFontCache.draw crashing due to index out of bounds

烈酒焚心 提交于 2019-12-18 17:34:23
问题 I just recently updated my Libgdx project from 1.4.x to 1.6.1. I use BitmapFontCache for my dialogue in my game, drawing a string character by character using BitmapFontCache.draw(start, end). This was working fine in 1.4.x but after making the necessary changes to get 1.6.1 to build, it seems to cause a crash when wrapping is enabled after the last character is displayed. Strangely this does not seem to be a problem with one line strings. Here is how I add my text: fontCache.addText( message

Pick up native JNI files in Maven test (lwjgl)

拜拜、爱过 提交于 2019-12-18 13:35:06
问题 I'm creating a program with LWJGL and Maven, and I'm writing unit tests for the graphical code. My problem is getting Maven to put the native binaries on the classpath so that the tests can pick it up. I can't get past the error: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path I've gotten the binaries to unpack to target/libs/native/, but the tests won't pick them up. Here's my pom: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema

No OpenGL context is current in the current thread

血红的双手。 提交于 2019-12-18 08:55:46
问题 I'm following a tutorial on youtube but I have a problem with OpenGL that I'm not able to solve. I have no idea how I can fix it. Exception in thread "EndlessRunner" java.lang.IllegalStateException: No OpenGL context is current in the current thread. at org.lwjgl.opengl.GLContextWindows.createFromCurrent(GLContextWindows.java:61) at org.lwjgl.opengl.GLContext.createFromCurrent(GLContext.java:36) at net.alfredo.Main.init(Main.java:59) at net.alfredo.Main.run(Main.java:91) at java.lang.Thread