이 페이지에서

QOpenGLShader Class

QOpenGLShader 클래스를 사용하면 OpenGL 셰이더를 컴파일할 수 있습니다. 더 보기...

헤더: #include <QOpenGLShader>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpenGL)
target_link_libraries(mytarget PRIVATE Qt6::OpenGL)
qmake: QT += opengl
상속: QObject

공개 유형

flags ShaderType
enum ShaderTypeBit { Vertex, Fragment, Geometry, TessellationControl, TessellationEvaluation, Compute }

공개 함수

QOpenGLShader(QOpenGLShader::ShaderType type, QObject *parent = nullptr)
virtual ~QOpenGLShader()
bool compileSourceCode(const char *source)
bool compileSourceCode(const QByteArray &source)
bool compileSourceCode(const QString &source)
bool compileSourceFile(const QString &fileName)
bool isCompiled() const
QString log() const
GLuint shaderId() const
QOpenGLShader::ShaderType shaderType() const
QByteArray sourceCode() const

정적 공용 멤버

bool hasOpenGLShaders(QOpenGLShader::ShaderType type, QOpenGLContext *context = nullptr)

상세 설명

이 클래스는 OpenGL 셰이딩 언어(GLSL) 및 OpenGL/ES 셰이딩 언어(GLSL/ES)로 작성된 셰이더를 지원합니다.

QOpenGLShader와 QOpenGLShaderProgram 는 프로그래머가 버텍스 및 프래그먼트 셰이더를 컴파일하고 링크하는 세부 사항에 신경 쓰지 않도록 해줍니다.

Qt OpenGLShader가 사용하는 모든 데이터는 신뢰할 수 있는 콘텐츠여야 합니다. 셰이더 소스 코드는 최소한의 수정 후, Qt의 관점에서 볼 때 블랙박스인 기본 OpenGL 구현의 컴파일러로 전달됩니다.

경고: 애플리케이션 개발자는 compileSourceFile()와 같은 함수에 사용자가 제공한 콘텐츠를 전달하기 전에 잠재적인 영향을 신중하게 고려해야 합니다.

QOpenGLShaderProgram도 참조하십시오 .

멤버 유형 설명서

enum QOpenGLShader::ShaderTypeBit
flags QOpenGLShader::ShaderType

이 열거형은 생성되는 ` QOpenGLShader `의 유형을 지정합니다.

상수상수설명
QOpenGLShader::Vertex0x0001OpenGL 셰이딩 언어(GLSL)로 작성된 버텍스 셰이더.
QOpenGLShader::Fragment0x0002OpenGL 셰이딩 언어(GLSL)로 작성된 프래그먼트 셰이더입니다.
QOpenGLShader::Geometry0x0004OpenGL 셰이딩 언어(GLSL)로 작성된 지오메트리 셰이더(OpenGL 3.2 이상 또는 OpenGL ES 3.2 이상 필요).
QOpenGLShader::TessellationControl0x0008OpenGL 셰이딩 언어(GLSL)로 작성된 테셀레이션 제어 셰이더(OpenGL 4.0 이상 또는 OpenGL ES 3.2 이상 필요).
QOpenGLShader::TessellationEvaluation0x0010OpenGL 셰이딩 언어(GLSL)로 작성된 테셀레이션 평가 셰이더(OpenGL 4.0 이상 또는 OpenGL ES 3.2 이상 필요).
QOpenGLShader::Compute0x0020OpenGL 셰이딩 언어(GLSL)로 작성된 컴퓨트 셰이더(OpenGL >= 4.3 또는 OpenGL ES >= 3.1 필요).

ShaderType 유형은 QFlags<ShaderTypeBit>에 대한 typedef입니다. 이 유형은 ShaderTypeBit 값들의 OR 조합을 저장합니다.

멤버 함수 설명서

[explicit] QOpenGLShader::QOpenGLShader(QOpenGLShader::ShaderType type, QObject *parent = nullptr)

지정된 ` type `의 새로운 `QOpenGLShader` 객체를 생성하고, 이를 ` parent`에 연결합니다. 셰이더 프로그램이 지원되지 않는 경우, ` QOpenGLShaderProgram::hasOpenGLShaderPrograms()`는 `false`를 반환합니다.

이 생성자 호출 후에는 일반적으로 compileSourceCode() 또는 compileSourceFile()이 호출됩니다.

이 셰이더는 현재 QOpenGLContext 에 연결됩니다.

compileSourceCode() 및 compileSourceFile()도 참조하십시오 .

[virtual noexcept] QOpenGLShader::~QOpenGLShader()

이 셰이더를 삭제합니다. 셰이더가 ‘ QOpenGLShaderProgram ’ 객체에 연결된 경우, ‘ QOpenGLShaderProgram ’가 소멸될 때까지 실제 셰이더는 그대로 유지됩니다.

bool QOpenGLShader::compileSourceCode(const char *source)

이 셰이더에 대한 ‘ source ’ 코드를 설정하고 컴파일합니다. 소스 컴파일이 성공하면 ` true `를 반환하고, 그렇지 않으면 `false`를 반환합니다.

compileSourceFile()도 참조하십시오 .

bool QOpenGLShader::compileSourceCode(const QByteArray &source)

이 셰이더에 대한 ‘ source ’ 코드를 설정하고 컴파일합니다. 소스 컴파일이 성공하면 ` true `를 반환하고, 그렇지 않으면 `false`를 반환합니다.

이 함수는 오버로드된 함수입니다.

compileSourceFile()도 참조하십시오 .

bool QOpenGLShader::compileSourceCode(const QString &source)

이 셰이더에 대한 source 코드를 설정하고 컴파일합니다. 소스 컴파일이 성공하면 true 를 반환하고, 그렇지 않으면 false를 반환합니다.

이 함수는 오버로드된 함수입니다.

compileSourceFile()도 참조하십시오 .

bool QOpenGLShader::compileSourceFile(const QString &fileName)

이 셰이더의 소스 코드를 fileName 의 내용으로 설정하고 컴파일합니다. 파일을 열 수 있고 소스 코드가 컴파일된 경우 true 를 반환하고, 그렇지 않은 경우 false를 반환합니다.

compileSourceCode()도 참조하십시오 .

[static] bool QOpenGLShader::hasOpenGLShaders(QOpenGLShader::ShaderType type, QOpenGLContext *context = nullptr)

이 시스템에서 type 유형의 셰이더 프로그램이 지원되는 경우 true 를 반환하고, 그렇지 않은 경우 false를 반환합니다.

context 는 GLSL 확장을 해결하는 데 사용됩니다. context 가 nullptr 인 경우, QOpenGLContext::currentContext()가 사용됩니다.

bool QOpenGLShader::isCompiled() const

이 셰이더가 컴파일된 경우 true 을 반환하고, 그렇지 않은 경우 false를 반환합니다.

compileSourceCode() 및 compileSourceFile()도 참조하십시오 .

QString QOpenGLShader::log() const

마지막 컴파일 중에 발생한 오류와 경고 메시지를 반환합니다.

compileSourceCode() 및 compileSourceFile()도 참조하십시오 .

GLuint QOpenGLShader::shaderId() const

이 셰이더와 연관된 OpenGL 식별자를 반환합니다.

QOpenGLShaderProgram::programId()도 참조하십시오 .

QOpenGLShader::ShaderType QOpenGLShader::shaderType() const

이 셰이더의 유형을 반환합니다.

QByteArray QOpenGLShader::sourceCode() const

이 셰이더의 소스 코드를 반환합니다.

compileSourceCode()도 참조하십시오 .

© 2026 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.