lwjgl

Camera Pitch/Yaw to Direction Vector

馋奶兔 提交于 2019-12-05 02:13:24
What I'm trying to do is cast a ray from my camera. I know the camera's x, y and z coordinates, as well as its pitch and yaw. I need to calculate its direction vector so I can pass it to my raytracing algorithm. The camera's up vector is (0, 1, 0). "Pitch", from the perspective of the camera, is looking up and down. (I would prefer to not use matrices, but I will if I have to) Assuming that your coordinate system is set up such that the following conditions are met: (pitch, yaw) -> (x, y, z) (0, 0) -> (1, 0, 0) (pi/2, 0) -> (0, 1, 0) (0, -pi/2) -> (0, 0, 1) This will calculate (x, y, z): xzLen

java and libGDX / LWJGL game fullscreen wrong size for multiple monitors on Ubuntu

时光怂恿深爱的人放手 提交于 2019-12-04 22:13:56
I'm working on a libGDX (library on top of LWJGL) game project, and use the Intellij IDEA IDE from several different workstations: Windows 7 x64 laptop with two displays (1920x1080 and 1600x1200), nVidia GT540M. Ubuntu 12.04 LTS on a laptop with a single display (1366x768), Intel integrated graphics. Ubuntu 12.04 LTS on a desktop with two displays (1920x1080 and 1280x1024), nVidia GTS 450. I'm using the OpenJDK for Java 6 on the Ubuntu boxes, and Sun/Oracle Java 6 on the Windows box (I heard Java 6 was the one to use for Android compatibility). When running on full-screen: Windows 7 laptop:

OpenGL perspective distorting scene much more than expected along z axis

半世苍凉 提交于 2019-12-04 17:16:27
I'm working in LWJGL and have been struggling for a while to write a program that allows for simple 3d viewing of a scene. The major issue that I'm running into is that whenever I apply perspective, my scene is stretched very, very far in the z axis. The square in the middle is a cube drawn with orthographic projection (here cube means "all sides are equal"). The shape trailing from the bottom left to the center is also a cube, but drawn with perspective projection! Obviously, this does not not look like a cube. Here is my code (it is a bit of aa wall, so I've broken it up): public class

OpenGL - Java - Rendering Issue, Polygons flickering and disappearing

岁酱吖の 提交于 2019-12-04 15:12:23
I'm having some trouble with rendering Master Cheif in Java using LWJGL and GLSL shaders where the is some flickering, dissapearing of polygons and strange colouring. And for the life of me I can't figure out why. What it should look like: What it does look like when I move the camera a little: Shaders: https://github.com/marko5049/LucidEngine/tree/master/src/res/shaders MainShaders: LightingMain ShdaowMapping Smapler Filters All the code: https://github.com/marko5049/LucidEngine StaticMesh: public void addVertices(Vertex[] vertices, int[] indices, boolean calcNorm) { if(calcNorm) { vertices =

JVM Fatal Error in native code, Not sure what to do

僤鯓⒐⒋嵵緔 提交于 2019-12-04 12:30:27
I'm developing a game in Java using LWJGL. Along with the main game, I'm developing a few Swing-based applications (a launcher, a configuration editor, and a map editor). When I run the launcher, I sometimes (about 10% of the time) get a fatal JVM crash. It's very strange - I can run the program a few seconds later and everything works. I have zero compilation errors or warnings, and when the program does work, it's completely functional. I haven't gotten the error when I run my LWJGL game, it's only when I run the launcher first. The process I use to initialize the launcher is: Tell swing to

Taskbar icon with lwjgl?

假如想象 提交于 2019-12-04 10:23:29
I want to add a taskbar icon for my running lwjgl process on Windows 7. Display.setIcon changes successfully the icon in the topleft of the window, but not in the taskbar. What do to? My code, something like: ArrayList byteBuffers = new ArrayList(); byteBuffers.add( ImageHelper.loadImageAsIconImage("stickmanicon32x32.png") ); byteBuffers.add( ImageHelper.loadImageAsIconImage("stickmanicon16x16.png") ); System.out.println( "taskbaricon result: " + Display.setIcon(byteBuffers.toArray(new ByteBuffer[]{})) ); I tried adding a 40x40 image too, but no change. MxR This code worked just fine for me.

LWJGL - Problems implementing 'roll' in a 6DOF Camera using quaternions and a translation matrix

限于喜欢 提交于 2019-12-04 08:39:25
I've spent a couple weeks on this issue and can't seem to find a proper solution and need some advice. I'm working on creating a Camera class using LWJGL/Java, and am using Quaternions to handle bearing (yaw), pitch and roll rotations. I'd like this camera to handle all 6 degrees of movement in 3D space, and roll. Bearing, Pitch and Roll are all quaternions. I multiply them into a 'change' quaternion, and create a translation matrix from that. I put that in a float buffer, and multiply the modelview matrix by my buffer containing the rotation matrix. I can get the bearing and pitch rotations

How do I load an image for use as an openGL texture with LWJGL?

走远了吗. 提交于 2019-12-04 06:46:24
I am trying to load an image as a texture for openGL using the LWJGL library. From what I found out so far, I need to pass the texture as a ByteBuffer to openGL. What I have right now is some code that correctly loads an image, and stores it in a BufferedImage object. The thing is, I have no clue how to get from a BufferedImage to a ByteBuffer that contains data in the right format for use with openGL (as input for the function GL11.glTexImage2D()). Help is greatly appreciated! Here's a method from the Space Invaders example that does what you want. (I think) /** * Convert the buffered image

LWJGL Texture is flipped upside down when displayed

梦想的初衷 提交于 2019-12-04 05:42:14
问题 I followed a tutorial for reading a picture and creating a texture out of it, however, it shows up flipped upside down when rendered. The image is power of two. Main class public class Main { public static void main(String args[]) throws IOException{ Main quadExample = new Main(); quadExample.start(); } public void start() throws IOException { try { Display.setDisplayMode(new DisplayMode(1280,720)); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } // init

Creating a BufferedImage causes GLFW in the LWJGL to lock up (Java)

旧时模样 提交于 2019-12-03 22:59:22
问题 There is a link to download the project below. The project already contains the LWJGL. Just open it with eclipse and tell me I'm not going crazy I'm experimenting with the LWJGL for the first time and have managed to get the sample code on the LWJGL website to work. The odd thing is, if I create an instance of a BufferedImage anywhere in the program, it causes the whole thing to lock up. I've managed to narrow it down to the ColorModel class (which is used by BufferedImage) but can't figure