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

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

问题描述

下面描述的是一个三维立方体的蹩脚的Photoshop模型。



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




  • ...使用Windows仿真器如wine

  • 编译并运行在我的小巧但忠实的Macbook Air ...在运行时产生一个看起来与上述模型相当接近的窗口

  • ...仅使用免费工具(speech中的free啤酒)

  • ...使用C(而不是C ++或C#)
  • ...能够渲染从在编译时,可能带有预处理器宏

  • ...使用GPU


    We!!

    潜在资源:


    解决方案

    NeHe教程已过时,并且无法编译,所以我写了这个要点用我的问题回答我自己的问题,它遵循我的问题的所有参数。



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

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



    它很大程度上取决于此要点中的代码, NeHe教程链接到Mark Stevens的答案中。


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

    Here are my parameters: The solution must...

    • ... 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

    Weee!

    Potential resources:

    解决方案

    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.

    It can be compiled on OS X 10.9.2 like so:

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

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

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

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