QSGGeometry Class

QSGGeometry クラスは、Qt Quick Scene Graph 内のグラフィックスプリミティブの低レベルストレージを提供します。詳細...

ヘッダー #include <QSGGeometry>
CMake: find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick)
qmake: QT += quick

パブリックな型

struct Attribute
struct AttributeSet
struct ColoredPoint2D
struct Point2D
struct TexturedPoint2D
enum AttributeType { UnknownAttribute, PositionAttribute, ColorAttribute, TexCoordAttribute, TexCoord1Attribute, TexCoord2Attribute }
enum DataPattern { AlwaysUploadPattern, DynamicPattern, StaticPattern, StreamPattern }
enum DrawingMode { DrawPoints, DrawLines, DrawLineStrip, DrawTriangles, DrawTriangleStrip }
enum Type { ByteType, UnsignedByteType, ShortType, UnsignedShortType, IntType, …, DoubleType }

パブリック関数

QSGGeometry(const QSGGeometry::AttributeSet &attributes, int vertexCount, int indexCount = 0, int indexType = UnsignedShortType)
virtual ~QSGGeometry()
void allocate(int vertexCount, int indexCount = 0)
int attributeCount() const
const QSGGeometry::Attribute *attributes() const
unsigned int drawingMode() const
int indexCount() const
void *indexData()
const void *indexData() const
uint *indexDataAsUInt()
const uint *indexDataAsUInt() const
quint16 *indexDataAsUShort()
const quint16 *indexDataAsUShort() const
QSGGeometry::DataPattern indexDataPattern() const
int indexType() const
float lineWidth() const
void markIndexDataDirty()
void markVertexDataDirty()
void setDrawingMode(unsigned int mode)
void setIndexDataPattern(QSGGeometry::DataPattern p)
void setLineWidth(float width)
void setVertexDataPattern(QSGGeometry::DataPattern p)
int sizeOfIndex() const
int sizeOfVertex() const
int vertexCount() const
void *vertexData()
const void *vertexData() const
QSGGeometry::ColoredPoint2D *vertexDataAsColoredPoint2D()
const QSGGeometry::ColoredPoint2D *vertexDataAsColoredPoint2D() const
QSGGeometry::Point2D *vertexDataAsPoint2D()
const QSGGeometry::Point2D *vertexDataAsPoint2D() const
QSGGeometry::TexturedPoint2D *vertexDataAsTexturedPoint2D()
const QSGGeometry::TexturedPoint2D *vertexDataAsTexturedPoint2D() const
QSGGeometry::DataPattern vertexDataPattern() const

静的パブリックメンバ

const QSGGeometry::AttributeSet &defaultAttributes_ColoredPoint2D()
const QSGGeometry::AttributeSet &defaultAttributes_Point2D()
const QSGGeometry::AttributeSet &defaultAttributes_TexturedPoint2D()
void updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect)
void updateRectGeometry(QSGGeometry *g, const QRectF &rect)
void updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &textureRect)

詳細な説明

QSGGeometry クラスは、シーングラフでレンダリングされたプリミティブのジオメトリを格納します。頂点データと、オプションでインデックスデータが含まれる。プリミティブのトポロジーとも呼ばれるジオメトリの描画に使用されるモードは、setDrawingMode() で指定します。

頂点は x と y の値で定義される点のような単純なものから、各頂点が法線、テクスチャ座標、3D 位置を含むような複雑なものまであります。QSGGeometry::AttributeSet は、頂点データの構築方法を記述するために使用されます。属性セットは構築時にのみ指定できます。QSGGeometry クラスは、デフォルトでいくつかの便利な属性と属性セットを提供します。defaultAttributes_Point2D() 関数は通常のベタ塗り長方形で使用する属性セットを返し、defaultAttributes_TexturedPoint2D 関数はテクスチャ付き 2D ジオメトリで使用する属性を返します。頂点データは内部的にvoid * として保存され、vertexData() 関数でアクセスできます。一般的なアトリビュート・セットの便利なアクセッサは、vertexDataAsPoint2D() とvertexDataAsTexturedPoint2D() で利用できます。頂点データは、コンストラクタに頂点数を渡すか、後でallocate() を呼び出すことで割り当てられます。

QSGGeometry には、符号なし 32 ビット、符号なし 16 ビット、または符号なし 8 ビット整数のいずれかのインデックスを含めることができます。インデックスの型は作成時に指定する必要があり、変更することはできません。

以下は、位置と色の頂点で構成されるジオメトリの作成方法を示すスニペットです。

struct MyPoint2D {
    float x;
    float y;
    float r;
    float g;
    float b;
    float a;

    void set(float x_, float y_, float r_, float g_, float b_, float a_) {
        x = x_;
        y = y_;
        r = r_;
        g = g_;
        b = b_;
        a = a_;
    }
};

QSGGeometry::Attribute MyPoint2D_Attributes[] = {
    QSGGeometry::Attribute::create(0, 2, FloatType, true),
    QSGGeometry::Attribute::create(1, 4, FloatType, false)
};

QSGGeometry::AttributeSet MyPoint2D_AttributeSet = {
    2,
    sizeof(MyPoint2D),
    MyPoint2D_Attributes
};

...

geometry = new QSGGeometry(MyPoint2D_AttributeSet, 2);
geometry->setDrawingMode(DrawLines);

MyPoint2D *vertices = static_cast<MyPoint2D *>(geometry->vertexData());
vertices[0].set(0, 0, 1, 0, 0, 1);
vertices[1].set(width(), height(), 0, 0, 1, 1);

QSGGeometry はソフトウェア・バッファであり、2D グラフィックスで使用されるバッファは通常、フレームごとに変化する多数の小さなバッファで構成され、グラフィックス・メモリにアップロードされるメリットがないため、レンダリングの高速化という点ではクライアント側である。ただし、QSGGeometry は、setVertexDataPattern ()とsetIndexDataPattern ()関数を使用して、バッファをアップロードする必要があることをレンダラーに示すヒントをサポートしています。このヒントが尊重されるかどうかは、実装によって異なります。

注意: QSG 接頭辞を持つすべてのクラスは、シーングラフのレンダリングスレッドでのみ使用する必要があります。詳しくはScene Graph と Renderingを参照してください。

QSGGeometryNodeScene Graph - Custom Geometryも参照してください

メンバータイプ ドキュメント

enum QSGGeometry::AttributeType

この列挙型は、いくつかの属性タイプを識別します。

定数説明
QSGGeometry::UnknownAttribute0気にしない
QSGGeometry::PositionAttribute1位置
QSGGeometry::ColorAttribute2
QSGGeometry::TexCoordAttribute3テクスチャ座標
QSGGeometry::TexCoord1Attribute4テクスチャ座標1
QSGGeometry::TexCoord2Attribute5テクスチャ座標2

enum QSGGeometry::DataPattern

DataPattern 列挙型は、ジオメトリ オブジェクトの頂点データとインデックス データの使用パターンを指定するために使用します。

定数説明
QSGGeometry::AlwaysUploadPattern0データは常にアップロードされます。つまり、インデックスと頂点のデータを変更した後、ユーザーが明示的にダーティとしてマークする必要はありません。これがデフォルトです。
QSGGeometry::DynamicPattern2データは繰り返し変更され、何度も描画されます。これはパフォーマンスを向上させるヒントです。設定されている場合、ユーザーはデータを変更した後に必ずダーティとしてマークする必要があります。
QSGGeometry::StaticPattern3データは一度だけ変更され、何度も描画されます。これはより良いパフォーマンスを提供する可能性のあるヒントです。設定すると、ユーザーはデータを変更した後に必ずダーティとしてマークする必要があります。
QSGGeometry::StreamPattern1データは描画されるたびに変更されます。これは、より良いパフォーマンスを提供する可能性のあるヒントです。設定されている場合、ユーザーはデータを変更した後、必ずダーティとしてマークしなければならない。

enum QSGGeometry::DrawingMode

プリミティブトポロジとも呼ばれる描画モードを指定します。

注意: Qt 6 からシーングラフは、サポートされているすべての 3D グラフィックス API でサポートされているトポロジーのみを公開します。その結果、DrawLineLoopDrawTriangleFan は、Qt 6 では実行時にサポートされなくなりました。

定数
QSGGeometry::DrawPoints0x0000
QSGGeometry::DrawLines0x0001
QSGGeometry::DrawLineStrip0x0003
QSGGeometry::DrawTriangles0x0004
QSGGeometry::DrawTriangleStrip0x0005

enum QSGGeometry::Type

頂点データのコンポーネントタイプを指定します。

定数説明
QSGGeometry::ByteType0x1400
QSGGeometry::UnsignedByteType0x1401
QSGGeometry::ShortType0x1402
QSGGeometry::UnsignedShortType0x1403
QSGGeometry::IntType0x1404
QSGGeometry::UnsignedIntType0x1405
QSGGeometry::FloatType0x1406
QSGGeometry::Bytes2Type0x1407Qt 5.14 で追加されました。
QSGGeometry::Bytes3Type0x1408Qt 5.14 で追加されました。
QSGGeometry::Bytes4Type0x1409Qt 5.14 で追加されました。
QSGGeometry::DoubleType0x140AQt 5.14 で追加されました。

メンバ関数のドキュメント

QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes, int vertexCount, int indexCount = 0, int indexType = UnsignedShortType)

attributes に基づいてジオメトリ・オブジェクトを構築する。

このオブジェクトは、attributes の累積サイズに基づいてvertexCount の頂点のためのスペースを割り当て、indexCount のためのスペースを割り当てます。

indexType にはUnsignedShortType またはUnsignedIntType を指定できます。後者のサポートは、実行時に使用されるグラフィックス API の実装に依存するため、常に利用できるとは限りません。

ジオメトリ・オブジェクトは、デフォルトではDrawTriangleStrip を描画モードとして構築されます。

注意: attributes と、それによって参照されるAttribute オブジェクトは、QSGGeometry の寿命が尽きるまで有効でなければなりません。QSGGeometry はattributes への参照を保持し、Attribute オブジェクトは削除しません。

[virtual noexcept] QSGGeometry::~QSGGeometry()

ジオメトリオブジェクトと、それが割り当てている頂点データとインデックスデータを破棄します。

void QSGGeometry::allocate(int vertexCount, int indexCount = 0)

このジオメトリ オブジェクトの頂点とインデックスのデータを、vertexCount 頂点とindexCount インデックスに合うようにリサイズします。

この呼び出しの後、頂点とインデックスのデータは無効になります。呼び出し元は、レンダラーが内部バッファを更新する機会を確保するために、node->markDirty(QSGNode::DirtyGeometry) を呼び出して、関連するジオメトリ ノードをダーティとしてマークする必要があります。

int QSGGeometry::attributeCount() const

このジオメトリが使用するアトリビュート・セットの数を返します。

const QSGGeometry::Attribute *QSGGeometry::attributes() const

このジオメトリの属性を配列で返します。配列のサイズはattributeCount() で指定します。

[static] const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_ColoredPoint2D()

頂点ごとの色付き2D描画に使用する属性を返す便利な関数。

[static] const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_Point2D()

2Dベタ塗り描画に使用する属性を返す便利な関数です。

[static] const QSGGeometry::AttributeSet &QSGGeometry::defaultAttributes_TexturedPoint2D()

テクスチャ付き2D描画に使用する属性を返す便利な関数。

unsigned int QSGGeometry::drawingMode() const

このジオメトリの描画モードを返します。

デフォルト値はDrawTriangleStrip です。

setDrawingMode()も参照してください

int QSGGeometry::indexCount() const

このジオメトリ・オブジェクトのインデックスの数を返します。

void *QSGGeometry::indexData()

このジオメトリオブジェクトの生のインデックスデータへのポインタを返します。

indexDataAsUShort() およびindexDataAsUInt()も参照

const void *QSGGeometry::indexData() const

このジオメトリオブジェクトの生のインデックスデータへのポインタを返します。

indexDataAsUShort() およびindexDataAsUInt()も参照

uint *QSGGeometry::indexDataAsUInt()

32ビット符号なし整数のミュータブル配列としてインデックスデータにアクセスするための便利な関数。

const uint *QSGGeometry::indexDataAsUInt() const

32ビット符号なし整数の不変配列としてインデックスデータにアクセスするための便利な関数。

quint16 *QSGGeometry::indexDataAsUShort()

16ビット符号なし整数からなる変更可能な配列としてインデックスデータにアクセスするための便利な関数。

const quint16 *QSGGeometry::indexDataAsUShort() const

インデックスデータを16ビット符号なし整数の不変配列としてアクセスするための便利な関数。

QSGGeometry::DataPattern QSGGeometry::indexDataPattern() const

このジオメトリ内のインデックスの使用パターンを返します。デフォルトのパターンはAlwaysUploadPattern です。

setIndexDataPattern()も参照してください

int QSGGeometry::indexType() const

このジオメトリ オブジェクトのインデックスに使用されるプリミティブ型を返します。

float QSGGeometry::lineWidth() const

このジオメトリに使用される現在の線幅または点幅を取得します。このプロパティは、drawingModeDrawLines またはDrawLineStrip のときの線幅にのみ適用されます。 サポートされている場合は、drawingModeDrawPoints のときのポイント サイズにも適用されます。

デフォルト値は1.0

注: 点描画と線描画のサポートは、プラットフォームとグラフィックス API によっ て、実行時に制限される場合があります。例えば、ポイント・スプライトをサポートしていないAPIもあるため、1以外のサイズを設定することはできません。

注: 1.0 の幅は常にサポートされている。

setLineWidth() およびdrawingMode()も参照

void QSGGeometry::markIndexDataDirty()

このジオメトリの頂点が変更されたため、再度アップロードする必要があることを示します。

この関数は、頂点の使用パターンが StaticData で、このジオメトリをレンダリングするレンダラーがジオメトリを頂点バッファオブジェクト(VBO)にアップロードする場合にのみ効果があります。

void QSGGeometry::markVertexDataDirty()

このジオメトリの頂点が変更されたため、再度アップロードする必要があることを示します。

この関数は、頂点の使用パターンが StaticData で、このジオメトリをレンダリングするレンダラーがジオメトリを頂点バッファオブジェクト(VBO)にアップロードする場合にのみ効果があります。

void QSGGeometry::setDrawingMode(unsigned int mode)

このジオメトリの描画に使用するmode を設定します。

デフォルト値はQSGGeometry::DrawTriangleStrip です。

drawingMode() およびDrawingModeも参照してください

void QSGGeometry::setIndexDataPattern(QSGGeometry::DataPattern p)

インデックスの使用パターンをp に設定します。

デフォルトはAlwaysUploadPattern 。デフォルト以外に設定した場合、ユーザは、インデックス・データを変更した後にQSGNode::markDirty() を呼び出すだけでなく、QSGNode::DirtyGeometry を使用してmarkIndexDataDirty() を呼び出す必要があります。

indexDataPattern()も参照

void QSGGeometry::setLineWidth(float width)

このジオメトリに使用する線幅または点幅をwidth に設定します。このプロパティは、drawingModeDrawLines またはDrawLineStrip の場合に線幅にのみ適用されます。サポートされている場合は、drawingModeDrawPoints の場合の点サイズにも適用されます。

注: 点描画と線描画のサポートは、プラットフォームとグラフィックス API によっ て、実行時に制限される場合があります。例えば、ポイント・スプライトをサポートしていない API もあるため、1 以外のサイズを設定することはできません。

注: 1.0 の幅は常にサポートされている。

lineWidth() およびdrawingMode()も参照

void QSGGeometry::setVertexDataPattern(QSGGeometry::DataPattern p)

頂点の使用パターンをp に設定します。

デフォルトはAlwaysUploadPattern です。デフォルト以外に設定した場合は、頂点データを変更した後に、QSGNode::DirtyGeometry を使用してQSGNode::markDirty() を呼び出すだけでなく、markVertexDataDirty() を呼び出す必要があります。

vertexDataPattern()も参照してください

int QSGGeometry::sizeOfIndex() const

インデックス型のバイトサイズを返す。

この値は、インデックス・タイプがUnsignedShortType の場合は2 に、UnsignedIntType の場合は4 になります。

int QSGGeometry::sizeOfVertex() const

1頂点のサイズをバイト単位で返す。

この値は属性に由来する。

[static] void QSGGeometry::updateColoredRectGeometry(QSGGeometry *g, const QRectF &rect)

ジオメトリgrect の座標で更新します。

この関数は、ジオメトリオブジェクトにQSGGeometry::ColoredPoint2D の頂点からなる単一の三角形の帯が含まれていると仮定します。

[static] void QSGGeometry::updateRectGeometry(QSGGeometry *g, const QRectF &rect)

ジオメトリgrect の座標で更新します。

この関数は、ジオメトリオブジェクトにQSGGeometry::Point2D の頂点からなる単一の三角形の帯が含まれていると仮定します。

[static] void QSGGeometry::updateTexturedRectGeometry(QSGGeometry *g, const QRectF &rect, const QRectF &textureRect)

rect の座標とtextureRect のテクスチャ座標でジオメトリg を更新します。

textureRect は正規化座標でなければなりません。

g は、 型の4つの頂点からなる三角形の帯であると仮定します。QSGGeometry::TexturedPoint2D

int QSGGeometry::vertexCount() const

このジオメトリ・オブジェクトの頂点の数を返します。

void *QSGGeometry::vertexData()

このジオメトリオブジェクトの生の頂点データへのポインタを返します。

vertexDataAsPoint2D() およびvertexDataAsTexturedPoint2D()も参照してください

const void *QSGGeometry::vertexData() const

このジオメトリオブジェクトの生の頂点データへのポインタを返します。

vertexDataAsPoint2D() およびvertexDataAsTexturedPoint2D()も参照してください

QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D()

QSGGeometry::ColoredPoint2D の変更可能な配列として頂点データにアクセスするための便利な関数です。

const QSGGeometry::ColoredPoint2D *QSGGeometry::vertexDataAsColoredPoint2D() const

頂点データをQSGGeometry::ColoredPoint2D の不変配列としてアクセスするための便利な関数。

QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D()

QSGGeometry::Point2D の変更可能な配列として頂点データにアクセスするための便利な関数です。

const QSGGeometry::Point2D *QSGGeometry::vertexDataAsPoint2D() const

頂点データをQSGGeometry::Point2D の不変配列としてアクセスするための便利な関数。

QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D()

QSGGeometry::TexturedPoint2D の変更可能な配列として頂点データにアクセスするための便利な関数です。

const QSGGeometry::TexturedPoint2D *QSGGeometry::vertexDataAsTexturedPoint2D() const

頂点データをQSGGeometry::TexturedPoint2D の不変配列としてアクセスするための便利な関数。

QSGGeometry::DataPattern QSGGeometry::vertexDataPattern() const

このジオメトリ内の頂点の使用パターンを返します。デフォルトのパターンはAlwaysUploadPattern です。

setVertexDataPattern()も参照してください

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.