LWJGL/OPENGL- Object flickers only when moving Cameras Position(Solved)

For whatever reason I have a textured spinning quad(2 triangles) which will flicker when I move my Camera’s position and is fine when I ONLY move the Quads position:

Camera’s POS: 0, 0, 1
Objects Pos: 0, 0, -5

I should also note that it only happens with Perspective Projection:

Camera.Main_Camera.SetProjection(new Matrix4f().perspective((float)Math.toRadians(60), Display.mainDisplay.Aspect, 0.01f, 1000.0f));

Anyone know what the possible causes could be?

I will show code I you ask.

EDIT: Object flickers more than GIF shows in-between changing size.

EDIT: I now believe it is the actual object/mesh overall that is flickering as when i disable the texture in Shader it still flickers.

thats too little code to tell.

but it is a very annoying error. what happens if you use double floats ?

I’m sorry but could you clarify what you mean by ‘use double floats’.

Your error is exactly this line. -> You are negating Position every frame.
Remember that in JOML every call will modify the object it is invoked on, unless an explicit destination parameter is passed.
That means Vector3.negate() will not produce a new vector object but will modify the vector directly.
You can remedy this by using [icode]translate(-Position.x, -Position.y, -Position.z)[/icode]

Yeah that fixed it, Thanks. :slight_smile:

I sometimes forget that JOML does that.

Yeah, that “zero allocation” policy can at times be annoying as hell, especially when working with small objects like vectors that are really just “values” not needing an identity. But that will all change when Java 10 arrives.