Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (856)
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  
  Question about glDrawElements  (Read 1362 times)
0 Members and 1 Guest are viewing this topic.
Offline vinodpatel

Senior Newbie





« Posted 2007-06-19 04:42:37 »


Hi All,

      Any one know, when program can crash by running glDrawElements method. I mean, is there any flag or status that crash the animation program?.

Thanks In Advance,
Vinod Patel
Offline turquoise3232

Junior Devvie




Java (games) rock!


« Reply #1 - Posted 2007-06-19 09:42:19 »

Hi the answer to your question must be in the sticky post just above yours...
http://www.java-gaming.org/forums/index.php?topic=11947.0
Offline vinodpatel

Senior Newbie





« Reply #2 - Posted 2007-06-19 11:58:30 »


Hi,
        I have read and done all stuff suggested in given link. Although it does not work.
        Any other solution for that...?

Regards
Patel Vinod
       
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lhkbob

JGO Knight


Medals: 32



« Reply #3 - Posted 2007-06-19 14:04:30 »

You flipped your name and before anyone call help you or tell you how to fix something, they need to know a little more context (ie post a small sample of code where the problem lies).

Offline vinodpatel

Senior Newbie





« Reply #4 - Posted 2007-06-20 04:43:29 »

Hello,

         This is a code where i getting problem
*********
   if (m_Texturing && m_EnvMapOn && normals != null) {
         CQ3DMatrix worldview = new CQ3DMatrix();
         worldview.mul(m_ViewMatrix, m_WorldMatrix);
         for (int i = 0, face = 0; i < nbIndex; i += 3, face++) {
            CQ3DVector normal = new CQ3DVector();

            normal.assign(normals[face]);
            normal.transformNoTrans(worldview);

            if (m_NormalizeNormals) {
               normal.normalize(); // Maybe a scale Huh
            }

            float UV[] = new float[2];

            UV[0] = normal.m_Vector.x * 0.5f + 0.5f;
            UV[1] = normal.m_Vector.y * 0.5f + 0.5f;

            float norm[] = new float[3];
            norm[0] = normals[face].x;
            norm[1] = normals[face].y;
            norm[2] = normals[face].z;

            m_gl.glBegin(GL.GL_TRIANGLES);
            m_gl.glNormal3fv(norm, 0);
            m_gl.glTexCoord3fv(UV, 0);
            norm[0] = vertices[faces[face + faceindex].a].pos.x;
            norm[1] = 0;
            norm[2] = 0;
            m_gl.glVertex3fv(norm, 0);
            norm[0] = vertices[faces[face + faceindex].b].pos.x;
            m_gl.glVertex3fv(norm, 0);
            norm[0] = vertices[faces[face + faceindex].c].pos.x;
            m_gl.glVertex3fv(norm, 0);
            m_gl.glEnd();
         }

      }

      SQ3DVERTEX[] Vertices = prepareVertices(vertices, nbVertices);

      m_gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
      
      FloatBuffer buffer = BufferUtil.newFloatBuffer(Vertices.length * 2);
      if (m_Texturing && !m_GenerateTexCoords) {
         m_gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
         for (int Icount = 0; Icount < Vertices.length; Icount++) {
            buffer.put(Vertices[Icount].u);
            buffer.put(Vertices[Icount].v);
         }
         buffer.rewind();
         m_gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, buffer);
      } else {
         m_gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
      }

      buffer = BufferUtil.newFloatBuffer(Vertices.length * 3);
      for (int Icount = 0; Icount < Vertices.length; Icount++) {
         buffer.put(Vertices[Icount].pos.x);
         buffer.put(Vertices[Icount].pos.y);
         buffer.put(Vertices[Icount].pos.z);
      }
      buffer.rewind();
      m_gl.glVertexPointer(3, GL.GL_FLOAT, 0, buffer);

      if (normals == null) {
         m_gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
         buffer = BufferUtil.newFloatBuffer(Vertices.length*3);
         for (int Icount = 0; Icount < Vertices.length; Icount++) {
            buffer.put(Vertices[Icount].normal.x);
            buffer.put(Vertices[Icount].normal.y);
            buffer.put(Vertices[Icount].normal.z);
         }
         buffer.rewind();
         m_gl.glNormalPointer(GL.GL_FLOAT, 0, buffer);

         ShortBuffer shBuf = BufferUtil.newShortBuffer(faces.length * 3);
         for (int Icount = faceindex; Icount < faces.length; Icount++) {
            shBuf.put((short) faces[Icount].a);
            shBuf.put((short) faces[Icount].b);
            shBuf.put((short) faces[Icount].c);
         }
         shBuf.rewind();
         
         m_gl.glDrawElements(GL.GL_TRIANGLES, (int) nbIndex,GL.GL_UNSIGNED_SHORT, shBuf);
         //m_gl.glDrawRangeElements(GL.GL_TRIANGLES,0,(int)nbIndex-1,(int)nbIndex,GL.GL_UNSIGNED_SHORT, shBuf);
         m_gl.glDisableClientState(GL.GL_NORMAL_ARRAY);
      } else {
         m_gl.glDisableClientState(GL.GL_NORMAL_ARRAY);
         m_gl.glBegin(GL.GL_TRIANGLES);
         for (int i = 0, face = 0; i < nbIndex; i += 3) {
            buffer.put(0, normals[face].x);
            buffer.put(1, normals[face].y);
            buffer.put(2, normals[face].z);
            m_gl.glNormal3fv(buffer);
            m_gl.glArrayElement(faces[face + faceindex].a);
            m_gl.glArrayElement(faces[face + faceindex].b);
            m_gl.glArrayElement(faces[face + faceindex].c);
            face++;
         }
         m_gl.glEnd();
         m_gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
      }

      m_gl.glDisableClientState(GL.GL_VERTEX_ARRAY);

      if (m_Texturing && !m_GenerateTexCoords) {
         m_gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);
      }

Regards.
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (696 views)
2018-11-16 13:46:03

hadezbladez (344 views)
2018-11-16 13:41:33

hadezbladez (678 views)
2018-11-16 13:35:35

hadezbladez (169 views)
2018-11-16 13:32:03

EgonOlsen (2362 views)
2018-06-10 19:43:48

EgonOlsen (2474 views)
2018-06-10 19:43:44

EgonOlsen (1463 views)
2018-06-10 19:43:20

DesertCoockie (2128 views)
2018-05-13 18:23:11

nelsongames (1904 views)
2018-04-24 18:15:36

nelsongames (2571 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!