1、本文所以内容来自 著名高校课件和学生笔记(校园里面经常见到有人高价买笔记)
2、任课教师不会提供参考文献,所以只能对作者表示感谢,如果引用了您的作品,可以用回复方式补充参考文献。
3、我不对文章无关问题进行解答,文章内容也比较难,我也很难解答您遇到的问题,如果发现BUG可以用回复方式帮我修正。
4、本课 属于Computer Graphics
,适用于计算机图形学课程,教材为电子工业出版社Computer Graphics(计算机图形学,中文版和英文版)
本课其他部分的导航条见页面底部
Chapter 4
Attributes of Graphics Primitives
State System and State Variables
A graphics system that maintain a list for the current values of attributes and parameters is called state system, or state machine.
Attributes of output primitives and some other parameters are called state variables or state parameters.
§4.1 OpenGL State Variables
OpenGL State Variables include:
Color and other primitives attributes
The current matrix mode
The elements of the model-view matrix
The current position for the frame buffer
The parameters for the lighting effects
Etc.
§4.2 Color and Grayscale
RGB color components
R, G, B components are mixed to display a particular color
Described with float numbers, the components ranged from 0.0 to 1.0
Described with integers, the components ranged from 0 to 255
Grayscale: only lighteness, without color
Described with float numbers, the lighteness ranged from 0.0 to 1.0
Described with integers, the lighteness ranged from 0 to 255
§4.3 OpenGL Color Functions
Set the color display mode:
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA);
Select the current color:
glColor3f (0.0, 1.0, 1.0);
glColor3i (255, 255, 0);
glColor3fv (colorArray);
RGBA Color Model
In RGBA color model, A is alpha coefficient.
The alpha coefficient controls color blending(颜色调和) for overlapping primitives.
Color blending is used in the simulation of transparency(透明) .
OpenGL Color Blending
To enable and disable color blending:
glEnable (GL_BLEND);
glDisable (GL_BLEND);
§4.4 Point Attributes in OpenGL
In OpenGL, a point has two attributes:
Size and color
To set the size of a point in OpenGL:
glPointSize(size);
To set the color of a point in OpenGL:
glColor3f (1.0, 0.0, 0.0);
glBegin (GL_POINTS);
glVertex2i (50,100);
glPointSize (2.0);
glEnd ( );
§4.5 Line Attributes in OpenGL
In OpenGL, a line has three attributes in general:
Width, style and color
To set the width of a line in OpenGL:
glLineWidth(width);
To set the color of a line in OpenGL, like to set the color of other primitives.
glColor3f (1.0, 0.0, 0.0);
glBegin (GL_LINES);
glVertex2iv (p1);
……
glEnd ( );
To Set Line-Style in OpenGL
To enable and disable line-style function:
glEnable (GL_LINE_STIPPLE);
glDisable (GL_LINE_STIPPLE);
To set the line-style:
glLineStipple (repeatFactor, pattern);
pattern is a 16-bit integer to describe the line-style:
§4.6 Curve Attributes
Parameters of curve attributes are the same as those for straight-line segments.
§4.9 Fill-Area Attributes
Scan-line approach:
Usually used in simple shapes
General graphics packages use this method
Use a starting interior point:
Usually used in complex shapes or interactive systems
Fill Styles
A basic fill-area attribute provided by a general graphics library is the display style of the interior.
We can display a region with
a hollow style
a single color
a specified fill pattern
§4.14 OpenGL Fill-Area Functions
We generate displays of filled convex polygons(凸多边形) in 4 steps:
Define a fill pattern;
Invoke the polygon-fill routine;
Activate the polygon-fill feature of OpenGL;
Describe the polygons to be filled.
GLubyte fillPattern []= {0xff, 0x00, ……};
glPolygonStripple (fillPattern);
glEnable(GL_POLYGON_STIPPLE);
OpenGL Interpolation(插值) Patterns
glShapeModel(GL_SMOOTH);
// GL_SMOOTH means smooth transition(过渡) effect
glBegin(GL_TRANGLES)
glColor(1.0, 0.0, 0.0);
glVertex2i(50,50);
glColor(0.0, 0.0, 1.0);
glVertex2i(0, 0);
glVertex2i(75, 0);
glEnd();
OpenGL Wire-Frame Methods
When the edges and interior area of a same polygon have different colors, we can:
glPolygonModel(GL_FRONT, GL_FILL);
glColor3f(1.0, 0.0, 0.0);
// Invoke polygon-generating routines
glPolygonModel(GL_FRONT, GL_LINE);
glColor3f(0.0, 1.0, 0.0);
// Invoke polygon-generating routines
§4.17 Anti-aliasing (反走样)
Graphics primitives have a jagged(锯齿状) appearance because of the low-frequent sampling(低频采样).
This is called aliasing (走样).
Methods that can eliminate aliasing is called anti-aliasing (反走样).
One is super-sample(过采样).
§4.18 OpenGL Anti-aliasing (反走样) Functions
glEnable (primitiveType);
// primitiveType can be GL_POINT_SMOOTH,
// GL_LINE_SMOOTH, GL_POLYGON_SMOOTH
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Color blending
§4.19 OpenGL Query Functions
Using OpenGL Query Functions, we can get current values for any state parameters.
glGet functions:
Each function needs two parameters:
glGetBooleanv(...);
glGetFloatv(...);
glGetIntegerv(...);
glGetFloatv(GL_CURRENT_COLOR, colorValues);
// The first parameter means what to be queried;
// The second parameter store the queried result.
分享到:
相关推荐
### 基于连续小波变换的地震波偏振属性特征化 #### 摘要与背景 本文探讨了一种利用连续小波变换(Continuous Wavelet Transforms, CWT)来表征地震波偏振属性的方法。传统的复杂迹分析方法虽然能够通过瞬时属性...
图形原语属性(Attributes of Graphics Primitives) - **颜色和光照**:颜色模型、光照模型及其实现细节。 - **纹理映射**:介绍纹理映射的基本概念和技术,包括纹理坐标、纹理过滤等。 - **透明度和混合**:透明...
Attributes结构在Java编程中是一个非常重要的概念,尤其对于理解类文件的元数据有着关键的作用。在Java类文件中,每个字段、方法或者类定义都可以有零个或多个属性(Attributes)。这些属性提供了额外的信息,例如...
Attributes are used to modify the runtime behavior of code in the .NET Framework. Applied .NET Attributes explores the application of .NET attributes and how developers can write custom attributes ...
本文档《Quality of Service Attributes for Diameter》(Diameter中的服务质量属性)由DIME(Diameter Maintenance and Extensions)工作组提出,详细阐述了如何在Diameter协议中定义和使用QoS相关的属性,以满足...
book makes the process of developing graphics interesting and entertaining by working in a graphic workspace, without the burden of mastering complicated language definitions and opaque examples. ...
属性信息存储在`attributes`属性中,这是一个Object类型的键值对集合,用来存储图形的各种元数据。然而,在实际应用中,特别是需要将这些属性展示在DataGrid控件中时,会遇到一些挑战,因为`attributes`对象不能直接...
commons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zipcommons-attributes-2.2.zip
.font(.systemFont(ofSize: 16)) .foregroundColor(.black) .backgroundColor(.white) .underlineStyle(.single) let attributedString = attributes.string("Hello, World!") ``` 这段代码首先创建了一个`...
XmlBuilder是一个针对XmlDocument对象的类库函数,主要目的是为了方便开发者更高效、更便捷地访问和操作XML文档的核心元素——DocumentElement,以及其包含的属性Attributes。在处理XML数据时,XmlDocument是.NET...
ChiMerge_Discretization_of_Numeric_Attributes_pychimerge
JavaEE源代码 commons-attributes-apiJavaEE源代码 commons-attributes-apiJavaEE源代码 commons-attributes-apiJavaEE源代码 commons-attributes-apiJavaEE源代码 commons-attributes-apiJavaEE源代码 commons-...
在深入探讨C#中的属性(Attributes)之前,我们先来明确一下这个概念的基本定义与功能。属性是C#中一种非常强大的元数据附加机制,它允许开发者为代码元素(如类、方法、属性等)添加额外的信息或元数据。这种机制在...
org-gephi-data-attributes-api可视化软件gephi的插件,nbm格式,
commons-attributes-compiler-2.2.zipcommons-attributes-compiler-2.2.zipcommons-attributes-compiler-2.2.zipcommons-attributes-compiler-2.2.zipcommons-attributes-compiler-2.2.zip
commons-attributes-api.jar,commons-attributes-compiler.jar,commons-beanutils.jar,commons-codec.jar,commons-collections.jar,commons-dbcp.jar,commons-digester.jar,commons-discovery.jar,commons-...
tkinter的menu attributes示例代码,结合https://blog.csdn.net/weixin_43708622/article/details/107053182一起学习
【Attributes在Visual C++中的应用】 Attributes在编程领域中,特别是在Microsoft的Visual C++环境中,是一种强大的元数据机制。它们允许程序员向代码添加特定的声明,这些声明在编译时和运行时为编译器、运行时...