差分

ナビゲーションに移動 検索に移動

MonoGame/クラスライブラリ/VertexBufferクラス

5,223 バイト追加, 2017年11月7日 (火) 01:52
ページの作成:「VertexBufferクラスは、ポリゴンを表示するのに使う頂点のリストである。 MonoGameでは頂点構造体を単純な配列で保持して...」
VertexBufferクラスは、ポリゴンを表示するのに使う頂点のリストである。

[[MonoGame]]では頂点構造体を単純な[[配列]]で保持しておいてもDrawUserPrimitevesメソッドで描画できるが、VertexBufferクラスを使っておくと[[頂点バッファ]]を[[メインメモリ]]から[[VRAM]]へ事前に転送しておけるので高速化が見込める。

[[C Sharp|C#]]でゴリゴリと頂点データを加工したい場合は[[メインメモリ]]と[[VRAM]]を行ったり来たりが相当な無駄になるのであまり向いていない。
逆にほとんどのケースが該当する「頂点データを決めたら破棄するまで変形させないもの」には使ったほうがよいとされている。
また、C#ではなく[[HLSL]]の[[頂点シェーダー]]で[[頂点バッファ]]の加工を行う場合は必須となる。

ちなみに一部のOpenGL系プラットフォームでは一度格納すると二度と取り出せない(GetDataできない)ものも存在している。
3Dモデルの頂点データを入れて頂点シェーダーで当たり判定の範囲を動的に生成しGetDataで取得していたものが動かなくて悲しくなった。

== 継承 ==
* System.Object
** Microsoft.Xna.Framework.Graphics.GraphicsResource
*** Microsoft.Xna.Framework.Graphics.VertexBuffer
**** Microsoft.Xna.Framework.Graphics.DynamicVertexBuffer

== 名前空間 ==
* [[MonoGame/クラスライブラリ/Microsoft.Xna.Framework.Graphics名前空間|Microsoft.Xna.Framework.Graphics名前空間]]

== 構文 ==
public class VertexBuffer : GraphicsResource

== コンストラクタ ==
{| class="wikitable"
|+
!
! 名称
! 概要
|-
| protected
! style="white-space:nowrap;text-align:left" | VertexBuffer(GraphicsDevice, VertexDeclaration, int, BufferUsage, bool)
|
|-
| public
! style="white-space:nowrap;text-align:left" | VertexBuffer(GraphicsDevice, VertexDeclaration, int, BufferUsage)
|
|-
| public
! style="white-space:nowrap;text-align:left" | VertexBuffer(GraphicsDevice, Type, int, BufferUsage)
|
|}

== プロパティ ==
{| class="wikitable"
|+
!
! 名称
! 概要
|-
| public
! style="white-space:nowrap;text-align:left" | BufferUsage
|
|-
| public
! style="white-space:nowrap;text-align:left" | GraphicsDevice
| (GameResourceクラスから継承)
|-
| public
! style="white-space:nowrap;text-align:left" | IsDisposed
| (GameResourceクラスから継承)
|-
| public
! style="white-space:nowrap;text-align:left" | Name
| (GameResourceクラスから継承)
|-
| public
! style="white-space:nowrap;text-align:left" | Tag
| (GameResourceクラスから継承)
|-
| public
! style="white-space:nowrap;text-align:left" | VertexCount
|
|-
| public
! style="white-space:nowrap;text-align:left" | VertexDeclaration
|
|}

== メソッド ==
{| class="wikitable"
|+
!
! 名称
! 概要
|-
| public
! style="white-space:nowrap;text-align:left" | Dispose(bool)
| 派生クラスを作る場合は自前管理のリソースの破棄を実装する必要がある。
|-
| protected
! style="white-space:nowrap;text-align:left" | Dispose()
| (GameResourceクラスから継承)
|-
| protected
! style="white-space:nowrap;text-align:left" | Finalize
| (GameResourceクラスから継承)
|-
| public
! style="white-space:nowrap;text-align:left" | GetData<T>(int, T[], int, int, int)
| この頂点バッファから頂点データを取得する。
|-
| public
! style="white-space:nowrap;text-align:left" | GetData<T>(T[], int, int)
|
|-
| public
! style="white-space:nowrap;text-align:left" | GetData<T>(T[])
|
|-
| protected internal
! style="white-space:nowrap;text-align:left" | GraphicsDeviceResetting
| GraphicsDeviceがリセットされGPU上のリソースを再作成する必要があるときに呼ばれる。
|-
| public
! style="white-space:nowrap;text-align:left" | SetData<T>(int, T[], int, int, int)
| この頂点バッファに頂点データを設定する。大雑把に言えば頂点データの配列をメインメモリからVRAMにコピーする。
|-
| public
! style="white-space:nowrap;text-align:left" | SetData<T>(T[])
|
|-
| public
! style="white-space:nowrap;text-align:left" | SetData<T>(T[], int, int)
|
|-
| protected
! style="white-space:nowrap;text-align:left" | SetDataInternal<T>
|
|-
| public
! style="white-space:nowrap;text-align:left" | ToString
| (GameResourceクラスから継承)
|}

== イベント ==
{| class="wikitable"
|+
!
! 名称
! 概要
|-
| public
| Disposing
| (GameResourceクラスから継承)
|}

== 関連項目 ==
* [[MonoGame/クラスライブラリ/GraphicsResourceクラス]]
** [[MonoGame/クラスライブラリ/VertexBufferクラス]]
** [[MonoGame/クラスライブラリ/IndexBufferクラス]]
* [[MonoGame/クラスライブラリ/IVertexTypeインターフェイス]]
** [[MonoGame/クラスライブラリ/VertexPositionColor構造体]]
** [[MonoGame/クラスライブラリ/VertexPositionTexture構造体]]
** [[MonoGame/クラスライブラリ/VertexPositionColorTexture構造体]]
** [[MonoGame/クラスライブラリ/VertexPositionNormalTexture構造体]]

[[category: MonoGame]]
匿名利用者

案内メニュー