Kstars

skymapgldraw.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 Akarsh Simha <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifdef _WIN32
8 #include <windows.h>
9 #endif
10 
11 #include "texturemanager.h"
12 #include "skymapcomposite.h"
13 #include "skyglpainter.h"
14 #include "skymapgldraw.h"
15 #include "skymap.h"
16 
18 {
19  if (!format().testOption(QGL::SampleBuffers))
20  qWarning() << "No sample buffer; can't use multisampling (antialiasing)";
21  if (!format().testOption(QGL::StencilBuffer))
22  qWarning() << "No stencil buffer; can't draw concave polygons";
23 }
24 
25 void SkyMapGLDraw::initializeGL()
26 {
27 }
28 
29 void SkyMapGLDraw::resizeGL(int width, int height)
30 {
31  Q_UNUSED(width)
32  Q_UNUSED(height)
33  //do nothing since we resize in SkyGLPainter::paintGL()
34 }
35 
36 void SkyMapGLDraw::paintEvent(QPaintEvent *event)
37 {
38  Q_UNUSED(event);
39  // This is machinery to prevent multiple concurrent paint events / recursive paint events
40  if (m_DrawLock)
41  return;
42  setDrawLock(true);
43 
44  QPainter p;
45  p.begin(this);
47  calculateFPS();
48  m_SkyMap->setupProjector();
49  makeCurrent();
50 
51  SkyGLPainter psky(this);
52  //FIXME: we may want to move this into the components.
53  psky.begin();
54 
55  //Draw all sky elements
56  psky.drawSkyBackground();
57  m_KStarsData->skyComposite()->draw(&psky);
58  //Finish up
59  psky.end();
60 
62  drawOverlays(p);
63  p.end();
64 
65  setDrawLock(false);
66 }
void endNativePainting()
This class defines the methods that both rendering engines (GLPainter and QPainter) must implement.
void drawOverlays(QPainter &p, bool drawFov=true)
Draw the overlays on top of the sky map.
SampleBuffers
void makeCurrent()
bool begin(QPaintDevice *device)
void draw(SkyPainter *skyp) override
Delegate draw requests to all sub components psky Reference to the QPainter on which to paint.
bool end()
void setupProjector()
Call to set up the projector before a draw cycle.
Definition: skymap.cpp:1212
virtual bool event(QEvent *e) override
SkyMapComposite * skyComposite()
Definition: kstarsdata.h:165
QGLFormat format() const const
void beginNativePainting()
Canvas widget for displaying the sky bitmap; also handles user interaction events.
Definition: skymap.h:52
SkyMapGLDraw(SkyMap *parent)
Constructor.
static void setDrawLock(bool state)
Acquire / release a draw lock.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.