使用DirectX或OpenGL显示100个浮动多维数据集 [英] Displaying 100 Floating Cubes Using DirectX OR OpenGL

查看:100
本文介绍了使用DirectX或OpenGL显示100个浮动多维数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用DirectXOpenGL显示100个浮动多维数据集.

I'd like to display 100 floating cubes using DirectX or OpenGL.

我正在寻找一些示例源代码或该技术的描述.我无法获得更多的多维数据集以正确显示.

I'm looking for either some sample source code, or a description of the technique. I have trouble getting more one cube to display correctly.

我已经为一系列好的教程精通了网络,尽管他们讨论了如何做3D原语,但我找不到的是有关如何做大量3D原语的信息-spherespyramids等.

I've combed the net for a good series of tutorials and although they talk about how to do 3D primitives, what I can't find is information on how to do large numbers of 3D primitives - cubes, spheres, pyramids, and so forth.

推荐答案

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

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 :)

这篇关于使用DirectX或OpenGL显示100个浮动多维数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆