FAQ Database Discussion Community


Players appear to be colliding with air?

java,opengl,collision-detection,lwjgl,collision
(Will be putting a bounty on this - Also, I'm not 100% sure what tags are relevant for this) I'm incredibly confused here. I am attempting to use this (simplified) model for my archers to collide with: However, as you can see, my archers appear to be colliding in mid-air!...

Rotating all rectangle corners

java,math,rotation,lwjgl
I'm working on a game where you are a spaceship. This spaceship has to be able to rotate. The rectangle has two arrays x[], y[] containing all the corners positions of the rectangle. But when I apply the rotation formula, I get a rather wierd rotation. To try to explain...

Opengl storing all vertex data using 1 buffer

java,lwjgl
I have created 1 float buffer and 1 vbo with all my vertex data(position, texture coordinates, normals), they are stored as follow: bf.put(vertices[i].position.x); bf.put(vertices[i].position.y); bf.put(vertices[i].position.z); bf.put(vertices[i].texCoords.x); bf.put(vertices[i].texCoords.y); bf.put(vertices[i].normals.x); bf.put(vertices[i].normals.y); bf.put(vertices[i].normals.z); How can I pass them to the shader using glVertexAttribPointer ? Is it possible to do something like: glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER,...

Calculating world coordinates from camera coordinates

java,opengl,math,matrix,lwjgl
I have a world that is rendered in 2D and I'm looking at it from the top. Tjat looks like this (the floor tiles have no texture and only random green color yet): Before rendering my entities, I transform the model-view matrix like this (while position is the position and...

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

java,libgdx,lwjgl,glyph
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...

finding the angle of a triangle using tan

java,lwjgl,trigonometry
alright so im making a ai for a zombie in one of my games, but when i try to rotate the zombie so that he is facing the player everything goes out of wack. they rotate the wrong way, spin around when i get close even though the angle shouldn't...

LWJGL Player Health bar not positioning properly

java,opengl,position,lwjgl
I'm making a game in Java using LWJGL and slick_util recently I'm trying to implement a health bar that will hover on top of the player's head. Problem is, it is not positioning correctly. The health bar's bottom left corner(from where OpenGL starts drawing) always appears at the top right...

How to create a wiresphere using lwjgl?

graphics,3d,lwjgl
I'm trying to find a way to draw a wire sphere using LWJGL. I have seen that using GLUT I could use the function glutWireSphere(double, int, int), but what about LWJGL? is there any way to do that similarly? I was looking for that but I haven't found anything yet....

Java 3D LWJGL collision

java,lwjgl,models,collision,detection
I am making a 3D Java game with the LWJGL library, and I was wondering how to add collision detection, so that the player does not go through models. I am using OBJ models. Here is the OBJLoader class, which loads the models: package renderEngine; import java.io.BufferedReader; import java.io.File; import...

Overlaying a transparent color over a Texture with GLSL

glsl,lwjgl,slick2d,vertex-shader,blending
I have an image that I am loading using the Slick library, and the image renders fine without my shader active. When I use my shader to overlay a transparent color over the image the entire image is replaced by the transparent color. without the shader With the shader Vertex...

OpenGL texture coordinates wrong

java,opengl,lwjgl
Using the answer from my previous question I have managed to render the entire font atlas to the screen. However, when it comes to rendering individual characters from the atlas my coordinates appear to be somewhat wrong: From that (the text is supposed to read 'Test font renderer text') I...

No OpenGL context is current in the current thread

java,opengl,lwjgl
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)...

Java lwjgl keyboard handler

java,input,lwjgl
I've created a class that takes lwjgl's keyboard input and turns it into a list of strings that are all the keys that are currently being pressed. public class KeyHandler { ArrayList<String> keysPressed; public KeyHandler() { keysPressed = new ArrayList<String>(); } public void checkKeys() { while (Keyboard.next()) { String keystring...

Doing a matrix multiplication in reverse

java,opengl,math,matrix,lwjgl
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,...

ExecutorService runnable never hits try when an Exception occurs

java,java-8,lwjgl
I am trying to use a CompletableFuture<T> to respond to a LWJGL OpenGL context being created. This is done by calling the open method on LWJGLGameWindow. Here is the concerning code: @Override public CompletableFuture<?> open() { CompletableFuture<Void> future = new CompletableFuture<>(); scheduledExecutorService.schedule(() -> { future.completeExceptionally(new TimeoutException("Could not establish contact with...

GLSL Shader not Compiling, no Error Message

java,compilation,glsl,lwjgl
I am trying to use a GLSL shader I wrote from LWJGL. It is just a simple fragment-based phong shader. The shader has worked fine in the past, even on this computer. The other day, all of a sudden, it simply stopped compiling for no apparent reason. When I try...

Trouble with slick.util and lwjgl textures

java,opengl,textures,lwjgl,slick2d
So I've recently started making a simple 2-D java game using jlwgl and slick-util. I ran into a problem when trying to load in textures to place on my tiles. I am using slick util to try and load textures in. This is the method I am using to do...

LWJGL make object always face up

java,opengl,lwjgl
I need to make 3D objects to face up same way no matter their position to the camera. As if camera was very very far away and zoomed in. Here is what I mean (take a look at the pillar and walls): http://youtu.be/Pn9fh93oV-c Here is what I have so far:...

opengl y-axis not scaling with x or z

java,opengl,lwjgl
I'm not really sure how to even describe this problem so please excuse the terrible title. I have a simple model ( it is actually a tile but I made it a cube to better illustrate the issue ) that is 2 units high, wide and deep. To draw a...

AL lib: (EE) UpdateDeviceParams: Failed to set 44100hz, got 48000hz instead

java,lwjgl,openal
I'm coding to manage OpenAL in java using lwjgl 3 and when I create the ALContext with this line: ALContext alContext = ALContext.create(); When I execute the console prints this advice AL lib: (EE) UpdateDeviceParams: Failed to set 44100hz, got 48000hz instead Any idea about whats wrong? By the way,...

OpenGL Vertices not drawn

java,opengl,lwjgl
I'm trying the whole day to get OpenGL to work in Java (with LWJGL 3/GLFW). The problem is that besides the clear color, I don't see anything drawn. Question: Is the order of my OpenGL Function calls ok? Are there any mistakes that prevents the vertices from being drawn? This...

How to resolve this JNI error when trying to run LWJGL “Hello World”?

java,lwjgl
I am trying to run the sample "Hello World" from the LWJGL website From this link: LWJGL "Getting Started" I'm trying to do this via the command line, just so I understand the "behind the scenes" a bit better. I've managed to compile without any errors, but when I try...

Callback to Class (non-instance)

java,oop,callback,lwjgl
LWJGL 3 uses a callback system to handle inputs, like so: public class Main { ... public static void main(String[] args) { glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() { @Override public void invoke(long window, int key, int scancode, int action, int mods) { } }); } } However, I do not...

Calculating angle of rebound in java

java,lwjgl,computational-geometry,slick2d
I am trying to bounce a projectile off of a wall in Slick. When the wall is vertical or horizontal, I can just invert the x or y velocity of the projectile, but when this is not the case I am struggling. I found another answer to a similar question...

LWJGL Display crashing when implemented with Jframe and canvas

java,swing,opengl,jframe,lwjgl
I'm working on creating a 2D Java game with a lighting engine with OpenGL using LWJGL, but I've hit a wall when trying to link up keyboard inputs. The render loop works fine, but as soon as I tried to implement a JFrame/canvas and the getParent/KeyListener combo The application crashes...

Java OpenGL EXCEPTION_ACCESS_VIOLATION on glDrawArrays only on NVIDIA

java,opengl,lwjgl,nvidia,gldrawarrays
I'm working on a game in java using lwjgl and it's OpenGL implementation. Never had any problems until I exchanged it with a colleague who uses NVIDIA instead of AMD, and suddenly it crashes on a line that works on AMD but it only crashes at that point in the...

Java LWJGL - Monster not following me, runs between a bounds of 2

java,opengl,lwjgl
I have written a script to be set off whenever a player is within a distance of the monster. The script checks if the x position is greater than or less than the players x, and same for the z. (y is automatically set to terrain) public int checkWalkX(Vector3f position)...

Where does “lwjgl-util.jar” belong to?

java,opengl,lwjgl
I'm developing a game with LWJGL 3.0.0a. Many tutorials out there use the lwjgl_util.jar that contains stuff like Vector2f and GLU for functions like gluUnProject. In this version though (available on the downloads page) there is no such library contained anymore; it only contains the core lwjgl.jar. Where have these...

Textures not working

java,opengl,textures,lwjgl,texture2d
So ok. That OpenGL state machine is kiddin' me! I'm serious! Just few days ago all worked with immediate mode and even VBO mode, but not today! Today im seein a white quad, cause i rewrote 80% of my old code. Thats such a cool thing, yo know. So. I...

Fragment Shader Rotation

java,opengl,lwjgl
I've been having a few problems with my fragment shader. After a bit of research, it appears that drivers clean up unused variables (ones which have no effect on the output?), which can cause glSetUniform and glGetUniform to return -1. My current problem is that I'm attempting to rotate a...

Issue with using Sampler2D with a Shader

opengl,shader,lwjgl,fbo
! I am aware that there are easier ways to draw to the screen than this, but i need to do it this specific way ! I am drawing to a texture through a fbo. I am then using a shader to re-draw it onto the screen, doing so with...

Adding mouselistener to canvas with lwjgl display on it

java,lwjgl,mouselistener
I'm using java and LWJGL. I created a mouse listener for a canvas, but when I set the Displays parent to the canvas it doesn't work. The mousehandlerClass: private static class handlerClass implements MouseListener { public handlerClass() { } @Override public void mouseClicked(MouseEvent e) { System.out.println("Canvas clicked"); } @Override public...

FBO lwjgl bigger than Screen Size - What I'm doing wrong?

size,lwjgl,fbo
I need your help again. I wanna use Frame Buffer Object bigger than the Screen size. When I do it as below FBO size 1024 x 1024 is cut off from the top in resolution 1024 x 768. I couldn't find the solution on my own - that's why I'm...

I get error “Exception in thread ”main“ org.lwjgl.opengl.OpenGLException: Invalid operation (1282)”, what it is?, how I can fix it?

java,opengl,lwjgl
I use NetBeans Programming language:Java OS:Windows 8.1 x64 I try to make game engine with TheBennyBox tutorial. I'm in part 11 and i try to run my project but i get this error message: Exception in thread "main" org.lwjgl.opengl.OpenGLException: Invalid operation (1282) at org.lwjgl.opengl.Util.checkGLError(Util.java:59) at org.lwjgl.opengl.GL20.glUniform1f(GL20.java:338) at com.base.engine.Shader.setUniformf(Shader.java:119) at com.base.engine.Game.update(Game.java:63)...

LWJGL reports that OpenGL is not supported on a modern nvidia card

libgdx,lwjgl
So i have been trying out libgdx for the past day and it works well, until i realized that it only works on my laptop with intel graphics while it instantly shuts down on my desktop with a nvidia 750ti. According to this github issue, this issue should've already been...

BufferOverFlowException at first .put()

java,opengl,buffer,lwjgl
I was having a problem due to not flipping the buffer previously, but now I can't get the buffer to add anything with the .put() or .putInt() it constantly throws the BufferOverflowException at the first attempt of: buffer.put((byte) c.getRed()); The relevant code below: BufferedImage image = loadImage(".\\res\\" + fileName); int[]...

How to translate using shaders and matrices?

opengl,matrix,glsl,shader,lwjgl
I'm am using LWJGL and shaders to try and translate everything I'm drawing within my shader program. I am using a 4 by 4 matrix 1,0,0,x, 0,1,0,y, 0,0,1,z, 0,0,0,1 Where x,y,z are the values I am using to translate. Then I use gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex * transformMatrix Where...

Put a LWJGL java app in a jpanel or canvas

java,lwjgl
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...

LookAt matrix distorts when looking up or down

java,opengl,matrix,lwjgl
I am using a lookAt matrix calculated in an open source math library I found for LWJGL called JOML for free cam in my game. It works well when rotating left and right, but looking up and down seems to cause major distortions issues similar to heavily increasing the FOV....

Scan the keys in lwjgl

java,keyboard,lwjgl
I have this game where I use the standard WASD keys as input. Though not all the keyboards have a QWERTY layout. For instance, when I use an AZERTY keyboard, the WASD is a bit hard to use with the left hand. I would like that no matter his keyboard...

LWJGL: detecting left/right clicks when getButtonCount returns 0

java,opengl,lwjgl
On the Dell Inspiron 15 3000, the touchpad doesn't have any physical left/right buttons. Instead, it is one giant touchpad that is pressure sensitive. I'm assuming it detects right/left clicks based off of hand position on the trackpad. In my LWJGL application, I detect mouse button clicks with Mouse.isButtonDown(0). This...

Java LWJGL Multiple Scissor Test

java,opengl,lwjgl
Is there any way to glEnable GL_SCISSOR_TEST inside an already enabled GL_SCISSOR_TEST? Like the following: GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor(0, 0, 64, 64); draw.rect(); GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor(32, 32, 48, 48); draw.smallRect(); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glDisable(GL11.GL_SCISSOR_TEST); I have tried the above and it seems to not work as expected and even by looking at the code it...

OpenGL: glLoadMatrix & depth buffer

java,lwjgl
Another depth buffer question: I've matrix based camera - matrix comuptations are on OpenGL side (glPushMatrix, rotations, get matrix from OpenGL, glPopMatrix) and when updating camera, I send those computed matrix stuff to OpenGL via glLoadMatrix. Everything is ok (movement and rotation), but depth buffer is messed up: without glLoadMatrix...

How to decode ogg vorbis file java?

java,lwjgl,ogg,vorbis
I'm getting started with lwjgl and openal, so I want to be able to decode an ogg vorbis file and play it with openal. My question is: how can I decode an ogg file from java, get the frequency, pcm data, etc. and send it over to openal so I...