在opengl中可以绘制二维图像,分为两种,BITMAP和image 1.bitmap和image的区别有: bitmap中对图像的每个像素只存储一位(0或1),用来表示用当前颜色绘制还是不绘制,而image是图像的每个像素存储可能很多位,存储它的各个通道的颜色信息; bitmap是绘制在
在opengl中可以绘制二维图像,分为两种,BITMAP和image
1.bitmap和image的区别有:
bitmap中对图像的每个像素只存储一位(0或1),用来表示用当前颜色绘制还是不绘制,而image是图像的每个像素存储可能很多位,存储它的各个通道的颜色信息;
bitmap是绘制在三位空间中的一群点,其中每个点都受各变换矩阵的影响,等同于一群Gl_begin(GL_POINTS)操作联合在一起 ,而image是直接绘制在帧缓存上,在绘制原点所投影到的屏幕坐标处开始绘制,就是直接在二维屏幕上绘制,就像普通的二维绘制一样,他只有那个绘制的原点受变换矩阵的影响,比如当原点的位置被裁剪掉之后,整张图片也将消失。
bitmap是绘制在三位场景的一些点,也就是每个点都会有法向等信息,回收光照等影响,拉近看还会发现点间的距离,image是直接写入帧缓存的,绘制的颜色就是最终看到的颜色, 像素点间不会有距离
2.bitmap的绘制步骤
glColor3f制定当前绘制的点的颜色
glRasterPos2f定义当前的绘制原点(OPENGL绘制的原点是在左下角的,即定义之后,都是从这点开始按照从左至右,从下至上绘制的)
只有当调用了 glRasterPos2f之后,他前面的glColor3f才会起作用,所以要先设置颜色,再定义原点
void glBitmap( GLsizei width, 绘制宽度的点数
GLsizei height, 绘制高度 的点数
GLfloat xorig, 在以原点的二维坐标系中的X坐标
GLfloat yorig, 在以原点的二维坐标系中的Y坐标
GLfloat xmove,绘制后原点的横向位移
GLfloat ymove,绘制后原点的纵向位移
const GLubyte * bitmap 存储的数据);
绘制存储在内存中的数据
其中bitmap中存储的数据按照从左下角起8位对其(一个GLUBYTE),例如下图的数据就应该因该存储为
0xc0, 0x00, 0xc0, 0x00, 0xc0,0x00, 0xc0, 0x00, 0xc0, 0x00,0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,0xff, 0xc0, 0xff, 0xc0。如果width不是八的倍数,比如是30个点,那么这一行仍然要占8的倍数位,应占用4个字节,最后面的两位将被自动舍弃。
bitmap更适合绘制颜色较单一,且需要能进行三维观察的图
他也可以绘制彩色图,只是要每个点绘制前改变当前绘制颜色,如图
2.image的绘制步骤
2.1glPixelStorei()设置数据的存储和解读方式,这里可以进行的常用设置有
GL_PACK_SWAP_BYTES改变一个像素各个成分(不是颜色通道的顺序)的顺序,比如原先的存储顺序为(颜色、深度、索引),颠倒后为(索引、深度、颜色),而一个颜色的通常都存储为RGB。这个设置通常不用改变
剪裁图像:比如我们只要绘制在内存中图像数据中的一个矩形区域,原图为640*480,我们需要绘制从(10,10) 开始长100,宽100的区域到屏幕。我们需要先用glPixelStorei(GL_UNPACK_ROW_LENGTH,640)设置图像的原宽为640,再用glPixelStorei(GL_UNPACK_SKIP_ROWS,10)设置我们跳过了10行,然后用glPixelStorei(GL_UNPACK_SKIP_PIXELS,10)设置我们又把起点跳过了10个像素(列),最后调用glDrawPixels(100,100...)来绘图。
2.2glPixelTransferf设置像素的传递和映射,用这个操作,可以在存储或读取时将特定的颜色映射到一种颜色,或者将特定颜色的值扩大缩小等
2.3glPixelZoom(x,y)设置几何变换,这将设置最后图像的一个像素在X/Y方向上被放大的倍数,都是2则放大四倍,如果为负数在读取时进行镜像
2.4调用glDrawPixels绘制存储在内存中的图像到帧缓存上
或调用glReadPixels读取帧缓存上的数据到内存中(可以做截图用)
或调用glCopyPixels拷贝帧缓存的一处数据到帧缓存的另一处(觉得很适合做赛车游戏的后视镜 ^^)

ACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

MySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.

MySQL is an efficient relational database management system suitable for storing and managing data. Its advantages include high-performance queries, flexible transaction processing and rich data types. In practical applications, MySQL is often used in e-commerce platforms, social networks and content management systems, but attention should be paid to performance optimization, data security and scalability.

The relationship between SQL and MySQL is the relationship between standard languages and specific implementations. 1.SQL is a standard language used to manage and operate relational databases, allowing data addition, deletion, modification and query. 2.MySQL is a specific database management system that uses SQL as its operating language and provides efficient data storage and management.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor