OpenGL如何渲染其三角形? [英] How does OpenGL render its triangles?

查看:220
本文介绍了OpenGL如何渲染其三角形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种无需使用OpenGL即可渲染像素完美三角形的算法.

I need an algorithm to render pixel perfect triangles without using OpenGL.

在哪里可以得到像OpenGL这样的算法?最好是单线程.

Where can I get such an algorithm like OpenGL is using? Preferrably single threaded.

它必须像OpenGL那样做,因为OpenGL不会在共享边的两个三角形上留下间隙或重叠像素. Scanline方法会导致这些错误: http://joshbeam.com/articles/triangle_rasterization/.我也尝试了这种半角算法: http://devmaster.net/forums/topic /1145-advanced-rasterization/,但我无法使其正常工作(乱码).

It must do it like OpenGL does it, because OpenGL doesn't leave gaps or overlapped pixels on two triangles that share an edge. Scanline method makes those errors: http://joshbeam.com/articles/triangle_rasterization/ . I tried this half-space algo too: http://devmaster.net/forums/topic/1145-advanced-rasterization/ but I couldnt make it work (renders gibberish).

  • OpenGL如何做到这一点?如此繁重的工作,我应该忘掉它,而改用(buggy)scanline方法吗?

  • How does OpenGL do it? Is it so intensive job that I should just forget about it and use the (buggy) scanline method instead?

我在哪里可以找到算法?

Where can I get the algorithm?

我希望使用C ++解决方案,但语言不是问题.

I would prefer a C++ solution but the language isn't the problem.

推荐答案

OpenGL使用基于扫描线的方法.但是,管理差距并不是数学准确性的问题.您需要为三角形边缘上的像素附加约定. OpenGL使用的约定与Direct3D使用的约定相同.它被称为左上",我见过的最好的解释是在此

OpenGL uses a scanline based method, as Alan and your article link mentions. However, managing gaps is not a matter of math accuracy. You need an additional convention for the pixels on the edges of the triangle. The convention OpenGL uses is the same as the convention used by Direct3D. It's called "top-left" and the best explanation I've seen is on this MSDN rasterization rules article.

这篇关于OpenGL如何渲染其三角形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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