first commit

This commit is contained in:
2025-12-18 09:26:50 +08:00
parent 02c1e325b9
commit b32406225f
70 changed files with 35435 additions and 0 deletions

147
qopengltest/.clang-format Normal file
View File

@@ -0,0 +1,147 @@
# 基础样式LLVMGoogleChromiumMozillaWebKit
BasedOnStyle: LLVM
# 类似于下面这行还没有实现未来希望clang提供分号;后不会强制换行的功能
# BreakAfterSemicolon: false
---
# 要使用的预处理器指令缩进样式
IndentPPDirectives: AfterHash
# 缩进宽度
IndentWidth: 4
# 标准: Cpp03, Cpp11, Auto
Standard: Latest
# tab宽度
TabWidth: 4
# 使用ObjC块时缩进宽度
ObjCBlockIndentWidth: 2
# 构造函数的初始化列表的缩进宽度
ConstructorInitializerIndentWidth: 2
# 延续的行的缩进宽度
ContinuationIndentWidth: 0
# 在ObjC的@property后添加一个空格
ObjCSpaceAfterProperty: false
# 在ObjC的protocol列表前添加一个空格
ObjCSpaceBeforeProtocolList: true
# 访问说明符的偏移
AccessModifierOffset: -4
# 连续的空行保留几行
MaxEmptyLinesToKeep: 2
# 调整连续行中的分配操作符(对齐等号)
AlignConsecutiveAssignments: true
# 校准连续的声明(对齐局部变量)
AlignConsecutiveDeclarations: true
# 允许排序#include
SortIncludes: false
# 允许排序 using 声明
SortUsingDeclarations: false
# 继承的符号后是否换行 类别AfterComma,AfterColon
BreakInheritanceList: AfterComma
# 总是在多行string字面量前换行
AlwaysBreakBeforeMultilineStrings: false
# 使用反斜杠换行对齐 RightDontAlign
AlignEscapedNewlines: DontAlign
# Align, DontAlign, AlwaysBreak(总是在开括号后换行)
AlignAfterOpenBracket: DontAlign
# 左对齐换行(使用反斜杠换行)的反斜杠
AlignEscapedNewlinesLeft: true
# 对齐连续的尾随的注释
AlignTrailingComments: true
# 允许短的case标签放在同一行
AllowShortCaseLabelsOnASingleLine: false
# 允许函数声明的所有参数在放在下一行
AllowAllParametersOfDeclarationOnNextLine: false
# 允许短的块放在同一行Empty
AllowShortBlocksOnASingleLine: true
# 在构造函数的初始化列表的逗号前换行
BreakConstructorInitializersBeforeComma: false
# 在构造函数的初始化列表的冒号后换行
BreakConstructorInitializers: AfterColon
# 在圆括号的(后和)前添加空格
SpacesInParentheses: false
# 允许在单行上使用短枚举
AllowShortEnumsOnASingleLine: true
# 允许短的函数放在同一行: None, InlineOnly(定义在类中), Empty(空函数), Inline(定义在类中,空函数), All
AllowShortFunctionsOnASingleLine: All
# 去除C++11的列表初始化的大括号{后和}前的空格
Cpp11BracedListStyle: false
# 继承最常用的指针和引用的对齐方式
DerivePointerAlignment: false
# 指针的*的位置
PointerAlignment: Left
# 允许在单行上使用简短的If语句
AllowShortIfStatementsOnASingleLine: WithoutElse
# 中括号两边空格 []
SpacesInSquareBrackets: false
# 等号两边的空格
SpaceBeforeAssignmentOperators: true
# 容器类的空格
SpacesInContainerLiterals: false
# 缩进包装函数名
IndentWrappedFunctionNames: false
# 在块的开头保留空行
KeepEmptyLinesAtTheStartOfBlocks: true
# 括号后添加空格
SpaceAfterCStyleCast: false
# 缩进case 标签
IndentCaseLabels: true
# 允许短的循环保持在同一行
AllowShortLoopsOnASingleLine: true
# 在模板声明“template<...>”后总是换行
AlwaysBreakTemplateDeclarations: Yes
# 二进制运算符之前的中断非赋值NonAssignment
BreakBeforeBinaryOperators: NonAssignment
# 三元运算符将被放置在换行后
BreakBeforeTernaryOperators: false
# 每行字符的限制0表示没有限制
ColumnLimit: 0
# 只有定义成Custom下面的大括号才会生效
BreakBeforeBraces: Custom
# 大括号后的分行
BraceWrapping :
# class定义后面
AfterClass: false
# 控制语句后面
AfterControlStatement: false
# enum定义后面
AfterEnum: false
# 函数定义后面
AfterFunction: false
# 命名空间定义后面
AfterNamespace: false
# ObjC定义后面
AfterObjCDeclaration: false
# struct定义后面
AfterStruct: false
# union定义后面
AfterUnion: false
# catch之前
BeforeCatch: true
# else之前
BeforeElse: true
# 缩进大括号
IndentBraces: false
# 语言: Cpp, Java, JavaScript, ObjC, Proto
Language: Cpp
# 模板关键字后的空格false
SpaceAfterTemplateKeyword: false
# 指针限定符周围的空格:之后
SpaceAroundPointerQualifiers: After
# 大小写冒号前的空格false
SpaceBeforeCaseColon: false
# C到r初始值设定项冒号前的空格false
SpaceBeforeCtorInitializerColon: false
# 继承冒号前的空格false
SpaceBeforeInheritanceColon: false
# 开圆括号之前添加一个空格: Never, ControlStatements, Always
SpaceBeforeParens: ControlStatements
# 基于范围的循环冒号前的空格false
SpaceBeforeRangeBasedForLoopColon: false
# 在尖括号的<>后和前添加空格
SpacesInAngles: false
# 收拾格子参数
BinPackArguments : false
# 纸盒包装参数
BinPackParameters : false
# 当格式化时,总是对字面量字符串换行
BreakStringLiterals : false
# Never, ForIndentation, ForContinuationAndIndentation, Always
UseTab: Never

7
qopengltest/.clangd Normal file
View File

@@ -0,0 +1,7 @@
CompileFlags:
Add: [
"--target=x86_64-w64-mingw32",
-IC:/msys64/mingw64/include/QtCore,
-IC:/msys64/mingw64/include/
-std=c++23
]

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.10.0)
project(qopengltest VERSION 0.1.0 LANGUAGES C CXX)
set(QT_VERSION Qt6 CACHE STRING "Qt major version to use")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(${QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets OpenGLWidgets OpenGL)
find_package(assimp)
include_directories(.)
add_executable(qopengltest main.cpp glwidget.cpp)
target_link_libraries(
${PROJECT_NAME} PRIVATE
${QT_VERSION}::Widgets
${QT_VERSION}::OpenGLWidgets
${QT_VERSION}::OpenGL
)

27
qopengltest/glwidget.cpp Normal file
View File

@@ -0,0 +1,27 @@
#include "glwidget.h"
#include <GL/gl.h>
#include <QtWidgets/qopenglwidget.h>
GLWidget::GLWidget(QWidget* parent): QOpenGLWidget(parent) {}
GLWidget::~GLWidget() {
makeCurrent();
doneCurrent();
}
void GLWidget::initializeGL() {
initializeOpenGLFunctions();
glEnable(GL_DEPTH_TEST);
// TODO: 1.编译shader 2.创建VAO VBO 3.加载texture 4.加载model
}
void GLWidget::resizeGL(int w, int h) {
glViewport(0, 0, w, h);
}
void GLWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// TODO 1.绑定shader 2.设置uniform 3.draw calls
// 不要swapBuffers
}

31
qopengltest/glwidget.h Normal file
View File

@@ -0,0 +1,31 @@
#pragma once
#include <QOpenGLVersionProfile>
#include <QtGui/QOpenGLFunctions_3_3_Core>
#include <QtWidgets/qopenglwidget.h>
#include <QtWidgets/qwidget.h>
class Shader {
public:
Shader(const std::string& vpath, const std::string& fpath) {
}
private:
unsigned int ID;
};
class GLWidget: public QOpenGLWidget,
protected QOpenGLFunctions_3_3_Core {
Q_OBJECT
public:
explicit GLWidget(QWidget* parent = nullptr);
~GLWidget() override;
protected:
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
// void keyPressEvent(QKeyEvent* e) override;
private:
};

19
qopengltest/main.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include <QtWidgets/QApplication>
#include <QtGui/qsurfaceformat.h>
#include <iostream>
int main(int argc, char** argv) {
QApplication app(argc, argv);
QSurfaceFormat fmt;
fmt.setVersion(3, 3);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setDepthBufferSize(24);
fmt.setStencilBufferSize(8);
fmt.setSamples(4);
fmt.setSwapInterval(1);
QSurfaceFormat::setDefaultFormat(fmt);
std::cout << "Hello, from qopengltest!\n";
return app.exec();
}