温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Primitives, Pipelines, and Pixels(图元、渲染管线与像素)

发布时间:2020-03-12 05:32:03 来源:网络 阅读:593 作者:萌谷王 栏目:游戏开发

As discussed, the model followed by OpenGL is that of a production line, or pipeline. Data flow within this model is generally one way, with data formed from commands called by your programs entering the front of the pipeline and flowing from stage to stage until it reaches the end of the pipeline(就想之前提到过得那些OpenGL的模型,它就像是流水线作业一样,数据在这个模型里从你的应用程序流进了流水线,然后经历了一个一个的处理阶段后,最终抵达流水线的结尾). Along the way, shaders or other fixedfunction blocks within the pipeline may pick up more data from buffers or textures, which are structures designed to store information that will be used during rendering.(在整个流水线处理的过程中,shader们和那些固定功能的部分会从缓冲区里取出有用的数据,用于渲染) Some stages in the pipeline may even save data into these buffers or textures(其中某些处理过程甚至可以往缓冲区里存放数据), allowing the application to read or save the data(这样一来应用程序既可以往缓冲区里写数据,也可以从缓冲区里读数据), or even permitting feedback to occur(甚至可以把数据从显卡回传到CPU的内存上)

The fundamental unit of rendering in OpenGL is known as the primitive(在OpenGL中最小的被渲染的基本单位是图元). OpenGL supports many types of primitives(OpenGL支持很多种图元), but the three basic renderable primitive types are points, lines, and triangles(这些图元就包括点、线、三角形等等). Everything you see rendered on the screen is a collection of (perhaps cleverly colored) points, lines, and triangles(一切你在画面上看到的东西都是由这些玩意组成). Applications will normally break complex surfaces into a very large number of triangles and send them to OpenGL(应用程序可以把复杂的东西干成一个个图元,并最终渲染出来), where they are rendered using a hardware accelerator called a rasterizer(最终这些图元会被硬件加速器中一个加光栅化的东西渲染,光栅化是直译英文,姑且这么记着就可以). Triangles are, relatively speaking, pretty easy to draw(相对来说,三角形是更容易绘制的). As polygons, triangles are always convex,so filling rules are easy to devise and follow(因为三角形永远是凸多边形). Concave polygons can always be broken down into two or more triangles(那些凹多边形可以被分解成多个三角形), so hardware natively supports rendering triangles directly and relies on other subsystems4 to break complex geometry into triangles(所以硬件一般都只支持绘制三角形,如果不是三角形,则需要其他辅助系统将这些图形转换成三角形,所以你画三角形效率是最好的). The rasterizer is dedicated hardware that converts the three-dimensional representation of a triangle into a series of pixels that need to be drawn onto the screen(光栅化这个操作主要是相关的硬件把你的三维数据表达成一堆二维像素点的过程)

Points, lines, and triangles are formed from collections of one, two, or three vertices, respectively(点、线、三角形分别由1、2、3个点构成). A vertex is simply a point within a coordinate space(一个顶点简单的可以指某个坐标系中的位置). In our case, we primarily consider a three-dimensional coordinate system(在我们的书本中,我们主要指的是三位坐标系). The graphics pipeline is broken down into two major parts(图形管线主要包含2个部分). The first part, often known as the front end,(第一部分就是常常人们所说的前端,但是我们不清楚常常是谁?有谁知道的话可以打电话给美国总统一下) processes vertices and primitives(处理顶点和图元), eventually forming them into the points, lines, and triangles that will be handed off to the rasterizer(直接把他们变成点、线、三角形这些光栅器能够直接处理的数据). This is known as primitive assembly(这就是传说中的图元的处理). After going through the rasterizer, the geometry has been converted from what is essentially a vector representation into a large number of independent pixels(在经过光栅器处理后,所有的几何数据都变成了各自独立的像素点). These are handed off to the back end(这些是被后端处理的,实际上就是指的显卡,在OpenGL中非得说你是个前端程序员,显卡是后端程序员,法克), which includes depth and stencil testing, fragment shading, blending, and updating of the output image(显卡处理的时候还会包含神马深度测试、蒙版测试、着色、混合、更新输出的画面)

As you progress through this book, you will see how to tell OpenGL to start working for you(随着你慢慢的深入,你将知道如何告诉OpenGL开始干活). We’ll go over how to create buffers and textures and hook them up to your programs(我们将教会兄弟们如何创建缓冲区、纹理对象,并且让他们能够在你的程序中被玩弄). We’ll also see how to write shaders to process your data and how to configure the fixed-function blocks of OpenGL to do what you want(我们也会教你们如何写shader以及如何去配置那些不让我们写shader的固定功能的部分). OpenGL is really a large collection of fairly simple concepts(OpenGL真的是一个非常庞大的相当简单的概念), built upon each other. Having a good foundation and a big-picture view of the system is essential(对OpenGL有一个总体的认识是基本的), and over the next few chapters, we hope to provide that to you(经过后面几个章节的学习后,我们希望能给你提供这样的一个全局的基本认识)

第一时间获取最新桥段,请关注东汉书院以及图形之心公众号

东汉书院、等你来玩哦

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI