| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
|
| 3 |
/*************************************************************************** |
| 4 |
* Copyright (c) 2024 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 5 |
* * |
| 6 |
* This file is part of FreeCAD. * |
| 7 |
* * |
| 8 |
* FreeCAD is free software: you can redistribute it and/or modify it * |
| 9 |
* under the terms of the GNU Lesser General Public License as * |
| 10 |
* published by the Free Software Foundation, either version 2.1 of the * |
| 11 |
* License, or (at your option) any later version. * |
| 12 |
* * |
| 13 |
* FreeCAD is distributed in the hope that it will be useful, but * |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 16 |
* Lesser General Public License for more details. * |
| 17 |
* * |
| 18 |
* You should have received a copy of the GNU Lesser General Public * |
| 19 |
* License along with FreeCAD. If not, see * |
| 20 |
* <https://www.gnu.org/licenses/>. * |
| 21 |
* * |
| 22 |
**************************************************************************/ |
| 23 |
|
| 24 |
#ifndef GUI_MULTISAMPLE_H |
| 25 |
#define GUI_MULTISAMPLE_H |
| 26 |
|
| 27 |
#include <map> |
| 28 |
#include <vector> |
| 29 |
#include <FCGlobal.h> |
| 30 |
#include <QOffscreenSurface> |
| 31 |
#include <QOpenGLContext> |
| 32 |
#include <QSurfaceFormat> |
| 33 |
|
| 34 |
namespace Gui |
| 35 |
{ |
| 36 |
|
| 37 |
/** @name Anti-Aliasing modes of the rendered 3D scene |
| 38 |
* Specifies Anti-Aliasing (AA) method |
| 39 |
* - Smoothing enables OpenGL line and vertex smoothing (basically deprecated) |
| 40 |
* - MSAA is hardware multi sampling (with 2, 4, 6 or 8 passes), a quite common and efficient AA |
| 41 |
* technique |
| 42 |
*/ |
| 43 |
//@{ |
| 44 |
enum class AntiAliasing |
| 45 |
{ |
| 46 |
None = 0, |
| 47 |
MSAA1x = 1, |
| 48 |
MSAA2x = 2, |
| 49 |
MSAA4x = 3, |
| 50 |
MSAA6x = 5, |
| 51 |
MSAA8x = 4 |
| 52 |
}; |
| 53 |
//@} |
| 54 |
|
| 55 |
class GuiExport Multisample |
| 56 |
{ |
| 57 |
public: |
| 58 |
Multisample(); |
| 59 |
bool testSamples(int num) const; |
| 60 |
std::vector<std::pair<QString, AntiAliasing>> supported() const; |
| 61 |
static int toSamples(AntiAliasing msaa); |
| 62 |
static AntiAliasing toAntiAliasing(int samples); |
| 63 |
static AntiAliasing readMSAAFromSettings(); |
| 64 |
static void writeMSAAToSettings(AntiAliasing msaa); |
| 65 |
|
| 66 |
private: |
| 67 |
QSurfaceFormat format; |
| 68 |
QOpenGLContext context; |
| 69 |
QOffscreenSurface offscreen; |
| 70 |
}; |
| 71 |
|
| 72 |
} // namespace Gui |
| 73 |
|
| 74 |
#endif // GUI_MULTISAMPLE_H |