Hot questions for Using Lightweight Java Game Library in arrays

Question:

I've recently started using OpenGL and LWJGL but ever since I tried to mess with/add vertex array objects, I've been getting the same error over and over:

GL_INVALID_OPERATION

I am having a hard time understanding why but I managed to pin down to problem to these methods:

glEnableClientState(GL_VERTEX_ARRAY);
vao = glGenVertexArrays();

glBindVertexArray(vao);
glEnableVertexAttribArray(vao);     
glVertexAttribPointer(0, count, GL_FLOAT, false, Float.SIZE * 2, 0);

glBindVertexArray(0);

...so basically anything that has to do with vertex arrays throws this error. If anyone could point out what exactly I am doing wrong, that would be great. This is the rest of my code:

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;

import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import org.lwjgl.BufferUtils; 

public class Model {

    private int count;
    private int ibo, vao;

    public Model(float[] vertices, int[] indices) {

        count = indices.length;

        glEnableClientState(GL_VERTEX_ARRAY);
        vao = glGenVertexArrays();

        glBindVertexArray(vao);
        glEnableVertexAttribArray(vao);
        glVertexAttribPointer(0, count, GL_FLOAT, false, Float.SIZE * 2, 0);

        glBindVertexArray(0);

        FloatBuffer vBuffer = BufferUtils.createFloatBuffer(vertices.length);
        vBuffer.put(vertices).flip();

        int vbo = glGenBuffers();
        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glBufferData(GL_ARRAY_BUFFER, vBuffer, GL_STATIC_DRAW);

        IntBuffer iBuffer = BufferUtils.createIntBuffer(indices.length);
        iBuffer.put(indices).flip();

        ibo = glGenBuffers();
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, iBuffer, GL_STATIC_DRAW);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    }
    public void draw() {

        glBindVertexArray(vao);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);

        glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, 0);

    }
}

Answer:

The parameter of glEnableVertexAttribArray is the attibute index. This means you have to change your code like this:

glBindVertexArray( vao );
glEnableVertexAttribArray( 0 ); // <--- attribute index instead of object name

Or you may use glEnableVertexArrayAttrib:

glEnableVertexArrayAttrib( vao, 0 );

OpenGL 4.6 core profile specification, 10.3. VERTEX ARRAYS, page 354:

An individual generic vertex attribute array in a vertex array object is enabled with the commands

void EnableVertexAttribArray( uint index );
void EnableVertexArrayAttrib( uint vaobj, uint index );

Note, glEnableClientState is part of the deprecated fixed function pipeline. If you want to use the fixed function pipeline and glEnableClientState, then you have to use glVertexPointer instead of glVertexAttribPointer.

Question:

All, Having difficulty with glGenVertexArrays(). I get the following error:

Exception in thread "main" java.lang.IllegalStateException: This functionality is not available. at org.lwjgl.system.Checks.checkFunctionality(Checks.java:57) at org.lwjgl.opengl.GL30.getInstance(GL30.java:667) at org.lwjgl.opengl.GL30.getInstance(GL30.java:662) at org.lwjgl.opengl.GL30.nglGenVertexArrays(GL30.java:2789) at org.lwjgl.opengl.GL30.glGenVertexArrays(GL30.java:2816) at renderEngine.Loader.createVAO(Loader.java:26) at renderEngine.Loader.loadToVAO(Loader.java:19) at renderEngine.MainGameLoop.main(MainGameLoop.java:27)

Here is my Main Game Loop (I call GL.createCapabilities() from the createDisplay() method.)

package renderEngine;

import static org.lwjgl.glfw.GLFW.*;

public class MainGameLoop {

public static DisplayManager dm = new DisplayManager();

public static void main(String[] args) {

    //Create Display
    dm.createDisplay();

    Loader loader = new Loader();
    Renderer renderer = new Renderer();

    float[] vertices = {
        -0.5f,0.5f,0f,
        -0.5f,-0.5f,0f,
        0.5f,-0.5f,0f,

        0.5f,-0.5f,0f,
        0.5f,0.5f,0f,
        -0.5f,0.5f,0f
    };

    RawModel model = loader.loadToVAO(vertices);
    //Game Loop
    while (glfwWindowShouldClose(dm.getWindowID()) != GLFW_TRUE) {
        renderer.prepare();
        renderer.render(model);
        dm.updateDisplay();
    }

    //Destroy Display
    dm.destroyWindow();
    loader.cleanUp();
}
}

As referenced above, here is the Display Manager class:

package renderEngine;

import static org.lwjgl.glfw.GLFW.*;

import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.opengl.GL;

public class DisplayManager {

private GLFWErrorCallback errorCallback;
private GLFWKeyCallback keyCallback;

private long windowID; 

//Constructor
public DisplayManager(){
    init();
}

private void init(){
    if(glfwInit() != GLFW_TRUE){
        throw new IllegalStateException("Unable to initiate GLFW");
    }
}

public long createDisplay(){
    windowID = glfwCreateWindow(640,480,"Hello World!", 0, 0);
    if(windowID == 0){
        glfwTerminate();
        throw new RuntimeException("Failed to create the GLFW window");
    }

    GLFW.glfwSetWindowTitle(windowID, "GLFW Window");

    setErrorCallback();
    setKeyCallback();

    glfwMakeContextCurrent(windowID);
    GL.createCapabilities();

    return windowID;
}

public long getWindowID(){
    return this.windowID;
}

private void setErrorCallback(){
    errorCallback = GLFWErrorCallback.createPrint(System.err);
    glfwSetErrorCallback(errorCallback);
}

private void setKeyCallback(){

    keyCallback = new GLFWKeyCallback(){
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS){
                glfwSetWindowShouldClose(window, GLFW_TRUE);
            }
        }
    };
    glfwSetKeyCallback(windowID, keyCallback);
}

public void updateDisplay(){
    GLFW.glfwSwapInterval(1);
    glfwSwapBuffers(windowID);
    glfwPollEvents();
}

public void destroyWindow(){
    glfwDestroyWindow(windowID);
    keyCallback.release();
    glfwTerminate();
    errorCallback.release();
}

}

If would seem the above mentioned error is with the loader class:

package renderEngine;

import java.util.List;
import java.nio.FloatBuffer;
import java.util.ArrayList;

import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;

public class Loader {

private List<Integer> vaos = new ArrayList<Integer>();
private List<Integer> vbos = new ArrayList<Integer>();

public RawModel loadToVAO(float[] positions){
    int vaoID = createVAO();
    storeDataInAttributeList(0,positions);
    unbindVAO();
    return new RawModel(vaoID,positions.length/3);
}

private int createVAO() {
    int vaoID = GL30.glGenVertexArrays();
    vaos.add(vaoID);
    GL30.glBindVertexArray(vaoID);
    return vaoID;

}

private void storeDataInAttributeList(int attributeNumber, float[] data) {
    int vboID = GL15.glGenBuffers();
    vbos.add(vboID);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    FloatBuffer buffer = storeDataInFloatBuffer(data);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(attributeNumber, 3, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}

private void unbindVAO() {
    GL30.glBindVertexArray(0); //0 un-binds currently bound VAO
}

public void cleanUp(){
    for(int vao:vaos){
        GL30.glDeleteVertexArrays(vao);
    }

    for(int vbo:vbos){
        GL15.glDeleteBuffers(vbo);
    }
}

private FloatBuffer storeDataInFloatBuffer(float[] data){
    FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
    buffer.put(data);
    buffer.flip();
    return buffer;
}

}

In Particular this line of code:

GL30.glBindVertexArray(vaoID);

As far as I can see this is the correct method to do it, and the GL capabilities/context have been set/called from the main thread (main game loops main method, utilising the display manager)

For completeness, here are the RawModel and Renderer Classes, do not suspect an issue these these:

package renderEngine;

public class RawModel {

private int vaoID;
private int vertexCount;

public RawModel(int vaoID, int vertexCount){
    this.vaoID = vaoID;
    this.vertexCount = vertexCount;
}

public int getVaoID() {
    return vaoID;
}

public int getVertexCount() {
    return vertexCount;
}

}

And here is the Renderer Class:

package renderEngine;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL30;

public class Renderer {

public void prepare(){
    GL11.glClearColor(1, 0, 0, 1);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
}

public void render(RawModel model){
    GL30.glBindVertexArray(model.getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.getVertexCount());
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
}

}

Any assistance you can give me regarding my implementation of 'glGenVertexArrays' would be much appreciated.

I have now added the following

    GLFW.glfwDefaultWindowHints();
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);

However, am now getting the following error:

Exception in thread "main" java.lang.RuntimeException: Failed to create the GLFW window at renderEngine.DisplayManager.createDisplay(DisplayManager.java:37) at renderEngine.MainGameLoop.main(MainGameLoop.java:12)

The specific implementation of my createDisplay() is as follows:

    public long createDisplay(){
    GLFW.glfwDefaultWindowHints();
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);


    windowID = glfwCreateWindow(640,480,"Hello World!", 0, 0);
    if(windowID == 0){
        glfwTerminate();
        throw new RuntimeException("Failed to create the GLFW window");
    }



    GLFW.glfwSetWindowTitle(windowID, "GLFW Window");

    setErrorCallback();
    setKeyCallback();

    glfwMakeContextCurrent(windowID);
    GL.createCapabilities();

    return windowID;
}

UPDATE

If have removed the error callbacks, as thought they might be causing an issue. The resulting error is:

Exception in thread "main" java.lang.RuntimeException: Failed to create the GLFW window at renderEngine.DisplayManager.createDisplay(DisplayManager.java:40) at renderEngine.MainGameLoop.main(MainGameLoop.java:12)

It seems the RuntimeException is being thrown, and is displaying my custom error message if the glfw window cannot be created. Could this be todo with the order in which I run this? I have played around with the placement of the 'init' method with noluck. There has got to be something I am overlooking?... Thanks.

Updated code for the Display Manager:

package renderEngine;

import static org.lwjgl.glfw.GLFW.*;

import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWErrorCallback;
import org.lwjgl.glfw.GLFWKeyCallback;
import org.lwjgl.opengl.GL;

public class DisplayManager {

private GLFWErrorCallback errorCallback;
private GLFWKeyCallback keyCallback;

private long windowID; 

//Constructor
public DisplayManager(){

    init();
}

private void init(){

    if(glfwInit() != GLFW_TRUE){
        throw new IllegalStateException("Unable to initiate GLFW");
    }
}

public long createDisplay(){
    GLFW.glfwDefaultWindowHints();
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 2);


    windowID = glfwCreateWindow(640,480,"Hello World!", 0, 0);
    System.out.println(windowID);
    if(windowID == 0){
        glfwTerminate();
        throw new RuntimeException("Failed to create the GLFW window");
    }

    glfwMakeContextCurrent(windowID);
    GL.createCapabilities();


    GLFW.glfwSetWindowTitle(windowID, "GLFW Window");

    //setErrorCallback();
    //setKeyCallback();


    return windowID;
}

public long getWindowID(){
    return this.windowID;
}

private void setErrorCallback(){
    errorCallback = GLFWErrorCallback.createPrint(System.err);
    glfwSetErrorCallback(errorCallback);
}

private void setKeyCallback(){

    keyCallback = new GLFWKeyCallback(){
        @Override
        public void invoke(long window, int key, int scancode, int action, int mods) {
            if(key == GLFW_KEY_ESCAPE && action == GLFW_PRESS){
                glfwSetWindowShouldClose(window, GLFW_TRUE);
            }
        }
    };
    glfwSetKeyCallback(windowID, keyCallback);
}

public void updateDisplay(){
    GLFW.glfwSwapInterval(1);
    glfwSwapBuffers(windowID);
    glfwPollEvents();
}

public void destroyWindow(){
    glfwDestroyWindow(windowID);
    keyCallback.release();
    glfwTerminate();
    errorCallback.release();
}

}

Many Thanks and Kind Regards, Jake


Answer:

The glGenVertexArrays function requires OpenGL 3.0 or higher. You have to explicitly tell GLFW this. Before calling glfwCreateWindow:

GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.CONTEXT_VERSION_MAJOR, 3);
GLFW.glfwWindowHint(GLFW.CONTEXT_VERSION_MINOR, 0);

You can check that you have OpenGL 3.0 or higher by calling GL11.glGetString(GL11.GL_VERSION) or by looking at the GL.getCapabilities().OpenGL30 flag.

Question:

I'm creating a voxel engine in Java using LWJGL just for practice, but I'm getting stuck on the chunk management system. More specifically, I'm trying to convert a Chunk, which is just a 3D array of integers for the block id, into an Octree for optimal rendering.

So far, I have the system working, but it's horribly inefficient.

Here's a screenshot of a 16*16*16 chunk with all positions below y=8 set to 1 (the red blocks)

https://raw.githubusercontent.com/ninthworld/Octree/master/screenshot0.png

I added a debugger to the OctNode generator code to find out how many times it needed to access the chunk array, and it came back with 8392704.

It accessed the chunk array over 8 million times just to generate 8 children nodes.

When I set the chunk array to only have blocks below y=4, the program has a blackscreen for almost 30 seconds, and the debugger returns 1623199744 array accesses.

Over 1.6 billion array calls just to generate 68 children nodes.

I obviously need to reduce the number of array calls, that much is certain, but I'm not sure how I would go about doing that. Here's the github page for the project if you'd like to see the entire source code.

Here are the important parts of my code:

Main.java

    // Initialize Octree Object
    // This is just an extended OctNode object
    octree = new Octree(chunk);
    octree.generate(lookup);

OctNode.java

public void generate(){
    int value = -1;

    // Loop through an area an area of width*width*width
    for(int x=0; x<width; x++){
        for(int y=0; y<width; y++){
            for(int z=0; z<width; z++){

                // Get the value from the master array based on the node's
                // offset + the forloop'd area
                int store = array[x+(int)offset.x][y+(int)offset.y][z+(int)offset.z];

                // Basically sets the value variable to the value at 
                // 0, 0, 0 with respect to the offset
                if(value < 0)
                    value = store;

                // Then check if the current position's value is the
                // same as the first one found (int value), if it's not,
                // then this node needs to be subdivided
                if(store != value){

                    // Create 8 children for this node
                    children = new OctNode[8];

                    // And for each of the children...
                    for(int i=0; i<children.length; i++){

                        // Set their offset equal to this node's offset +
                        // this node's width/2 all with respect to it's
                        // individual quadrant (which is related to i)
                        Vector3f offS = new Vector3f(offset.x + (width/2f)*(i%2), offset.y + (width/2f)*((int)Math.floor(i/2f)%2), offset.z + (width/2f)*((int)Math.floor(i/4f)%2));

                        // Initialize the new child node
                        children[i] = new OctNode(array, (int)(width/2f), offS);

                        // And now do the same thing (recursion), but
                        // for a smaller area
                        children[i].generate();
                    }
                }
            }
        }
    }

    // This is only called if the node is completely made of one value
    if(children == null){
        data = value;
    }
}

That's the best I can explain it unfortunately. If you could point out an easier, faster way to do the same thing that would be amazing.


Answer:

You are partitioning the tree too frequently. If you have a 16x16x16 array with all different values, you are going to recurse at every cell except the first, so you will call generate (16x16x16-1) times at the top level, rather than just once; the value of the children array will be overwritten many times over; of course, you will repeat the doing of unnecessary work at the next level down etc.

You should move the decision to subdivide the current octree node outside the nested for loops. For example:

public void generate(){
    // Assuming that width >= 1.
    int minValue = Integer.MAX_VALUE;
    int maxValue = Integer.MIN_VALUE;

    // Loop through an area an area of width*width*width
    // looking for min and max values in that area.
    for(int x=0; x<width; x++){
        for(int y=0; y<width; y++){
            for(int z=0; z<width; z++){
                int store = array[x+(int)offset.x][y+(int)offset.y][z+(int)offset.z];
                minValue = Math.min(minValue, store);
                maxValue = Math.max(maxValue, store);
            }
        }
    }

    if (minValue != maxValue) {
      // Subdivide if the min and maxValues are different,
      // as above.
      children = new OctNode[8];
      // etc.
    } else {
      data = minValue;
    }
}

Question:

How I can add vertex data (float[]) to a Vector3f list? It gives me an error if I try.

float[] vertexData = new float[ allindices2.length * vertexDataSize / 3];
for (int i = 0; i < vertexData.length / vertexDataSize; i++){
      vertexData[i * vertexDataSize + 0] = Float.parseFloat(allindices2 [Integer.parseInt(allindices2 [i * source.size() + 0]) * 3 + 0]);
      vertexData[i * vertexDataSize + 1] = Float.parseFloat(allpositions2[Integer.parseInt(allindices2[i * source.size() + 0]) * 3 + 1]);
      vertexData[i * vertexDataSize + 2] = Float.parseFloat(allpositions2[Integer.parseInt(allindices2[i * source.size() + 0]) * 3 + 2]);

      vertices.add(vertexData);
}

Answer:

If you don't need the vertexData array for any other reason, you should not create it at all. Instead, you can directly create the required Vector3f instances.

for (int i = 0; i < vertexData.length / vertexDataSize; i++){

      float x = Float.parseFloat(allindices2  [Integer.parseInt(allindices2[i * source.size() + 0]) * 3 + 0]);
      float y = Float.parseFloat(allpositions2[Integer.parseInt(allindices2[i * source.size() + 0]) * 3 + 1]);
      float z = Float.parseFloat(allpositions2[Integer.parseInt(allindices2[i * source.size() + 0]) * 3 + 2]);

      vertices.add(new Vector3f(x,y,z));
}

Nevertheless, all these parse... calls and the general structure look highly dubious. Unless you obtain this data directly from a file or so, you should consider a different data model.

Additionally:

  • Are you sure that the first allindices2 should not be allpositions2?
  • There's no need to do work twice. You can pull out the computation of the index.

Most likely, the code could also be written as

for (int i = 0; i < vertexData.length / vertexDataSize; i++){
      int index = Integer.parseInt(allindices2[i * source.size()]);
      float x = Float.parseFloat(allpositions2[index * 3 + 0]);
      float y = Float.parseFloat(allpositions2[index * 3 + 1]);
      float z = Float.parseFloat(allpositions2[index * 3 + 2]);
      vertices.add(new Vector3f(x,y,z));
}

Question:

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 code. That is the weardest part because I use the same method to create the VBOs from .obj-files. I even tried it with the same file but still at that point it crashes on all other occasion not. Could it be maybe a wrong set flag or something? I hope somebody here can help.

for (int i = 0; i < material.length; i++) {
  material[i].activate();

  glEnableClientState(GL_VERTEX_ARRAY);
  GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexVBO[i]);
  glVertexPointer(3, GL_FLOAT, 0, 0);

  if (normalsEnabled[i]) {
    glEnableClientState(GL_NORMAL_ARRAY);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, normalVBO[i]);
    glNormalPointer(GL_FLOAT, 0, 0);
  }

  if (material[i].getTexture() != null) {
    glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, textureVBO[i]);
    GL11.glTexCoordPointer(2, GL_FLOAT, 0, 0);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    glDrawArrays(GL11.GL_TRIANGLES, 0, sizeVBO[i]);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

  } else //CRASHS HERE
    glDrawArrays(GL11.GL_TRIANGLES, 0, sizeVBO[i]);

}

resulting error:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000003ffe68, pid=4936, tid=4048
#
# JRE version: Java(TM) SE Runtime Environment (8.0_25-b18) (build 1.8.0_25-b18)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  0x00000000003ffe68
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x00000000003ef000):  JavaThread "main" [_thread_in_native, id=4048, stack(0x0000000002330000,0x0000000002430000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x0000000000000000

Registers:
RAX=0x0000000058461574, RBX=0x0000000011fe0000, RCX=0x0000000000000000, RDX=0x0000000000000038
RSP=0x000000000242ee00, RBP=0x00000000bc7602a4, RSI=0x0000000000000000, RDI=0x0000000000000000
R8 =0x0000000000000000, R9 =0x0000000000000038, R10=0x0000000000000277, R11=0x0000000000410158
R12=0x0000000000000000, R13=0x00000000003ffdc0, R14=0x0000000000000009, R15=0x0000000000000038
RIP=0x00000000003ffe68, EFLAGS=0x0000000000010206

Top of Stack: (sp=0x000000000242ee00)
0x000000000242ee00:   ffffffffa6c87b00 0000000000000000
0x000000000242ee10:   0000000000000ce8 0000000011fe0000
0x000000000242ee20:   0000000000000038 000000005a9e84da
0x000000000242ee30:   0000000000000004 000000005a9cd07a
0x000000000242ee40:   0000000011fe0000 0000000000000000
0x000000000242ee50:   00000000003ef000 0000000000000004
0x000000000242ee60:   0000000057fe0080 0000000000000d20
0x000000000242ee70:   0000000000000000 000000005a9e6397
0x000000000242ee80:   0000000000000000 000000005484c780
0x000000000242ee90:   0000000011fe0000 0000000000000000
0x000000000242eea0:   000c000000003003 0080000000000000
0x000000000242eeb0:   000000000242efd8 000000005a6bfdc2
0x000000000242eec0:   0000000011fe0000 000000000242ef98
0x000000000242eed0:   0000000000000000 0000000000000004
0x000000000242eee0:   000000000242ef98 000000000242ef58
0x000000000242eef0:   000000000242ef58 000000000271a111 

Instructions: (pc=0x00000000003ffe68)
0x00000000003ffe48:   08 89 78 14 48 be 90 b3 02 12 00 00 00 00 48 8b
0x00000000003ffe58:   36 48 8b b6 c8 01 00 00 48 8d 3c 49 48 8d 34 be
0x00000000003ffe68:   8b 3e 8b 6e 04 89 78 18 89 68 1c 8b 7e 08 89 78
0x00000000003ffe78:   20 48 83 c0 24 ff c1 ff ca 0f 85 72 ff ff ff 48 


Register to memory mapping:

RAX=0x0000000058461574 is an unknown value
RBX=0x0000000011fe0000 is an unknown value
RCX=0x0000000000000000 is an unknown value
RDX=0x0000000000000038 is an unknown value
RSP=0x000000000242ee00 is pointing into the stack for thread: 0x00000000003ef000
RBP=0x00000000bc7602a4 is an unknown value
RSI=0x0000000000000000 is an unknown value
RDI=0x0000000000000000 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x0000000000000038 is an unknown value
R10=0x0000000000000277 is an unknown value
R11=0x0000000000410158 is an unknown value
R12=0x0000000000000000 is an unknown value
R13=0x00000000003ffdc0 is an unknown value
R14=0x0000000000000009 is an unknown value
R15=0x0000000000000038 is an unknown value


Stack: [0x0000000002330000,0x0000000002430000],  sp=0x000000000242ee00,  free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  0x00000000003ffe68

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.GL11.nglDrawArrays(IIIJ)V+0
j  org.lwjgl.opengl.GL11.glDrawArrays(III)V+20
j  ogl.gui.obj.ObjectOGL.paint3D(F)V+150
j  ogl.gui.obj.ComplexObjectOGL.paint3D(F)V+77
j  ogl.game.connect.BattleMapEditorOGL.paint3D(F)V+110
j  ogl.gui.MainAppOGL.renderGL(I)V+16
j  ogl.gui.MainAppOGL.start()V+28
j  ogl.gui.MainAppOGL.main([Ljava/lang/String;)V+9
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x0000000058fbf000 JavaThread "LWJGL Timer" daemon [_thread_blocked, id=1040, stack(0x0000000059920000,0x0000000059a20000)]
  0x0000000056c12000 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=4804, stack(0x0000000059710000,0x0000000059810000)]
  0x0000000054d8f800 JavaThread "Service Thread" daemon [_thread_blocked, id=976, stack(0x0000000056e70000,0x0000000056f70000)]
  0x0000000054d89800 JavaThread "C1 CompilerThread1" daemon [_thread_blocked, id=4272, stack(0x0000000056190000,0x0000000056290000)]
  0x0000000054d4f800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=2432, stack(0x0000000056510000,0x0000000056610000)]
  0x0000000054d4b800 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=4116, stack(0x00000000567b0000,0x00000000568b0000)]
  0x0000000054d3c800 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=4304, stack(0x00000000566a0000,0x00000000567a0000)]
  0x0000000054d38000 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=1252, stack(0x0000000056410000,0x0000000056510000)]
  0x0000000054d28800 JavaThread "Attach Listener" daemon [_thread_blocked, id=3676, stack(0x0000000055eb0000,0x0000000055fb0000)]
  0x0000000054d27800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3516, stack(0x0000000055c90000,0x0000000055d90000)]
  0x0000000054cc7800 JavaThread "Finalizer" daemon [_thread_blocked, id=4364, stack(0x0000000055870000,0x0000000055970000)]
  0x0000000054cc0800 JavaThread "Reference Handler" daemon [_thread_blocked, id=3596, stack(0x00000000559f0000,0x0000000055af0000)]
=>0x00000000003ef000 JavaThread "main" [_thread_in_native, id=4048, stack(0x0000000002330000,0x0000000002430000)]

Other Threads:
  0x0000000054cbb000 VMThread [stack: 0x0000000055770000,0x0000000055870000] [id=3268]
  0x00000000568c5000 WatcherThread [stack: 0x0000000056fc0000,0x00000000570c0000] [id=4464]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap:
 PSYoungGen      total 18944K, used 18941K [0x00000000eab00000, 0x00000000ec000000, 0x0000000100000000)
  eden space 16384K, 100% used [0x00000000eab00000,0x00000000ebb00000,0x00000000ebb00000)
  from space 2560K, 99% used [0x00000000ebb00000,0x00000000ebd7f4a0,0x00000000ebd80000)
  to   space 2560K, 0% used [0x00000000ebd80000,0x00000000ebd80000,0x00000000ec000000)
 ParOldGen       total 44032K, used 756K [0x00000000c0000000, 0x00000000c2b00000, 0x00000000eab00000)
  object space 44032K, 1% used [0x00000000c0000000,0x00000000c00bd238,0x00000000c2b00000)
 Metaspace       used 9280K, capacity 9467K, committed 9728K, reserved 1058816K
  class space    used 955K, capacity 986K, committed 1024K, reserved 1048576K

Card table byte_map: [0x0000000011ac0000,0x0000000011cd0000] byte_map_base: 0x00000000114c0000

Marking Bits: (ParMarkBitMap*) 0x000000005df7d490
 Begin Bits: [0x0000000012190000, 0x0000000013190000)
 End Bits:   [0x0000000013190000, 0x0000000014190000)

Polling page: 0x0000000000120000

CodeCache: size=245760Kb used=3758Kb max_used=3766Kb free=242001Kb
 bounds [0x0000000002700000, 0x0000000002ac0000, 0x0000000011700000]
 total_blobs=1472 nmethods=950 adapters=445
 compilation: enabled

Compilation events (10 events):
Event: 3.587 Thread 0x0000000054d4f800  893       4       java.util.ArrayList$SubList$1::hasNext (20 bytes)
Event: 3.587 Thread 0x0000000054d4f800 nmethod 893 0x0000000002a96b10 code [0x0000000002a96c40, 0x0000000002a96cd8]
Event: 3.587 Thread 0x0000000054d4f800  842       4       javax.vecmath.Matrix3f::setIdentity (46 bytes)
Event: 3.588 Thread 0x0000000054d4f800 nmethod 842 0x0000000002a96910 code [0x0000000002a96a40, 0x0000000002a96ab8]
Event: 3.588 Thread 0x0000000054d4f800  849       4       com.bulletphysics.$Stack::pop$com$bulletphysics$linearmath$Transform (21 bytes)
Event: 3.588 Thread 0x0000000054d4f800 nmethod 849 0x0000000002a96650 code [0x0000000002a96780, 0x0000000002a96858]
Event: 3.588 Thread 0x0000000054d4f800  859       4       javax.vecmath.Tuple3f::sub (40 bytes)
Event: 3.589 Thread 0x0000000054d4f800 nmethod 859 0x0000000002a96390 code [0x0000000002a964c0, 0x0000000002a96578]
Event: 3.607 Thread 0x0000000054d89800  952       3       ogl.matrix.tile.TileMap::getTile (25 bytes)
Event: 3.608 Thread 0x0000000054d89800 nmethod 952 0x0000000002a94a10 code [0x0000000002a94c00, 0x0000000002a95628]

GC Heap History (2 events):
Event: 3.024 GC heap before
{Heap before GC invocations=1 (full 0):
 PSYoungGen      total 18944K, used 16384K [0x00000000eab00000, 0x00000000ec000000, 0x0000000100000000)
  eden space 16384K, 100% used [0x00000000eab00000,0x00000000ebb00000,0x00000000ebb00000)
  from space 2560K, 0% used [0x00000000ebd80000,0x00000000ebd80000,0x00000000ec000000)
  to   space 2560K, 0% used [0x00000000ebb00000,0x00000000ebb00000,0x00000000ebd80000)
 ParOldGen       total 44032K, used 0K [0x00000000c0000000, 0x00000000c2b00000, 0x00000000eab00000)
  object space 44032K, 0% used [0x00000000c0000000,0x00000000c0000000,0x00000000c2b00000)
 Metaspace       used 8681K, capacity 8751K, committed 8960K, reserved 1056768K
  class space    used 885K, capacity 918K, committed 1024K, reserved 1048576K
Event: 3.032 GC heap after
Heap after GC invocations=1 (full 0):
 PSYoungGen      total 18944K, used 2557K [0x00000000eab00000, 0x00000000ec000000, 0x0000000100000000)
  eden space 16384K, 0% used [0x00000000eab00000,0x00000000eab00000,0x00000000ebb00000)
  from space 2560K, 99% used [0x00000000ebb00000,0x00000000ebd7f4a0,0x00000000ebd80000)
  to   space 2560K, 0% used [0x00000000ebd80000,0x00000000ebd80000,0x00000000ec000000)
 ParOldGen       total 44032K, used 756K [0x00000000c0000000, 0x00000000c2b00000, 0x00000000eab00000)
  object space 44032K, 1% used [0x00000000c0000000,0x00000000c00bd238,0x00000000c2b00000)
 Metaspace       used 8681K, capacity 8751K, committed 8960K, reserved 1056768K
  class space    used 885K, capacity 918K, committed 1024K, reserved 1048576K
}

Deoptimization events (0 events):
No events

Internal exceptions (10 events):
Event: 3.480 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaa43a0) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.484 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaa5a38) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.490 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaa70c0) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.523 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaa87c0) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.526 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaa9ef0) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.529 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaab5d8) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.568 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaaccb8) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.590 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaae398) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.600 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebaafa68) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]
Event: 3.603 Thread 0x00000000003ef000 Exception <a 'java/security/PrivilegedActionException'> (0x00000000ebab10b8) thrown at [D:\re\workspace\8-2-build-windows-amd64-cygwin\jdk8u25\1677\hotspot\src\share\vm\prims\jvm.cpp, line 1312]

Events (10 events):
Event: 23.658 Executing VM operation: GetOrSetLocal
Event: 23.658 Executing VM operation: GetOrSetLocal done
Event: 29.716 Executing VM operation: EnterInterpOnlyMode
Event: 29.716 Executing VM operation: EnterInterpOnlyMode done
Event: 29.716 Executing VM operation: GetCurrentLocation
Event: 29.716 Executing VM operation: GetCurrentLocation done
Event: 29.716 Executing VM operation: ChangeSingleStep
Event: 29.717 Executing VM operation: ChangeSingleStep done
Event: 29.718 Executing VM operation: ChangeSingleStep
Event: 29.718 Executing VM operation: ChangeSingleStep done


Dynamic libraries:
0x000000013fb10000 - 0x000000013fb44000     C:\Program Files\Java\jre1.8.0_25\bin\javaw.exe
0x0000000076db0000 - 0x0000000076f5a000     C:\Windows\SYSTEM32\ntdll.dll
0x0000000076c90000 - 0x0000000076db0000     C:\Windows\system32\kernel32.dll
0x000007fefcc00000 - 0x000007fefcc6b000     C:\Windows\system32\KERNELBASE.dll
0x000007fefedd0000 - 0x000007fefeeab000     C:\Windows\system32\ADVAPI32.dll
0x000007fefebd0000 - 0x000007fefec6f000     C:\Windows\system32\msvcrt.dll
0x000007fefd910000 - 0x000007fefd92f000     C:\Windows\SYSTEM32\sechost.dll
0x000007fefd330000 - 0x000007fefd45d000     C:\Windows\system32\RPCRT4.dll
0x0000000076b90000 - 0x0000000076c8a000     C:\Windows\system32\USER32.dll
0x000007fefd4c0000 - 0x000007fefd527000     C:\Windows\system32\GDI32.dll
0x000007fefe740000 - 0x000007fefe74e000     C:\Windows\system32\LPK.dll
0x000007fefd530000 - 0x000007fefd5fa000     C:\Windows\system32\USP10.dll
0x000007fefb320000 - 0x000007fefb514000     C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_fa396087175ac9ac\COMCTL32.dll
0x000007fefd600000 - 0x000007fefd671000     C:\Windows\system32\SHLWAPI.dll
0x000007fefd680000 - 0x000007fefd6ae000     C:\Windows\system32\IMM32.DLL
0x000007fefeac0000 - 0x000007fefebc9000     C:\Windows\system32\MSCTF.dll
0x0000000065ba0000 - 0x0000000065c72000     C:\Program Files\Java\jre1.8.0_25\bin\msvcr100.dll
0x000000005d7a0000 - 0x000000005dffa000     C:\Program Files\Java\jre1.8.0_25\bin\server\jvm.dll
0x000007feef2c0000 - 0x000007feef2c9000     C:\Windows\system32\WSOCK32.dll
0x000007fefcf30000 - 0x000007fefcf7d000     C:\Windows\system32\WS2_32.dll
0x000007fefd6b0000 - 0x000007fefd6b8000     C:\Windows\system32\NSI.dll
0x000007fef94a0000 - 0x000007fef94db000     C:\Windows\system32\WINMM.dll
0x0000000076f80000 - 0x0000000076f87000     C:\Windows\system32\PSAPI.DLL
0x0000000073af0000 - 0x0000000073aff000     C:\Program Files\Java\jre1.8.0_25\bin\verify.dll
0x0000000073070000 - 0x0000000073098000     C:\Program Files\Java\jre1.8.0_25\bin\java.dll
0x0000000071030000 - 0x0000000071065000     C:\Program Files\Java\jre1.8.0_25\bin\jdwp.dll
0x0000000073060000 - 0x0000000073068000     C:\Program Files\Java\jre1.8.0_25\bin\npt.dll
0x00000000730b0000 - 0x00000000730c6000     C:\Program Files\Java\jre1.8.0_25\bin\zip.dll
0x000007fefd9b0000 - 0x000007fefe739000     C:\Windows\system32\SHELL32.dll
0x000007fefeeb0000 - 0x000007feff0b3000     C:\Windows\system32\ole32.dll
0x000007fefcb70000 - 0x000007fefcb7f000     C:\Windows\system32\profapi.dll
0x0000000072fb0000 - 0x0000000072fb9000     C:\Program Files\Java\jre1.8.0_25\bin\dt_socket.dll
0x000007fefaa80000 - 0x000007fefaa95000     C:\Windows\system32\NLAapi.dll
0x000007fefa330000 - 0x000007fefa345000     C:\Windows\system32\napinsp.dll
0x000007fefa120000 - 0x000007fefa139000     C:\Windows\system32\pnrpnsp.dll
0x000007fefc370000 - 0x000007fefc3c5000     C:\Windows\System32\mswsock.dll
0x000007fefc1f0000 - 0x000007fefc24b000     C:\Windows\system32\DNSAPI.dll
0x000007fefa630000 - 0x000007fefa63b000     C:\Windows\System32\winrnr.dll
0x000007fefa670000 - 0x000007fefa697000     C:\Windows\system32\IPHLPAPI.DLL
0x000007fefa660000 - 0x000007fefa66b000     C:\Windows\system32\WINNSI.DLL
0x000007fef9fa0000 - 0x000007fef9ff3000     C:\Windows\System32\fwpuclnt.dll
0x000007fefa320000 - 0x000007fefa328000     C:\Windows\system32\rasadhlp.dll
0x000007fefbd10000 - 0x000007fefbd17000     C:\Windows\System32\wshtcpip.dll
0x0000000180000000 - 0x0000000180064000     C:\Users\Demon\workspace\ogl\native\windows\OpenAL64.dll
0x0000000011e30000 - 0x0000000011e83000     C:\Users\Demon\workspace\ogl\native\windows\lwjgl64.dll
0x000007feedbd0000 - 0x000007feedced000     C:\Windows\system32\OPENGL32.dll
0x000007fef9a20000 - 0x000007fef9a4d000     C:\Windows\system32\GLU32.dll
0x000007feeb770000 - 0x000007feeb861000     C:\Windows\system32\DDRAW.dll
0x000007fef9aa0000 - 0x000007fef9aa8000     C:\Windows\system32\DCIMAN32.dll
0x000007fefe8e0000 - 0x000007fefeab7000     C:\Windows\system32\SETUPAPI.dll
0x000007fefcd20000 - 0x000007fefcd56000     C:\Windows\system32\CFGMGR32.dll
0x000007fefcf80000 - 0x000007fefd057000     C:\Windows\system32\OLEAUT32.dll
0x000007fefcf10000 - 0x000007fefcf2a000     C:\Windows\system32\DEVOBJ.dll
0x000007fefa8a0000 - 0x000007fefa8b8000     C:\Windows\system32\dwmapi.dll
0x000007fefbc40000 - 0x000007fefbc4c000     C:\Windows\system32\VERSION.dll
0x000007fefb140000 - 0x000007fefb196000     C:\Windows\system32\uxtheme.dll
0x000007feed2a0000 - 0x000007feed2e8000     C:\Users\Demon\AppData\Local\Temp\TeamViewer\tv_x64.dll
0x0000000059e90000 - 0x000000005bac0000     C:\Windows\system32\nvoglv64.DLL
0x000007fefcba0000 - 0x000007fefcbdb000     C:\Windows\system32\WINTRUST.dll
0x000007fefcd60000 - 0x000007fefcecd000     C:\Windows\system32\CRYPT32.dll
0x000007fefcb80000 - 0x000007fefcb8f000     C:\Windows\system32\MSASN1.dll
0x000007fefaef0000 - 0x000007fefaf1d000     C:\Windows\system32\ntmarta.dll
0x000007fefd460000 - 0x000007fefd4b2000     C:\Windows\system32\WLDAP32.dll
0x000007fefca10000 - 0x000007fefca1f000     C:\Windows\system32\CRYPTBASE.dll
0x000007fef94e0000 - 0x000007fef957c000     C:\Windows\system32\mscms.dll
0x000007fefced0000 - 0x000007fefceef000     C:\Windows\system32\USERENV.dll
0x000007fef1a60000 - 0x000007fef1aa2000     C:\Windows\system32\icm32.dll
0x0000000059cf0000 - 0x0000000059e88000     C:\Program Files\Java\jre1.8.0_25\bin\awt.dll
0x000007fef0e10000 - 0x000007fef0f35000     C:\Windows\system32\dbghelp.dll

VM Arguments:
jvm_args: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:50127 -Dfile.encoding=Cp1252 
java_command: ogl.gui.MainAppOGL
java_class_path (initial): C:\Users\Demon\workspace\ogl\bin;C:\Users\Demon\workspace\ogl\lib\lwjgl_util.jar;C:\Users\Demon\workspace\ogl\lib\lwjgl.jar;C:\Users\Demon\workspace\game\bin;C:\Users\Demon\workspace\jbox2d-library\target\classes;C:\Users\Demon\workspace\jbox2d-library\target\test-classes;C:\Users\Demon\Downloads\eclipse-jee-luna-SR2-win32-x86_64\eclipse\plugins\org.junit_4.11.0.v201303080030\junit.jar;C:\Users\Demon\workspace\math\bin;C:\Users\Demon\workspace\game\lib\asm-all-3.1.jar;C:\Users\Demon\workspace\game\lib\jbullet.jar;C:\Users\Demon\workspace\game\lib\stack-alloc.jar;C:\Users\Demon\workspace\game\lib\swing-layout-1.0.3.jar;C:\Users\Demon\workspace\game\lib\vecmath.jar;C:\Users\Demon\workspace\ui\bin
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:/Program Files/Java/jre1.8.0_25/bin/server;C:/Program Files/Java/jre1.8.0_25/bin;C:/Program Files/Java/jre1.8.0_25/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\Demon\Downloads\eclipse-jee-luna-SR2-win32-x86_64\eclipse;
USERNAME=Demon
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 23 Stepping 6, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 , 64 bit Build 7601 Service Pack 1

CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, tsc

Memory: 4k page, physical 4193396k(1615584k free), swap 8384932k(5290520k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (25.25-b02) for windows-amd64 JRE (1.8.0_25-b18), built on Oct  7 2014 14:25:37 by "java_re" with MS VC++ 10.0 (VS2010)

time: Fri May 22 23:50:01 2015
elapsed time: 29 seconds (0d 0h 0m 29s)

Answer:

I found it:

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

...

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

All client states have to be deactivated after every call on NVIDIA components.

Question:

im trying to create a obj loader. my camera and all works perfectly if i try to just draw a triangle with code and run. but when i try to use this obj loader on a simple box created in 3ds max then it all goes to hell.

to be specific the error goes:

exception in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Float.valueOf(Unknown Source)
at asdas.Loader.loadModel(Loader.java:16)
at asdas.ThreeDeeWorld.setUpBox(ThreeDeeWorld.java:43)
at asdas.ThreeDeeWorld.main(ThreeDeeWorld.java:28)

so it complains both about my loader and the way i try to draw and i cant see why? :/

This is my loader:

public static Model loadModel(File f) throws FileNotFoundException, IOException {

    BufferedReader reader = new BufferedReader(new FileReader(f));
    Model m = new Model();
    String line; 
    while ((line = reader.readLine())!= null){
        if (line.startsWith("v ")){
            Float x = Float.valueOf(line.split(" ")[1]);
            Float y = Float.valueOf(line.split(" ")[2]);
            Float z = Float.valueOf(line.split(" ")[3]);
            m.vertices.add(new Vector3f(x,y,z));
        } else if (line.startsWith("vn ")){
            Float x = Float.valueOf(line.split(" ")[1]);
            Float y = Float.valueOf(line.split(" ")[2]);
            Float z = Float.valueOf(line.split(" ")[3]);
            m.normals.add(new Vector3f(x,y,z));
        } else if (line.startsWith("f ")){
            Vector3f vertexIndices = new Vector3f(Float.valueOf(line.split(" ")[1].split("/")[0]), 
                    Float.valueOf(line.split(" ")[2].split("/")[0]),
                    Float.valueOf(line.split(" ")[3].split("/")[0]));

            Vector3f normalIndices = new Vector3f(Float.valueOf(line.split(" ")[1].split("/")[2]), 
                    Float.valueOf(line.split(" ")[2].split("/")[2]),
                    Float.valueOf(line.split(" ")[3].split("/")[2]));
            m.faces.add(new Face(vertexIndices, normalIndices));

        }
    }
    reader.close();
    return m;


}

}

this is how i try to load and draw the obj file:

public static void setUpBox() {
    int objectDisplayList = glGenLists(1);
    glNewList(objectDisplayList, GL_COMPILE);
    asdas.Model m = null;

    try { 
         m = Loader.loadModel(new File("src/box.obj.obj"));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                Display.destroy();
                System.exit(1);
            } catch (IOException e){
                e.printStackTrace();
                Display.destroy();
                System.exit(1);
            }
    glBegin(GL_TRIANGLES);
    for (Face face : m.faces) {
        Vector3f n1 = m.normals.get((int) face.normal.x -1);
        glNormal3f(n1.x, n1.y, n1.z);
        Vector3f v1 = m.vertices.get((int) face.vertex.x -1);
        glVertex3f(v1.x, v1.y, v1.z);
        Vector3f n2 = m.normals.get((int) face.normal.y -1);
        glNormal3f(n2.x, n2.y, n2.z);
        Vector3f v2 = m.vertices.get((int) face.vertex.y -1);
        glVertex3f(v2.x, v2.y, v2.z);
        Vector3f n3 = m.normals.get((int) face.normal.z -1);
        glNormal3f(n3.x, n3.y, n3.z);
        Vector3f v3 = m.vertices.get((int) face.vertex.z -1);
        glVertex3f(v3.x, v3.y, v3.z);

    }
    glEnd();
    glEndList();

}

my obj file looks like this:

# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 12.10.2014 15:11:35

#
# object Box001
#

v  -1.2169 0.0000 40.0295
v  -1.2169 0.0000 -42.7719
v  14.2454 0.0000 -42.7719
v  14.2454 0.0000 40.0295
v  -1.2169 32.5605 40.0295
v  14.2454 32.5605 40.0295
v  14.2454 32.5605 -42.7719
v  -1.2169 32.5605 -42.7719
# 8 vertices

vn 0.0000 -1.0000 -0.0000
vn 0.0000 1.0000 -0.0000
vn 0.0000 0.0000 1.0000
vn 1.0000 0.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 0.0000 -0.0000
# 6 vertex normals

f 1//1 2//1 3//1 
f 3//1 4//1 1//1 
f 5//2 6//2 7//2 
f 7//2 8//2 5//2 
f 1//3 4//3 6//3 
f 6//3 5//3 1//3 
f 4//4 3//4 7//4 
f 7//4 6//4 4//4 
f 3//5 2//5 8//5 
f 8//5 7//5 3//5 
f 2//6 1//6 5//6 
f 5//6 8//6 2//6 
# 12 faces

I really hope one of you guys can help me figure this out since i have spend several days on this mystery so far :/


Answer:

If you take a look at the line starting with v, you will see something interesting...

v  -1.2169 0.0000 40.0295

v and -1.2169 are separated by a double space (" "), not a single space, this means that when you split on a single space (" "), the extra space actually gets considered, not that anything is in between the two spaces, so you end up with a empty String

If you put in someting like...

String parts[] = line.split(" ");
for (String value : parts) {
    System.out.println("\"" + value + "\"");
}

before you try parsing the line, it will print

"v"
""
"-1.2169"
"0.0000"
"40.0295"

The simplest solution would be to start at index [2] instead of index [1], but me, personally, I'd be stripping off the leading "header" section up to the first number, but that's me...

line = line.substring(1).trim();
System.out.println(line);

Which outputs...

-1.2169 0.0000 40.0295

Now, you can just split it and use index [0], [1] and [2]...

Question:

I created a checkerboard/chessboard in opengl, it has 100 boxes. Logically I'm representing that board in a 2D array (10 by 10). Now I want the user to click anywhere in the opengl window and i can determine which index the box belongs to in the array, so that i can do some processing. How can i achieve that?

I'm using LWJGL a java wrapper for opengl. I know i have to get the mouse coordinates and i know they are returned in Normalized Device Coordinates ( in the range of 1 to -1) How can I map NDC to indexes? I've been searching but didn't find much.

I know the NDC ranges for each boxes. That's because i drew them by giving vertices so i know where each box starts and ends in NDC. But entering the ranges and its respective indexes in the form of key-value pairs would be too troublesome.

Currently I'm trying to create a formula through basic arithmetic such that it transforms NDC and gives me indexes. Is this possible? or is there any other feasible approach?

For those who are thinking how i have made the checkerboard, I drew vertical lines from -1 to 1 at a regular distance of 0.2. Similar is the case for horizontal ones.


Answer:

If you are drawing directly in screen space it is quite easy to compute the box indices from NDC coords:

index.x = (int) ((ndc.x/2.0f + 0.5f) * boardSize.x)
index.y = (int) ((ndc.y/2.0f + 0.5f) * boardSize.y)
if (index.x == boardSize.x) // in case ndc.x was exactly 1
    --index.x;
if (index.y == boardSize.y) // in case ndc.y was exactly 1
    --index.y;