16 language-agnostic opengl directx 3d
我想用DirectX
或显示100个浮动立方体OpenGL
.
我正在寻找一些示例源代码或技术描述.我无法让更多的立方体正确显示.
我梳理了净一个良好的系列教程的,虽然他们谈论怎么办3D
原语,我无法找到是怎么做大量的信息3D
原语- ,cubes
,spheres
,pyramids
等等.
你说你有足够的麻烦让一个立方体显示...所以我不确定你是否有一个显示或不显示.
基本上......把你的代码放在一个函数中编写一个多维数据集,然后只调用那个函数100次.
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是你如何做到这一点的基本大纲.如果你想要更高效的东西,一旦你弄清楚基础知识,你可以看一下显示列表:)
只需使用glTranslatef(或DirectX等效项)使用相同的代码绘制一个立方体,但移动绘制它的相对点.也许有更好的方法来做到这一点,我是OpenGL的新手.请务必设置您的视点,以便全部查看.
归档时间: |
|
查看次数: |
1296 次 |
最近记录: |