In my rendering loop, I have the following logic. I have other effects that are displayed on the screen and they are visualized (I deleted this code to get the right to this point). This code does not display the scope, and I cannot understand why not. Am I missing something in math? I went through the debugger and the values look right. Note. MBubbleDiameter is 20 set in the constructor of this object.
static GLfloat staticDegreesToRadians(GLfloat tmpDegrees) { return tmpDegrees * ((std::atan(1.0f)*4)/180.0f); } void LedPannelWidget::updateGL() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, mWidth, mHeight); glOrtho(0, mWidth, 0, mHeight, -mBubbleDiameter, mBubbleDiameter); glMatrixMode(GL_MODELVIEW); glScissor(0, 0, mWidth, mHeight); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.92f, 0.92f, 0.92f, 1.0); glLoadIdentity(); const GLfloat tmpRadius = mDiameter/2.0f; const GLfloat tmpDelta = 5.00f; const GLfloat tmpDeltaRadians = staticDegreesToRadians(tmpDelta); for (int32_t tmpTheta = 180; tmpTheta > 0; tmpTheta -= tmpDelta) { for (int32_t tmpPhi = 0; tmpPhi < 360; tmpPhi += tmpDelta) { GLfloat tmpThetaRadians = staticDegreesToRadians(tmpTheta); GLfloat tmpPhiRadians = staticDegreesToRadians(tmpTheta); GLfloat tmpX1 = tmpRadius * std::sin(tmpThetaRadians) * std::cos(tmpPhiRadians); GLfloat tmpY1 = tmpRadius * std::sin(tmpThetaRadians) * std::cos(tmpPhiRadians); GLfloat tmpZ1 = tmpRadius * std::cos(tmpThetaRadians); GLfloat tmpX2 = tmpRadius * std::sin(tmpThetaRadians - tmpDeltaRadians) * std::cos(tmpPhiRadians); GLfloat tmpY2 = tmpRadius * std::sin(tmpThetaRadians - tmpDeltaRadians) * std::cos(tmpPhiRadians); GLfloat tmpZ2 = tmpRadius * std::cos(tmpThetaRadians - tmpDeltaRadians); GLfloat tmpX3 = tmpRadius * std::sin(tmpThetaRadians - tmpDeltaRadians) * std::cos(tmpPhiRadians + tmpDeltaRadians); GLfloat tmpY3 = tmpRadius * std::sin(tmpThetaRadians - tmpDeltaRadians) * std::cos(tmpPhiRadians + tmpDeltaRadians); GLfloat tmpZ3 = tmpRadius * std::cos(tmpThetaRadians - tmpDeltaRadians); GLfloat tmpX4 = tmpRadius * std::sin(tmpThetaRadians) * std::cos(tmpPhiRadians + tmpDeltaRadians); GLfloat tmpY4 = tmpRadius * std::sin(tmpThetaRadians) * std::cos(tmpPhiRadians + tmpDeltaRadians); GLfloat tmpZ4 = tmpRadius * std::cos(tmpThetaRadians); glBegin(GL_QUADS); glVertex3f(tmpX1, tmpY1, tmpZ1); glVertex3f(tmpX2, tmpY2, tmpZ2); glVertex3f(tmpX3, tmpY3, tmpZ3); glVertex3f(tmpX4, tmpY4, tmpZ4); glEnd(); if (tmpGLError != GL_NO_ERROR) { QApplication::exit(0); } } } swapBuffers(); }
GL working algorithm:
const GLfloat r = mDiameter/2.0f; const GLfloat phid = 20.00f; const GLfloat thetad = 20.00f; const GLfloat x = mCenterXCoord; const GLfloat y = mCenterYCoord; using namespace std; for (int32_t phi = 180; phi > 0; phi -= phid) { int32_t theta = 0; GLfloat rphi = staticDegreesToRadians(phi); GLfloat rtheta = staticDegreesToRadians(theta); glBegin(GL_QUAD_STRIP); glColor3f(mCurrentColor.red()/255.0, mCurrentColor.green()/255.0, mCurrentColor.blue()/255.0); glVertex3f( (x + (r * sin(rphi) * cos(rtheta))), (y + (r * cos(rphi))), (0 + (r * sin(rphi) * cos(rtheta)))); glVertex3f( (x + (r * sin(rphi + phid) * cos(rtheta))), (y + (r * cos(rphi + phid))), (0 + (r * sin(rphi + phid) * cos(rtheta)))); for (; theta < 360; theta += thetad) { rtheta = staticDegreesToRadians(theta); glVertex3f( (x + (r * sin(rphi + phid) * cos(rtheta + thetad))), (y + (r * cos(rphi + phid))), (0 + (r * sin(rphi + phid) * cos(rtheta + thetad)))); glVertex3f( (x + (r * sin(rphi) * cos(rtheta + thetad))), (y + (r * cos(rphi))), (0 + (r * sin(rphi) * cos(rtheta + thetad)))); } glEnd(); }