Hello Guest

Problem with Vertex Arrays - please help

  • 4 Replies
  • 3888 Views
Problem with Vertex Arrays - please help
« on: October 25, 2004, 08:02:52 »
Ok, so this is my source, more or less:

   for (int i = -10; i <= 10; i++) {
      for (int j = -20; j <= 20; j++) {
        if (j % 2 != 0) {
          offset = 0.5f;
        } else {
          offset = 0.0f;
        }

        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        FloatBuffer b = BufferUtils.createFloatBuffer(3 * 4);
        b.put((float) ((i + offset) * 1.4142f));
        b.put((float) (j * 0.7071f));
        b.put(0.0f);
        b.put((float) ((i + 0.5f + offset) * 1.4142f));
        b.put((float) ((j - 1.0f) * 0.7071f));
        b.put(0.0f);
        b.put((float) ((i + 1.0f + offset) * 1.4142f));
        b.put((float) (j * 0.7071f));
        b.put(0.0f);
        b.put((float) ((i + 0.5f + offset) * 1.4142f));
        b.put((float) ((j + 1.0f) * 0.7071f));
        b.put(0.0f);
        b.flip();
        ByteBuffer b2 = ByteBuffer.allocateDirect(1024).order(ByteOrder.nativeOrder());
        b2.put((byte) 0).put((byte) 1).put((byte) 0).put((byte) 1);
        b2.flip();
        GL11.glVertexPointer(3, GL11.GL_FLOAT, b);
        GL11.glDrawElements(GL11.GL_QUADS, b2); ***
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

Each time I try to run it I get this error:

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x3DC003D
Function=[Unknown.]
Library=(N/A)

NOTE: We are unable to locate the function name symbol for the error
      just occurred. Please refer to release documentation for possible
      reason and solutions.


Current Java thread:
   at org.lwjgl.opengl.GL11.nglDrawElements(Native Method)
   at org.lwjgl.opengl.GL11.glDrawElements(Unknown Source)
   at client.OpenGLController.initGameView(OpenGLController.java:180)
   at client.OpenGLController.<init>(OpenGLController.java:74)
   at client.GUIController.run(GUIController.java:127)

The line it's referring to is marked with ***s.

ps.: Everything else works, the openGL context is up, running and rendering, if I just other GL11-functions.

*

Offline princec

  • *****
  • 1931
    • Puppygames
Problem with Vertex Arrays - please help
« Reply #1 on: October 25, 2004, 09:16:31 »
Could be a driver problem. What drivers / OS are you on?

Cas :)

Problem with Vertex Arrays - please help
« Reply #2 on: October 25, 2004, 10:19:37 »
WinXP SP2, and everything else runs fine :|

*

Offline elias

  • *****
  • 899
    • http://oddlabs.com
Problem with Vertex Arrays - please help
« Reply #3 on: October 25, 2004, 11:05:18 »
Try using a ShortBuffer for indices. Byte indices are not very common, as far as I know. If that works, it could be a driver bug.

 - elias

Problem with Vertex Arrays - please help
« Reply #4 on: October 25, 2004, 19:07:27 »
That seems to have fixed it, I'll update this if it keeps working (the bug doesnt show up 100% of the time).