Java Code Examples for org.lwjgl.BufferUtils#createDoubleBuffer()
The following examples show how to use
org.lwjgl.BufferUtils#createDoubleBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLButton.java From oreon-engine with GNU General Public License v3.0 | 6 votes |
public boolean onClick() { DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1); DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1); glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos); Vec2f mousePos = new Vec2f((float) xPos.get(),(float) yPos.get()); if(pos[0].getX() < mousePos.getX() && pos[1].getX() < mousePos.getX() && pos[2].getX() > mousePos.getX() && pos[3].getX() > mousePos.getX() && pos[0].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && pos[3].getY() < BaseContext.getWindow().getHeight() - mousePos.getY() && pos[1].getY() > BaseContext.getWindow().getHeight() - mousePos.getY() && pos[2].getY() > BaseContext.getWindow().getHeight() - mousePos.getY()) { return true; } else return false; }
Example 2
Source File: TerrainPicking.java From oreon-engine with GNU General Public License v3.0 | 5 votes |
public void getTerrainPosition(){ if (isActive() && glfwGetMouseButton(BaseContext.getWindow().getId(),1) == GLFW_PRESS){ Vec3f pos = new Vec3f(0,0,0); DoubleBuffer xPos = BufferUtils.createDoubleBuffer(1); DoubleBuffer yPos = BufferUtils.createDoubleBuffer(1); glfwGetCursorPos(BaseContext.getWindow().getId(), xPos, yPos); Vec2f screenPos = new Vec2f((float) xPos.get(),(float) yPos.get()); GLContext.getResources().getSceneDepthMap().bind(); glGetTexImage(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,GL_FLOAT,depthmapBuffer); float depth = depthmapBuffer.get((int) (BaseContext.getWindow().getWidth() * screenPos.getY() + screenPos.getX())); // window coords Vec2f w = new Vec2f(screenPos.getX()/BaseContext.getWindow().getWidth(), screenPos.getY()/BaseContext.getWindow().getHeight()); //ndc coords Vec3f ndc = new Vec3f(w.getX() * 2 - 1, w.getY() * 2 - 1, depth); float cw = BaseContext.getCamera().getProjectionMatrix().get(3,2) / (ndc.getZ() - BaseContext.getCamera().getProjectionMatrix().get(2,2)); Vec3f clip = ndc.mul(cw); Vec4f clipPos = new Vec4f(clip.getX(),clip.getY(),clip.getZ(),cw); Vec4f worldPos = BaseContext.getCamera().getViewProjectionMatrix().invert().mul(clipPos); worldPos = worldPos.div(worldPos.getW()); pos.setX(worldPos.getX()); pos.setY(worldPos.getY()); pos.setZ(worldPos.getZ()); System.out.println("TerrainPicking: " + pos); } }
Example 3
Source File: OpenGLInput.java From DareEngine with BSD 2-Clause "Simplified" License | 5 votes |
public OpenGLInput(long inputSource) { this.inputSource = inputSource; this.mouseX = BufferUtils.createDoubleBuffer(1); this.mouseY = BufferUtils.createDoubleBuffer(1); this.joystickAxes = new FloatBuffer[IInput.JOYSTICK_LAST]; this.joystickButtons = new ByteBuffer[joystickAxes.length]; this.mouseDeltaX = 0; this.mouseDeltaY = 0; this.hasBeenUpdated = false; }
Example 4
Source File: URendererOGL.java From ure with MIT License | 4 votes |
public URendererOGL() { Injector.getAppComponent().inject(this); xf = BufferUtils.createDoubleBuffer(1); yf = BufferUtils.createDoubleBuffer(1); }
Example 5
Source File: BufferUtil.java From Lwjgl3-Game-Engine-Programming-Series with MIT License | 4 votes |
public static DoubleBuffer createDoubleBuffer(int size) { return BufferUtils.createDoubleBuffer(size); }
Example 6
Source File: BufferUtil.java From oreon-engine with GNU General Public License v3.0 | 4 votes |
public static DoubleBuffer createDoubleBuffer(int size) { return BufferUtils.createDoubleBuffer(size); }