且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用DirectX或OpenGL显示100个浮动多维数据集

更新时间:2023-11-08 11:31:04

您说要显示一个多维数据集有很多麻烦...所以我不确定是否要显示一个多维数据集.

You say you have enough trouble getting one cube to display... so I am not sure if you have got one to display or not.

基本上...将用于编写多维数据集的代码放在一个函数中,然后只需调用该函数100次即可.

Basically... put your code for writing a cube in one function, then just call that function 100 times.

void DrawCube()
{
    //code to draw the cube
}

void DisplayCubes()
{
    for(int i = 0; i < 10; ++i)
    {   
         for(int j = 0; j < 10; ++j)
         {
             glPushMatrix();
             //alter these values depending on the size of your cubes.
             //This call makes sure that your cubes aren't drawn overtop of each other
             glTranslatef(i*5.0, j*5.0, 0);
             DrawCube();
             glPopMatrix();
         }
    }              
}

这是您如何执行此操作的基本概述.如果您想要更有效的方法,那么一旦掌握了基本知识,就可以在一段时间后查看显示列表":)

That is the basic outline for how you could go about doing this. If you want something more efficient take a look into Display Lists sometime once you have the basics figured out :)