当前位置:网站首页>OpenGL (1) vertex buffer
OpenGL (1) vertex buffer
2022-07-24 20:23:00 【thefist11】
1. Vertex buffer object (Vertex Buffer Objects, VBO)
Will be in GPU Memory ( It is often called video memory ) Store a large number of vertices in . Used to manage this memory , The advantage of using these buffer objects is that we can send a large amount of data to the graphics card at one time , Instead of sending once per vertex .
step1. Use glGenBuffers Function and a buffer ID Generate a VBO object
unsigned int VBO;
glGenBuffers(1, &VBO);
OpenGL There are many buffer object types , The buffer type of vertex buffer object is GL_ARRAY_BUFFER.
step2. Use glBindBuffer Function to bind the newly created buffer to GL_ARRAY_BUFFER On the goal
glBindBuffer(GL_ARRAY_BUFFER, VBO);
From this moment on , Any... We use ( stay GL_ARRAY_BUFFER On the target ) Buffer calls are used to configure the buffer of the current binding (VBO).
step3. You can call glBufferData Function copies the previously defined vertex data into the buffered memory :
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBufferData Is a function specially used to copy user-defined data to the current binding buffer .
Parameter one : Type of target buffer , The vertex buffer object is currently bound to GL_ARRAY_BUFFER On the goal .
Parameter two : Specifies the size of the transferred data ( In bytes ); With a simple sizeof Calculate the vertex data size .
Parameter 3 : The actual data sent .
Parameter 4 : Specifies how we want the graphics card to manage the given data . It comes in three forms :
GL_STATIC_DRAW : The data will not or will hardly change .
GL_DYNAMIC_DRAW: The data will be changed a lot .
GL_STREAM_DRAW : Data changes every time it's plotted .
The position data of the triangle will not change , Keep as is every render call , So its best use type is GL_STATIC_DRAW.eg. Say that the data in a buffer will be changed frequently , Then the type used is GL_DYNAMIC_DRAW or GL_STREAM_DRAW, This ensures that the graphics card places the data in the memory part that can be written at high speed .
Now we have stored the vertex data in the memory of the graphics card , use VBO This vertex buffer object is managed .
边栏推荐
- Batch download files from the server to the local
- Introduction and advanced tutorial of Albert duilib
- Sql164 next day retention rate of new users per day in November 2021
- Virtual machine win7 system installation vmtool
- [training Day8] interesting number [digital DP]
- 872. Maximum common divisor
- Lights of thousands of families in the year of xinchou
- Covid-19-20 - basic method of network segmentation based on vnet3d
- Install MySQL 5.7.37 on windows10
- Redisgraph graphic database multi activity design scheme
猜你喜欢

Student achievement management system based on PHP
![[training Day6] triangle [mathematics] [violence]](/img/57/d603886c202de7d46ea03487b633f5.png)
[training Day6] triangle [mathematics] [violence]

Alibaba cloud technology expert Yang Zeqiang: building observable capabilities on elastic computing cloud

C# 窗体应用TreeView控件使用
![[training Day6] game [mathematics]](/img/b2/09c752d789eead9a6b60f4b4b1d5d4.png)
[training Day6] game [mathematics]

Implementation of OA office system based on JSP

Alibaba Sentinel 基操

The difference between map and flatmap in stream

Install MySQL 5.7.37 on windows10

Do you want to enroll in a training class or study by yourself?
随机推荐
Please ask a question. Follow the quick start method. After creating the table, the Flink SQL queries and displays the table structure, but there is an error when it exceeds the limit. What should we
Applet wonderful bug update~
"Hualiu is the top stream"? Share your idea of yyds
[training Day9] maze [line segment tree]
Machine learning job interview summary: five key points that resume should pay attention to
870. Approximate number
Redis common configuration description
[training Day8] tent [mathematics] [DP]
Monotone stack and monotone queue (linear complexity optimization)
Install MySQL 5.7.37 on windows10
Todolist case
Batch download files from the server to the local
Richview table table alignment
[Extension Program - cat scratch 1.0.15 _ online video and audio acquisition artifact _ installation tutorial plus acquisition]
(posted) differences and connections between beanfactory and factorybean
存储类别
[training Day10] linear [mathematics] [thinking]
Codeforces round 580 (Div. 2) c- almost equal [Law]
Analysis of xmldecoder parsing process
Call Baidu AI open platform to realize image and character recognition