使用单个光源渲染 3D 立方体的最简单方法是什么? [英] What is the simplest way to render a 3D cube with a single lighting source?

查看:26
本文介绍了使用单个光源渲染 3D 立方体的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面描述的是一个糟糕的 Photoshop 三维立方体模型.

Depicted below is a crappy Photoshop mockup of a three-dimensional cube.

这是我的参数:解决方案必须...

Here are my parameters: The solution must...

  • ...在我小巧但忠实的 Macbook Air 上编译并运行 不使用 Wine 等 Windows 模拟器
  • ... 运行时生成一个与上述模型相当接近的窗口
  • ...只使用免费工具(免费"如语音"啤酒")
  • ...使用 C(不是 C++ 或 C#)
  • ... 能够渲染从编译时定义的不同角度查看的立方体,也许使用预处理器宏
  • ...利用 GPU
  • ... compile and run on my dinky but faithful Macbook Air without using Windows emulators like wine
  • ... produce a window that looks reasonably close to the above mockup when run
  • ... use only free tools ("free" as in "speech" and "beer")
  • ... use C (not C++ or C#)
  • ... be capable of rendering the cube viewed from different angles defined at compile-time, perhaps with preprocessor macros
  • ... make use of the GPU

呸!

潜在资源:

推荐答案

NeHe的教程已经过时,无法编译,所以我写了this gist 用一个符合我问题所有参数的工作片段来回答我自己的问题.

The NeHe tutorials are outdated and do not compile, so I wrote this gist to answer my own question with a working snippet that obeys all the parameters of my question.

它可以像这样在 OS X 10.9.2 上编译:

It can be compiled on OS X 10.9.2 like so:

$ gcc -Wall -framework OpenGL -framework GLUT -o my3dcube my3dcube.c

它大量改编自本要点中的代码以及 Mark Stevens 中链接的 NeHe 教程回答.

It is adapted heavily from the code in this gist and the NeHe tutorials linked to in Mark Stevens' answer.

这篇关于使用单个光源渲染 3D 立方体的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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