Exemple #1
0
void Surface::draw(RenderContext* renderContext)
{
  material.beginUse(renderContext);
  vertexArray.beginUse();

  if (material.texture)
    texCoordArray.beginUse();

  for(int iz=0;iz<nz-1;iz++) {
    glBegin(GL_QUAD_STRIP);
    for(int ix=0;ix<nx;ix++) {

      int i;

      i = (iz)  *nx+ix;
      if (material.lit)
        setNormal(ix, iz);
      glArrayElement( i );

      i = (iz+1)*nx+ix;
      if (material.lit)
        setNormal(ix, iz+1);
      glArrayElement( i );

    }
    glEnd();
  }

  if (material.texture)
    texCoordArray.endUse();

  vertexArray.endUse();

  material.endUse(renderContext);
}
Exemple #2
0
void SphereMesh::draw(RenderContext* renderContext)
{
  vertexArray.beginUse();

  if (genNormal)
    normalArray.beginUse();

  if (genTexCoord)
    texCoordArray.beginUse();

  for(int i=0; i<sections; i++ ) {

    int curr = i * (segments+1);
    int next = curr + (segments+1);

    glBegin(GL_QUAD_STRIP);
    for(int i=0;i<=segments;i++) {
      glArrayElement( next + i );
      glArrayElement( curr + i );
    }
    glEnd();
  }

  vertexArray.endUse();

  if (genNormal)
    normalArray.endUse();

  if (genTexCoord)
    texCoordArray.endUse();
}
//-----------------------------------------------------------------------------
void mglCanvasGL::quad_draw(long k1, long k2, long k3, long k4)
{
	glBegin(GL_QUADS);
	glArrayElement(k1);	glArrayElement(k2);
	glArrayElement(k4);	glArrayElement(k3);
	glEnd();
}
Exemple #4
0
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	
	// step 1,启用数组
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	
	// step 2,指定数组数据
	// glColorPointer(3, GL_FLOAT, 0, colors);
	// glVertexPointer(2, GL_INT, 0, vertics);
	glColorPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), &intertwined[0]);
	glVertexPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), &intertwined[3]);
	
	// step 3, 解引用和渲染
	glBegin(GL_TRIANGLES);
	glArrayElement(2);
	glArrayElement(3);
	glArrayElement(5);
	glEnd();
	
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	
	glFlush();
	
}
Exemple #5
0
//-----------------------------------------------------------------------------
void mglCanvasGL::line_draw(long k1, long k2)
{
	if(PDef==0)	return;
	set_pen(PDef,PenWidth, pPos);
	glBegin(GL_LINES);
	glArrayElement(k1);	glArrayElement(k2);
	glEnd();
}
Exemple #6
0
void draw_text() {
	glDrawElements(GL_TRIANGLES, _num_tris * 3, GL_UNSIGNED_INT, _tris);
	if(0) {
		glBegin(GL_TRIANGLES);
		glArrayElement(0);
		glArrayElement(1);
		glArrayElement(2);
		glEnd();
	}
}
//-----------------------------------------------------------------------------
void mglCanvasGL::line_draw(long k1, long k2)
{
	if(PDef==0)	return;
/*	unsigned pdef = PDef*0x10001;
	pdef = pdef << (int(100*pPos+0.5)%16);
	set_pen(pdef&0xffff,PenWidth);*/
	set_pen(PDef,PenWidth);
	glBegin(GL_LINES);
	glArrayElement(k1);	glArrayElement(k2);
	glEnd();
}
Exemple #8
0
void WidgetGL::paintGL()
{
    /*清除屏幕和深度缓存*/
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    /*重置当前的模型观察矩阵*/
    glLoadIdentity();   //将当前点移到了屏幕中心,X坐标轴从左至右,Y坐标轴从下至上,Z坐标轴从里至外
    glTranslatef( -1.0, 0.0, zoom-6.0 );
    //glRotatef( Angle, Xvector, Yvector, Zvector )负责让对象绕某个轴旋转,
    //Angle 通常是个变量代表对象转过的角度,
    //Xvector,Yvector和Zvector三个参数则共同决定旋转轴的方向.
    glRotatef( xRot,  1.0,  1.0,  1.0 );//绕着Y轴从左向右旋转
    glRotatef( yRot,  1.0,  1.0,  1.0 );//绕着Y轴从左向右旋转
    glRotatef( zRot,  1.0,  1.0,  1.0 );//绕着Y轴从左向右旋转
    /*开始绘制三角形*/
    glBegin(GL_TRIANGLES);
    glColor3f( 1.0, 0.0, 0.0 );//着色,为每一个顶点
    glVertex3f(  0.0,   1.0, 0.0 );//上顶点
    glColor3f( 0.0, 1.0, 0.0 );
    glVertex3f( -1.0,  -1.0,  0.0 );//左下顶点
    glColor3f( 0.0, 0.0, 1.0 );
    glVertex3f(  1.0,  -1.0, 0.0 );//右下顶点
    glEnd();

    //增加了另一个glLoadIdentity()调用。目的是为了重置模型观察矩阵。如果没有重置,直接调用glTranslate的话,会出现意料之外的结果。
    glLoadIdentity();

    createFiveStar();
    /*绘制五角星*/
    glTranslatef( 1.5,  0.0, zoom-6.0  );
    glRotatef( xRot,  1.0,  1.0,  1.0 );
    glRotatef( yRot,  1.0,  1.0,  1.0 );
    glRotatef( zRot,  1.0,  1.0,  1.0 );
    //glColor3f( 1.0, 0.0, 0.0 );//一次性全部着同一色
    glBegin( GL_LINE_LOOP );
    glColor3f( 1.0, 0.0, 1.0 );
    glArrayElement(1);
    glColor3f( 1.0, 0.0, 0.0 );
    glArrayElement(4);
    glColor3f( 1.0, 1.0, 0.0 );
    glArrayElement(2);
    glColor3f( 0.0, 1.0, 0.0 );
    glArrayElement(0);
    glColor3f( 0.0, 0.0, 1.0 );
    glArrayElement(3);
    glEnd();

}
Exemple #9
0
//===========================================================================
// DG_ArrayElement
//===========================================================================
void DG_ArrayElement(int index)
{
	if(!noArrays)
	{
		glArrayElement(index);
	}
	else
	{
		int     i;

		for(i = 0; i < maxTexUnits && i < MAX_TEX_UNITS; i++)
		{
			if(arrays[AR_TEXCOORD0 + i].enabled)
			{
				glMultiTexCoord2fvARB(GL_TEXTURE0 + i,
									  ((gl_texcoord_t *)
									   arrays[AR_TEXCOORD0 +
											  i].data)[index].st);
			}
		}

		if(arrays[AR_COLOR].enabled)
			glColor4ubv(((gl_color_t *) arrays[AR_COLOR].data)[index].rgba);

		if(arrays[AR_VERTEX].enabled)
			glVertex3fv(((gl_vertex_t *) arrays[AR_VERTEX].data)[index].xyz);
	}
}
Exemple #10
0
void display(void)
{
   glClear (GL_COLOR_BUFFER_BIT);

   if (derefMethod == DRAWARRAY) 
      glDrawArrays (GL_TRIANGLES, 0, 6);
   else if (derefMethod == ARRAYELEMENT) {
      glBegin (GL_TRIANGLES);
      glArrayElement (2);
      glArrayElement (3);
      glArrayElement (5);
      glEnd ();
   }
   else if (derefMethod == DRAWELEMENTS) {
      GLuint indices[4] = {0, 1, 3, 4};

      glDrawElements (GL_POLYGON, 4, GL_UNSIGNED_INT, indices);
   }
   glFlush ();
}
static void do_ArrayElement(GLenum mode, GLsizei count,
                             GLenum type, const GLvoid *indices)
{
   GLuint index;

   glBegin(mode);
   for (index = 0; index < count; index++) {
      glArrayElement(read_index_value(indices, type, index));
   }
   glEnd();
}
Exemple #12
0
void Surface::draw(RenderContext* renderContext)
{
  material.beginUse(renderContext);
  vertexArray.beginUse();

  bool use_texcoord = material.texture && !(material.texture->is_envmap() );
  bool use_normal   = material.lit || ( (material.texture) && (material.texture->is_envmap() ) );

  if (use_texcoord)
    texCoordArray.beginUse();

  for(int iz=0;iz<nz-1;iz++) {
    glBegin(GL_QUAD_STRIP);
    for(int ix=0;ix<nx;ix++) {

      int i;
      
      // If orientation == 1, we draw iz+1 first, otherwise iz first

      i = (iz+  orientation)*nx+ix;
      if (use_normal)
        setNormal(ix, iz+orientation);
      glArrayElement( i );

      i = (iz+ !orientation)*nx+ix;
      if (use_normal)
        setNormal(ix, iz+!orientation);
      glArrayElement( i );

    }
    glEnd();
  }

  if (use_texcoord)
    texCoordArray.endUse();

  vertexArray.endUse();

  material.endUse(renderContext);
}
void		display_rect(int x, int y, int lettre)
{
	static GLfloat	vertices[] = {

	0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0,
	0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0};
	glPushMatrix();
	glLoadIdentity();
	glVertexPointer(3, GL_FLOAT, 0, vertices);
	glTexCoordPointer(2, GL_FLOAT, 0, vertices + 12);
	glBindTexture(GL_TEXTURE_2D, g_env->textures[lettre]);
	glScalef(0.03, 0.03, 0);
	glTranslatef(x, y, 0);
	glBegin(GL_QUADS);
	{
		glArrayElement(0);
		glArrayElement(1);
		glArrayElement(2);
		glArrayElement(3);
	}
	glEnd();
	glPopMatrix();
}
Exemple #14
0
void drawSpace(void)
{
	int i, n, index;

	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	glVertexPointer(3, GL_INT, 0, 0);

	glEnableClientState(GL_VERTEX_ARRAY);
	glColor3f(1.0, 1.0, 1.0);

	index = 0;
	n = (SPACE_WIDTH/STRIDE+1) + (SPACE_HEIGHT/STRIDE+1) + (SPACE_DEPTH/STRIDE+1);
	for (i = 0; i < n; i++) {
		glBegin(GL_LINE_STRIP);
		    glArrayElement(index++);
		    glArrayElement(index++);
		    glArrayElement(index++);
		glEnd();
	}

	glDisableClientState(GL_VERTEX_ARRAY);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void Shadow3DObject::DrawShadow(float r,float g,float b,float a)
{
	int i;

	/* Dibuja el objeto: */ 
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,0,shdw_puntos);
	glColor4f(r,g,b,a);
	glNormal3f(0,1,0);

	if (a!=1) {
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
	} /* if */ 
	glBegin(GL_TRIANGLES);
	for(i=0;i<shdw_ncaras;i++) {
		glArrayElement(shdw_caras[i*3]);
		glArrayElement(shdw_caras[i*3+1]);
		glArrayElement(shdw_caras[i*3+2]);
	} /* for */ 
	glEnd();

	if (a!=1) glDisable(GL_BLEND);
} /* Shadow3DObject::DraqwShadow */ 
Exemple #16
0
void Surface::renderZSort(RenderContext* renderContext)
{
  std::multimap<float,int> distanceMap;
  for (int ix = 0 ; ix < nx-1 ; ++ix ) {
    for (int iz = 0 ; iz < nz-1 ; ++iz ) {
      float distance = renderContext->getDistance( getCenter(ix, iz) );
      distanceMap.insert( std::pair<float,int>(-distance,iz*nx + ix) );
    }
  }

  material.beginUse(renderContext);
  vertexArray.beginUse();

  bool use_texcoord = material.texture && !(material.texture->is_envmap() );
  bool use_normal   = material.lit || ( (material.texture) && (material.texture->is_envmap() ) );

  if (use_texcoord)
    texCoordArray.beginUse();

  for ( std::multimap<float,int>::iterator iter = distanceMap.begin(); iter != distanceMap.end() ; ++ iter ) {
    glBegin(GL_QUAD_STRIP);
    for (int i = 0 ; i < 2; ++i ) {
      int ix = iter->second % nx + i;
      for (int j = 0 ; j < 2; ++j ) {
        int iz;
        if (orientation)
          iz = iter->second / nx + !j;
        else
          iz = iter->second / nx + j;
        if (use_normal)
          setNormal(ix, iz);
        glArrayElement( iz*nx + ix );       
      }
    }
    glEnd();
  }  

  if (use_texcoord)
    texCoordArray.endUse();

  vertexArray.endUse();

  material.endUse(renderContext);
}
Exemple #17
0
Fichier : gl.c Projet : rzr/glshim
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *uindices) {
    // TODO: split for count > 65535?
    GLushort *indices = copy_gl_array(uindices, type, 1, 0, GL_UNSIGNED_SHORT, 1, 0, count);
    // TODO: do this in a more direct fashion.
    if (should_intercept_render(mode)) {
        glBegin(mode);
        for (int i = 0; i < count; i++) {
            glArrayElement(indices[i]);
        }
        glEnd();
        free(indices);
        return;
    }

    bool compiling = (state.list.active && state.list.compiling);
    if (compiling) {
        renderlist_t *list = NULL;
        GLsizei min, max;

        if (compiling)
            list = state.list.active = extend_renderlist(state.list.active);

        normalize_indices(indices, &max, &min, count);
        list = arrays_to_renderlist(list, mode, 0, max + 1);
        list->indices = indices;
        list->len = count;

        end_renderlist(list);
        if (! compiling) {
            draw_renderlist(list);
            free_renderlist(list);
        }
    } else {
        LOAD_GLES(glDrawElements);
        gles_glDrawElements(mode, count, type, indices);
        free(indices);
    }
}
Exemple #18
0
void PrimitiveSet::drawAll(RenderContext* renderContext)
{
  if (!hasmissing)
    glDrawArrays(type, 0, nverticesperelement*nprimitives );
    // FIXME: refactor to vertexArray.draw( type, 0, nverticesperelement*nprimitives );
  else {
    bool missing = true;
    for (int i=0; i<nprimitives; i++) {
      bool skip = false;
      for (int j=0; j<nverticesperelement; j++) 
        skip |= vertexArray[nverticesperelement*i + j].missing();
      if (missing != skip) {
        missing = !missing;
        if (missing) glEnd();
        else glBegin(type);
      }
      if (!missing) 
        for (int j=0; j<nverticesperelement; j++)
          glArrayElement( nverticesperelement*i + j );
    }
    if (!missing) glEnd();
  }              
}
Exemple #19
0
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *uindices) {
    // TODO: split for count > 65535?
    GLushort *indices = gl_copy_array(uindices, type, 1, 0, GL_UNSIGNED_SHORT, 1, 0, count, false);
    // TODO: do this in a more direct fashion.
    if (should_intercept_render(mode)) {
        glBegin(mode);
        state.block.active->artificial = true;
        for (int i = 0; i < count; i++) {
            glArrayElement(indices[i]);
        }
        glEnd();
        free(indices);
        return;
    }

    displaylist_t *list = state.list.active;
    if (list) {
        GLsizei min, max;

        normalize_indices(indices, &max, &min, count);
        block_t *block = block_from_arrays(mode, min, max + 1);
        block->indices = indices;
        block->count = count;

        bl_end(block);
        if (list) {
            dl_append_block(list, block);
        } else {
            bl_draw(block);
            bl_free(block);
        }
    } else {
        LOAD_GLES(glDrawElements);
        gles_glDrawElements(mode, count, type, indices);
        free(indices);
    }
}
Exemple #20
0
static void draw_surface( unsigned int with_state )
{
   GLint i, j;
   
   if (with_state & DISPLAYLIST) {
      if ((with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK|MATERIAL_MASK)) != 
	  dlist_state) {
	 /* 
	  */
	 fprintf(stderr, "rebuilding displaylist\n");

	 if (dlist_state)
	    glDeleteLists( surf1, 1 );

	 dlist_state = with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK|
				     MATERIAL_MASK);
	 surf1 = glGenLists(1);
	 glNewList(surf1, GL_COMPILE);
	 draw_surface( dlist_state );
	 glEndList();
      }

      glCallList( surf1 );
      return;
   }

   switch (with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK)) {
#ifdef GL_EXT_vertex_array

   case (DRAW_ELTS|TRIANGLES):
      if (with_state & MATERIALS) {
	 for (j = i = 0 ; i < num_tri_verts ; i += 600, j++) {
	    GLuint nr = MIN(num_tri_verts-i, 600);
	    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
	    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
	    glDrawElements( GL_TRIANGLES, nr, GL_UNSIGNED_INT, tri_indices+i );
	 }
      } else {
	 glDrawElements( GL_TRIANGLES, num_tri_verts, GL_UNSIGNED_INT,
			 tri_indices );
      }
      break;

   case (DRAW_ARRAYS|TRIANGLES):
      glDrawArraysEXT( GL_TRIANGLES, 0, (numverts-2)*3 );
      break;

   case (ARRAY_ELT|TRIANGLES):
      if (with_state & MATERIALS) {
	 for (j = i = 0 ; i < num_tri_verts ; i += 600, j++) {
	    GLuint nr = MIN(num_tri_verts-i, 600);
	    GLuint k;
	    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
	    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
	    glBegin( GL_TRIANGLES );
	    for (k = 0 ; k < nr ; k++)
	       glArrayElement( tri_indices[i+k] );
	    glEnd();
	 }
      } else {
	 glBegin( GL_TRIANGLES );
	 for (i = 0 ; i < num_tri_verts ; i++)
	    glArrayElement( tri_indices[i] );

	 glEnd();
      }
      break;


      /* Uses the original arrays (including duplicate elements):
       */
   case (DRAW_ARRAYS|STRIPS):
      glDrawArraysEXT( GL_TRIANGLE_STRIP, 0, numverts );
      break;
   case (DRAW_ELTS|STRIPS):
      glDrawElements( GL_TRIANGLE_STRIP, numverts,
		      GL_UNSIGNED_INT, strip_indices );
      break;

      /* Uses the original arrays (including duplicate elements):
       */
   case (ARRAY_ELT|STRIPS):
      glBegin( GL_TRIANGLE_STRIP );
      for (i = 0 ; i < numverts ; i++)
	 glArrayElement( i );
      glEnd();
      break;

   case (DRAW_ARRAYS|POINTS):
      glDrawArraysEXT( GL_POINTS, 0, numuniq );
      break;
   case (DRAW_ELTS|POINTS):
      /* can use numuniq with strip_indices as strip_indices[i] == i.
       */
      glDrawElements( GL_POINTS, numuniq, 
		      GL_UNSIGNED_INT, strip_indices );
      break;
   case (ARRAY_ELT|POINTS):
      /* just emit each unique element once:
       */
      glBegin( GL_POINTS );
      for (i = 0 ; i < numuniq ; i++)
	 glArrayElement( i );
      glEnd();
      break;
#endif

   case (GLVERTEX|TRIANGLES):
      if (with_state & MATERIALS) {
	 for (j = i = 0 ; i < num_tri_verts ; i += 600, j++) {
	    GLuint nr = MIN(num_tri_verts-i, 600);
	    GLuint k;
	    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
	    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
	    glBegin( GL_TRIANGLES );
	    for (k = 0 ; k < nr ; k++) {
	       glNormal3fv( &compressed_data[tri_indices[i+k]][3] );
	       glVertex3fv( &compressed_data[tri_indices[i+k]][0] );
	    }
	    glEnd();
	 }
      } else {
	 glBegin( GL_TRIANGLES );
	 for (i = 0 ; i < num_tri_verts ; i++) {
	    glNormal3fv( &compressed_data[tri_indices[i]][3] );
	    glVertex3fv( &compressed_data[tri_indices[i]][0] );
	 }
	 glEnd();
      }
      break;

   case (GLVERTEX|POINTS):
      /* Renders all points, but not in strip order...  Shouldn't be a
       * problem, but people may be confused as to why points are so
       * much faster in this demo...  And why cva doesn't help them...
       */
      glBegin( GL_POINTS );
      for ( i = 0 ; i < numuniq ; i++ ) {
         glNormal3fv( &compressed_data[i][3] );
         glVertex3fv( &compressed_data[i][0] );
      }
      glEnd();
      break;

   case (GLVERTEX|STRIPS):
      glBegin( GL_TRIANGLE_STRIP );
      for (i=0;i<numverts;i++) {
         glNormal3fv( &data[i][3] );
         glVertex3fv( &data[i][0] );
      }
      glEnd();
      break;

   default:
      fprintf(stderr, "unimplemented mode %x...\n", 
	      (with_state & (RENDER_STYLE_MASK|PRIMITIVE_MASK)));
      break;
   }
}
Exemple #21
0
void glArrayElementEXT( GLint i )
{
	glArrayElement( i );
}
void glOutlineDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
{ 
   if(mode == GL_POLYGON)
      mode = GL_LINE_LOOP;

   if(mode == GL_POINTS || mode == GL_LINE_STRIP || mode == GL_LINE_LOOP || mode == GL_LINES)   
      glDrawElements( mode, count, type, indices );
   else
   {
      glBegin(GL_LINES);
      if(mode == GL_TRIANGLE_STRIP)
      {
         U32 i;
         for(i = 0; i < count - 1; i++)
         {
            glArrayElement(getIndex(type, indices, i));
            glArrayElement(getIndex(type, indices, i + 1));
            if(i + 2 != count)
            {
               glArrayElement(getIndex(type, indices, i));
               glArrayElement(getIndex(type, indices, i + 2));
            }
         }
      }
      else if(mode == GL_TRIANGLE_FAN)
      {
         for(U32 i = 1; i < count; i ++)
         {
            glArrayElement(getIndex(type, indices, 0));
            glArrayElement(getIndex(type, indices, i));
            if(i != count - 1)
            {
               glArrayElement(getIndex(type, indices, i));
               glArrayElement(getIndex(type, indices, i + 1));
            }
         }
      }
      else if(mode == GL_TRIANGLES)
      {
         for(U32 i = 3; i <= count; i += 3)
         {
            glArrayElement(getIndex(type, indices, i - 3));
            glArrayElement(getIndex(type, indices, i - 2));
            glArrayElement(getIndex(type, indices, i - 2));
            glArrayElement(getIndex(type, indices, i - 1));
            glArrayElement(getIndex(type, indices, i - 3));
            glArrayElement(getIndex(type, indices, i - 1));
         }
      }
      else if(mode == GL_QUADS)
      {
         for(U32 i = 4; i <= count; i += 4)
         {
            glArrayElement(getIndex(type, indices, i - 4));
            glArrayElement(getIndex(type, indices, i - 3));
            glArrayElement(getIndex(type, indices, i - 3));
            glArrayElement(getIndex(type, indices, i - 2));
            glArrayElement(getIndex(type, indices, i - 2));
            glArrayElement(getIndex(type, indices, i - 1));
            glArrayElement(getIndex(type, indices, i - 4));
            glArrayElement(getIndex(type, indices, i - 1));
         }
      }
      else if(mode == GL_QUAD_STRIP)
      {
         if(count < 4)
            return;
         glArrayElement(getIndex(type, indices, 0));
         glArrayElement(getIndex(type, indices, 1));
         for(U32 i = 4; i <= count; i += 2)
         {
            glArrayElement(getIndex(type, indices, i - 4));
            glArrayElement(getIndex(type, indices, i - 2));

            glArrayElement(getIndex(type, indices, i - 3));
            glArrayElement(getIndex(type, indices, i - 1));

            glArrayElement(getIndex(type, indices, i - 2));
            glArrayElement(getIndex(type, indices, i - 1));
         }
      }
      glEnd();
   }
}
void glOutlineDrawArrays(GLenum mode, GLint first, GLsizei count) 
{ 
   if(mode == GL_POLYGON)
      mode = GL_LINE_LOOP;

   if(mode == GL_POINTS || mode == GL_LINE_STRIP || mode == GL_LINE_LOOP || mode == GL_LINES)   
      glDrawArrays( mode, first, count );
   else
   {
      glBegin(GL_LINES);
      if(mode == GL_TRIANGLE_STRIP)
      {
         U32 i;
         for(i = 0; i < count - 1; i++) 
         {
            glArrayElement(first + i);
            glArrayElement(first + i + 1);
            if(i + 2 != count)
            {
               glArrayElement(first + i);
               glArrayElement(first + i + 2);
            }
         }
      }
      else if(mode == GL_TRIANGLE_FAN)
      {
         for(U32 i = 1; i < count; i ++)
         {
            glArrayElement(first);
            glArrayElement(first + i);
            if(i != count - 1)
            {
               glArrayElement(first + i);
               glArrayElement(first + i + 1);
            }
         }
      }
      else if(mode == GL_TRIANGLES)
      {
         for(U32 i = 3; i <= count; i += 3)
         {
            glArrayElement(first + i - 3);
            glArrayElement(first + i - 2);
            glArrayElement(first + i - 2);
            glArrayElement(first + i - 1);
            glArrayElement(first + i - 3);
            glArrayElement(first + i - 1);
         }
      }
      else if(mode == GL_QUADS)
      {
         for(U32 i = 4; i <= count; i += 4)
         {
            glArrayElement(first + i - 4);
            glArrayElement(first + i - 3);
            glArrayElement(first + i - 3);
            glArrayElement(first + i - 2);
            glArrayElement(first + i - 2);
            glArrayElement(first + i - 1);
            glArrayElement(first + i - 4);
            glArrayElement(first + i - 1);
         }
      }
      else if(mode == GL_QUAD_STRIP)
      {
         if(count < 4)
            return;
         glArrayElement(first + 0);
         glArrayElement(first + 1);
         for(U32 i = 4; i <= count; i += 2)
         {
            glArrayElement(first + i - 4);
            glArrayElement(first + i - 2);

            glArrayElement(first + i - 3);
            glArrayElement(first + i - 1);

            glArrayElement(first + i - 2);
            glArrayElement(first + i - 1);
         }
      }
      glEnd();
   }
}
/////////////////////////////////////////////////////////
// Render
//
void GEMglArrayElement :: render(GemState *state) {
	glArrayElement (i);
}
Exemple #25
0
GLuint frame_display_list(void)
{
	GLuint list;
	vec3 vertex[] = {
		{0.0, 0.0, 0.0},
		{1.0, 0.0, 0.0},
		{0.0, 1.0, 0.0},
		{0.0, 0.0, 1.0}
	};

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, vertex);

	list = glGenLists(1);

	glNewList(list, GL_COMPILE);
		glBegin(GL_LINES);
			/* Bottom */
			glNormal3f(0.0, 1.0, 0.0);

			/* x */
			glColor3f(1, 0, 0);
			glArrayElement(0);
			glArrayElement(1);

			/* z */
			glColor3f(0, 0, 1);
			glArrayElement(0);
			glArrayElement(3);

			/* Left */
			glNormal3f(1.0, 0.0, 0.0);

			/* z */
			glColor3f(0, 0, 1);
			glArrayElement(0);
			glArrayElement(3);

			/* y */
			glColor3f(0, 1, 0);
			glArrayElement(0);
			glArrayElement(2);

			/* Back */
			glNormal3f(0.0, 0.0, 1.0);
			/* x */
			glColor3f(1, 0, 0);
			glArrayElement(0);
			glArrayElement(1);

			/* y */
			glColor3f(0, 1, 0);
			glArrayElement(0);
			glArrayElement(2);

		glEnd();
	glEndList();

	return list;
}
Exemple #26
0
GLuint cube_display_list(void)
{
	GLuint list;
	vec3 vertex[] = {
		{0.0, 0.0, 0.0},
		{0.0, 1.0, 0.0},
		{1.0, 1.0, 0.0},
		{1.0, 0.0, 0.0},

		{0.0, 0.0, 1.0},
		{1.0, 0.0, 1.0},
		{1.0, 1.0, 1.0},
		{0.0, 1.0, 1.0},

		{0.5, 0.5, 0.5},
		{2.5, 0.5, 0.5},
		{0.5, 2.5, 0.5},
		{0.5, 0.5, 2.5},
	};

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, vertex);

	list = glGenLists(1);

	glNewList(list, GL_COMPILE);
		glBegin(GL_QUADS);
			/* back */
			glColor3f(1, 0, 0);
			glNormal3f(0.0, 0.0, -1.0);
			glArrayElement(0);
			glArrayElement(1);
			glArrayElement(2);
			glArrayElement(3);

			/* front */
			glColor3f(0, 1, 0);
			glNormal3f(0.0, 0.0, 1.0);
			glArrayElement(4);
			glArrayElement(5);
			glArrayElement(6);
			glArrayElement(7);

			/* left */
			glColor3f(0, 0, 1);
			glNormal3f(-1.0, 0.0, 0.0);
			glArrayElement(0);
			glArrayElement(4);
			glArrayElement(7);
			glArrayElement(1);

			/* right */
			glNormal3f(1.0, 0.0, 0.0);
			glArrayElement(5);
			glArrayElement(6);
			glArrayElement(2);
			glArrayElement(3);

			/* top */
			glNormal3f(0.0, 1.0, 0.0);
			glArrayElement(7);
			glArrayElement(6);
			glArrayElement(2);
			glArrayElement(1);

			/* bottom */
			glNormal3f(0.0, -1.0, 0.0);
			glArrayElement(4);
			glArrayElement(0);
			glArrayElement(3);
			glArrayElement(5);
		glEnd();

#if 0
		glBegin(GL_LINES);
			glNormal3f(0.0, 0.0, 1.0);
			glColor3f(1, 0, 0);
			glArrayElement(8);
			glArrayElement(9);

			glColor3f(0, 1, 0);
			glArrayElement(8);
			glArrayElement(10);

			glColor3f(0, 0, 1);
			glArrayElement(8);
			glArrayElement(11);
		glEnd();
#endif
	glEndList();

	return list;
}
Exemple #27
0
// Finally, the actual calls to do something with all this data.  You can either choose to render
// it given the configuration, or generate a display list of rendering it with the given
// configuration (uses GL_COMPILE mode to build the list).  Fails if insufficient data has
// been given (i.e. if you don't give it an array for an enabled parameter, if you don't
// give it an array of indices when it needs them).
// Note that rendering with GLVERTEX_MODE currently involves a lot of CPU overhead to
// unpack the data and pass it to the GL; while the results will be correct, it would be
// unwise to use this method for rendering that is to be benchmarked, because it will
// underestimate performance significantly on some machines.
bool GeomRenderer::renderPrimitives(GLenum mode)
{
    if (!isReadyToRender())
    {
        return false;
    }

    // Okay, different sections here depending on what we're doing.
    if (drawMethod == GLVERTEX_MODE)
    {
        glBegin(mode);
        for (unsigned int x=0; x<indicesCount; x++)
        {
            int directIndex = getIndex(x);
            if (parameterBits & COLOR_BIT) sendColor(directIndex);
            if (parameterBits & TEXTURE_COORD_BIT) sendTexCoord(directIndex);
            if (parameterBits & NORMAL_BIT) sendNormal(directIndex);
            sendVertex(directIndex);
        }
        glEnd();
    }
    // Otherwise it has something to do with arrays; set up the arrays.
    else
    {
        if (parameterBits & COLOR_BIT)
        { 
            glEnableClientState(GL_COLOR_ARRAY);
            glColorPointer(colorData.size, colorData.type, colorData.stride, colorData.pointer);
//            std::cout << "Enabled color arrays, size [" << colorData.size << "], type [" << colorData.type 
//                      << "], stride [" << colorData.stride << "], pointer [" << colorData.pointer << "]" << std::endl;
        }
        if (parameterBits & TEXTURE_COORD_BIT)
        { 
            glEnableClientState(GL_TEXTURE_COORD_ARRAY);
            glTexCoordPointer(texCoordData.size, texCoordData.type, texCoordData.stride, texCoordData.pointer);
//            std::cout << "Enabled texCoord arrays, size [" << texCoordData.size << "], type [" << texCoordData.type 
//                      << "], stride [" << texCoordData.stride << "], pointer [" << texCoordData.pointer << "]" << std::endl;
        }
        if (parameterBits & NORMAL_BIT)
        { 
            glEnableClientState(GL_NORMAL_ARRAY);
            glNormalPointer(normalData.type, normalData.stride, normalData.pointer);
//            std::cout << "Enabled normal arrays, size [" << normalData.size << "], type [" << normalData.type 
//                      << "], stride [" << normalData.stride << "], pointer [" << normalData.pointer << "]" << std::endl;
        }
        glEnableClientState(GL_VERTEX_ARRAY);
        glVertexPointer(vertexData.size, vertexData.type, vertexData.stride, vertexData.pointer);
//        std::cout << "Enabled vertex arrays, size [" << vertexData.size << "], type [" << vertexData.type 
//                  << "], stride [" << vertexData.stride << "], pointer [" << vertexData.pointer << "]" << std::endl;

        // Should we lock?
        if (compileArrays)
        {
            assert(GLUtils::haveExtension("GL_EXT_compiled_vertex_array"));
            glLockArraysEXT(0, arrayLength);
        }

        // Okay, arrays configured; what exactly are we doing?
        if (drawMethod == GLARRAYELEMENT_MODE)
        {
            glBegin(mode);
            for (unsigned int x=0; x<indicesCount; x++)
            {
                glArrayElement(getIndex(x));
            }
            glEnd();
        }
        else if (drawMethod == GLDRAWARRAYS_MODE)
        {
            glDrawArrays(mode, 0, arrayLength);
            std::cout << "Called glDrawArrays, mode [" << mode << "], from 0 to " << arrayLength << std::endl;
        }
        else if (drawMethod == GLDRAWELEMENTS_MODE)
        {
            glDrawElements(mode, indicesCount, indicesType, indices);
        }

        // Done.  If we locked, unlock.
        if (compileArrays)
        {
            assert(GLUtils::haveExtension("GL_EXT_compiled_vertex_array"));
            glUnlockArraysEXT();
        }
    }

    return true;
}
void tveVertexArray::drawArray(int dir)
{
    if (detail) // full detail
    {
        for (int k=0; k<LEAF_GRANULARITY; k++)
        {
            glDrawElements(GL_TRIANGLE_STRIP, (LEAF_GRANULARITY+1)*2, GL_UNSIGNED_INT, &faces_strip_detail[k*(LEAF_GRANULARITY+1)*2]);
        }
    }
    else if (!dir) // full coarse
    {
        for (int k=0; k<LEAF_GRANULARITY; k+=2)
        {
            glDrawElements(GL_TRIANGLE_STRIP, (LEAF_GRANULARITY/2+1)*2, GL_UNSIGNED_INT, &faces_strip_coarse[(k/2)*(LEAF_GRANULARITY/2+1)*2]);
        }
    }
    else // mix of coarse and detail
    {
        int offset_x = 0;
        int offset_y = 0;
        int size_x   = LEAF_GRANULARITY/2+1;
        int size_y   = LEAF_GRANULARITY/2+1;

        if (dir & DIR_NORTH_MASK)
        {
            size_y--;
            offset_y++;
        }
        if (dir & DIR_SOUTH_MASK)
        {
            size_y--;
        }
        if (dir & DIR_WEST_MASK)
        {
            size_x--;
            offset_x++;
        }
        if (dir & DIR_EAST_MASK)
        {
            size_x--;
        }
        for (int k=offset_y; k<size_y+offset_y-1; k++)
        {
            glDrawElements(GL_TRIANGLE_STRIP, size_x*2, GL_UNSIGNED_INT, &faces_strip_coarse[2*k*(LEAF_GRANULARITY/2+1)+offset_x*2]);
        }
        // render junctions
        for (int j=2; j<LEAF_GRANULARITY-2; j+=2)
        {
            if (dir & DIR_NORTH_MASK)
            {
                glBegin(GL_TRIANGLE_STRIP);
                  glArrayElement(j+0);
                  glArrayElement(2*(LEAF_GRANULARITY+1)+0+j);
                  glArrayElement(j+1);
                  glArrayElement(2*(LEAF_GRANULARITY+1)+2+j);
                  glArrayElement(j+2);
                glEnd();
            }
            if (dir & DIR_WEST_MASK)
            {
                glBegin(GL_TRIANGLE_STRIP);
                  glArrayElement((LEAF_GRANULARITY+1)*(j+2));
                  glArrayElement((LEAF_GRANULARITY+1)*(j+2)+2);
                  glArrayElement((LEAF_GRANULARITY+1)*(j+1));
                  glArrayElement((LEAF_GRANULARITY+1)*j+2);
                  glArrayElement((LEAF_GRANULARITY+1)*j);
                glEnd();
            }
            if (dir & DIR_EAST_MASK)
            {
                glBegin(GL_TRIANGLE_STRIP);
                  glArrayElement(LEAF_GRANULARITY-2+(LEAF_GRANULARITY+1)*j+2);
                  glArrayElement(LEAF_GRANULARITY-2+(LEAF_GRANULARITY+1)*j);
                  glArrayElement(LEAF_GRANULARITY-2+(LEAF_GRANULARITY+1)*(j+1)+2);
                  glArrayElement(LEAF_GRANULARITY-2+(LEAF_GRANULARITY+1)*(j+2));
                  glArrayElement(LEAF_GRANULARITY-2+(LEAF_GRANULARITY+1)*(j+2)+2);
                glEnd();
            }
            if (dir & DIR_SOUTH_MASK)
            {
                glBegin(GL_TRIANGLE_STRIP);
                  glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-(j+0)-1);
                  glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-(2*(LEAF_GRANULARITY+1)+0+j)-1);
                  glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-(j+1)-1);
                  glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-(2*(LEAF_GRANULARITY+1)+2+j)-1);
                  glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-(j+2)-1);
                glEnd();
            }
        }
        if (dir & (DIR_NORTH_MASK|DIR_WEST_MASK))
        {
            glBegin(GL_TRIANGLE_FAN);
              glArrayElement(2*(LEAF_GRANULARITY+1)+2);
              glArrayElement(2);
              if (dir & DIR_NORTH_MASK) glArrayElement(1);
              glArrayElement(0);
              if (dir & DIR_WEST_MASK) glArrayElement(LEAF_GRANULARITY+1+0);
              glArrayElement(2*(LEAF_GRANULARITY+1)+0);
            glEnd();
        }
        if (dir & (DIR_EAST_MASK|DIR_NORTH_MASK))
        {
            glBegin(GL_TRIANGLE_FAN);
              glArrayElement(LEAF_GRANULARITY-2+2*(LEAF_GRANULARITY+1)+0);
              glArrayElement(LEAF_GRANULARITY-2+2*(LEAF_GRANULARITY+1)+2);
              if (dir & DIR_EAST_MASK) glArrayElement(LEAF_GRANULARITY-2+LEAF_GRANULARITY+1+2);
              glArrayElement(LEAF_GRANULARITY-2+2);
              if (dir & DIR_NORTH_MASK) glArrayElement(LEAF_GRANULARITY-2+1);
              glArrayElement(LEAF_GRANULARITY-2+0);
            glEnd();
        }
        if (dir & (DIR_WEST_MASK|DIR_SOUTH_MASK))
        {
            glBegin(GL_TRIANGLE_FAN);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY-2)+2);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY-2)+0);
              if (dir & DIR_WEST_MASK) glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY-1)+0);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+0)+0);
              if (dir & DIR_SOUTH_MASK) glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+0)+1);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+0)+2);
            glEnd();
        }
        if (dir & (DIR_SOUTH_MASK|DIR_EAST_MASK))
        {
            glBegin(GL_TRIANGLE_FAN);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY-1)-3);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-3);
              if (dir & DIR_SOUTH_MASK) glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-2);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+1)-1);
              if (dir & DIR_EAST_MASK) glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY+0)-1);
              glArrayElement((LEAF_GRANULARITY+1)*(LEAF_GRANULARITY-1)-1);
            glEnd();
        }
    }
}
Exemple #29
0
static void drawscene(float angle)
{
	int i;

	GLCHK(glDisable(GL_TEXTURE_2D));
	GLCHK(glEnable(GL_BLEND));
	//GLCHK(glEnable(GL_CULL_FACE));
	GLCHK(glEnable(GL_DEPTH_TEST));
	GLCHK(glDisable(GL_LIGHTING));
	GLCHK(glShadeModel(render & R_FLAT ? GL_FLAT : GL_SMOOTH));
	GLCHK(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));

	for(i = 0; i < nlights; i++) {
		GLfloat pos[] = { 1, 0, 0, 1 };
		GLfloat vec[] = {-1, 0, 0 };

		GLCHK(glPushMatrix());

		GLCHK(glRotatef(angle + 90*i, 0,0,1));
		GLCHK(glRotatef(-40, 0,1,0));
		GLCHK(glTranslatef(.9,.9,0));

		GLCHK(glLightfv(GL_LIGHT0 + i, GL_POSITION, pos));
		GLCHK(glLightfv(GL_LIGHT0 + i, GL_SPOT_DIRECTION, vec));

		GLCHK(glColor4fv(lights[i].specular));

		glBegin(GL_LINE_STRIP);
		glVertex3fv(pos);
		glColor4f(0,0,0,0);
		glVertex3f(pos[0]+vec[0],
			   pos[1]+vec[1],
			   pos[2]+vec[2]);
		glEnd();

		GLCHK(glPopMatrix());
	}

	GLCHK(glScalef(3,3,1));

	GLCHK(glDisable(GL_BLEND));

	/* axes */
	glBegin(GL_LINES);
		glColor3f(1,0,0);
		glVertex3f(0,0,0);
		glVertex3f(1,0,0);

		glColor3f(0,1,0);
		glVertex3f(0,0,0);
		glVertex3f(0,1,0);

		glColor3f(1,1,0);
		glVertex3f(0,0,0);
		glVertex3f(0,0,1);
	glEnd();

	if (render & R_TEX)
		GLCHK(glEnable(GL_TEXTURE_2D));
	GLCHK(glEnable(GL_LIGHTING));
#if GL_PSP_bezier_patch
	if ((primidx / 3) == 0) {
		if (0) {
			GLCHK(glDrawBezierArraysPSP(prims[primidx%3], MESHX, MESHY, 0));
		} else {
			idx_t idx[MESHX*MESHY];
			int x, y, i;

			i = 0;
			for(y = 0; y < MESHY-3; y++)
				for(x = 0; x < MESHX; x++)
					idx[i++] = y*MESHX+x;
			GLCHK(glDrawBezierElementsPSP(prims[primidx%3],
						      MESHX, MESHY-3, IDX_TYPE, idx));

			/* need to overlap a row */
			i = 0;
			for(y = MESHY-4; y < MESHY; y++)
				for(x = 0; x < MESHX; x++)
					idx[i++] = y*MESHX+x;
			GLCHK(glDrawBezierElementsPSP(prims[primidx%3],
						      MESHX, 4, IDX_TYPE, idx));
		}
	} else {
		if (0) {
			GLCHK(glDrawSplineArraysPSP(prims[primidx%3],
						    MESHX, MESHY,
						    GL_PATCH_OUTER_INNER_PSP,
						    GL_PATCH_INNER_INNER_PSP,
						    0));
		} else {
			idx_t idx[MESHX*MESHY];
			int x, y, i;

			i = 0;
			for(y = 0; y < MESHY-3; y++)
				for(x = 0; x < MESHX; x++)
					idx[i++] = y*MESHX+x;
			GLCHK(glDrawSplineElementsPSP(prims[primidx%3],
						      MESHX, MESHY-3,
						      GL_PATCH_OUTER_OUTER_PSP,
						      GL_PATCH_INNER_OUTER_PSP,
						      IDX_TYPE, idx));

			/* need to overlap 3 rows */
			i = 0;
			for(y = MESHY-6; y < MESHY; y++)
				for(x = 0; x < MESHX; x++)
					idx[i++] = y*MESHX+x;
			GLCHK(glDrawSplineElementsPSP(prims[primidx%3],
						      MESHX, 6,
						      GL_PATCH_OUTER_OUTER_PSP,
						      GL_PATCH_OUTER_INNER_PSP,
						      IDX_TYPE, idx));
		}
	}
#else
	glBegin(GL_QUADS);
	for(i = 0; i < MESHY-1; i++) {
		int j;
		for(j = 0; j < MESHX-1; j++) {
			glArrayElement(i*MESHX + j);
			glArrayElement(i*MESHX + j+1);
			glArrayElement((i+1)*MESHX + j+1);
			glArrayElement((i+1)*MESHX + j);
		}
	}
	GLCHK(glEnd());
#endif

	GLCHK(glDisable(GL_LIGHTING));
	GLCHK(glDisable(GL_TEXTURE_2D));
	GLCHK(glShadeModel(GL_SMOOTH));

	GLCHK(glEnable(GL_BLEND));
	GLCHK(glColor4f(.2,.2,.2,.2));
	GLCHK(glBlendFunc(GL_ONE, GL_ONE));

	if (render & R_HULL) {
		/* draw hull */
		for(i = 0; i < MESHY; i++)
			GLCHK(glDrawArrays(GL_LINE_STRIP, i*MESHX, MESHX));

		for(i = 0; i < MESHX; i++) {
			idx_t idx[MESHY];
			int j;

			for(j = 0; j < MESHY; j++)
				idx[j] = i + j*MESHX;

			GLCHK(glDrawElements(GL_LINE_STRIP, MESHY, IDX_TYPE, idx));
		}
	}

	if (render & R_NORM) {
		/* draw normals */
		glBegin(GL_LINES);
		for(i = 0; i < MESHX*MESHY; i++) {
			glVertex3fv(&mesh[i].x);
			glVertex3f(mesh[i].x + mesh[i].nx * .1,
				   mesh[i].y + mesh[i].ny * .1,
				   mesh[i].z + mesh[i].nz * .1);
		}
		glEnd();
	}
}
void openglwindow::paintGL()
{
    glRotatef(0.5,1,1,1);
	if(ndata > NULL)
	{
        
		glRotatef(0.5,1,1,1);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glEnableClientState(GL_VERTEX_ARRAY);
        glVertexPointer(3, GL_FLOAT, 0, &ndata->GetVertices());
		GLenum face_mode;
		switch(ndata->GetVertices().size())
            {
              case 1: face_mode = GL_POINTS; break;
              case 2: face_mode = GL_LINES; break;
              case 3: face_mode = GL_TRIANGLES; break;
              default: face_mode = GL_POLYGON; break;
            }
           glBegin(GL_TRIANGLES);
			for (unsigned int i=0; i < ndata->GetVertices().size(); i++)
			{
            glArrayElement(i);
            }
			
		glEnd();
		
    glDisableClientState(GL_VERTEX_ARRAY);
    glFlush();
	}
	else if(di > NULL)
	{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	for (unsigned int i=0 ;i < di->mNumMeshes; i++)
	{
		const aiMesh* amesh=di->mMeshes[i];

		for (unsigned int is=0;is < amesh->mNumFaces ; is++)
		{

			const aiFace* face = &amesh->mFaces[is];
			GLenum face_mode;
            switch(face->mNumIndices)
            {
              case 1: face_mode = GL_POINTS; break;
              case 2: face_mode = GL_LINES; break;
              case 3: face_mode = GL_TRIANGLES; break;
              default: face_mode = GL_POLYGON; break;
            }
           glBegin(face_mode);
		   for(unsigned int ik = 0; ik < face->mNumIndices; ik++) 
           {
           int index = face->mIndices[ik];
            glVertex3fv(&amesh->mVertices[index].x);
			glNormal3fv(&amesh->mNormals[index].x);
		   }
		   glEnd();
		}

	  }
	}
	else
    { 
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glutSolidTeapot(0.6);
    }
 }