StelPainter.cpp   StelPainter.cpp 
skipping to change at line 49 skipping to change at line 49
#include <QOpenGLTexture> #include <QOpenGLTexture>
#include <QApplication> #include <QApplication>
static const int TEX_CACHE_LIMIT = 7000000; static const int TEX_CACHE_LIMIT = 7000000;
#ifndef NDEBUG #ifndef NDEBUG
QMutex* StelPainter::globalMutex = new QMutex(); QMutex* StelPainter::globalMutex = new QMutex();
#endif #endif
QCache<QByteArray, StringTexture> StelPainter::texCache(TEX_CACHE_LIMIT); QCache<QByteArray, StringTexture> StelPainter::texCache(TEX_CACHE_LIMIT);
QOpenGLShaderProgram* StelPainter::texturesShaderProgram=NULL; QOpenGLShaderProgram* StelPainter::texturesShaderProgram=Q_NULLPTR;
QOpenGLShaderProgram* StelPainter::basicShaderProgram=NULL; QOpenGLShaderProgram* StelPainter::basicShaderProgram=Q_NULLPTR;
QOpenGLShaderProgram* StelPainter::colorShaderProgram=NULL; QOpenGLShaderProgram* StelPainter::colorShaderProgram=Q_NULLPTR;
QOpenGLShaderProgram* StelPainter::texturesColorShaderProgram=NULL; QOpenGLShaderProgram* StelPainter::texturesColorShaderProgram=Q_NULLPTR;
StelPainter::BasicShaderVars StelPainter::basicShaderVars; StelPainter::BasicShaderVars StelPainter::basicShaderVars;
StelPainter::TexturesShaderVars StelPainter::texturesShaderVars; StelPainter::TexturesShaderVars StelPainter::texturesShaderVars;
StelPainter::BasicShaderVars StelPainter::colorShaderVars; StelPainter::BasicShaderVars StelPainter::colorShaderVars;
StelPainter::TexturesColorShaderVars StelPainter::texturesColorShaderVars; StelPainter::TexturesColorShaderVars StelPainter::texturesColorShaderVars;
StelPainter::GLState::GLState(QOpenGLFunctions* gl) StelPainter::GLState::GLState(QOpenGLFunctions* gl)
: blend(false), : blend(false),
blendSrc(GL_SRC_ALPHA), blendDst(GL_ONE_MINUS_SRC_ALPHA), blendSrc(GL_SRC_ALPHA), blendDst(GL_ONE_MINUS_SRC_ALPHA),
depthTest(false), depthTest(false),
depthMask(false), depthMask(false),
skipping to change at line 107 skipping to change at line 107
void StelPainter::GLState::reset() void StelPainter::GLState::reset()
{ {
*this = GLState(gl); *this = GLState(gl);
apply(); apply();
} }
bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name) bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name)
{ {
bool ret = prog->link(); bool ret = prog->link();
if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link w QString log = prog->log();
as successful"))) if (!ret || (!log.isEmpty() && !log.contains("Link was successful")
&& !(log=="No errors."))) //"No errors." returned on some Intel drivers
qWarning() << QString("StelPainter: Warnings while linking % 1 shader program:\n%2").arg(name, prog->log()); qWarning() << QString("StelPainter: Warnings while linking % 1 shader program:\n%2").arg(name, prog->log());
return ret; return ret;
} }
StelPainter::StelPainter(const StelProjectorP& proj) : QOpenGLFunctions(QOp enGLContext::currentContext()), glState(this) StelPainter::StelPainter(const StelProjectorP& proj) : QOpenGLFunctions(QOp enGLContext::currentContext()), glState(this)
{ {
Q_ASSERT(proj); Q_ASSERT(proj);
#ifndef NDEBUG #ifndef NDEBUG
Q_ASSERT(globalMutex); Q_ASSERT(globalMutex);
skipping to change at line 333 skipping to change at line 334
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);
if(oldBlendState) if(oldBlendState)
glEnable(GL_BLEND); glEnable(GL_BLEND);
} }
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<32);
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 ;
} }
int slices = innerFanSlices<<level; int slices = innerFanSlices<<level;
float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices); float* cos_sin_theta = StelUtils::ComputeCosSinTheta(slices);
skipping to change at line 818 skipping to change at line 819
static Vec3d pt1, pt2; static Vec3d pt1, pt2;
void StelPainter::drawGreatCircleArc(const Vec3d& start, const Vec3d& stop, const SphericalCap* clippingCap, void StelPainter::drawGreatCircleArc(const Vec3d& start, const Vec3d& stop, const SphericalCap* clippingCap,
void (*viewportEdgeIntersectCallback)(const Vec3d& screenPos, const Vec3d& direction, void* userData), void* userData) void (*viewportEdgeIntersectCallback)(const Vec3d& screenPos, const Vec3d& direction, void* userData), void* userData)
{ {
if (clippingCap) if (clippingCap)
{ {
pt1=start; pt1=start;
pt2=stop; pt2=stop;
if (clippingCap->clipGreatCircle(pt1, pt2)) if (clippingCap->clipGreatCircle(pt1, pt2))
{ {
drawSmallCircleArc(pt1, pt2, Vec3d(0), viewportEdgeI ntersectCallback, userData); drawSmallCircleArc(pt1, pt2, Vec3d(0.), viewportEdge IntersectCallback, userData);
} }
return; return;
} }
drawSmallCircleArc(start, stop, Vec3d(0), viewportEdgeIntersectCallb ack, userData); drawSmallCircleArc(start, stop, Vec3d(0.), viewportEdgeIntersectCall back, userData);
} }
/************************************************************************* /*************************************************************************
Draw a small circle arc in the current frame Draw a small circle arc in the current frame
*************************************************************************/ *************************************************************************/
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
skipping to change at line 939 skipping to change at line 940
// 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>* outTexturePo s, const Vec3f *colors, QVarLengthArray<Vec3f, 4096> *outColors, const Vec2f* texturePos, QVarLengthArray<Vec2f, 4096>* outTexturePo s, const Vec3f *colors, QVarLengthArray<Vec3f, 4096> *outColors,
double maxSqDistortion, int nbI, bool checkDisc1, bool checkDisc2, bool checkDisc3) const double maxSqDistortion, int nbI, bool checkDisc1, bool checkDisc2, 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 = Q_NULLPTR;
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]);
bool cDiscontinuity3 = checkDisc3 && prj->intersectViewportDiscontin uity(vertices[0], vertices[2]); bool cDiscontinuity3 = checkDisc3 && prj->intersectViewportDiscontin uity(vertices[0], vertices[2]);
const bool cd1=cDiscontinuity1; const bool cd1=cDiscontinuity1;
const bool cd2=cDiscontinuity2; const bool cd2=cDiscontinuity2;
const bool cd3=cDiscontinuity3; const bool cd3=cDiscontinuity3;
Vec3d e0=vertices[0]; Vec3d e0=vertices[0];
skipping to change at line 1449 skipping to change at line 1450
// 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, QVarLen gthArray<Vec3f, 4096>* aoutColors=NULL, double amaxSqDistortion=5.) QVarLengthArray<Vec3f, 4096 >* aoutVertices, QVarLengthArray<Vec2f, 4096>* aoutTexturePos=Q_NULLPTR, QV arLengthArray<Vec3f, 4096>* aoutColors=Q_NULLPTR, double amaxSqDistortion=5 .)
: vertexArray(ar), painter(apainter), clippingCap(aclippi ngCap), outVertices(aoutVertices), : vertexArray(ar), painter(apainter), clippingCap(aclippi ngCap), outVertices(aoutVertices),
outColors(aoutColors), outTexturePos(aoutTexturePos ), maxSqDistortion(amaxSqDistortion) 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, const Vec3f* c0, const Ve c3f* c1, const Vec3f* c2,
unsigned int, unsigned in t, unsigned) unsigned int, unsigned in t, unsigned)
skipping to change at line 1472 skipping to change at line 1473
const Vec3d tmpVertex[3] = {*v0, *v1, *v2}; const Vec3d tmpVertex[3] = {*v0, *v1, *v2};
if ( (outTexturePos) && (outColors)) if ( (outTexturePos) && (outColors))
{ {
const Vec2f tmpTexture[3] = {*t0, *t1, *t2}; const Vec2f tmpTexture[3] = {*t0, *t1, *t2};
const Vec3f tmpColor[3] = {*c0, *c1, *c2}; const Vec3f tmpColor[3] = {*c0, *c1, *c2};
painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, tmpTexture, outTexturePos, tmpColor, outColors, maxSqDis tortion); painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, tmpTexture, outTexturePos, tmpColor, outColors, maxSqDis tortion);
} }
else if (outTexturePos) else if (outTexturePos)
{ {
const Vec2f tmpTexture[3] = {*t0, *t1, *t2}; const Vec2f tmpTexture[3] = {*t0, *t1, *t2};
painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, tmpTexture, outTexturePos, NULL, NULL, maxSqDistortion); painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, tmpTexture, outTexturePos, Q_NULLPTR, Q_NULLPTR, maxSqDi stortion);
} }
else if (outColors) else if (outColors)
{ {
const Vec3f tmpColor[3] = {*c0, *c1, *c2}; const Vec3f tmpColor[3] = {*c0, *c1, *c2};
painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, NULL, NULL, tmpColor, outColors, maxSqDistortion); painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, Q_NULLPTR, Q_NULLPTR, tmpColor, outColors, maxSqDistorti on);
} }
else else
painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, NULL, NULL, NULL, NULL, maxSqDistortion); painter->projectSphericalTriangle(clippingCap, tmpVe rtex, outVertices, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, maxSqDistort ion);
} }
// 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());
if (outColors) if (outColors)
painter->setColorPointer(3, GL_FLOAT, outColors->con stData()); painter->setColorPointer(3, GL_FLOAT, outColors->con stData());
painter->enableClientStates(true, outTexturePos != NULL, out Colors != NULL); painter->enableClientStates(true, outTexturePos != Q_NULLPTR , outColors != Q_NULLPTR);
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<Vec3f, 4096>* outColors;
skipping to change at line 1567 skipping to change at line 1568
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, colored ? &polygonColorArray : NULL, maxSqDistortio n)); VertexArrayProjector result = va.foreachTriangle(VertexArray Projector(va, this, clippingCap, &polygonVertexArray, textured ? &polygonTe xtureCoordArray : Q_NULLPTR, colored ? &polygonColorArray : Q_NULLPTR, maxS qDistortion));
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 1774 skipping to change at line 1775
{ {
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 = Q_NULLPTR;
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.1415f) && (topAngle<0.0001f)) // 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);
} }
// 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;
skipping to change at line 1857 skipping to change at line 1858
{ {
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; //StelUtils::ComputeCosSinRho(stack s); const float* cos_sin_rho = Q_NULLPTR; //StelUtils::ComputeCosSinRho( stacks);
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.1415f) && (topAngle<0.0001f)) // 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);
} }
// 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;
skipping to change at line 2086 skipping to change at line 2087
texturesColorShaderVars.projectionMatrix = texturesColorShaderProgra m->uniformLocation("projectionMatrix"); texturesColorShaderVars.projectionMatrix = texturesColorShaderProgra m->uniformLocation("projectionMatrix");
texturesColorShaderVars.texCoord = texturesColorShaderProgram->attri buteLocation("texCoord"); texturesColorShaderVars.texCoord = texturesColorShaderProgram->attri buteLocation("texCoord");
texturesColorShaderVars.vertex = texturesColorShaderProgram->attribu teLocation("vertex"); texturesColorShaderVars.vertex = texturesColorShaderProgram->attribu teLocation("vertex");
texturesColorShaderVars.color = texturesColorShaderProgram->attribut eLocation("color"); texturesColorShaderVars.color = texturesColorShaderProgram->attribut eLocation("color");
texturesColorShaderVars.texture = texturesColorShaderProgram->unifor mLocation("tex"); texturesColorShaderVars.texture = texturesColorShaderProgram->unifor mLocation("tex");
} }
void StelPainter::deinitGLShaders() void StelPainter::deinitGLShaders()
{ {
delete basicShaderProgram; delete basicShaderProgram;
basicShaderProgram = NULL; basicShaderProgram = Q_NULLPTR;
delete colorShaderProgram; delete colorShaderProgram;
colorShaderProgram = NULL; colorShaderProgram = Q_NULLPTR;
delete texturesShaderProgram; delete texturesShaderProgram;
texturesShaderProgram = NULL; texturesShaderProgram = Q_NULLPTR;
delete texturesColorShaderProgram; delete texturesColorShaderProgram;
texturesColorShaderProgram = NULL; texturesColorShaderProgram = Q_NULLPTR;
texCache.clear(); texCache.clear();
} }
void StelPainter::setArrays(const Vec3d* vertices, const Vec2f* texCoords, const Vec3f* colorArray, const Vec3f* normalArray) void StelPainter::setArrays(const Vec3d* vertices, const Vec2f* texCoords, const Vec3f* colorArray, const Vec3f* normalArray)
{ {
enableClientStates(vertices, texCoords, colorArray, normalArray); enableClientStates(vertices, texCoords, colorArray, normalArray);
setVertexPointer(3, GL_DOUBLE, vertices); setVertexPointer(3, GL_DOUBLE, 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);
skipping to change at line 2131 skipping to change at line 2132
void StelPainter::drawFromArray(DrawingMode mode, int count, int offset, bo ol 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, Q_NULLPTR);
} }
QOpenGLShaderProgram* pr=NULL; QOpenGLShaderProgram* pr=Q_NULLPTR;
const Mat4f& m = getProjector()->getProjectionMatrix(); const Mat4f& m = getProjector()->getProjectionMatrix();
const QMatrix4x4 qMat(m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[1 3], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]); const QMatrix4x4 qMat(m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[1 3], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]);
if (!texCoordArray.enabled && !colorArray.enabled && !normalArray.en abled) if (!texCoordArray.enabled && !colorArray.enabled && !normalArray.en abled)
{ {
pr = basicShaderProgram; pr = basicShaderProgram;
pr->bind(); pr->bind();
pr->setAttributeArray(basicShaderVars.vertex, (const GLfloat *)projectedVertexArray.pointer, projectedVertexArray.size); pr->setAttributeArray(basicShaderVars.vertex, projectedVerte xArray.type, projectedVertexArray.pointer, projectedVertexArray.size);
pr->enableAttributeArray(basicShaderVars.vertex); pr->enableAttributeArray(basicShaderVars.vertex);
pr->setUniformValue(basicShaderVars.projectionMatrix, qMat); pr->setUniformValue(basicShaderVars.projectionMatrix, qMat);
pr->setUniformValue(basicShaderVars.color, currentColor[0], currentColor[1], currentColor[2], currentColor[3]); pr->setUniformValue(basicShaderVars.color, currentColor[0], currentColor[1], currentColor[2], currentColor[3]);
} }
else if (texCoordArray.enabled && !colorArray.enabled && !normalArra y.enabled) else if (texCoordArray.enabled && !colorArray.enabled && !normalArra y.enabled)
{ {
pr = texturesShaderProgram; pr = texturesShaderProgram;
pr->bind(); pr->bind();
pr->setAttributeArray(texturesShaderVars.vertex, (const GLfl oat*)projectedVertexArray.pointer, projectedVertexArray.size); pr->setAttributeArray(texturesShaderVars.vertex, projectedVe rtexArray.type, projectedVertexArray.pointer, projectedVertexArray.size);
pr->enableAttributeArray(texturesShaderVars.vertex); pr->enableAttributeArray(texturesShaderVars.vertex);
pr->setUniformValue(texturesShaderVars.projectionMatrix, qMa t); pr->setUniformValue(texturesShaderVars.projectionMatrix, qMa t);
pr->setUniformValue(texturesShaderVars.texColor, currentColo r[0], currentColor[1], currentColor[2], currentColor[3]); pr->setUniformValue(texturesShaderVars.texColor, currentColo r[0], currentColor[1], currentColor[2], currentColor[3]);
pr->setAttributeArray(texturesShaderVars.texCoord, (const GL float*)texCoordArray.pointer, 2); pr->setAttributeArray(texturesShaderVars.texCoord, texCoordA rray.type, texCoordArray.pointer, texCoordArray.size);
pr->enableAttributeArray(texturesShaderVars.texCoord); pr->enableAttributeArray(texturesShaderVars.texCoord);
//pr->setUniformValue(texturesShaderVars.texture, 0); // use texture unit 0 //pr->setUniformValue(texturesShaderVars.texture, 0); // use texture unit 0
} }
else if (texCoordArray.enabled && colorArray.enabled && !normalArray .enabled) else if (texCoordArray.enabled && colorArray.enabled && !normalArray .enabled)
{ {
pr = texturesColorShaderProgram; pr = texturesColorShaderProgram;
pr->bind(); pr->bind();
pr->setAttributeArray(texturesColorShaderVars.vertex, (const GLfloat*)projectedVertexArray.pointer, projectedVertexArray.size); pr->setAttributeArray(texturesColorShaderVars.vertex, projec tedVertexArray.type, projectedVertexArray.pointer, projectedVertexArray.siz e);
pr->enableAttributeArray(texturesColorShaderVars.vertex); pr->enableAttributeArray(texturesColorShaderVars.vertex);
pr->setUniformValue(texturesColorShaderVars.projectionMatrix , qMat); pr->setUniformValue(texturesColorShaderVars.projectionMatrix , qMat);
pr->setAttributeArray(texturesColorShaderVars.texCoord, (con st GLfloat*)texCoordArray.pointer, 2); pr->setAttributeArray(texturesColorShaderVars.texCoord, texC oordArray.type, texCoordArray.pointer, texCoordArray.size);
pr->enableAttributeArray(texturesColorShaderVars.texCoord); pr->enableAttributeArray(texturesColorShaderVars.texCoord);
pr->setAttributeArray(texturesColorShaderVars.color, (const GLfloat*)colorArray.pointer, colorArray.size); pr->setAttributeArray(texturesColorShaderVars.color, colorAr ray.type, colorArray.pointer, colorArray.size);
pr->enableAttributeArray(texturesColorShaderVars.color); pr->enableAttributeArray(texturesColorShaderVars.color);
//pr->setUniformValue(texturesShaderVars.texture, 0); // use texture unit 0 //pr->setUniformValue(texturesShaderVars.texture, 0); // use texture unit 0
} }
else if (!texCoordArray.enabled && colorArray.enabled && !normalArra y.enabled) else if (!texCoordArray.enabled && colorArray.enabled && !normalArra y.enabled)
{ {
pr = colorShaderProgram; pr = colorShaderProgram;
pr->bind(); pr->bind();
pr->setAttributeArray(colorShaderVars.vertex, (const GLfloat *)projectedVertexArray.pointer, projectedVertexArray.size); pr->setAttributeArray(colorShaderVars.vertex, projectedVerte xArray.type, projectedVertexArray.pointer, projectedVertexArray.size);
pr->enableAttributeArray(colorShaderVars.vertex); pr->enableAttributeArray(colorShaderVars.vertex);
pr->setUniformValue(colorShaderVars.projectionMatrix, qMat); pr->setUniformValue(colorShaderVars.projectionMatrix, qMat);
pr->setAttributeArray(colorShaderVars.color, (const GLfloat* )colorArray.pointer, colorArray.size); pr->setAttributeArray(colorShaderVars.color, colorArray.type , colorArray.pointer, colorArray.size);
pr->enableAttributeArray(colorShaderVars.color); pr->enableAttributeArray(colorShaderVars.color);
} }
else else
{ {
qDebug() << "Unhandled parameters." << texCoordArray.enabled << colorArray.enabled << normalArray.enabled; qDebug() << "Unhandled parameters." << texCoordArray.enabled << colorArray.enabled << normalArray.enabled;
Q_ASSERT(0); Q_ASSERT(0);
return; return;
} }
if (indices) if (indices)
 End of changes. 28 change blocks. 
32 lines changed or deleted 33 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/