StelPainter.cpp   StelPainter.cpp 
skipping to change at line 163 skipping to change at line 163
QFontMetrics StelPainter::getFontMetrics() const QFontMetrics StelPainter::getFontMetrics() const
{ {
return QFontMetrics(currentFont); return QFontMetrics(currentFont);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Standard methods for drawing primitives // Standard methods for drawing primitives
// Fill with black around the circle // Fill with black around the circle
void StelPainter::drawViewportShape(void) void StelPainter::drawViewportShape(const GLfloat innerRadius)
{ {
if (prj->maskType != StelProjector::MaskDisk) if (prj->maskType != StelProjector::MaskDisk)
return; return;
glDisable(GL_BLEND); glDisable(GL_BLEND);
setColor(0.f,0.f,0.f); setColor(0.f,0.f,0.f);
GLfloat innerRadius = 0.5*prj->viewportFovDiameter;
GLfloat outerRadius = prj->getViewportWidth()+prj->getViewportHeight (); GLfloat outerRadius = prj->getViewportWidth()+prj->getViewportHeight ();
GLint slices = 256; GLint slices = 256;
GLfloat sweepAngle = 360.; GLfloat sweepAngle = 360.;
GLfloat sinCache[240]; GLfloat sinCache[240];
GLfloat cosCache[240]; GLfloat cosCache[240];
GLfloat vertices[(240+1)*2][3]; GLfloat vertices[(240+1)*2][3];
GLfloat deltaRadius; GLfloat deltaRadius;
GLfloat radiusHigh; GLfloat radiusHigh;
skipping to change at line 225 skipping to change at line 224
vertices[i*2][1]= prj->viewportCenter[1] + outerRadius*cosCa che[i]; vertices[i*2][1]= prj->viewportCenter[1] + outerRadius*cosCa che[i];
vertices[i*2][2] = 0.0; vertices[i*2][2] = 0.0;
vertices[i*2+1][0]= prj->viewportCenter[0] + radiusHigh*sinC ache[i]; vertices[i*2+1][0]= prj->viewportCenter[0] + radiusHigh*sinC ache[i];
vertices[i*2+1][1]= prj->viewportCenter[1] + radiusHigh*cosC ache[i]; vertices[i*2+1][1]= prj->viewportCenter[1] + radiusHigh*cosC ache[i];
vertices[i*2+1][2] = 0.0; vertices[i*2+1][2] = 0.0;
} }
drawFromArray(TriangleStrip, (slices+1)*2, 0, false); drawFromArray(TriangleStrip, (slices+1)*2, 0, false);
enableClientStates(false); enableClientStates(false);
} }
void StelPainter::drawViewportShape(void)
{
this->drawViewportShape(0.5*prj->viewportFovDiameter);
}
void StelPainter::computeFanDisk(float radius, int innerFanSlices, int leve l, QVector<double>& vertexArr, QVector<float>& texCoordArr) void StelPainter::computeFanDisk(float radius, int innerFanSlices, int leve l, QVector<double>& vertexArr, QVector<float>& texCoordArr)
{ {
Q_ASSERT(level<64); Q_ASSERT(level<64);
float rad[64]; float rad[64];
int i,j; int i,j;
rad[level] = radius; rad[level] = radius;
for (i=level-1;i>=0;--i) for (i=level-1;i>=0;--i)
{ {
rad[i] = rad[i+1]*(1.f-M_PI/(innerFanSlices<<(i+1)))*2.f/3.f ; rad[i] = rad[i+1]*(1.f-M_PI/(innerFanSlices<<(i+1)))*2.f/3.f ;
} }
skipping to change at line 334 skipping to change at line 338
} }
static void sSphereMapTexCoordFast(float rho_div_fov, const float costheta, const float sintheta, QVector<float>& out) static void sSphereMapTexCoordFast(float rho_div_fov, const float costheta, const float sintheta, QVector<float>& out)
{ {
if (rho_div_fov>0.5f) if (rho_div_fov>0.5f)
rho_div_fov=0.5f; rho_div_fov=0.5f;
out << 0.5f + rho_div_fov * costheta << 0.5f + rho_div_fov * sinthet a; out << 0.5f + rho_div_fov * costheta << 0.5f + rho_div_fov * sinthet a;
} }
void StelPainter::sSphereMap(const float radius, const int slices, const in t stacks, const float textureFov, const int orientInside) void StelPainter::sSphereMap(float radius, int slices, int stacks, float te xtureFov, int orientInside)
{ {
float rho,x,y,z; float rho,x,y,z;
int i, j; int i, j;
const float* cos_sin_rho = StelUtils::ComputeCosSinRho(stacks); const float* cos_sin_rho = StelUtils::ComputeCosSinRho(stacks);
const float* cos_sin_rho_p; const float* cos_sin_rho_p;
const float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices); const float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices);
const float* cos_sin_theta_p; const float* cos_sin_theta_p;
float drho = M_PI / stacks; float drho = M_PI / stacks;
skipping to change at line 407 skipping to change at line 411
z = cos_sin_rho_p[0]; z = cos_sin_rho_p[0];
sSphereMapTexCoordFast(rho, cos_sin_theta_p[ 0], -cos_sin_theta_p[1], texCoordArr); sSphereMapTexCoordFast(rho, cos_sin_theta_p[ 0], -cos_sin_theta_p[1], texCoordArr);
vertexArr << x*radius << y*radius << z*radiu s; vertexArr << x*radius << y*radius << z*radiu s;
} }
setArrays((Vec3d*)vertexArr.constData(), (Vec2f*)tex CoordArr.constData()); setArrays((Vec3d*)vertexArr.constData(), (Vec2f*)tex CoordArr.constData());
drawFromArray(TriangleStrip, vertexArr.size()/3); drawFromArray(TriangleStrip, vertexArr.size()/3);
} }
} }
} }
void StelPainter::drawTextGravity180(float x, float y, const QString& ws, c onst float xshift, const float yshift) void StelPainter::drawTextGravity180(float x, float y, const QString& ws, f loat xshift, float yshift)
{ {
float dx, dy, d, theta, theta_o, psi; float dx, dy, d, theta, theta_o, psi;
dx = x - prj->viewportCenter[0]; dx = x - prj->viewportCenter[0];
dy = y - prj->viewportCenter[1]; dy = y - prj->viewportCenter[1];
d = std::sqrt(dx*dx + dy*dy); d = std::sqrt(dx*dx + dy*dy);
float limit = 120.; float limit = 120.;
// If the text is too far away to be visible in the screen return // If the text is too far away to be visible in the screen return
if (d>qMax(prj->viewportXywh[3], prj->viewportXywh[2])*2) if (d>qMax(prj->viewportXywh[3], prj->viewportXywh[2])*2)
return; return;
skipping to change at line 476 skipping to change at line 480
{ {
x = d * std::cos (theta) + xVc; x = d * std::cos (theta) + xVc;
y = d * std::sin (theta) + yVc; y = d * std::sin (theta) + yVc;
drawText(x, y, ws[slen-1-i], 90. + theta*180 ./M_PI, 0., 0.); drawText(x, y, ws[slen-1-i], 90. + theta*180 ./M_PI, 0., 0.);
theta += psi * M_PI/180. * (1 + ((float)getF ontMetrics().width(ws[slen-1-i]) - cWidth)/ cWidth); theta += psi * M_PI/180. * (1 + ((float)getF ontMetrics().width(ws[slen-1-i]) - cWidth)/ cWidth);
} }
} }
} }
} }
void StelPainter::drawText(const Vec3d& v, const QString& str, const float angleDeg, const float xshift, const float yshift, const bool noGravity) void StelPainter::drawText(const Vec3d& v, const QString& str, float angleD eg, float xshift, float yshift, bool noGravity)
{ {
Vec3d win; Vec3d win;
if (prj->project(v, win)) if (prj->project(v, win))
drawText(win[0], win[1], str, angleDeg, xshift, yshift, noGr avity); drawText(win[0], win[1], str, angleDeg, xshift, yshift, noGr avity);
} }
/************************************************************************* /*************************************************************************
Draw the string at the given position and angle with the given font Draw the string at the given position and angle with the given font
*************************************************************************/ *************************************************************************/
skipping to change at line 509 skipping to change at line 513
height(0), height(0),
subTexWidth(0), subTexWidth(0),
subTexHeight(0) {;} subTexHeight(0) {;}
~StringTexture() ~StringTexture()
{ {
if (texture != 0) if (texture != 0)
glDeleteTextures(1, &texture); glDeleteTextures(1, &texture);
} }
}; };
void StelPainter::drawText(float x, float y, const QString& str, float angl eDeg, float xshift, float yshift, const bool noGravity) void StelPainter::drawText(float x, float y, const QString& str, float angl eDeg, float xshift, float yshift, bool noGravity)
{ {
StelPainter::GLState state; // Will restore the opengl state at the end of the function. StelPainter::GLState state; // Will restore the opengl state at the end of the function.
if (prj->gravityLabels && !noGravity) if (prj->gravityLabels && !noGravity)
{ {
drawTextGravity180(x, y, str, xshift, yshift); drawTextGravity180(x, y, str, xshift, yshift);
} }
else else
{ {
QOpenGLPaintDevice device; QOpenGLPaintDevice device;
device.setSize(QSize(prj->getViewportWidth(), prj->getViewpo rtHeight())); device.setSize(QSize(prj->getViewportWidth(), prj->getViewpo rtHeight()));
skipping to change at line 541 skipping to change at line 545
painter.setPen(QColor(currentColor[0]*255, currentColor[1]*2 55, currentColor[2]*255, currentColor[3]*255)); painter.setPen(QColor(currentColor[0]*255, currentColor[1]*2 55, currentColor[2]*255, currentColor[3]*255));
xshift*=StelApp::getInstance().getGlobalScalingRatio(); xshift*=StelApp::getInstance().getGlobalScalingRatio();
yshift*=StelApp::getInstance().getGlobalScalingRatio(); yshift*=StelApp::getInstance().getGlobalScalingRatio();
y = prj->getViewportHeight()-y; y = prj->getViewportHeight()-y;
yshift = -yshift; yshift = -yshift;
// Translate/rotate // Translate/rotate
if (!noGravity) if (!noGravity)
angleDeg += prj->defautAngleForGravityText; angleDeg += prj->defaultAngleForGravityText;
if (std::fabs(angleDeg)>1.f) if (std::fabs(angleDeg)>1.f)
{ {
QTransform m; QTransform m;
m.translate(x, y); m.translate(x, y);
m.rotate(-angleDeg); m.rotate(-angleDeg);
painter.setTransform(m); painter.setTransform(m);
painter.drawText(xshift, yshift, str); painter.drawText(xshift, yshift, str);
} }
else else
skipping to change at line 642 skipping to change at line 646
void StelPainter::drawSmallCircleArc(const Vec3d& start, const Vec3d& stop, const Vec3d& rotCenter, void (*viewportEdgeIntersectCallback)(const Vec3d& screenPos, const Vec3d& direction, void* userData), void* userData) void StelPainter::drawSmallCircleArc(const Vec3d& start, const Vec3d& stop, const Vec3d& rotCenter, void (*viewportEdgeIntersectCallback)(const Vec3d& screenPos, const Vec3d& direction, void* userData), void* userData)
{ {
Q_ASSERT(smallCircleVertexArray.empty()); Q_ASSERT(smallCircleVertexArray.empty());
QLinkedList<Vec3d> tessArc; // Contains the list of projected po ints from the tesselated arc QLinkedList<Vec3d> tessArc; // Contains the list of projected po ints from the tesselated arc
Vec3d win1, win2; Vec3d win1, win2;
win1[2] = prj->project(start, win1) ? 1.0 : -1.; win1[2] = prj->project(start, win1) ? 1.0 : -1.;
win2[2] = prj->project(stop, win2) ? 1.0 : -1.; win2[2] = prj->project(stop, win2) ? 1.0 : -1.;
tessArc.append(win1); tessArc.append(win1);
if (rotCenter.lengthSquared()<0.00000001) if (rotCenter.lengthSquared()<1e-11)
{ {
// Great circle // Great circle
// Perform the tesselation of the arc in small segments in a way so that the lines look smooth // Perform the tesselation of the arc in small segments in a way so that the lines look smooth
fIter(prj, start, stop, win1, win2, tessArc, tessArc.insert( tessArc.end(), win2), 1, rotCenter); fIter(prj, start, stop, win1, win2, tessArc, tessArc.insert( tessArc.end(), win2), 1, rotCenter);
} }
else else
{ {
Vec3d tmp = (rotCenter^start)/rotCenter.length(); Vec3d tmp = (rotCenter^start)/rotCenter.length();
const double radius = fabs(tmp.length()); const double radius = fabs(tmp.length());
// Perform the tesselation of the arc in small segments in a way so that the lines look smooth // Perform the tesselation of the arc in small segments in a way so that the lines look smooth
skipping to change at line 695 skipping to change at line 699
smallCircleVertexArray.append(Vec2f(p1[0], p 1[1])); smallCircleVertexArray.append(Vec2f(p1[0], p 1[1]));
drawSmallCircleVertexArray(); drawSmallCircleVertexArray();
} }
} }
Q_ASSERT(smallCircleVertexArray.isEmpty()); Q_ASSERT(smallCircleVertexArray.isEmpty());
} }
// Project the passed triangle on the screen ensuring that it will look smo oth, even for non linear distortion // Project the passed triangle on the screen ensuring that it will look smo oth, even for non linear distortion
// by splitting it into subtriangles. // by splitting it into subtriangles.
void StelPainter::projectSphericalTriangle(const SphericalCap* clippingCap, const Vec3d* vertices, QVarLengthArray<Vec3f, 4096>* outVertices, void StelPainter::projectSphericalTriangle(const SphericalCap* clippingCap, const Vec3d* vertices, QVarLengthArray<Vec3f, 4096>* outVertices,
const Vec2f* texturePos, QVarLengthArray<Vec2f, 4096>* outTe const Vec2f* texturePos, QVarLengthArray<Vec2f, 4096>* outTexturePo
xturePos, s, const Vec3f *colors, QVarLengthArray<Vec3f, 4096> *outColors,
const double maxSqDistortion, const int nbI, const bool chec double maxSqDistortion, int nbI, bool checkDisc1, bool checkDisc2,
kDisc1, const bool checkDisc2, const bool checkDisc3) const bool checkDisc3) const
{ {
Q_ASSERT(fabs(vertices[0].length()-1.)<0.00001); Q_ASSERT(fabs(vertices[0].length()-1.)<0.00001);
Q_ASSERT(fabs(vertices[1].length()-1.)<0.00001); Q_ASSERT(fabs(vertices[1].length()-1.)<0.00001);
Q_ASSERT(fabs(vertices[2].length()-1.)<0.00001); Q_ASSERT(fabs(vertices[2].length()-1.)<0.00001);
if (clippingCap && clippingCap->containsTriangle(vertices)) if (clippingCap && clippingCap->containsTriangle(vertices))
clippingCap = NULL; clippingCap = NULL;
if (clippingCap && !clippingCap->intersectsTriangle(vertices)) if (clippingCap && !clippingCap->intersectsTriangle(vertices))
return; return;
bool cDiscontinuity1 = checkDisc1 && prj->intersectViewportDiscontin uity(vertices[0], vertices[1]); bool cDiscontinuity1 = checkDisc1 && prj->intersectViewportDiscontin uity(vertices[0], vertices[1]);
bool cDiscontinuity2 = checkDisc2 && prj->intersectViewportDiscontin uity(vertices[1], vertices[2]); bool cDiscontinuity2 = checkDisc2 && prj->intersectViewportDiscontin uity(vertices[1], vertices[2]);
skipping to change at line 754 skipping to change at line 758
win3[1] -= (e0[1]+e2[1])*0.5; win3[1] -= (e0[1]+e2[1])*0.5;
cDiscontinuity3 = (win3[0]*win3[0]+win3[1]*win3[1])>maxSqDis tortion; cDiscontinuity3 = (win3[0]*win3[0]+win3[1]*win3[1])>maxSqDis tortion;
} }
if (!cDiscontinuity1 && !cDiscontinuity2 && !cDiscontinuity3) if (!cDiscontinuity1 && !cDiscontinuity2 && !cDiscontinuity3)
{ {
// The triangle is clean, appends it // The triangle is clean, appends it
outVertices->append(Vec3f(e0[0], e0[1], e0[2])); outVertices ->append(Vec3f(e1[0], e1[1], e1[2])); outVertices->append(Vec3f(e2[0], e2[1 ], e2[2])); outVertices->append(Vec3f(e0[0], e0[1], e0[2])); outVertices ->append(Vec3f(e1[0], e1[1], e1[2])); outVertices->append(Vec3f(e2[0], e2[1 ], e2[2]));
if (outTexturePos) if (outTexturePos)
outTexturePos->append(texturePos,3); outTexturePos->append(texturePos,3);
if (outColors)
outColors->append(colors,3);
return; return;
} }
if (nbI > 4) if (nbI > 4)
{ {
// If we reached the limit number of iterations and still ha ve a discontinuity, // If we reached the limit number of iterations and still ha ve a discontinuity,
// discards the triangle. // discards the triangle.
if (cd1 || cd2 || cd3) if (cd1 || cd2 || cd3)
return; return;
// Else display it, it will be suboptimal though. // Else display it, it will be suboptimal though.
outVertices->append(Vec3f(e0[0], e0[1], e0[2])); outVertices ->append(Vec3f(e1[0], e1[1], e2[2])); outVertices->append(Vec3f(e2[0], e2[1 ], e2[2])); outVertices->append(Vec3f(e0[0], e0[1], e0[2])); outVertices ->append(Vec3f(e1[0], e1[1], e2[2])); outVertices->append(Vec3f(e2[0], e2[1 ], e2[2]));
if (outTexturePos) if (outTexturePos)
outTexturePos->append(texturePos,3); outTexturePos->append(texturePos,3);
if (outColors)
outColors->append(colors,3);
return; return;
} }
// Recursively splits the triangle into sub triangles. // Recursively splits the triangle into sub triangles.
// Depending on which combination of sides of the triangle has to be split a different strategy is used. // Depending on which combination of sides of the triangle has to be split a different strategy is used.
Vec3d va[3]; Vec3d va[3];
Vec2f ta[3]; Vec2f ta[3];
Vec3f ca[3];
// Only 1 side has to be split: split the triangle in 2 // Only 1 side has to be split: split the triangle in 2
if (cDiscontinuity1 && !cDiscontinuity2 && !cDiscontinuity3) if (cDiscontinuity1 && !cDiscontinuity2 && !cDiscontinuity3)
{ {
va[0]=vertices[0]; va[0]=vertices[0];
va[1]=vertices[0];va[1]+=vertices[1]; va[1]=vertices[0];va[1]+=vertices[1];
va[1].normalize(); va[1].normalize();
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[0]+texturePos[1])*0.5; ta[1]=(texturePos[0]+texturePos[1])*0.5;
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, true, true, false); {
ca[0]=colors[0];
ca[1]=(colors[0]+colors[1])*0.5;
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, true, true, false);
//va[0]=vertices[0]+vertices[1]; //va[0]=vertices[0]+vertices[1];
//va[0].normalize(); //va[0].normalize();
va[0]=va[1]; va[0]=va[1];
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[1])*0.5; ta[0]=(texturePos[0]+texturePos[1])*0.5;
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, true, false, true); {
ca[0]=(colors[0]+colors[1])*0.5;
ca[1]=colors[1];
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, true, false, true);
return; return;
} }
if (!cDiscontinuity1 && cDiscontinuity2 && !cDiscontinuity3) if (!cDiscontinuity1 && cDiscontinuity2 && !cDiscontinuity3)
{ {
va[0]=vertices[0]; va[0]=vertices[0];
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[1];va[2]+=vertices[2]; va[2]=vertices[1];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=(texturePos[1]+texturePos[2])*0.5; ta[2]=(texturePos[1]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, false, true, true); {
ca[0]=colors[0];
ca[1]=colors[1];
ca[2]=(colors[1]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, false, true, true);
va[0]=vertices[0]; va[0]=vertices[0];
//va[1]=vertices[1]+vertices[2]; //va[1]=vertices[1]+vertices[2];
//va[1].normalize(); //va[1].normalize();
va[1]=va[2]; va[1]=va[2];
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[1]+texturePos[2])*0.5; ta[1]=(texturePos[1]+texturePos[2])*0.5;
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, true, true, false); {
ca[0]=colors[0];
ca[1]=(colors[1]+colors[2])*0.5;
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, true, true, false);
return; return;
} }
if (!cDiscontinuity1 && !cDiscontinuity2 && cDiscontinuity3) if (!cDiscontinuity1 && !cDiscontinuity2 && cDiscontinuity3)
{ {
va[0]=vertices[0]; va[0]=vertices[0];
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[0];va[2]+=vertices[2]; va[2]=vertices[0];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, false, true, true); {
ca[0]=colors[0];
ca[1]=colors[1];
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, false, true, true);
//va[0]=vertices[0]+vertices[2]; //va[0]=vertices[0]+vertices[2];
//va[0].normalize(); //va[0].normalize();
va[0]=va[2]; va[0]=va[2];
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[2])*0.5; ta[0]=(texturePos[0]+texturePos[2])*0.5;
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, true, false, true); {
ca[0]=(colors[0]+colors[2])*0.5;
ca[1]=colors[1];
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, true, false, true);
return; return;
} }
// 2 sides have to be split: split the triangle in 3 // 2 sides have to be split: split the triangle in 3
if (cDiscontinuity1 && cDiscontinuity2 && !cDiscontinuity3) if (cDiscontinuity1 && cDiscontinuity2 && !cDiscontinuity3)
{ {
va[0]=vertices[0]; va[0]=vertices[0];
va[1]=vertices[0];va[1]+=vertices[1]; va[1]=vertices[0];va[1]+=vertices[1];
va[1].normalize(); va[1].normalize();
va[2]=vertices[1];va[2]+=vertices[2]; va[2]=vertices[1];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[0]+texturePos[1])*0.5; ta[1]=(texturePos[0]+texturePos[1])*0.5;
ta[2]=(texturePos[1]+texturePos[2])*0.5; ta[2]=(texturePos[1]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1); {
ca[0]=colors[0];
ca[1]=(colors[0]+colors[1])*0.5;
ca[2]=(colors[1]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1);
//va[0]=vertices[0]+vertices[1]; //va[0]=vertices[0]+vertices[1];
//va[0].normalize(); //va[0].normalize();
va[0]=va[1]; va[0]=va[1];
va[1]=vertices[1]; va[1]=vertices[1];
//va[2]=vertices[1]+vertices[2]; //va[2]=vertices[1]+vertices[2];
//va[2].normalize(); //va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[1])*0.5; ta[0]=(texturePos[0]+texturePos[1])*0.5;
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=(texturePos[1]+texturePos[2])*0.5; ta[2]=(texturePos[1]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1); {
ca[0]=(colors[0]+colors[1])*0.5;
ca[1]=colors[1];
ca[2]=(colors[1]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1);
va[0]=vertices[0]; va[0]=vertices[0];
//va[1]=vertices[1]+vertices[2]; //va[1]=vertices[1]+vertices[2];
//va[1].normalize(); //va[1].normalize();
va[1]=va[2]; va[1]=va[2];
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[1]+texturePos[2])*0.5; ta[1]=(texturePos[1]+texturePos[2])*0.5;
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, true, true, false); {
ca[0]=colors[0];
ca[1]=(colors[1]+colors[2])*0.5;
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, true, true, false);
return; return;
} }
if (cDiscontinuity1 && !cDiscontinuity2 && cDiscontinuity3) if (cDiscontinuity1 && !cDiscontinuity2 && cDiscontinuity3)
{ {
va[0]=vertices[0]; va[0]=vertices[0];
va[1]=vertices[0];va[1]+=vertices[1]; va[1]=vertices[0];va[1]+=vertices[1];
va[1].normalize(); va[1].normalize();
va[2]=vertices[0];va[2]+=vertices[2]; va[2]=vertices[0];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[0]+texturePos[1])*0.5; ta[1]=(texturePos[0]+texturePos[1])*0.5;
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1); {
ca[0]=colors[0];
ca[1]=(colors[0]+colors[1])*0.5;
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1);
//va[0]=vertices[0]+vertices[1]; //va[0]=vertices[0]+vertices[1];
//va[0].normalize(); //va[0].normalize();
va[0]=va[1]; va[0]=va[1];
va[1]=vertices[2]; va[1]=vertices[2];
//va[2]=vertices[0]+vertices[2]; //va[2]=vertices[0]+vertices[2];
//va[2].normalize(); //va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[1])*0.5; ta[0]=(texturePos[0]+texturePos[1])*0.5;
ta[1]=texturePos[2]; ta[1]=texturePos[2];
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1); {
ca[0]=(colors[0]+colors[1])*0.5;
ca[1]=colors[2];
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1);
//va[0]=vertices[0]+vertices[1]; //va[0]=vertices[0]+vertices[1];
//va[0].normalize(); //va[0].normalize();
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[1])*0.5; ta[0]=(texturePos[0]+texturePos[1])*0.5;
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, true, false, true); {
ca[0]=(colors[0]+colors[1])*0.5;
ca[1]=colors[1];
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, true, false, true);
return; return;
} }
if (!cDiscontinuity1 && cDiscontinuity2 && cDiscontinuity3) if (!cDiscontinuity1 && cDiscontinuity2 && cDiscontinuity3)
{ {
va[0]=vertices[0]; va[0]=vertices[0];
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[1];va[2]+=vertices[2]; va[2]=vertices[1];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=(texturePos[1]+texturePos[2])*0.5; ta[2]=(texturePos[1]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1, false, true, true); {
ca[0]=colors[0];
ca[1]=colors[1];
ca[2]=(colors[1]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1, false, true, true);
//va[0]=vertices[1]+vertices[2]; //va[0]=vertices[1]+vertices[2];
//va[0].normalize(); //va[0].normalize();
va[0]=va[2]; va[0]=va[2];
va[1]=vertices[2]; va[1]=vertices[2];
va[2]=vertices[0];va[2]+=vertices[2]; va[2]=vertices[0];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[1]+texturePos[2])*0.5; ta[0]=(texturePos[1]+texturePos[2])*0.5;
ta[1]=texturePos[2]; ta[1]=texturePos[2];
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1); {
ca[0]=(colors[1]+colors[2])*0.5;
ca[1]=colors[2];
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1);
va[1]=va[0]; va[1]=va[0];
va[0]=vertices[0]; va[0]=vertices[0];
//va[1]=vertices[1]+vertices[2]; //va[1]=vertices[1]+vertices[2];
//va[1].normalize(); //va[1].normalize();
//va[2]=vertices[0]+vertices[2]; //va[2]=vertices[0]+vertices[2];
//va[2].normalize(); //va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[1]+texturePos[2])*0.5; ta[1]=(texturePos[1]+texturePos[2])*0.5;
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, o if (outColors)
utTexturePos, maxSqDistortion, nbI+1); {
ca[0]=colors[0];
ca[1]=(colors[1]+colors[2])*0.5;
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, o
utTexturePos, ca, outColors, maxSqDistortion, nbI+1);
return; return;
} }
// Last case: the 3 sides have to be split: cut in 4 triangles a' la HTM // Last case: the 3 sides have to be split: cut in 4 triangles a' la HTM
va[0]=vertices[0];va[0]+=vertices[1]; va[0]=vertices[0];va[0]+=vertices[1];
va[0].normalize(); va[0].normalize();
va[1]=vertices[1];va[1]+=vertices[2]; va[1]=vertices[1];va[1]+=vertices[2];
va[1].normalize(); va[1].normalize();
va[2]=vertices[0];va[2]+=vertices[2]; va[2]=vertices[0];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[1])*0.5; ta[0]=(texturePos[0]+texturePos[1])*0.5;
ta[1]=(texturePos[1]+texturePos[2])*0.5; ta[1]=(texturePos[1]+texturePos[2])*0.5;
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur if (outColors)
ePos, maxSqDistortion, nbI+1); {
ca[0]=(colors[0]+colors[1])*0.5;
ca[1]=(colors[1]+colors[2])*0.5;
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur
ePos, ca, outColors, maxSqDistortion, nbI+1);
va[1]=va[0]; va[1]=va[0];
va[0]=vertices[0]; va[0]=vertices[0];
//va[1]=vertices[0]+vertices[1]; //va[1]=vertices[0]+vertices[1];
//va[1].normalize(); //va[1].normalize();
//va[2]=vertices[0]+vertices[2]; //va[2]=vertices[0]+vertices[2];
//va[2].normalize(); //va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=texturePos[0]; ta[0]=texturePos[0];
ta[1]=(texturePos[0]+texturePos[1])*0.5; ta[1]=(texturePos[0]+texturePos[1])*0.5;
ta[2]=(texturePos[0]+texturePos[2])*0.5; ta[2]=(texturePos[0]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur if (outColors)
ePos, maxSqDistortion, nbI+1); {
ca[0]=colors[0];
ca[1]=(colors[0]+colors[1])*0.5;
ca[2]=(colors[0]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur
ePos, ca, outColors, maxSqDistortion, nbI+1);
//va[0]=vertices[0]+vertices[1]; //va[0]=vertices[0]+vertices[1];
//va[0].normalize(); //va[0].normalize();
va[0]=va[1]; va[0]=va[1];
va[1]=vertices[1]; va[1]=vertices[1];
va[2]=vertices[1];va[2]+=vertices[2]; va[2]=vertices[1];va[2]+=vertices[2];
va[2].normalize(); va[2].normalize();
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[1])*0.5; ta[0]=(texturePos[0]+texturePos[1])*0.5;
ta[1]=texturePos[1]; ta[1]=texturePos[1];
ta[2]=(texturePos[1]+texturePos[2])*0.5; ta[2]=(texturePos[1]+texturePos[2])*0.5;
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur if (outColors)
ePos, maxSqDistortion, nbI+1); {
ca[0]=(colors[0]+colors[1])*0.5;
ca[1]=colors[1];
ca[2]=(colors[1]+colors[2])*0.5;
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur
ePos, ca, outColors, maxSqDistortion, nbI+1);
va[0]=vertices[0];va[0]+=vertices[2]; va[0]=vertices[0];va[0]+=vertices[2];
va[0].normalize(); va[0].normalize();
//va[1]=vertices[1]+vertices[2]; //va[1]=vertices[1]+vertices[2];
//va[1].normalize(); //va[1].normalize();
va[1]=va[2]; va[1]=va[2];
va[2]=vertices[2]; va[2]=vertices[2];
if (outTexturePos) if (outTexturePos)
{ {
ta[0]=(texturePos[0]+texturePos[2])*0.5; ta[0]=(texturePos[0]+texturePos[2])*0.5;
ta[1]=(texturePos[1]+texturePos[2])*0.5; ta[1]=(texturePos[1]+texturePos[2])*0.5;
ta[2]=texturePos[2]; ta[2]=texturePos[2];
} }
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur if (outColors)
ePos, maxSqDistortion, nbI+1); {
ca[0]=(colors[0]+colors[2])*0.5;
ca[1]=(colors[1]+colors[2])*0.5;
ca[2]=colors[2];
}
projectSphericalTriangle(clippingCap, va, outVertices, ta, outTextur
ePos, ca, outColors, maxSqDistortion, nbI+1);
return; return;
} }
static QVarLengthArray<Vec3f, 4096> polygonVertexArray; static QVarLengthArray<Vec3f, 4096> polygonVertexArray;
static QVarLengthArray<Vec2f, 4096> polygonTextureCoordArray; static QVarLengthArray<Vec2f, 4096> polygonTextureCoordArray;
static QVarLengthArray<Vec3f, 4096> polygonColorArray;
static QVarLengthArray<unsigned int, 4096> indexArray; static QVarLengthArray<unsigned int, 4096> indexArray;
void StelPainter::drawGreatCircleArcs(const StelVertexArray& va, const Sphe ricalCap* clippingCap) void StelPainter::drawGreatCircleArcs(const StelVertexArray& va, const Sphe ricalCap* clippingCap)
{ {
Q_ASSERT(va.vertex.size()!=1); Q_ASSERT(va.vertex.size()!=1);
Q_ASSERT(!va.isIndexed()); // Indexed unsupported yet Q_ASSERT(!va.isIndexed()); // Indexed unsupported yet
switch (va.primitiveType) switch (va.primitiveType)
{ {
case StelVertexArray::Lines: case StelVertexArray::Lines:
Q_ASSERT(va.vertex.size()%2==0); Q_ASSERT(va.vertex.size()%2==0);
skipping to change at line 1092 skipping to change at line 1216
// The function object that we use as an interface between VertexArray::for eachTriangle and // The function object that we use as an interface between VertexArray::for eachTriangle and
// StelPainter::projectSphericalTriangle. // StelPainter::projectSphericalTriangle.
// //
// This is used by drawSphericalTriangles to project all the triangles coor dinates in a StelVertexArray into our global // This is used by drawSphericalTriangles to project all the triangles coor dinates in a StelVertexArray into our global
// vertex array buffer. // vertex array buffer.
class VertexArrayProjector class VertexArrayProjector
{ {
public: public:
VertexArrayProjector(const StelVertexArray& ar, StelPainter* apainte r, const SphericalCap* aclippingCap, VertexArrayProjector(const StelVertexArray& ar, StelPainter* apainte r, const SphericalCap* aclippingCap,
QVarLengthArray<Vec3f, 4096 >* aoutVertices, QVarLengthArray<Vec2f, 4096>* aoutTexturePos=NULL, double amaxSqDistortion=5.) QVarLengthArray<Vec3f, 4096 >* aoutVertices, QVarLengthArray<Vec2f, 4096>* aoutTexturePos=NULL, QVarLen gthArray<Vec3f, 4096>* aoutColors=NULL, double amaxSqDistortion=5.)
: vertexArray(ar), painter(apainter), clippingCap(aclippi ngCap), outVertices(aoutVertices), : vertexArray(ar), painter(apainter), clippingCap(aclippi ngCap), outVertices(aoutVertices),
outTexturePos(aoutTexturePos), maxSqDistortion(amax SqDistortion) outColors(aoutColors), outTexturePos(aoutTexturePos ), maxSqDistortion(amaxSqDistortion)
{ {
} }
// Project a single triangle and add it into the output arrays // Project a single triangle and add it into the output arrays
inline void operator()(const Vec3d* v0, const Vec3d* v1, const Vec3d * v2, inline void operator()(const Vec3d* v0, const Vec3d* v1, const Vec3d * v2,
const Vec2f* t0, const Ve c2f* t1, const Vec2f* t2, const Vec2f* t0, const Ve c2f* t1, const Vec2f* t2,
const Vec3f* c0, const Ve c3f* c1, const Vec3f* c2,
unsigned int, unsigned in t, unsigned) unsigned int, unsigned in t, unsigned)
{ {
// XXX: we may optimize more by putting the declaration and the test outside of this method. // XXX: we may optimize more by putting the declaration and the test outside of this method.
const Vec3d tmpVertex[3] = {*v0, *v1, *v2}; const Vec3d tmpVertex[3] = {*v0, *v1, *v2};
if (outTexturePos) if ( (outTexturePos) && (outColors))
{
const Vec2f tmpTexture[3] = {*t0, *t1, *t2};
const Vec3f tmpColor[3] = {*c0, *c1, *c2};
painter->projectSphericalTriangle(clippingCap, tmpVe
rtex, outVertices, tmpTexture, outTexturePos, tmpColor, outColors, maxSqDis
tortion);
}
else if (outTexturePos)
{ {
const Vec2f tmpTexture[3] = {*t0, *t1, *t2}; const Vec2f tmpTexture[3] = {*t0, *t1, *t2};
painter->projectSphericalTriangle(clippingCap, tmpVe painter->projectSphericalTriangle(clippingCap, tmpVe
rtex, outVertices, tmpTexture, outTexturePos, maxSqDistortion); rtex, outVertices, tmpTexture, outTexturePos, NULL, NULL, maxSqDistortion);
}
else if (outColors)
{
const Vec3f tmpColor[3] = {*c0, *c1, *c2};
painter->projectSphericalTriangle(clippingCap, tmpVe
rtex, outVertices, NULL, NULL, tmpColor, outColors, maxSqDistortion);
} }
else else
painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, NULL, NULL, maxSqDistortion); painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, NULL, NULL, NULL, NULL, maxSqDistortion);
} }
// Draw the resulting arrays // Draw the resulting arrays
void drawResult() void drawResult()
{ {
painter->setVertexPointer(3, GL_FLOAT, outVertices->constDat a()); painter->setVertexPointer(3, GL_FLOAT, outVertices->constDat a());
if (outTexturePos) if (outTexturePos)
painter->setTexCoordPointer(2, GL_FLOAT, outTextureP os->constData()); painter->setTexCoordPointer(2, GL_FLOAT, outTextureP os->constData());
painter->enableClientStates(true, outTexturePos != NULL); if (outColors)
painter->setColorPointer(3, GL_FLOAT, outColors->con
stData());
painter->enableClientStates(true, outTexturePos != NULL, out
Colors != NULL);
painter->drawFromArray(StelPainter::Triangles, outVertices-> size(), 0, false); painter->drawFromArray(StelPainter::Triangles, outVertices-> size(), 0, false);
painter->enableClientStates(false); painter->enableClientStates(false);
} }
private: private:
const StelVertexArray& vertexArray; const StelVertexArray& vertexArray;
StelPainter* painter; StelPainter* painter;
const SphericalCap* clippingCap; const SphericalCap* clippingCap;
QVarLengthArray<Vec3f, 4096>* outVertices; QVarLengthArray<Vec3f, 4096>* outVertices;
QVarLengthArray<Vec3f, 4096>* outColors;
QVarLengthArray<Vec2f, 4096>* outTexturePos; QVarLengthArray<Vec2f, 4096>* outTexturePos;
double maxSqDistortion; double maxSqDistortion;
}; };
void StelPainter::drawStelVertexArray(const StelVertexArray& arr, const boo l checkDiscontinuity) void StelPainter::drawStelVertexArray(const StelVertexArray& arr, bool chec kDiscontinuity)
{ {
if (checkDiscontinuity && prj->hasDiscontinuity()) if (checkDiscontinuity && prj->hasDiscontinuity())
{ {
// The projection has discontinuities, so we need to make su re that no triangle is crossing them. // The projection has discontinuities, so we need to make su re that no triangle is crossing them.
drawStelVertexArray(arr.removeDiscontinuousTriangles(this->g etProjector().data()), false); drawStelVertexArray(arr.removeDiscontinuousTriangles(this->g etProjector().data()), false);
return; return;
} }
setVertexPointer(3, GL_DOUBLE, arr.vertex.constData()); setVertexPointer(3, GL_DOUBLE, arr.vertex.constData());
if (arr.isTextured()) if (arr.isTextured())
{ {
setTexCoordPointer(2, GL_FLOAT, arr.texCoords.constData()); setTexCoordPointer(2, GL_FLOAT, arr.texCoords.constData());
enableClientStates(true, true); if (arr.isColored())
{
setColorPointer(3, GL_FLOAT, arr.colors.constData())
;
enableClientStates(true, true, true);
}
else
enableClientStates(true, true, false);
} }
else else
{ {
enableClientStates(true, false); if (arr.isColored())
{
setColorPointer(3, GL_FLOAT, arr.colors.constData())
;
enableClientStates(true, false, true);
}
else
enableClientStates(true, false, false);
} }
if (arr.isIndexed()) if (arr.isIndexed())
drawFromArray((StelPainter::DrawingMode)arr.primitiveType, a rr.indices.size(), 0, true, arr.indices.constData()); drawFromArray((StelPainter::DrawingMode)arr.primitiveType, a rr.indices.size(), 0, true, arr.indices.constData());
else else
drawFromArray((StelPainter::DrawingMode)arr.primitiveType, a rr.vertex.size()); drawFromArray((StelPainter::DrawingMode)arr.primitiveType, a rr.vertex.size());
enableClientStates(false); enableClientStates(false);
} }
void StelPainter::drawSphericalTriangles(const StelVertexArray& va, const b ool textured, const SphericalCap* clippingCap, const bool doSubDivide, cons t double maxSqDistortion) void StelPainter::drawSphericalTriangles(const StelVertexArray& va, bool te xtured, bool colored, const SphericalCap* clippingCap, bool doSubDivide, do uble maxSqDistortion)
{ {
if (va.vertex.isEmpty()) if (va.vertex.isEmpty())
return; return;
Q_ASSERT(va.vertex.size()>2); Q_ASSERT(va.vertex.size()>2);
polygonVertexArray.clear(); polygonVertexArray.clear();
polygonTextureCoordArray.clear(); polygonTextureCoordArray.clear();
indexArray.clear(); indexArray.clear();
if (!doSubDivide) if (!doSubDivide)
{ {
// The simplest case, we don't need to iterate through the t riangles at all. // The simplest case, we don't need to iterate through the t riangles at all.
drawStelVertexArray(va); drawStelVertexArray(va);
return; return;
} }
// the last case. It is the slowest, it process the triangles one b y one. // the last case. It is the slowest, it process the triangles one b y one.
{ {
// Project all the triangles of the VertexArray into our buf fer arrays. // Project all the triangles of the VertexArray into our buf fer arrays.
VertexArrayProjector result = va.foreachTriangle(VertexArray Projector(va, this, clippingCap, &polygonVertexArray, textured ? &polygonTe xtureCoordArray : NULL, maxSqDistortion)); VertexArrayProjector result = va.foreachTriangle(VertexArray Projector(va, this, clippingCap, &polygonVertexArray, textured ? &polygonTe xtureCoordArray : NULL, colored ? &polygonColorArray : NULL, maxSqDistortio n));
result.drawResult(); result.drawResult();
return; return;
} }
} }
// Draw the given SphericalPolygon. // Draw the given SphericalPolygon.
void StelPainter::drawSphericalRegion(const SphericalRegion* poly, Spherica lPolygonDrawMode drawMode, const SphericalCap* clippingCap, const bool doSu bDivise, const double maxSqDistortion) void StelPainter::drawSphericalRegion(const SphericalRegion* poly, Spherica lPolygonDrawMode drawMode, const SphericalCap* clippingCap, const bool doSu bDivise, const double maxSqDistortion)
{ {
if (!prj->getBoundingCap().intersects(poly->getBoundingCap())) if (!prj->getBoundingCap().intersects(poly->getBoundingCap()))
return; return;
skipping to change at line 1203 skipping to change at line 1356
switch (drawMode) switch (drawMode)
{ {
case SphericalPolygonDrawModeBoundary: case SphericalPolygonDrawModeBoundary:
if (doSubDivise || prj->intersectViewportDiscontinui ty(poly->getBoundingCap())) if (doSubDivise || prj->intersectViewportDiscontinui ty(poly->getBoundingCap()))
drawGreatCircleArcs(poly->getOutlineVertexAr ray(), clippingCap); drawGreatCircleArcs(poly->getOutlineVertexAr ray(), clippingCap);
else else
drawStelVertexArray(poly->getOutlineVertexAr ray(), false); drawStelVertexArray(poly->getOutlineVertexAr ray(), false);
break; break;
case SphericalPolygonDrawModeFill: case SphericalPolygonDrawModeFill:
case SphericalPolygonDrawModeTextureFill: case SphericalPolygonDrawModeTextureFill:
case SphericalPolygonDrawModeTextureFillColormodulated:
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
// The polygon is already tesselated as triangles // The polygon is already tesselated as triangles
if (doSubDivise || prj->intersectViewportDiscontinui ty(poly->getBoundingCap())) if (doSubDivise || prj->intersectViewportDiscontinui ty(poly->getBoundingCap()))
drawSphericalTriangles(poly->getFillVertexAr // flag for color-modulated textured mode (e
ray(), drawMode==SphericalPolygonDrawModeTextureFill, clippingCap, doSubDiv .g. for Milky Way/extincted)
ise, maxSqDistortion); drawSphericalTriangles(poly->getFillVertexAr
ray(), drawMode>=SphericalPolygonDrawModeTextureFill, drawMode==SphericalPo
lygonDrawModeTextureFillColormodulated, clippingCap, doSubDivise, maxSqDist
ortion);
else else
drawStelVertexArray(poly->getFillVertexArray (), false); drawStelVertexArray(poly->getFillVertexArray (), false);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
break; break;
default: default:
Q_ASSERT(0); Q_ASSERT(0);
} }
} }
/************************************************************************* /*************************************************************************
draw a simple circle, 2d viewport coordinates in pixel draw a simple circle, 2d viewport coordinates in pixel
*************************************************************************/ *************************************************************************/
void StelPainter::drawCircle(const float x, const float y, float r) void StelPainter::drawCircle(float x, float y, float r)
{ {
if (r <= 1.0) if (r <= 1.0)
return; return;
const Vec2f center(x,y); const Vec2f center(x,y);
const Vec2f v_center(0.5f*prj->viewportXywh[2],0.5f*prj->viewportXyw h[3]); const Vec2f v_center(0.5f*prj->viewportXywh[2],0.5f*prj->viewportXyw h[3]);
const float R = v_center.length(); const float R = v_center.length();
const float d = (v_center-center).length(); const float d = (v_center-center).length();
if (d > r+R || d < r-R) if (d > r+R || d < r-R)
return; return;
const int segments = 180; const int segments = 180;
skipping to change at line 1251 skipping to change at line 1406
r = dx*cp-dy*sp; r = dx*cp-dy*sp;
dy = dx*sp+dy*cp; dy = dx*sp+dy*cp;
dx = r; dx = r;
} }
enableClientStates(true); enableClientStates(true);
setVertexPointer(3, GL_FLOAT, circleVertexArray.data()); setVertexPointer(3, GL_FLOAT, circleVertexArray.data());
drawFromArray(LineLoop, 180, 0, false); drawFromArray(LineLoop, 180, 0, false);
enableClientStates(false); enableClientStates(false);
} }
void StelPainter::drawSprite2dMode(const float x, const float y, float radi us) void StelPainter::drawSprite2dMode(float x, float y, float radius)
{ {
static float vertexData[] = {-10.,-10.,10.,-10., 10.,10., -10.,10.}; static float vertexData[] = {-10.,-10.,10.,-10., 10.,10., -10.,10.};
static const float texCoordData[] = {0.,0., 1.,0., 0.,1., 1.,1.}; static const float texCoordData[] = {0.,0., 1.,0., 0.,1., 1.,1.};
// Takes into account device pixel density and global scale ratio, a s we are drawing 2D stuff. // Takes into account device pixel density and global scale ratio, a s we are drawing 2D stuff.
radius *= prj->getDevicePixelsPerPixel()*StelApp::getInstance().getG lobalScalingRatio(); radius *= prj->getDevicePixelsPerPixel()*StelApp::getInstance().getG lobalScalingRatio();
vertexData[0]=x-radius; vertexData[1]=y-radius; vertexData[0]=x-radius; vertexData[1]=y-radius;
vertexData[2]=x+radius; vertexData[3]=y-radius; vertexData[2]=x+radius; vertexData[3]=y-radius;
vertexData[4]=x-radius; vertexData[5]=y+radius; vertexData[4]=x-radius; vertexData[5]=y+radius;
vertexData[6]=x+radius; vertexData[7]=y+radius; vertexData[6]=x+radius; vertexData[7]=y+radius;
enableClientStates(true, true); enableClientStates(true, true);
setVertexPointer(2, GL_FLOAT, vertexData); setVertexPointer(2, GL_FLOAT, vertexData);
setTexCoordPointer(2, GL_FLOAT, texCoordData); setTexCoordPointer(2, GL_FLOAT, texCoordData);
drawFromArray(TriangleStrip, 4, 0, false); drawFromArray(TriangleStrip, 4, 0, false);
enableClientStates(false); enableClientStates(false);
} }
void StelPainter::drawSprite2dModeNoDeviceScale(const float x, const float y, const float radius) void StelPainter::drawSprite2dModeNoDeviceScale(float x, float y, float rad ius)
{ {
drawSprite2dMode(x, y, radius/(prj->getDevicePixelsPerPixel()*StelAp p::getInstance().getGlobalScalingRatio())); drawSprite2dMode(x, y, radius/(prj->getDevicePixelsPerPixel()*StelAp p::getInstance().getGlobalScalingRatio()));
} }
void StelPainter::drawSprite2dMode(const Vec3d& v, const float radius) void StelPainter::drawSprite2dMode(const Vec3d& v, float radius)
{ {
Vec3d win; Vec3d win;
if (prj->project(v, win)) if (prj->project(v, win))
drawSprite2dMode(win[0], win[1], radius); drawSprite2dMode(win[0], win[1], radius);
} }
void StelPainter::drawSprite2dMode(const float x, const float y, float radi us, const float rotation) void StelPainter::drawSprite2dMode(float x, float y, float radius, float ro tation)
{ {
static float vertexData[8]; static float vertexData[8];
static const float texCoordData[] = {0.,0., 1.,0., 0.,1., 1.,1.}; static const float texCoordData[] = {0.,0., 1.,0., 0.,1., 1.,1.};
// compute the vertex coordinates applying the translation and the r otation // compute the vertex coordinates applying the translation and the r otation
static const float vertexBase[] = {-1., -1., 1., -1., -1., 1., 1., 1 .}; static const float vertexBase[] = {-1., -1., 1., -1., -1., 1., 1., 1 .};
const float cosr = std::cos(rotation / 180 * M_PI); const float cosr = std::cos(rotation / 180 * M_PI);
const float sinr = std::sin(rotation / 180 * M_PI); const float sinr = std::sin(rotation / 180 * M_PI);
// Takes into account device pixel density and global scale ratio, a s we are drawing 2D stuff. // Takes into account device pixel density and global scale ratio, a s we are drawing 2D stuff.
skipping to change at line 1308 skipping to change at line 1463
vertexData[i+1] = y + radius * vertexBase[i] * sinr + radius * vertexBase[i+1] * cosr; vertexData[i+1] = y + radius * vertexBase[i] * sinr + radius * vertexBase[i+1] * cosr;
} }
enableClientStates(true, true); enableClientStates(true, true);
setVertexPointer(2, GL_FLOAT, vertexData); setVertexPointer(2, GL_FLOAT, vertexData);
setTexCoordPointer(2, GL_FLOAT, texCoordData); setTexCoordPointer(2, GL_FLOAT, texCoordData);
drawFromArray(TriangleStrip, 4, 0, false); drawFromArray(TriangleStrip, 4, 0, false);
enableClientStates(false); enableClientStates(false);
} }
void StelPainter::drawRect2d(const float x, const float y, const float widt h, const float height, const bool textured) void StelPainter::drawRect2d(float x, float y, float width, float height, b ool textured)
{ {
static float vertexData[] = {-10.,-10.,10.,-10., 10.,10., -10.,10.}; static float vertexData[] = {-10.,-10.,10.,-10., 10.,10., -10.,10.};
static const float texCoordData[] = {0.,0., 1.,0., 0.,1., 1.,1.}; static const float texCoordData[] = {0.,0., 1.,0., 0.,1., 1.,1.};
vertexData[0]=x; vertexData[1]=y; vertexData[0]=x; vertexData[1]=y;
vertexData[2]=x+width; vertexData[3]=y; vertexData[2]=x+width; vertexData[3]=y;
vertexData[4]=x; vertexData[5]=y+height; vertexData[4]=x; vertexData[5]=y+height;
vertexData[6]=x+width; vertexData[7]=y+height; vertexData[6]=x+width; vertexData[7]=y+height;
if (textured) if (textured)
{ {
enableClientStates(true, true); enableClientStates(true, true);
skipping to change at line 1334 skipping to change at line 1489
enableClientStates(true); enableClientStates(true);
setVertexPointer(2, GL_FLOAT, vertexData); setVertexPointer(2, GL_FLOAT, vertexData);
} }
drawFromArray(TriangleStrip, 4, 0, false); drawFromArray(TriangleStrip, 4, 0, false);
enableClientStates(false); enableClientStates(false);
} }
/************************************************************************* /*************************************************************************
Draw a GL_POINT at the given position Draw a GL_POINT at the given position
*************************************************************************/ *************************************************************************/
void StelPainter::drawPoint2d(const float x, const float y) void StelPainter::drawPoint2d(float x, float y)
{ {
static float vertexData[] = {0.,0.}; static float vertexData[] = {0.,0.};
vertexData[0]=x; vertexData[0]=x;
vertexData[1]=y; vertexData[1]=y;
enableClientStates(true); enableClientStates(true);
setVertexPointer(2, GL_FLOAT, vertexData); setVertexPointer(2, GL_FLOAT, vertexData);
drawFromArray(Points, 1, 0, false); drawFromArray(Points, 1, 0, false);
enableClientStates(false); enableClientStates(false);
} }
skipping to change at line 1365 skipping to change at line 1520
vertexData[3]=y2; vertexData[3]=y2;
enableClientStates(true); enableClientStates(true);
setVertexPointer(2, GL_FLOAT, vertexData); setVertexPointer(2, GL_FLOAT, vertexData);
drawFromArray(Lines, 2, 0, false); drawFromArray(Lines, 2, 0, false);
enableClientStates(false); enableClientStates(false);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Drawing methods for general (non-linear) mode. // Drawing methods for general (non-linear) mode.
// GZ This used to draw a full sphere. Now it's possible to have a spherica l zone only. // This used to draw a full sphere. Since 0.13 it's possible to have a sphe rical zone only.
void StelPainter::sSphere(const float radius, const float oneMinusOblatenes s, const int slices, const int stacks, const int orientInside, const bool f lipTexture, const float topAngle, const float bottomAngle) void StelPainter::sSphere(const float radius, const float oneMinusOblatenes s, const int slices, const int stacks, const int orientInside, const bool f lipTexture, const float topAngle, const float bottomAngle)
{ {
GLfloat x, y, z; GLfloat x, y, z;
GLfloat s=0.f, t=0.f; GLfloat s=0.f, t=0.f;
GLint i, j; GLint i, j;
GLfloat nsign; GLfloat nsign;
if (orientInside) if (orientInside)
{ {
nsign = -1.f; nsign = -1.f;
t=0.f; // from inside texture is reversed t=0.f; // from inside texture is reversed
} }
else else
{ {
nsign = 1.f; nsign = 1.f;
t=1.f; t=1.f;
} }
const float* cos_sin_rho = NULL; const float* cos_sin_rho = NULL;
Q_ASSERT(topAngle<bottomAngle); // don't forget: These are opening a ngles counted from top. Q_ASSERT(topAngle<bottomAngle); // don't forget: These are opening a ngles counted from top.
if ((bottomAngle>3.1415) && (topAngle<0.0001)) // safety margin. if ((bottomAngle>3.1415f) && (topAngle<0.0001f)) // safety margin.
cos_sin_rho = StelUtils::ComputeCosSinRho(stacks); cos_sin_rho = StelUtils::ComputeCosSinRho(stacks);
else else
{ {
const float drho = (bottomAngle-topAngle) / stacks; // delta Rho: originally just 180degrees/stacks, now the range clamped. const float drho = (bottomAngle-topAngle) / stacks; // delta Rho: originally just 180degrees/stacks, now the range clamped.
cos_sin_rho = StelUtils::ComputeCosSinRhoZone(drho, stacks, M_PI-bottomAngle); cos_sin_rho = StelUtils::ComputeCosSinRhoZone(drho, stacks, M_PI-bottomAngle);
} }
// GZ: Allow parameters so that pole regions may remain free. // Allow parameters so that pole regions may remain free.
const float* cos_sin_rho_p; const float* cos_sin_rho_p;
const float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices); const float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices);
const float *cos_sin_theta_p; const float *cos_sin_theta_p;
// texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y ax is // texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y ax is
// t goes from -1.0/+1.0 at z = -radius/+radius (linear along longit udes) // t goes from -1.0/+1.0 at z = -radius/+radius (linear along longit udes)
// cannot use triangle fan on texturing (s coord. at top/bottom tip varies) // cannot use triangle fan on texturing (s coord. at top/bottom tip varies)
// If the texture is flipped, we iterate the coordinates backward. // If the texture is flipped, we iterate the coordinates backward.
const GLfloat ds = (flipTexture ? -1.f : 1.f) / slices; const GLfloat ds = (flipTexture ? -1.f : 1.f) / slices;
const GLfloat dt = nsign / stacks; // from inside texture is reverse d const GLfloat dt = nsign / stacks; // from inside texture is reverse d
// draw intermediate as quad strips // draw intermediate as quad strips
static QVector<double> vertexArr; static QVector<double> vertexArr;
static QVector<float> texCoordArr; static QVector<float> texCoordArr;
static QVector<float> colorArr; static QVector<float> colorArr;
static QVector<unsigned short> indiceArr; static QVector<unsigned short> indiceArr;
texCoordArr.resize(0); texCoordArr.resize(0);
vertexArr.resize(0); vertexArr.resize(0);
colorArr.resize(0); colorArr.resize(0);
indiceArr.resize(0); indiceArr.resize(0);
skipping to change at line 1448 skipping to change at line 1603
indiceArr << offset+j << offset+j-1 << offset+j+1; indiceArr << offset+j << offset+j-1 << offset+j+1;
} }
t -= dt; t -= dt;
} }
// Draw the array now // Draw the array now
setArrays((Vec3d*)vertexArr.constData(), (Vec2f*)texCoordArr.constDa ta()); setArrays((Vec3d*)vertexArr.constData(), (Vec2f*)texCoordArr.constDa ta());
drawFromArray(Triangles, indiceArr.size(), 0, true, indiceArr.constD ata()); drawFromArray(Triangles, indiceArr.size(), 0, true, indiceArr.constD ata());
} }
StelVertexArray StelPainter::computeSphereNoLight(const float radius, const StelVertexArray StelPainter::computeSphereNoLight(float radius, float oneMi
float oneMinusOblateness, const int slices, const int stacks, const int or nusOblateness, int slices, int stacks,
ientInside, const bool flipTexture) int orientInside, bool flipTexture, float topAngl
e, float bottomAngle)
{ {
StelVertexArray result(StelVertexArray::Triangles); StelVertexArray result(StelVertexArray::Triangles);
GLfloat x, y, z; GLfloat x, y, z;
GLfloat s=0.f, t=0.f; GLfloat s=0.f, t=0.f;
GLint i, j; GLint i, j;
GLfloat nsign; GLfloat nsign;
if (orientInside) if (orientInside)
{ {
nsign = -1.f; nsign = -1.f;
t=0.f; // from inside texture is reversed t=0.f; // from inside texture is reversed
} }
else else
{ {
nsign = 1.f; nsign = 1.f;
t=1.f; t=1.f;
} }
const float* cos_sin_rho = StelUtils::ComputeCosSinRho(stacks); const float* cos_sin_rho = NULL; //StelUtils::ComputeCosSinRho(stack
s);
Q_ASSERT(topAngle<bottomAngle); // don't forget: These are opening a
ngles counted from top.
if ((bottomAngle>3.1415f) && (topAngle<0.0001f)) // safety margin.
cos_sin_rho = StelUtils::ComputeCosSinRho(stacks);
else
{
const float drho = (bottomAngle-topAngle) / stacks; // delta
Rho: originally just 180degrees/stacks, now the range clamped.
cos_sin_rho = StelUtils::ComputeCosSinRhoZone(drho, stacks,
M_PI-bottomAngle);
}
// Allow parameters so that pole regions may remain free.
const float* cos_sin_rho_p; const float* cos_sin_rho_p;
const float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices); const float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices);
const float *cos_sin_theta_p; const float *cos_sin_theta_p;
// texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y ax is // texturing: s goes from 0.0/0.25/0.5/0.75/1.0 at +y/+x/-y/-x/+y ax is
// t goes from -1.0/+1.0 at z = -radius/+radius (linear along longit udes) // t goes from -1.0/+1.0 at z = -radius/+radius (linear along longit udes)
// cannot use triangle fan on texturing (s coord. at top/bottom tip varies) // cannot use triangle fan on texturing (s coord. at top/bottom tip varies)
// If the texture is flipped, we iterate the coordinates backward. // If the texture is flipped, we iterate the coordinates backward.
const GLfloat ds = (flipTexture ? -1.f : 1.f) / slices; const GLfloat ds = (flipTexture ? -1.f : 1.f) / slices;
const GLfloat dt = nsign / stacks; // from inside texture is reverse d const GLfloat dt = nsign / stacks; // from inside texture is reverse d
// draw intermediate as quad strips // draw intermediate as quad strips
for (i = 0,cos_sin_rho_p = cos_sin_rho; i < stacks; ++i,cos_sin_rho_ p+=2) for (i = 0,cos_sin_rho_p = cos_sin_rho; i < stacks; ++i,cos_sin_rho_ p+=2)
{ {
s = !flipTexture ? 0.f : 1.f; s = !flipTexture ? 0.f : 1.f;
for (j = 0,cos_sin_theta_p = cos_sin_theta; j<=slices;++j,co s_sin_theta_p+=2) for (j = 0,cos_sin_theta_p = cos_sin_theta; j<=slices;++j,co s_sin_theta_p+=2)
{ {
x = -cos_sin_theta_p[1] * cos_sin_rho_p[1]; x = -cos_sin_theta_p[1] * cos_sin_rho_p[1];
y = cos_sin_theta_p[0] * cos_sin_rho_p[1]; y = cos_sin_theta_p[0] * cos_sin_rho_p[1];
z = nsign * cos_sin_rho_p[0]; z = nsign * cos_sin_rho_p[0];
result.texCoords << Vec2f(s,t); result.texCoords << Vec2f(s,t);
result.vertex << Vec3d(x*radius, y*radius, z*oneMinu sOblateness*radius); result.vertex << Vec3d(x*radius, y*radius, z*oneMinu sOblateness*radius);
skipping to change at line 1509 skipping to change at line 1674
{ {
result.indices << offset+j-2 << offset+j-1 << offset +j; result.indices << offset+j-2 << offset+j-1 << offset +j;
result.indices << offset+j << offset+j-1 << offset+j +1; result.indices << offset+j << offset+j-1 << offset+j +1;
} }
t -= dt; t -= dt;
} }
return result; return result;
} }
// Reimplementation of gluCylinder : glu is overrided for non standard proj ection // Reimplementation of gluCylinder : glu is overrided for non standard proj ection
void StelPainter::sCylinder(const float radius, const float height, const i nt slices, const int orientInside) void StelPainter::sCylinder(float radius, float height, int slices, int ori entInside)
{ {
if (orientInside) if (orientInside)
glCullFace(GL_FRONT); glCullFace(GL_FRONT);
static QVarLengthArray<Vec2f, 512> texCoordArray; static QVarLengthArray<Vec2f, 512> texCoordArray;
static QVarLengthArray<Vec3d, 512> vertexArray; static QVarLengthArray<Vec3d, 512> vertexArray;
texCoordArray.clear(); texCoordArray.clear();
vertexArray.clear(); vertexArray.clear();
float s = 0.f; float s = 0.f;
float x, y; float x, y;
skipping to change at line 1539 skipping to change at line 1704
vertexArray.append(Vec3d(x*radius, y*radius, height)); vertexArray.append(Vec3d(x*radius, y*radius, height));
s += ds; s += ds;
} }
setArrays(vertexArray.constData(), texCoordArray.constData()); setArrays(vertexArray.constData(), texCoordArray.constData());
drawFromArray(TriangleStrip, vertexArray.size()); drawFromArray(TriangleStrip, vertexArray.size());
if (orientInside) if (orientInside)
glCullFace(GL_BACK); glCullFace(GL_BACK);
} }
void StelPainter::enableTexture2d(const bool b) void StelPainter::enableTexture2d(bool b)
{ {
texture2dEnabled = b; texture2dEnabled = b;
} }
void StelPainter::initGLShaders() void StelPainter::initGLShaders()
{ {
qWarning() << "Intializing basic GL shaders... "; qWarning() << "Intializing basic GL shaders... ";
// Basic shader: just vertex filled with plain color // Basic shader: just vertex filled with plain color
QOpenGLShader vshader3(QOpenGLShader::Vertex); QOpenGLShader vshader3(QOpenGLShader::Vertex);
const char *vsrc3 = const char *vsrc3 =
skipping to change at line 1718 skipping to change at line 1883
void StelPainter::setArrays(const Vec3f* vertices, const Vec2f* texCoords, const Vec3f* colorArray, const Vec3f* normalArray) void StelPainter::setArrays(const Vec3f* vertices, const Vec2f* texCoords, const Vec3f* colorArray, const Vec3f* normalArray)
{ {
enableClientStates(vertices, texCoords, colorArray, normalArray); enableClientStates(vertices, texCoords, colorArray, normalArray);
setVertexPointer(3, GL_FLOAT, vertices); setVertexPointer(3, GL_FLOAT, vertices);
setTexCoordPointer(2, GL_FLOAT, texCoords); setTexCoordPointer(2, GL_FLOAT, texCoords);
setColorPointer(3, GL_FLOAT, colorArray); setColorPointer(3, GL_FLOAT, colorArray);
setNormalPointer(GL_FLOAT, normalArray); setNormalPointer(GL_FLOAT, normalArray);
} }
void StelPainter::enableClientStates(const bool vertex, const bool texture, const bool color, const bool normal) void StelPainter::enableClientStates(bool vertex, bool texture, bool color, bool normal)
{ {
vertexArray.enabled = vertex; vertexArray.enabled = vertex;
texCoordArray.enabled = texture; texCoordArray.enabled = texture;
colorArray.enabled = color; colorArray.enabled = color;
normalArray.enabled = normal; normalArray.enabled = normal;
} }
void StelPainter::drawFromArray(const DrawingMode mode, const int count, co nst int offset, const bool doProj, const unsigned short* indices) void StelPainter::drawFromArray(DrawingMode mode, int count, int offset, bo ol doProj, const unsigned short* indices)
{ {
ArrayDesc projectedVertexArray = vertexArray; ArrayDesc projectedVertexArray = vertexArray;
if (doProj) if (doProj)
{ {
// Project the vertex array using current projection // Project the vertex array using current projection
if (indices) if (indices)
projectedVertexArray = projectArray(vertexArray, 0, count, indices + offset); projectedVertexArray = projectArray(vertexArray, 0, count, indices + offset);
else else
projectedVertexArray = projectArray(vertexArray, off set, count, NULL); projectedVertexArray = projectArray(vertexArray, off set, count, NULL);
} }
 End of changes. 67 change blocks. 
85 lines changed or deleted 263 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/