1
0
mirror of https://github.com/LearnOpenGL-CN/LearnOpenGL-CN.git synced 2025-08-23 04:35:28 +08:00

Revert all the changes since 851f9ec

This commit is contained in:
Meow J
2016-07-04 19:21:32 +08:00
parent d8ebc4ee4f
commit 12a8b3eb38
144 changed files with 134 additions and 166 deletions

View File

@@ -1,4 +1,4 @@
# OpenGL
# OpenGL (Open Graphics Library)
原文 | [OpenGL](http://learnopengl.com/#!Getting-started/OpenGL)
---|---
@@ -21,9 +21,9 @@ OpenGL规范严格规定了每个函数该如何执行以及它们的输出
所有版本的OpenGL规范文档都被公开的寄存在Khronos那里。有兴趣的读者可以找到OpenGL3.3(我们将要使用的版本)的[规范文档](https://www.opengl.org/registry/doc/glspec33.core.20100311.withchanges.pdf)。如果你想深入到OpenGL的细节只关心函数功能的描述而不是函数的实现这是个很好的选择。如果你想知道每个函数**具体的**运作方式,这个规范也是一个很棒的参考。
## 核心模式与立即渲染模式
## 核心模式(Core-profile)与立即渲染模式(Immediate mode)
早期的OpenGL使用**立即渲染模式**Immediate mode也就是**固定渲染管线**这个模式下绘制图形很方便。OpenGL的大多数功能都被库隐藏起来开发者很少能控制OpenGL如何进行计算的自由。而开发者迫切希望能有更多的灵活性。随着时间推移规范越来越灵活开发者对绘图细节有了更多的掌控。立即渲染模式确实容易使用和理解但是效率太低。因此从OpenGL3.2开始,规范文档开始废弃立即渲染模式,推出核心模式(Core-profile),这个模式完全移除了旧的特性。
早期的OpenGL使用**立即渲染模式**(也就是**固定渲染管线**这个模式下绘制图形很方便。OpenGL的大多数功能都被库隐藏起来开发者很少能控制OpenGL如何进行计算的自由。而开发者迫切希望能有更多的灵活性。随着时间推移规范越来越灵活开发者对绘图细节有了更多的掌控。立即渲染模式确实容易使用和理解但是效率太低。因此从OpenGL3.2开始,规范文档开始废弃立即渲染模式,推出核心模式,这个模式完全移除了旧的特性。
当使用OpenGL的核心模式时OpenGL迫使我们使用现代的函数。当我们试图使用一个已废弃的函数时OpenGL会抛出一个错误并终止绘图。现代函数的优势是更高的灵活性和效率然而也更难于学习。立即渲染模式从OpenGL**实际**运作中抽象掉了很多细节因而它易于学习的同时也很难去把握OpenGL具体是如何运作的。现代函数要求使用者真正理解OpenGL和图形编程它有一些难度然而提供了更多的灵活性更高的效率更重要的是可以更深入的理解图形编程。
@@ -35,11 +35,11 @@ OpenGL规范严格规定了每个函数该如何执行以及它们的输出
当使用新版本的OpenGL特性时只有新一代的显卡能够支持你的应用程序。这也是为什么大多数开发者基于较低版本的OpenGL编写程序并只提供选项启用新版本的特性。
在有些教程里你会看见更现代的特性,它们同样会以这种色注释方式标明。
在有些教程里你会看见更现代的特性,它们同样会以这种色注释方式标明。
## 扩展
## 扩展(Extension)
OpenGL的一大特性就是对扩展(Extension)的支持,当一个显卡公司提出一个新特性或者渲染上的大优化,通常会以**扩展**的方式在驱动中实现。如果一个程序在支持这个扩展的显卡上运行开发者可以使用这个扩展提供的一些更先进更有效的图形功能。通过这种方式开发者不必等待一个新的OpenGL规范面世就可以使用这些新的渲染特性了只需要简单地检查一下显卡是否支持此扩展。通常当一个扩展非常流行或者非常有用的时候它将最终成为未来的OpenGL规范的一部分。
OpenGL的一大特性就是对扩展的支持当一个显卡公司提出一个新特性或者渲染上的大优化通常会以**扩展**的方式在驱动中实现。如果一个程序在支持这个扩展的显卡上运行开发者可以使用这个扩展提供的一些更先进更有效的图形功能。通过这种方式开发者不必等待一个新的OpenGL规范面世就可以使用这些新的渲染特性了只需要简单地检查一下显卡是否支持此扩展。通常当一个扩展非常流行或者非常有用的时候它将最终成为未来的OpenGL规范的一部分。
使用扩展的代码大多看上去如下:
@@ -56,17 +56,17 @@ else
使用OpenGL3.3时,我们很少需要使用扩展来完成大多数功能,当需要的时候,本教程将提供适当的指示。
## 状态机
## 状态机(State Machine)
OpenGL自身是一个巨大的状态机(State Machine)一系列的变量描述OpenGL此刻应当如何运行。OpenGL的状态通常被称为OpenGL**上下文(Context)**。我们通常使用如下途径去更改OpenGL状态设置选项操作缓冲。最后我们使用当前OpenGL上下文来渲染。
OpenGL自身是一个巨大的状态机一系列的变量描述OpenGL此刻应当如何运行。OpenGL的状态通常被称为OpenGL**上下文(Context)**。我们通常使用如下途径去更改OpenGL状态设置选项操作缓冲。最后我们使用当前OpenGL上下文来渲染。
假设当我们想告诉OpenGL去画线段而不是三角形的时候我们通过改变一些上下文变量来改变OpenGL状态从而告诉OpenGL如何去绘图。一旦我们改变了OpenGL的状态为绘制线段下一个绘制命令就会画出线段而不是三角形。
当使用OpenGL的时候我们会遇到一些**状态设置**函数(State-changing Function),这类函数将会改变上下文。以及**状态应用**函数(State-using Function)这类函数会根据当前OpenGL的状态执行一些操作。只要你记住OpenGL本质上是个大状态机就能更容易理解它的大部分特性。
## 对象
## 对象(Object)
OpenGL库是用C语言写的同时也支持多种语言的派生但其内核仍是一个C库。由于C的一些语言结构不易被翻译到其它的高级语言因此OpenGL开发的时候引入了一些抽象层。“对象(Object)”就是其中一个。
OpenGL库是用C语言写的同时也支持多种语言的派生但其内核仍是一个C库。由于C的一些语言结构不易被翻译到其它的高级语言因此OpenGL开发的时候引入了一些抽象层。“对象”就是其中一个。
在OpenGL中一个**对象**是指一些选项的集合它代表OpenGL状态的一个子集。比如我们可以用一个对象来代表绘图窗口的设置之后我们就可以设置它的大小、支持的颜色位数等等。可以把对象看做一个C风格的结构体(Struct)
@@ -81,7 +81,6 @@ struct object_name {
!!! important
**基元类型(Primitive Type)**
使用OpenGL时建议使用OpenGL定义的基元类型。比如使用`float`时我们加上前缀`GL`(因此写作`GLfloat`)。`int``uint``char``bool`等等也类似。OpenGL定义的这些GL基元类型的内存布局是与平台无关的而int等基元类型在不同操作系统上可能有不同的内存布局。使用GL基元类型可以保证你的程序在不同的平台上工作一致。
当我们使用一个对象时通常看起来像如下一样把OpenGL上下文看作一个大的结构体

70
css/code_fixer.css Normal file
View File

@@ -0,0 +1,70 @@
.wy-nav-content {
max-width: 1300px;
}
body {
font-family: "微软雅黑", "宋体", "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
margin-bottom: 10px;
margin-top: 20px;
}
h1, h2 {
margin-top: 25px;
border-bottom: 1px solid #e1e4e5;
padding-bottom: 10px;
}
.wy-nav-content p, .wy-nav-content ol, .wy-nav-content ul, .wy-nav-content dl {
margin-bottom: 10px !important;
}
table td, table th {
font-size: 100% !important;
}
code,.rst-content tt {
font-size: 100%;
background: #F8F8F8;
}
p code {
font-size: 80%;
word-wrap: normal;
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
}
div.admonition code {
display: inline-block;
overflow-x: visible;
line-height: 18px;
color: #404040;
border: 1px solid rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 0.7);
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
}
.rst-content img {
display: block;
margin-left: auto;
margin-right: auto;
}
video {
display: block;
margin-left: auto;
margin-right: auto;
}
@media screen and (max-width: 800px) {
p, ol, ul {
text-align: left;
}
}
.hljs-comment {
font-style: normal;
font-size: 85%;
}

View File

@@ -1,29 +0,0 @@
.admonition-title {
display: none;
}
.admonition p{
margin: auto;
}
.important, .note, .attention {
display: block;
margin: 20px;
padding: 15px;
color: #444;
border-radius: 5px;
}
.important {
background-color: #D8F5D8;
border: 2px solid #AFDFAF;
}
.attention {
background-color: #FFD2D2;
border: 2px solid #E0B3B3;
}
.important {
background: #dbfaf4;
}

View File

@@ -1,66 +0,0 @@
body {
font-family: "微软雅黑", "宋体", "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, h4, h5, h6 {
margin-bottom: 15px;
margin-top: 20px;
}
h1, h2 {
margin-top: 25px;
border-bottom: 1px solid #e1e4e5;
padding-bottom: 15px;
}
.col-md-9 p {
line-height: 180%;
}
table td, table th {
font-size: 100% !important;
}
code {
font-size: 100%;
background: #F8F8F8;
}
p code {
font-size: 80%;
word-wrap: normal;
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
}
div.admonition code {
display: inline-block;
overflow-x: visible;
line-height: 18px;
color: #404040;
border: 1px solid rgba(0, 0, 0, 0.2);
background: rgba(255, 255, 255, 0.7);
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
}
img {
display: block;
margin-left: auto;
margin-right: auto;
}
video {
display: block;
margin-left: auto;
margin-right: auto;
}
@media screen and (max-width: 800px) {
p, ol, ul {
text-align: left;
}
}
.hljs-comment {
font-style: normal;
font-size: 90%;
}

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 801 B

After

Width:  |  Height:  |  Size: 801 B

View File

Before

Width:  |  Height:  |  Size: 777 B

After

Width:  |  Height:  |  Size: 777 B

View File

Before

Width:  |  Height:  |  Size: 432 B

After

Width:  |  Height:  |  Size: 432 B

View File

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 673 B

View File

Before

Width:  |  Height:  |  Size: 576 B

After

Width:  |  Height:  |  Size: 576 B

View File

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 574 B

View File

Before

Width:  |  Height:  |  Size: 612 B

After

Width:  |  Height:  |  Size: 612 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 887 B

After

Width:  |  Height:  |  Size: 887 B

View File

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 489 B

After

Width:  |  Height:  |  Size: 489 B

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

View File

Before

Width:  |  Height:  |  Size: 460 B

After

Width:  |  Height:  |  Size: 460 B

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 530 B

After

Width:  |  Height:  |  Size: 530 B

View File

Before

Width:  |  Height:  |  Size: 524 B

After

Width:  |  Height:  |  Size: 524 B

View File

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 536 B

View File

Before

Width:  |  Height:  |  Size: 527 B

After

Width:  |  Height:  |  Size: 527 B

View File

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 502 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 487 B

After

Width:  |  Height:  |  Size: 487 B

View File

Before

Width:  |  Height:  |  Size: 627 B

After

Width:  |  Height:  |  Size: 627 B

View File

Before

Width:  |  Height:  |  Size: 878 B

After

Width:  |  Height:  |  Size: 878 B

View File

Before

Width:  |  Height:  |  Size: 661 B

After

Width:  |  Height:  |  Size: 661 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

View File

Before

Width:  |  Height:  |  Size: 533 B

After

Width:  |  Height:  |  Size: 533 B

View File

Before

Width:  |  Height:  |  Size: 492 B

After

Width:  |  Height:  |  Size: 492 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Some files were not shown because too many files have changed in this diff Show More