File indexing completed on 2022-12-06 18:58:53

0001 /*
0002     SPDX-FileCopyrightText: 2010 Akarsh Simha <akarsh.simha@kdemail.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifdef _WIN32
0008 #include <windows.h>
0009 #endif
0010 
0011 #include "texturemanager.h"
0012 #include "skymapcomposite.h"
0013 #include "skyglpainter.h"
0014 #include "skymapgldraw.h"
0015 #include "skymap.h"
0016 
0017 SkyMapGLDraw::SkyMapGLDraw(SkyMap *sm) : QGLWidget(sm), SkyMapDrawAbstract(sm)
0018 {
0019     if (!format().testOption(QGL::SampleBuffers))
0020         qWarning() << "No sample buffer; can't use multisampling (antialiasing)";
0021     if (!format().testOption(QGL::StencilBuffer))
0022         qWarning() << "No stencil buffer; can't draw concave polygons";
0023 }
0024 
0025 void SkyMapGLDraw::initializeGL()
0026 {
0027 }
0028 
0029 void SkyMapGLDraw::resizeGL(int width, int height)
0030 {
0031     Q_UNUSED(width)
0032     Q_UNUSED(height)
0033     //do nothing since we resize in SkyGLPainter::paintGL()
0034 }
0035 
0036 void SkyMapGLDraw::paintEvent(QPaintEvent *event)
0037 {
0038     Q_UNUSED(event);
0039     // This is machinery to prevent multiple concurrent paint events / recursive paint events
0040     if (m_DrawLock)
0041         return;
0042     setDrawLock(true);
0043 
0044     QPainter p;
0045     p.begin(this);
0046     p.beginNativePainting();
0047     calculateFPS();
0048     m_SkyMap->setupProjector();
0049     makeCurrent();
0050 
0051     SkyGLPainter psky(this);
0052     //FIXME: we may want to move this into the components.
0053     psky.begin();
0054 
0055     //Draw all sky elements
0056     psky.drawSkyBackground();
0057     m_KStarsData->skyComposite()->draw(&psky);
0058     //Finish up
0059     psky.end();
0060 
0061     p.endNativePainting();
0062     drawOverlays(p);
0063     p.end();
0064 
0065     setDrawLock(false);
0066 }