コード例 #1
0
  Mesh::Mesh( 
      int step, 
      int depth_width, int depth_height,
      int tex_width, int tex_height )
  {
    this->step = step;
    this->depth_width = depth_width;

    width = (float)depth_width / step;
    height = (float)depth_height / step;
    mesh_len = width * height;
    ibo_len = mesh_len * 4;

    init_ibo();
    init_texcoords( tex_width, tex_height );
    init_colors();        
    init_pts();

    // init vbo

    vbo.setVertexData( pts0x(), 3, mesh_len, 
        GL_DYNAMIC_DRAW, sizeof_pts() );

    //vbo.setNormalData( normals0x(), mesh_len, GL_DYNAMIC_DRAW, sizeof_normals() );

    vbo.setIndexData( ibo, 
        ibo_len, GL_STATIC_DRAW );

    vbo.setColorData( vbo_color, 
        mesh_len, GL_STATIC_DRAW );

    vbo.setTexCoordData( vbo_texcoords, 
        mesh_len, GL_STATIC_DRAW );
  }
コード例 #2
0
ファイル: Mesh.cpp プロジェクト: chparsons/ofxCamaraLucida
  Mesh::Mesh( 
      int res, 
      int depth_width, 
      int depth_height,
      int tex_width, 
      int tex_height )
  {
    this->res = res;
    this->depth_width = depth_width;

    width = (float)depth_width / res;
    height = (float)depth_height / res;
    mesh_len = width * height;
    ibo_len = mesh_len * 6;

    init_ibo();
    init_texcoords(tex_width,tex_height);
    init_colors();        
    init_pts();

    vbo.setVertexData( &(pts3d)[0].x, 3, mesh_len, /*GL_STATIC_DRAW*/ GL_DYNAMIC_DRAW, sizeof(ofVec3f) );
    //vbo.setNormalData( normals0x(), mesh_len, GL_DYNAMIC_DRAW, sizeof_normals() );
    vbo.setIndexData( ibo, ibo_len, GL_STATIC_DRAW );
    vbo.setColorData( colors, mesh_len, GL_STATIC_DRAW );
    vbo.setTexCoordData( texcoords, mesh_len, GL_STATIC_DRAW );
  }
コード例 #3
0
ファイル: terrain.c プロジェクト: johnh530/electro
static void init_terrain(int i)
{
    if (terrain[i].state == 0)
    {
        GLushort *indices;

        indices    = init_indices(terrain[i].n);
        terrain[i].ibo = init_ibo(terrain[i].n, indices);
        free(indices);

        terrain[i].scratch = init_scratch(terrain[i].n);
        terrain[i].cache   = init_cache  (terrain[i].n, terrain[i].m);

        terrain[i].tail    = terrain[i].m - 1;
        terrain[i].head    = 0;
        terrain[i].state   = 1;

        terrain[i].tex[0][0] = init_texture("mars2.dxt", 4096, 4096);
        terrain[i].tex[1][0] = init_texture("mars3.dxt", 4096, 4096);
        terrain[i].tex[2][0] = init_texture("mars0.dxt", 4096, 4096);
        terrain[i].tex[3][0] = init_texture("mars1.dxt", 4096, 4096);
        terrain[i].tex[0][1] = init_texture("mars6.dxt", 4096, 4096);
        terrain[i].tex[1][1] = init_texture("mars7.dxt", 4096, 4096);
        terrain[i].tex[2][1] = init_texture("mars4.dxt", 4096, 4096);
        terrain[i].tex[3][1] = init_texture("mars5.dxt", 4096, 4096);

		glBindTexture   (GL_TEXTURE_2D,              0);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB,         0);
        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);

    }
}