QSGGeometry Class

QSGGeometry 클래스는 Qt Quick 씬 그래프에서 그래픽 프리미티브에 대한 저수준 스토리지를 제공합니다. 더 보기...

헤더: #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()를 호출하여 할당됩니다.

QSG지오메트리는 선택적으로 부호 없는 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);

2D 그래픽에 사용되는 버퍼는 일반적으로 매 프레임마다 변경되는 많은 작은 버퍼로 구성되며 그래픽 메모리에 업로드되어 이점을 얻지 못하기 때문에 QSGGeometry는 소프트웨어 버퍼이자 가속 렌더링 측면에서 클라이언트 측 버퍼입니다. 그러나 QSG지오메트리는 setVertexDataPattern() 및 setIndexDataPattern() 함수를 사용하여 버퍼를 업로드해야 한다는 것을 렌더러에 힌트하는 기능을 지원합니다. 이 힌트를 존중할지 여부는 구현에 따라 다릅니다.

참고: 접두사가 QSG인 모든 클래스는 씬 그래프의 렌더링 스레드에서만 사용해야 합니다. 자세한 내용은 씬 그래프 및 렌더링을 참조하십시오.

QSGGeometryNode씬 그래프 - 커스텀 지오메트리도참조하세요 .

멤버 유형 문서

enum QSGGeometry::AttributeType

이 열거형은 여러 속성 유형을 식별합니다.

Constant설명
QSGGeometry::UnknownAttribute0상관 없음
QSGGeometry::PositionAttribute1Position
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에서 더 이상 런타임에 지원되지 않습니다.

ConstantValue
QSGGeometry::DrawPoints0x0000
QSGGeometry::DrawLines0x0001
QSGGeometry::DrawLineStrip0x0003
QSGGeometry::DrawTriangles0x0004
QSGGeometry::DrawTriangleStrip0x0005

enum QSGGeometry::Type

버텍스 데이터의 컴포넌트 유형을 지정합니다.

Constant설명
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 을 기반으로 지오메트리 객체를 생성합니다.

이 객체는 attributesindexCount 에 누적된 크기를 기준으로 vertexCount 정점에 대한 공간을 할당합니다.

indexTypeUnsignedShortType 또는 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()

이 지오메트리의 버텍스가 변경되었으므로 다시 업로드해야 함을 표시합니다.

이 함수는 버텍스의 사용 패턴이 정적 데이터이고 이 지오메트리를 렌더링하는 렌더러가 지오메트리를 VBO(버텍스 버퍼 오브젝트)에 업로드하는 경우에만 효과가 있습니다.

void QSGGeometry::markVertexDataDirty()

이 지오메트리의 버텍스가 변경되었으므로 다시 업로드해야 함을 표시합니다.

이 함수는 버텍스의 사용 패턴이 정적 데이터이고 이 지오메트리를 렌더링하는 렌더러가 지오메트리를 VBO(버텍스 버퍼 오브젝트)에 업로드하는 경우에만 효과가 있습니다.

void QSGGeometry::setDrawingMode(unsigned int mode)

이 지오메트리를 그리는 데 사용할 mode 을 설정합니다.

기본값은 QSGGeometry::DrawTriangleStrip 입니다.

drawingMode() 및 DrawingMode도 참조하세요 .

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

인덱스의 사용 패턴을 p 으로 설정합니다.

기본값은 AlwaysUploadPattern 입니다. 기본값이 아닌 다른 것으로 설정하면 사용자는 QSGNode::DirtyGeometry 으로 QSGNode::markDirty()을 호출하는 것 외에도 인덱스 데이터를 변경한 후 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

하나의 버텍스의 크기를 바이트 단위로 반환합니다.

이 값은 어트리뷰트에서 가져옵니다.

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

rect 의 좌표로 g 지오메트리를 업데이트합니다.

이 함수는 지오메트리 객체에 QSGGeometry::ColoredPoint2D 정점으로 이루어진 단일 삼각형 스트립이 포함되어 있다고 가정합니다.

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

rect 의 좌표로 g 지오메트리를 업데이트합니다.

이 함수는 지오메트리 객체에 QSGGeometry::Point2D 정점으로 이루어진 단일 삼각형 스트립이 포함되어 있다고 가정합니다.

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

rect 의 좌표와 textureRect 의 텍스처 좌표로 지오메트리 g 를 업데이트합니다.

textureRect 는 정규화된 좌표여야 합니다.

gQSGGeometry::TexturedPoint2D 유형의 정점 4개로 이루어진 삼각형 스트립으로 가정합니다.

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.