mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 17:45:37 +00:00
8dcb8601a2
Hopefully this is the first and last time we have to do this.
29 lines
2.6 KiB
Plaintext
29 lines
2.6 KiB
Plaintext
{\rtf1\ansi\ansicpg1253\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}
|
||
{\colortbl ;\red163\green21\blue21;}
|
||
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\cf1\lang1033\b\fs28 Introduction\b0\fs22\par
|
||
\par
|
||
This sample demonstrates how to modify the data in an existing VBO.\par
|
||
\b\fs28\par
|
||
Controls\par
|
||
\b0\fs22\par
|
||
Press Esc or click the close button to exit.\par
|
||
\par
|
||
\b\fs28 Implementation\par
|
||
\b0\fs22\par
|
||
This sample builds on the concepts of the "VBO Static" sample, so please refer to that for instructions on how to load and render a VBO.\par
|
||
\par
|
||
OpenGL defines nine different BufferUsageHints for VBO that can improve rendering performance when used correctly. Each hint consists of two parts:\par
|
||
1. update frequency, which can be one of "static", "dynamic" or "stream", and\par
|
||
2. buffer usage, which can be one of "draw", "read" or "copy".\par
|
||
\par
|
||
Update frequency defines how often the buffer will be updated: static means that the buffer is modified infrequently or not at all; dynamic means that parts of it may be modified frequently; stream means that the whole buffer is discarded and recreated frequently.\par
|
||
\par
|
||
Buffer usage defines how the buffer will be used: draw means that the buffer will be used to draw geometry; read means that the buffer will be used to read data from OpenGL back into system memory (via GL.GetBufferSubData or GL.MapBuffer); copy means that the buffer will hold intermediate results that will be copied from/to other OpenGL buffers.\par
|
||
\par
|
||
When uploading data to a VBO via GL.BufferData, you should specify the BufferUsageHint that most closely resembles the usage pattern for this buffer. For example, if you are planning to use this buffer for rendering unchanging (or mostly unchanging) geometry you should specify BufferUsageHint.StaticDraw. If you are planning to read back results that change every frame, you should use BufferUsageHint.StreamRead.\par
|
||
\par
|
||
Note that this is only a hint that might allow the driver to optimize performance. It doesn't prevent you from using the buffer in a way opposed to the hint (for example, reading back data from a StaticDraw buffer). However, doing so might result in a performance penalty.\par
|
||
\par
|
||
In this sample, we use a StreamDraw buffer that is recreated every frame (see OnRenderFrame method). Since OpenGL might not have finished drawing from the buffer when we try to update its data, we first call GL.BufferData(..., IntPtr.Zero) to allocate a new buffer and upload the new data to this. Without this optimization, OpenGL would have to block until the old buffer would finish drawing; this optimization allows the drawing and the data upload to go on at the same time.\par
|
||
}
|
||
|