leocad/qt/lc_qaboutdialog.cpp
2021-01-03 11:57:26 -08:00

66 lines
3.6 KiB
C++

#include "lc_global.h"
#include "lc_qaboutdialog.h"
#include "ui_lc_qaboutdialog.h"
#include "lc_mainwindow.h"
#include "lc_view.h"
#include "lc_glextensions.h"
#include "lc_viewwidget.h"
lcQAboutDialog::lcQAboutDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::lcQAboutDialog)
{
ui->setupUi(this);
#ifdef LC_CONTINUOUS_BUILD
ui->version->setText(tr("LeoCAD Continuous Build %1").arg(QString::fromLatin1(QT_STRINGIFY(LC_CONTINUOUS_BUILD))));
#else
ui->version->setText(tr("LeoCAD Version %1").arg(QString::fromLatin1(LC_VERSION_TEXT)));
#endif
lcViewWidget* Widget = gMainWindow->GetActiveView()->GetWidget();
#ifdef LC_USE_QOPENGLWIDGET
QSurfaceFormat Format = Widget->context()->format();
#else
QGLFormat Format = Widget->context()->format();
#endif
int ColorDepth = Format.redBufferSize() + Format.greenBufferSize() + Format.blueBufferSize() + Format.alphaBufferSize();
const QString QtVersionFormat = tr("Qt Version %1 (compiled with %2)\n\n");
const QString QtVersion = QtVersionFormat.arg(qVersion(), QT_VERSION_STR);
const QString VersionFormat = tr("OpenGL Version %1 (GLSL %2)\n%3 - %4\n\n");
const QString Version = VersionFormat.arg(QString((const char*)glGetString(GL_VERSION)), QString((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION)), QString((const char*)glGetString(GL_RENDERER)), QString((const char*)glGetString(GL_VENDOR)));
const QString BuffersFormat = tr("Color Buffer: %1 bits\nDepth Buffer: %2 bits\nStencil Buffer: %3 bits\n\n");
const QString Buffers = BuffersFormat.arg(QString::number(ColorDepth), QString::number(Format.depthBufferSize()), QString::number(Format.stencilBufferSize()));
#ifdef LC_USE_QOPENGLWIDGET
const QString ExtensionsFormat = tr("Buffers: %1\nShaders: %2\nFramebuffers: %3\nTexImage2DMultisample: %4\nBlendFuncSeparate: %5\nAnisotropic: %6\n");
const QString VertexBuffers = gSupportsVertexBufferObject ? tr("Supported") : tr("Not supported");
const QString Shaders = gSupportsShaderObjects ? tr("Supported") : tr("Not supported");
const QString Framebuffers = gSupportsFramebufferObject ? tr("Supported") : tr("Not supported");
const QString TexImage2DMultisample = gSupportsTexImage2DMultisample ? tr("Supported") : tr("Not supported");
const QString BlendFuncSeparate = gSupportsBlendFuncSeparate ? tr("Supported") : tr("Not supported");
const QString Anisotropic = gSupportsAnisotropic ? tr("Supported (max %1)").arg(gMaxAnisotropy) : tr("Not supported");
const QString Extensions = ExtensionsFormat.arg(VertexBuffers, Shaders, Framebuffers, TexImage2DMultisample, BlendFuncSeparate, Anisotropic);
#else
const QString ExtensionsFormat = tr("GL_ARB_vertex_buffer_object extension: %1\nGL_ARB_framebuffer_object extension: %2\nGL_EXT_framebuffer_object extension: %3\nGL_EXT_blend_func_separate: %4\nGL_EXT_texture_filter_anisotropic extension: %5\n");
const QString VertexBufferObject = gSupportsVertexBufferObject ? tr("Supported") : tr("Not supported");
const QString FramebufferObjectARB = gSupportsFramebufferObjectARB ? tr("Supported") : tr("Not supported");
const QString FramebufferObjectEXT = gSupportsFramebufferObjectEXT ? tr("Supported") : tr("Not supported");
const QString BlendFuncSeparateEXT = gSupportsBlendFuncSeparate ? tr("Supported") : tr("Not supported");
const QString Anisotropic = gSupportsAnisotropic ? tr("Supported (max %1)").arg(gMaxAnisotropy) : tr("Not supported");
const QString Extensions = ExtensionsFormat.arg(VertexBufferObject, FramebufferObjectARB, FramebufferObjectEXT, BlendFuncSeparateEXT, Anisotropic);
#endif
ui->info->setText(QtVersion + Version + Buffers + Extensions);
}
lcQAboutDialog::~lcQAboutDialog()
{
delete ui;
}