Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  glVertexPointer NIO problem  (Read 831 times)
0 Members and 2 Guests are viewing this topic.
Offline aaron_08544

JGO n00b
*

Posts: 7


Java games rock!


« on: 2003-11-11 16:56:27 »

Hi,

I am using the glVertexPointer with JOGL which in turn uses the new NIO feature in JDK 1.4 (as opposed to float[] in gl4java) to setup the vertex array. Occasionally (>50%) I will get EXCEPTION_ACCESS_VIOLATION error in the native code when executing net.java.games.jogl.impl.windows.WindowsGLImpl.glArrayElement(Native Method)

Since I am new to NIO, is there anything I should look out for? I am porting my project from gl4java so the original code works fine.

Thanks and appreciate for any suggestions.
Aaron

Offline Orangy Tang

JGO Kernel
*****

Posts: 2960
Medals: 37


Monkey for a head


« Reply #1 on: 2003-11-11 17:38:33 »

The first thing to check would be the number of elements you're passing in to drawArrays/drawElements to see if you're going past the end of the array. But if you've switched straight from an existing app this is probably ok.

In terms of NIO specific, its very easy to forget to call .clear and .rewind before you fill it with data again, and end up putting data in places you don't expect.

Short of that, hows about seeing some code?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Ken Russell

JGO Kernel
*****

Posts: 3446
Medals: 3


Java games rock!


« Reply #2 on: 2003-11-11 17:51:28 »

You may want to look at the VertexArrayRange and VertexBufferObject demos in the jogl-demos project on java.net; unlike these demos you should use the SIZEOF_FLOAT and SIZEOF_INT constants in net.java.games.jogl.util.BufferUtils if necessary.
Games published by our own members! Go get 'em!
Offline aaron_08544

JGO n00b
*

Posts: 7


Java games rock!


« Reply #3 on: 2003-11-11 19:43:26 »

Here's my code to set the array:
where the varray is a set of {x,y,z} and tarray is a set of {s,t}

  public void setVertexArrayPtr(float[] varray)              {
      FloatBuffer f = net.java.games.jogl.util.BufferUtils.newFloatBuffer(varray.length);
      f.put(varray);
      gl.glVertexPointer(3, GL.GL_FLOAT, 0, f);
  }
  public void setTextureArrayPtr(float[] tarray)             {
      FloatBuffer f = net.java.games.jogl.util.BufferUtils.newFloatBuffer(tarray.length);
      f.put(tarray);
      gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, f);
  }

Am I calling it correctly?
Aaron
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.066 seconds with 20 queries.