StelPainter.hpp   StelPainter.hpp 
skipping to change at line 40 skipping to change at line 40
#ifdef USE_OPENGL_ES2 #ifdef USE_OPENGL_ES2
#define STELPAINTER_GL2 1 #define STELPAINTER_GL2 1
#endif #endif
#ifdef STELPAINTER_GL2 #ifdef STELPAINTER_GL2
class QGLShaderProgram; class QGLShaderProgram;
#endif #endif
class QPainter; class QPainter;
class QGLContext;
class StelPainterLight class StelPainterLight
{ {
public: public:
StelPainterLight(int alight=0) : light(alight), enabled(false) {} StelPainterLight(int alight=0) : light(alight), enabled(false) {}
void setPosition(const Vec4f& v); void setPosition(const Vec4f& v);
Vec4f& getPosition() {return position;} Vec4f& getPosition() {return position;}
void setDiffuse(const Vec4f& v); void setDiffuse(const Vec4f& v);
skipping to change at line 146 skipping to change at line 147
//! Return the instance of projector associated to this painter //! Return the instance of projector associated to this painter
const StelProjectorP& getProjector() const {return prj;} const StelProjectorP& getProjector() const {return prj;}
void setProjector(const StelProjectorP& p); void setProjector(const StelProjectorP& p);
//! Fill with black around the viewport. //! Fill with black around the viewport.
void drawViewportShape(void); void drawViewportShape(void);
//! Draw the string at the given position and angle with the given f ont. //! Draw the string at the given position and angle with the given f ont.
//! If the gravity label flag is set, uses drawTextGravity180. //! If the gravity label flag is set, uses drawTextGravity180.
//! @param font the font to use for display
//! @param x horizontal position of the lower left corner of the fir st character of the text in pixel. //! @param x horizontal position of the lower left corner of the fir st character of the text in pixel.
//! @param y horizontal position of the lower left corner of the fir st character of the text in pixel. //! @param y horizontal position of the lower left corner of the fir st character of the text in pixel.
//! @param str the text to print. //! @param str the text to print.
//! @param angleDeg rotation angle in degree. Rotation is around x,y . //! @param angleDeg rotation angle in degree. Rotation is around x,y .
//! @param xshift shift in pixel in the rotated x direction. //! @param xshift shift in pixel in the rotated x direction.
//! @param yshift shift in pixel in the rotated y direction. //! @param yshift shift in pixel in the rotated y direction.
//! @param noGravity don't take into account the fact that the text should be written with gravity. //! @param noGravity don't take into account the fact that the text should be written with gravity.
void drawText(float x, float y, const QString& str, float angleDeg=0 .f, void drawText(float x, float y, const QString& str, float angleDeg=0 .f,
float xshift=0.f, float yshift=0.f, bool noGravity =true) const; float xshift=0.f, float yshift=0.f, bool noGravity =true) const;
void drawText(const Vec3d& v, const QString& str, float angleDeg=0.f , void drawText(const Vec3d& v, const QString& str, float angleDeg=0.f ,
float xshift=0.f, float yshift=0.f, bool noGravity =true) const; float xshift=0.f, float yshift=0.f, bool noGravity =true) const;
//! Draw the given SphericalRegion. //! Draw the given SphericalRegion.
//! @param region The SphericalRegion to draw. //! @param region The SphericalRegion to draw.
//! @param drawMode define whether to draw the outline or the fill o r both. //! @param drawMode define whether to draw the outline or the fill o r both.
//! @param boundaryColor use this color for drawing the boundary onl y if the drawMode is SphericalPolygonDrawModeFillAndBoundary.
//! @param clippingCap if not set to NULL, tells the painter to try to clip part of the region outside the cap. //! @param clippingCap if not set to NULL, tells the painter to try to clip part of the region outside the cap.
//! @param doSubDivise if true tesselates the object to follow proje ction distortions.
//! Typically set that to false if you think that the region is full y contained in the viewport. //! Typically set that to false if you think that the region is full y contained in the viewport.
void drawSphericalRegion(const SphericalRegion* region, SphericalPol ygonDrawMode drawMode=SphericalPolygonDrawModeFill, const SphericalCap* cli ppingCap=NULL, bool doSubDivise=true); void drawSphericalRegion(const SphericalRegion* region, SphericalPol ygonDrawMode drawMode=SphericalPolygonDrawModeFill, const SphericalCap* cli ppingCap=NULL, bool doSubDivise=true);
void drawGreatCircleArcs(const StelVertexArray& va, const SphericalC ap* clippingCap=NULL, bool doSubDivide=true); void drawGreatCircleArcs(const StelVertexArray& va, const SphericalC ap* clippingCap=NULL);
void drawSphericalTriangles(const StelVertexArray& va, bool textured , const SphericalCap* clippingCap=NULL, bool doSubDivide=true); void drawSphericalTriangles(const StelVertexArray& va, bool textured , const SphericalCap* clippingCap=NULL, bool doSubDivide=true);
//! Draw a small circle arc between points start and stop with rotat ion point in rotCenter. //! Draw a small circle arc between points start and stop with rotat ion point in rotCenter.
//! The angle between start and stop must be < 180 deg. //! The angle between start and stop must be < 180 deg.
//! The algorithm ensures that the line will look smooth, even for n on linear distortion. //! The algorithm ensures that the line will look smooth, even for n on linear distortion.
//! Each time the small circle crosses the edge of the viewport, the viewportEdgeIntersectCallback is called with the //! Each time the small circle crosses the edge of the viewport, the viewportEdgeIntersectCallback is called with the
//! screen 2d position, direction of the currently drawn arc toward the inside of the viewport. //! screen 2d position, direction of the currently drawn arc toward the inside of the viewport.
//! If rotCenter is equal to 0,0,0, the method draws a great circle. //! If rotCenter is equal to 0,0,0, the method draws a great circle.
void drawSmallCircleArc(const Vec3d& start, const Vec3d& stop, const Vec3d& rotCenter, void (*viewportEdgeIntersectCallback)(const Vec3d& scree nPos, const Vec3d& direction, void* userData)=NULL, void* userData=NULL); void drawSmallCircleArc(const Vec3d& start, const Vec3d& stop, const Vec3d& rotCenter, void (*viewportEdgeIntersectCallback)(const Vec3d& scree nPos, const Vec3d& direction, void* userData)=NULL, void* userData=NULL);
//! Draw a great circle arc between points start and stop. //! Draw a great circle arc between points start and stop.
//! The angle between start and stop must be < 180 deg. //! The angle between start and stop must be < 180 deg.
//! The algorithm ensures that the line will look smooth, even for n on linear distortion. //! The algorithm ensures that the line will look smooth, even for n on linear distortion.
//! Each time the small circle crosses the edge of the viewport, the viewportEdgeIntersectCallback is called with the //! Each time the small circle crosses the edge of the viewport, the viewportEdgeIntersectCallback is called with the
//! screen 2d position, direction of the currently drawn arc toward the inside of the viewport. //! screen 2d position, direction of the currently drawn arc toward the inside of the viewport.
//! @param clippingCap if not set to NULL, tells the painter to try to clip part of the region outside the cap. //! @param clippingCap if not set to NULL, tells the painter to try to clip part of the region outside the cap.
void drawGreatCircleArc(const Vec3d& start, const Vec3d& stop, const SphericalCap* clippingCap=NULL, void (*viewportEdgeIntersectCallback)(cons t Vec3d& screenPos, const Vec3d& direction, void* userData)=NULL, void* use rData=NULL); void drawGreatCircleArc(const Vec3d& start, const Vec3d& stop, const SphericalCap* clippingCap=NULL, void (*viewportEdgeIntersectCallback)(cons t Vec3d& screenPos, const Vec3d& direction, void* userData)=NULL, void* use rData=NULL);
//! Draw a simple circle, 2d viewport coordinates in pixel //! Draw a simple circle, 2d viewport coordinates in pixel
void drawCircle(double x,double y,double r); void drawCircle(float x, float y, float r);
//! Draw a square using the current texture at the given projected 2 d position. //! Draw a square using the current texture at the given projected 2 d position.
//! This method is not thread safe. //! This method is not thread safe.
//! @param x x position in the viewport in pixel. //! @param x x position in the viewport in pixel.
//! @param y y position in the viewport in pixel. //! @param y y position in the viewport in pixel.
//! @param radius the half size of a square side in pixel. //! @param radius the half size of a square side in pixel.
void drawSprite2dMode(double x, double y, float radius); void drawSprite2dMode(float x, float y, float radius);
void drawSprite2dMode(const Vec3d& v, float radius); void drawSprite2dMode(const Vec3d& v, float radius);
//! Draw a rotated square using the current texture at the given pro jected 2d position. //! Draw a rotated square using the current texture at the given pro jected 2d position.
//! This method is not thread safe. //! This method is not thread safe.
//! @param x x position in the viewport in pixel. //! @param x x position in the viewport in pixel.
//! @param y y position in the viewport in pixel. //! @param y y position in the viewport in pixel.
//! @param radius the half size of a square side in pixel. //! @param radius the half size of a square side in pixel.
//! @param rotation rotation angle in degree. //! @param rotation rotation angle in degree.
void drawSprite2dMode(double x, double y, float radius, float rotati on); void drawSprite2dMode(float x, float y, float radius, float rotation );
//! Draw a GL_POINT at the given position. //! Draw a GL_POINT at the given position.
//! @param x x position in the viewport in pixels. //! @param x x position in the viewport in pixels.
//! @param y y position in the viewport in pixels. //! @param y y position in the viewport in pixels.
void drawPoint2d(double x, double y); void drawPoint2d(float x, float y);
//! Draw a line between the 2 points. //! Draw a line between the 2 points.
//! @param x1 x position of point 1 in the viewport in pixels. //! @param x1 x position of point 1 in the viewport in pixels.
//! @param y1 y position of point 1 in the viewport in pixels. //! @param y1 y position of point 1 in the viewport in pixels.
//! @param x2 x position of point 2 in the viewport in pixels. //! @param x2 x position of point 2 in the viewport in pixels.
//! @param y2 y position of point 2 in the viewport in pixels. //! @param y2 y position of point 2 in the viewport in pixels.
void drawLine2d(double x1, double y1, double x2, double y2); void drawLine2d(float x1, float y1, float x2, float y2);
//! Draw a rectangle using the current texture at the given projecte d 2d position. //! Draw a rectangle using the current texture at the given projecte d 2d position.
//! This method is not thread safe. //! This method is not thread safe.
//! @param x x position of the top left corner in the viewport in pi xel. //! @param x x position of the top left corner in the viewport in pi xel.
//! @param y y position of the tope left corner in the viewport in p ixel. //! @param y y position of the tope left corner in the viewport in p ixel.
//! @param width width in pixel. //! @param width width in pixel.
//! @param height height in pixel. //! @param height height in pixel.
//! @param textured whether the current texture should be used for p ainting.
void drawRect2d(float x, float y, float width, float height, bool te xtured=true); void drawRect2d(float x, float y, float width, float height, bool te xtured=true);
//! Re-implementation of gluSphere : glu is overridden for non-stand ard projection. //! Re-implementation of gluSphere : glu is overridden for non-stand ard projection.
void sSphere(double radius, double oneMinusOblateness, int slices, i void sSphere(float radius, float oneMinusOblateness, int slices, int
nt stacks, int orientInside = 0, bool flipTexture = false); stacks, int orientInside = 0, bool flipTexture = false);
//! Generate a StelVertexArray for a sphere.
static StelVertexArray computeSphereNoLight(float radius, float oneM
inusOblateness, int slices, int stacks, int orientInside = 0, bool flipText
ure = false);
//! Re-implementation of gluCylinder : glu is overridden for non-sta ndard projection. //! Re-implementation of gluCylinder : glu is overridden for non-sta ndard projection.
void sCylinder(double radius, double height, int slices, int orientI nside = 0); void sCylinder(float radius, float height, int slices, int orientIns ide = 0);
//! Draw a disk with a special texturing mode having texture center at center of disk. //! Draw a disk with a special texturing mode having texture center at center of disk.
//! The disk is made up of concentric circles with increasing refine ment. //! The disk is made up of concentric circles with increasing refine ment.
//! The number of slices of the outmost circle is (innerFanSlices<<l evel). //! The number of slices of the outmost circle is (innerFanSlices<<l evel).
//! @param radius the radius of the disk. //! @param radius the radius of the disk.
//! @param innerFanSlices the number of slices. //! @param innerFanSlices the number of slices.
//! @param level the numbe of concentric circles. //! @param level the numbe of concentric circles.
void sFanDisk(double radius,int innerFanSlices,int level); //! @param vertexArr the vertex array in which the resulting vertice
s are returned.
//! @param texCoordArr the vertex array in which the resulting textu
re coordinates are returned.
static void computeFanDisk(float radius, int innerFanSlices, int lev
el, QVector<double>& vertexArr, QVector<float>& texCoordArr);
//! Draw a ring with a radial texturing. //! Draw a ring with a radial texturing.
void sRing(double rMin, double rMax, int slices, int stacks, int ori entInside); void sRing(float rMin, float rMax, int slices, int stacks, int orien tInside);
//! Draw a fisheye texture in a sphere. //! Draw a fisheye texture in a sphere.
void sSphereMap(double radius, int slices, int stacks, double textur eFov = 2.*M_PI, int orientInside = 0); void sSphereMap(float radius, int slices, int stacks, float textureF ov = 2.f*M_PI, int orientInside = 0);
//! Set the font to use for subsequent text drawing. //! Set the font to use for subsequent text drawing.
void setFont(const QFont& font); void setFont(const QFont& font);
//! Set the color to use for subsequent drawing. //! Set the color to use for subsequent drawing.
void setColor(float r, float g, float b, float a=1.f); void setColor(float r, float g, float b, float a=1.f);
//! Get the color currently used for drawing. //! Get the color currently used for drawing.
Vec4f getColor() const; Vec4f getColor() const;
//! Get the light //! Get the light
StelPainterLight& getLight() {return light;} StelPainterLight& getLight() {return light;}
//! Get the material //! Get the material
StelPainterMaterial& getMaterial() {return material;} StelPainterMaterial& getMaterial() {return material;}
//! Get the font metrics for the current font. //! Get the font metrics for the current font.
QFontMetrics getFontMetrics() const; QFontMetrics getFontMetrics() const;
//! Get some informations about the OS openGL capacities. //! Get some informations about the OS openGL capacities and set the GLContext which will be used by Stellarium.
//! This method needs to be called once at init. //! This method needs to be called once at init.
static void initSystemGLInfo(); static void initSystemGLInfo(QGLContext* ctx);
//! Set the QPainter to use for performing some drawing operations. //! Set the QPainter to use for performing some drawing operations.
static void setQPainter(QPainter* qPainter); static void setQPainter(QPainter* qPainter);
//! Swap the OpenGL buffers. You normally don't need to do that.
static void swapBuffer();
//! Make sure that our GL context is current and valid.
static void makeMainGLContextCurrent();
// The following methods try to reflect the API of the incoming QGLP ainter class // The following methods try to reflect the API of the incoming QGLP ainter class
//! Sets the point size to use with draw(). //! Sets the point size to use with draw().
//! This function has no effect if a shader program is in use, or on OpenGL/ES 2.0. Shader programs must set the //! This function has no effect if a shader program is in use, or on OpenGL/ES 2.0. Shader programs must set the
//! point size in the vertex shader. //! point size in the vertex shader.
void setPointSize(qreal size); void setPointSize(qreal size);
//! Define the current shade model used when interpolating between v ertex. //! Define the current shade model used when interpolating between v ertex.
void setShadeModel(ShadeModel m); void setShadeModel(ShadeModel m);
skipping to change at line 322 skipping to change at line 334
//! It is equivalent to calling enableClientState and set the array pointer for each arrays. //! It is equivalent to calling enableClientState and set the array pointer for each arrays.
void setArrays(const Vec3d* vertice, const Vec2f* texCoords=NULL, co nst Vec3f* colorArray=NULL, const Vec3f* normalArray=NULL); void setArrays(const Vec3d* vertice, const Vec2f* texCoords=NULL, co nst Vec3f* colorArray=NULL, const Vec3f* normalArray=NULL);
//! Draws primitives using vertices from the arrays specified by set VertexArray(). //! Draws primitives using vertices from the arrays specified by set VertexArray().
//! The type of primitive to draw is specified by mode. //! The type of primitive to draw is specified by mode.
//! If indices is NULL, this operation will consume count values fro m the enabled arrays, starting at offset. //! If indices is NULL, this operation will consume count values fro m the enabled arrays, starting at offset.
//! Else it will consume count elements of indices, starting at offs et, which are used to index into the //! Else it will consume count elements of indices, starting at offs et, which are used to index into the
//! enabled arrays. //! enabled arrays.
void drawFromArray(DrawingMode mode, int count, int offset=0, bool d oProj=true, const unsigned int* indices=NULL); void drawFromArray(DrawingMode mode, int count, int offset=0, bool d oProj=true, const unsigned int* indices=NULL);
//! Draws the primitives defined in the StelVertexArray.
void drawStelVertexArray(const StelVertexArray& arr);
private: private:
friend class StelTextureMgr;
friend class StelTexture;
//! Struct describing one opengl array //! Struct describing one opengl array
typedef struct typedef struct
{ {
int size; // The number of coo rdinates per vertex. int size; // The number of coo rdinates per vertex.
int type; // The data type of each coordinate (GL_SHORT, GL_INT, GL_FLOAT, or GL_DOUBLE). int type; // The data type of each coordinate (GL_SHORT, GL_INT, GL_FLOAT, or GL_DOUBLE).
const void* pointer; // Pointer to the first coordinate o f the first vertex in the array. const void* pointer; // Pointer to the first coordinate o f the first vertex in the array.
bool enabled; // Define whether the array is enabled or not. bool enabled; // Define whether the array is enabled or not.
} ArrayDesc; } ArrayDesc;
//! Project an array using the current projection. //! Project an array using the current projection.
skipping to change at line 363 skipping to change at line 381
StelProjectorP prj; StelProjectorP prj;
#ifndef NDEBUG #ifndef NDEBUG
//! Mutex allowing thread safety //! Mutex allowing thread safety
static class QMutex* globalMutex; static class QMutex* globalMutex;
#endif #endif
//! The QPainter to use for some drawing operations. //! The QPainter to use for some drawing operations.
static QPainter* qPainter; static QPainter* qPainter;
//! The main GL Context used by Stellarium.
static QGLContext* glContext;
#ifdef STELPAINTER_GL2 #ifdef STELPAINTER_GL2
Vec4f currentColor; Vec4f currentColor;
bool texture2dEnabled; bool texture2dEnabled;
static QGLShaderProgram* basicShaderProgram; static QGLShaderProgram* basicShaderProgram;
struct BasicShaderVars { struct BasicShaderVars {
int projectionMatrix; int projectionMatrix;
int color; int color;
int vertex; int vertex;
}; };
static BasicShaderVars basicShaderVars; static BasicShaderVars basicShaderVars;
static QGLShaderProgram* colorShaderProgram; static QGLShaderProgram* colorShaderProgram;
static QGLShaderProgram* texturesShaderProgram; static QGLShaderProgram* texturesShaderProgram;
struct TexturesShaderVars { struct TexturesShaderVars {
int projectionMatrix; int projectionMatrix;
int texCoord; int texCoord;
int vertex; int vertex;
int texColor; int texColor;
int texture;
}; };
static TexturesShaderVars texturesShaderVars; static TexturesShaderVars texturesShaderVars;
static QGLShaderProgram* texturesColorShaderProgram; static QGLShaderProgram* texturesColorShaderProgram;
struct TexturesColorShaderVars { struct TexturesColorShaderVars {
int projectionMatrix; int projectionMatrix;
int texCoord; int texCoord;
int vertex; int vertex;
int color; int color;
int texture;
}; };
static TexturesColorShaderVars texturesColorShaderVars; static TexturesColorShaderVars texturesColorShaderVars;
#endif #endif
//! The descriptor for the current opengl vertex array //! The descriptor for the current opengl vertex array
ArrayDesc vertexArray; ArrayDesc vertexArray;
//! The descriptor for the current opengl texture coordinate array //! The descriptor for the current opengl texture coordinate array
ArrayDesc texCoordArray; ArrayDesc texCoordArray;
//! The descriptor for the current opengl normal array //! The descriptor for the current opengl normal array
ArrayDesc normalArray; ArrayDesc normalArray;
 End of changes. 24 change blocks. 
16 lines changed or deleted 44 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/