Hello Guest

VM Crash at VAO / VBO drawing

  • 5 Replies
  • 7800 Views
*

Offline Meanz

  • *
  • 40
VM Crash at VAO / VBO drawing
« on: September 29, 2011, 23:14:37 »
[VBO Supported]
[VAO Supported]
[Anistropic Filtering Supported]

(Tried Ani off / on)

Code: [Select]
---------------  T H R E A D  ---------------

Current thread (0x00299400):  JavaThread "main" [_thread_in_native, id=6100, stack(0x00470000,0x004c0000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x00000000, EBX=0x00001400, ECX=0xffffffff, EDX=0x00000000
ESP=0x004bf928, EBP=0x00000000, ESI=0x00000000, EDI=0x05f30068
EIP=0x04f9e6b0, EFLAGS=0x00010206

Top of Stack: (sp=0x004bf928)
0x004bf928:   00000007 05ffe807 05f30068 05ffe407
0x004bf938:   04f9e9dc 00000007 00001400 00001405
0x004bf948:   00000000 00001400 00000000 00000000
0x004bf958:   004bf9c4 3425aa18 00299400 3425aa18
0x004bf968:   1000c338 00000007 00001400 00001405
0x004bf978:   00000000 02499f47 00299518 004bf9cc
0x004bf988:   00000007 00001400 00001405 00000000
0x004bf998:   00000000 04f29410 00000000 004bf9a4

Instructions: (pc=0x04f9e6b0)
0x04f9e6a0:   e8 02 75 5f 33 ed 85 db 7e 59 8d 9b 00 00 00 00
0x04f9e6b0:   8b 04 aa 3b c8 0f 43 c8 3b f0 0f 46 f0 45 3b eb


Stack: [0x00470000,0x004c0000],  sp=0x004bf928,  free space=13e004bf40ck
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ig4icd32.dll+0x9e6b0]

[error occurred during error reporting (printing native stack), id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.GL11.nglDrawElementsBO(IIIJJ)V+0
j  org.lwjgl.opengl.GL11.glDrawElements(IIIJ)V+28
j  org.meanzoft.fractalworld.render.VAO.render()V+32
j  org.meanzoft.fractalworld.world.Chunk.draw()V+33
J  org.meanzoft.fractalworld.world.World.drawChunks(Lorg/lwjgl/util/vector/Vector3f;I)V
j  org.meanzoft.fractalworld.Game.render()V+170
j  org.meanzoft.fractalworld.Game.gameLoop()V+80
j  org.meanzoft.fractalworld.Game.<init>()V+385
j  org.meanzoft.fractalworld.Client.start()V+8
j  org.meanzoft.fractalworld.Client.<init>()V+5
j  org.meanzoft.fractalworld.Launcher.main([Ljava/lang/String;)V+4
v  ~StubRoutines::call_stub

That is the thread stack from the error file. Not so familiar with VM crashes so :p

Got any ideas? Oh and the graphics card is Intel GMA 4500M (Yeah I know it's crap, the laptop is mainly for schoolwork anyways).


Oh and yeah forgot to mention, it works fine on a GTX560Ti


(Have to run to bed so ill just post all the info I can post)

Code: [Select]
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.meanzoft.fractalworld.render;

import java.nio.FloatBuffer;
import org.lwjgl.opengl.ARBVertexBufferObject;

/**
 *
 * @author Meanz
 */
public class VBO {

    public static final int TARGET_DATA = ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB;
    public static final int TARGET_INDEX = ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB;
    public static final int BUFFER_DYNAMIC_DRAW = ARBVertexBufferObject.GL_DYNAMIC_DRAW_ARB;
    public static final int BUFFER_STATIC_DRAW = ARBVertexBufferObject.GL_STATIC_DRAW_ARB;
    public static final int BUFFER_DYNAMIC_READ = ARBVertexBufferObject.GL_DYNAMIC_READ_ARB;
   
    private int id;
    private int target;

    public static VBO create(int target) {
        return new VBO(target);
    }

    public VBO(int target) {
        id = ARBVertexBufferObject.glGenBuffersARB();
        this.target = target;
    }

    public void bind() {
        ARBVertexBufferObject.glBindBufferARB(target, id);
    }

    public void buffer(int type, FloatBuffer buffer) {
        ARBVertexBufferObject.glBufferDataARB(target, buffer, type);
    }

    public void unbind() {
        ARBVertexBufferObject.glBindBufferARB(target, 0);
    }
   
    public void unmap() {
        ARBVertexBufferObject.glUnmapBufferARB(target);
    }
}
Code: [Select]
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.meanzoft.fractalworld.render;

import java.util.LinkedList;
import org.lwjgl.opengl.ARBVertexArrayObject;

import static org.lwjgl.opengl.GL11.*;
/**
 *
 * @author Meanz
 */
public class VAO {

    private int id;
    private LinkedList<DrawableObject> objects;
    private int numVertices;
    private boolean isBuffered;

    public static VAO create() {
        return new VAO();
    }

    public VAO() {
        id = ARBVertexArrayObject.glGenVertexArrays();
        objects = new LinkedList<DrawableObject>();
        isBuffered = false;
    }

    public void addObject(DrawableObject obj) {
        objects.add(obj);
    }

    public void buffer() {
        isBuffered = true;
        numVertices = 0;
        bind();
        {
            for (DrawableObject obj : objects) {
                numVertices += obj.getNumVertices();
                obj.update();
            }
        }
        unbind();
    }

    public void render() {
        if(!isBuffered) {
            return;
        }
        bind();
        {
            glEnableClientState(GL_VERTEX_ARRAY);
            //glEnableClientState(GL_NORMAL_ARRAY);
            //glEnableClientState(GL_COLOR_ARRAY);
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glDrawElements(GL_QUADS, numVertices, GL_UNSIGNED_INT, 0);
            glDisableClientState(GL_VERTEX_ARRAY);
            //glDisableClientState(GL_COLOR_ARRAY);
            //glDisableClientState(GL_NORMAL_ARRAY);
            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        }
        unbind();
    }

    public void bind() {
        ARBVertexArrayObject.glBindVertexArray(id);
    }

    public void unbind() {
        ARBVertexArrayObject.glBindVertexArray(0);
    }
}
Code: [Select]
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.meanzoft.fractalworld.render;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;

import static org.lwjgl.opengl.GL11.*;

/**
 *
 * @author Meanz
 */
public abstract class DrawableObject {

    public static int VERTEX_SIZE = 12;
    public static int TEX_COORD_SIZE = 8;
    public static int NORMAL_SIZE = 12;
    public static int COLOR_SIZE = 12;
    private VBO dataVBO;
    private VBO indexVBO;
    private ByteBuffer data;
    private ByteBuffer index;
    private int numVertices;
    private int numTexCoords;
    private boolean usingTexCoords, usingNormals, usingColors, isBuffered;

    public DrawableObject() {
        dataVBO = VBO.create(VBO.TARGET_DATA);
        indexVBO = VBO.create(VBO.TARGET_INDEX);
        allocate(0);
        allocateIndex(0);
    }

    public void update() {
        if(isBuffered) {
            dataVBO.bind();
            indexVBO.bind();
            return;
        }
        isBuffered = true;
        /**
         * Buffer the data
         */
        dataVBO.bind();
        {
            dataVBO.buffer(VBO.BUFFER_DYNAMIC_DRAW, ((ByteBuffer) data.flip()).asFloatBuffer());
            /**
             * Set up the attributes
             */
            int ELEMENT_SIZE = (usingTexCoords ? TEX_COORD_SIZE : 0) + (usingNormals ? NORMAL_SIZE : 0) + (usingColors ? COLOR_SIZE : 0) + VERTEX_SIZE;
            glVertexPointer(3, GL_FLOAT, ELEMENT_SIZE, 0);
            if (usingTexCoords) {
                glTexCoordPointer(2, GL_FLOAT, ELEMENT_SIZE, VERTEX_SIZE);
            }
            if (usingColors) {
                glColorPointer(3, GL_FLOAT, ELEMENT_SIZE, (usingTexCoords ? TEX_COORD_SIZE : 0) + VERTEX_SIZE);
            }
            if (usingNormals) {
                glNormalPointer(GL_FLOAT, ELEMENT_SIZE, (usingTexCoords ? TEX_COORD_SIZE : 0) + (usingColors ? COLOR_SIZE : 0) + VERTEX_SIZE);
            }
            /**
             * Buffer the index
             */
            indexVBO.bind();
            {
                /**
                 * Kinda genius, if we don't define any indexes it will automatically detect that and create it for us using ascending ordering.
                 */
                if (index.position() == 0) {
                    allocateIndex(numVertices * 4);
                    for (int i = 0; i < numVertices; i++) {
                        index.putInt(i);
                    }
                }
                indexVBO.buffer(VBO.BUFFER_DYNAMIC_READ, ((ByteBuffer) index.flip()).asFloatBuffer());
            }
        }
    }

    /**
     * Attribute operations
     */
    public int getNumTexCoords() {
        return numTexCoords;
    }

    public int getNumVertices() {
        return numVertices;
    }

    public boolean isUsingColors() {
        return usingColors;
    }

    public void setUsingColors(boolean usingColors) {
        this.usingColors = usingColors;
    }

    public boolean isUsingNormals() {
        return usingNormals;
    }

    public void setUsingNormals(boolean usingNormals) {
        this.usingNormals = usingNormals;
    }

    public boolean isUsingTexCoords() {
        return usingTexCoords;
    }

    public void setUsingTexCoords(boolean usingTexCoords) {
        this.usingTexCoords = usingTexCoords;
    }

    /**
     * Buffer operations (Data operations)
     */
    public void allocateIndex(int size) {
        index = ByteBuffer.allocateDirect(size);
        index.order(ByteOrder.nativeOrder());
    }

    public void allocate(int size) {
        data = ByteBuffer.allocateDirect(size);
        data.order(ByteOrder.nativeOrder());
    }

    public void clear() {
        data.clear();
        index.clear();
        numVertices = 0;
        numTexCoords = 0;
        isBuffered = false;
    }

    public void addIndex(int idx) {
        index.putInt(idx);
    }

    public void addFloat(float x, float y, float z) {
        data.putFloat(x);
        data.putFloat(y);
        data.putFloat(z);
    }

    public void addFloat(float x, float y) {
        data.putFloat(x);
        data.putFloat(y);
    }

    public void addVertex(Vector3f vert) {
        addVertex(vert.x, vert.y, vert.z);
    }

    public void addVertex(float x, float y, float z) {
        addFloat(x, y, z);
        numVertices++;
    }

    public void addTexCoord(Vector2f texCoord) {
        addTexCoord(texCoord.x, texCoord.y);
    }

    public void addTexCoord(float x, float y) {
        addFloat(x, y);
        numTexCoords++;
    }

    public void addNormal(Vector3f normal) {
        addNormal(normal.x, normal.y, normal.z);
    }

    public void addNormal(float x, float y, float z) {
        addFloat(x, y, z);
    }
}
« Last Edit: September 29, 2011, 23:35:01 by Meanz »

*

Offline princec

  • *****
  • 1933
    • Puppygames
Re: VM Crash at VAO / VBO drawing
« Reply #1 on: September 30, 2011, 19:09:55 »
Crap drivers. End of. Give up or find new drivers. Don't expect to code around it. I imagine you still have enough hair not to mind losing a bit now but believe me when you get to my age you'll wish you'd taken better care of it when you were younger...

Cas :)

Re: VM Crash at VAO / VBO drawing
« Reply #2 on: September 30, 2011, 20:46:50 »
What happens if you try the GL implementation of VBOs rather than ARB? Just curious.  ::)
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline Meanz

  • *
  • 40
Re: VM Crash at VAO / VBO drawing
« Reply #3 on: October 02, 2011, 01:32:21 »
@princec

So it's definately my drivers and not my code, and if yes, what made you conclude with that :p? And well, you can purchase those expensive hair replacement things, ya know =)

@elias4444

I will look into it and post the results, however atm I don't know the difference about the GL implementation of VBO's and ARB ;p
Anyways google will sort that out for me.

Re: VM Crash at VAO / VBO drawing
« Reply #4 on: October 02, 2011, 16:24:27 »
I'm really not sure if it'll make a difference at all (they probably both link to the same API calls anyway). I was just curious if it made any difference as far as the drivers were concerned.

As far as switching it over, it's all located in GL15. Just remove the "ARB" at the end of all the calls and stick "GL15." at the front.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

*

Offline Meanz

  • *
  • 40
Re: VM Crash at VAO / VBO drawing
« Reply #5 on: October 03, 2011, 09:56:21 »
Yeah the ARB values are the same as the GL15. ones.
Still crashing and making me annoyed because I can't program in class.. Which makes class boring.