Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  glDrawElements() unexplained ERROR!  (Read 5128 times)
0 Members and 1 Guest are viewing this topic.
Offline 2late4u

Senior Newbie




.....


« Posted 2004-03-24 05:15:55 »

i have a runtime error in this portion of code demended to draw a curved surface ..... my 3d engine is totally written in java using jogl .... and is capable to rendering Quake3 Level complete with lightmaps ... (without curved surface right now Sad)
the code is:
-----------------------------------------------------------

public void draw(GL gl) {
           list = gl.glGenLists(1);
      gl.glNewList(list, gl.GL_COMPILE_AND_EXECUTE);
           int total = meshArray.length;
           int line = meshArray[0].length;

       for (int i = 0; i < total;  i++)
            gl.glDrawElements(gl.GL_TRIANGLE_STRIP, line, gl.GL_UNSIGNED_INT, meshArray);
           gl.glEndList();
     }

------------------------------------------------------------

ERROR:
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x1CEEFC84
Function=DrvSetLayerPaletteEntries+0x138E34
Library=C:\WINNT\System32\i81xgicd.dll

I've tryen on other machine..but error is the same ...
QUESTION:
1 - Whats wrong?
2 - Do exists a different method for rendering CURVED SURFACE
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2004-03-24 07:26:34 »

glDrawElements' second parameter is the number of primatives to render, not vertices. Replace 'line' with
1  
meshArray[i].length - 2

for triangle strips.

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

Junior Member




Java games rock!


« Reply #2 - Posted 2004-03-24 08:08:39 »

No he got it right : glDrawElements' second parameter is the number of indices to be read from the array.

I have no idea where the problem could come from. And the error message is not really helpful... Do you know if the equivalent C code run on your machine ?

EDIT : Probably a dumb thing to ask but your meshArray contains indices, not vertex data ?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2004-03-24 08:21:11 »

/me squints at OpenGL docs again

Oops, my bad. Odd choice of words in the docs I've got here though Embarrassed

In that case, I'd check your indices are right. If they're too big they could be trying to reference some arbitrary point in memory (hence the access violation).

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

Junior Member




Java games rock!


« Reply #4 - Posted 2004-03-24 09:19:55 »

Orangy Tang : The term 'count' is quite misleading, they should have called it nbIndices. I googled a bit to be sure before posting  Wink

2late4u : Do you have a gfx card or a on-board graphics controller ? From the message error I'd say the latter. OpenGL drivers for such chipsets can be really crappy, did you have any problem with native apps ?
Offline milvich

Senior Newbie




Java games rock!


« Reply #5 - Posted 2004-03-24 12:21:18 »

Does each one of your "lines" in your mesh array have the same number of indices? Also, check to make sure that your array pointers are valid, and have enough vertices to match up with your indices.
Offline 2late4u

Senior Newbie




.....


« Reply #6 - Posted 2004-03-24 13:21:17 »

I have got a Radeon 9600Pro ... but the code .. hit down with the same error.. on Nvidia 5200Fx and radeon 9100 too ....
damned

the method works fine for other surface ...
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #7 - Posted 2004-03-24 13:59:01 »

Post more code! It would be nice to see how you create and fill those mesh arrays. And how you create and bind your vertex/texCoord arrays as well.

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

Senior Newbie




Java games rock!


« Reply #8 - Posted 2004-03-24 15:27:21 »

1  
2  
3  
4  
int line = meshArray[0].length;
 
   for (int i = 0; i < total;  i++)
   gl.glDrawElements(gl.GL_TRIANGLE_STRIP, line, gl.GL_UNSIGNED_INT, meshArray[i]);


are you really sure, you want to say meshArray[0].length? Effectively using the same length for all your arrays?
I think you need to get the length for each array-entry in the for-loop.
Or do all of them have exactly the same length?
Offline 2late4u

Senior Newbie




.....


« Reply #9 - Posted 2004-03-25 03:56:24 »

.... the generic algorithm approssimation must be like this

1  
2  
3  
4  
5  
6  
int line;  
   for (int i = 0; i < total;  i++)
   {
          line = meshArray[i].length;
          gl.glDrawElements(gl.GL_TRIANGLE_STRIP, line, gl.GL_UNSIGNED_INT, meshArray[i]);
    }  

but the error is the same ....
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jeickmann

Senior Newbie




Java games rock!


« Reply #10 - Posted 2004-03-25 05:20:22 »

Can you post your vertex-arrays setup code?
Maybe the error is there.
Offline 2late4u

Senior Newbie




.....


« Reply #11 - Posted 2004-03-25 13:58:56 »


this is the vertex array setup ..... but the bug cannot be in this code .... infact it works fine with FlatSurface and Mesh ..... it fails only with Patch surface ....

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
      public void prepareArray(GL gl, int flags) {

    gl.glClientActiveTextureARB(gl.GL_TEXTURE0_ARB);
      if ((flags & VERTEX) > 0)
                  gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertBuffer);
        if ((flags & TEXTURE) > 0)
                  gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, texBuffer );
       if ((flags & LIGHTMAP) > 0)
        {
                  gl.glClientActiveTextureARB(gl.GL_TEXTURE1_ARB);
              gl.glEnable(gl.GL_TEXTURE_2D);
                  gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, lmBuffer );
                  gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY);
            }

          gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
            gl.glActiveTextureARB(gl.GL_TEXTURE1_ARB);
          gl.glTexEnvf (gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_COMBINE_EXT);

                        // Operator.
                     gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_RGB_EXT, gl.GL_MODULATE);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_ALPHA_EXT, gl.GL_MODULATE );
                      // Arg0.

                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE0_RGB_EXT, gl.GL_PREVIOUS_EXT );
//                      gl.glTexEnvfv(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_COLOR, new float [] { 0.3f, 0.3f, 0.3f, 0.0f} );
                     gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_OPERAND0_RGB_EXT,  gl.GL_SRC_COLOR);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE0_ALPHA_EXT,  gl.GL_PREVIOUS_EXT);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_OPERAND0_ALPHA_EXT, gl.GL_SRC_ALPHA );

                      // Arg1.
                     gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE1_RGB_EXT, gl.GL_TEXTURE);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_OPERAND1_RGB_EXT, gl.GL_SRC_COLOR);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE1_ALPHA_EXT, gl.GL_TEXTURE );
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_OPERAND1_ALPHA_EXT, gl.GL_SRC_ALPHA );

                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE2_RGB_EXT, gl.GL_PRIMARY_COLOR_EXT);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_OPERAND2_RGB_EXT, gl.GL_SRC_COLOR);
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE2_ALPHA_EXT, gl.GL_PRIMARY_COLOR_EXT );
                      gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_OPERAND2_ALPHA_EXT, gl.GL_SRC_ALPHA );

      }


The engine works fine ..... but it doesn't render curved surface .... HELP PLEASE!
Offline 2late4u

Senior Newbie




.....


« Reply #12 - Posted 2004-03-25 14:03:00 »

this is my MeshSurface Class.....

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
public class MeshSurface extends Surface {
      public int [] mesh;

      int list;
     
      public void draw(GL gl) {
            list = gl.glGenLists(1);
            gl.glNewList(list, gl.GL_COMPILE_AND_EXECUTE);
            gl.glDrawElements(gl.GL_TRIANGLES, mesh.length, gl.GL_UNSIGNED_INT, mesh);
            gl.glEndList();
      }

      public void draw(GL gl, GLU glu, VertexArray vertexArray) {
            gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB);
            gl.glEnable(gl.GL_TEXTURE_2D);

                  gl.glBindTexture(gl.GL_TEXTURE_2D, shader.texture[0]);
                  gl.glCallList(list);
      }
}
Offline 2late4u

Senior Newbie




.....


« Reply #13 - Posted 2004-03-25 14:04:52 »

and this is the ...... CurvedSurface class ..... tha FAILS!!!

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
public class CurvedSurface extends Surface
{
      public int [][] meshArray = null;
      int list;

    public void draw(GL gl) {
            list = gl.glGenLists(1);
       gl.glNewList(list, gl.GL_COMPILE_AND_EXECUTE);
            int total = meshArray.length;
            int line = meshArray[0].length;

        for (int i = 0; i < total;  i++)
             gl.glDrawElements(gl.GL_TRIANGLES, meshArray[i].length, gl.GL_UNSIGNED_INT, meshArray[i]);
            gl.glEndList();
      }

     
      public void draw(GL gl, GLU glu, VertexArray vertexArray) {
            gl.glActiveTextureARB(gl.GL_TEXTURE0_ARB);
            gl.glEnable(gl.GL_TEXTURE_2D);

                  gl.glBindTexture(gl.GL_TEXTURE_2D, shader.texture[0]);
                  gl.glCallList(list);
      }
}



damned!
Offline jeickmann

Senior Newbie




Java games rock!


« Reply #14 - Posted 2004-03-26 11:37:07 »

You can try to use the IntBuffer based version of glDrawElements. Create a direct int-buffer with jogl's BufferUtils-class and use that one instead of the int-array.
Direct Buffers are on the native side of JNI, maybe the gc shuffles your int-array around and the pointer is no longer valid, when the GL accesses it after your DrawElements-call has returned.
Maybe your curved-surfaces are bigger than the others and this results in the gc kicking in or something...

Jan
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!