本文整理汇总了C++中QOpenGLFunctions_2_1::glColor3f方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glColor3f方法的具体用法?C++ QOpenGLFunctions_2_1::glColor3f怎么用?C++ QOpenGLFunctions_2_1::glColor3f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glColor3f方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMeOnly
void ccIndexedTransformationBuffer::drawMeOnly(CC_DRAW_CONTEXT& context)
{
//no picking enabled on trans. buffers
if (MACRO_DrawEntityNames(context))
return;
//only in 3D
if (!MACRO_Draw3D(context))
return;
//get the set of OpenGL functions (version 2.1)
QOpenGLFunctions_2_1 *glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert( glFunc != nullptr );
if ( glFunc == nullptr )
return;
size_t count = size();
//show path
{
ccGL::Color3v(glFunc, ccColor::green.rgba);
glFunc->glBegin(count > 1 && m_showAsPolyline ? GL_LINE_STRIP : GL_POINTS); //show path as a polyline or points?
for (ccIndexedTransformationBuffer::const_iterator it=begin(); it!=end(); ++it)
glFunc->glVertex3fv(it->getTranslation());
glFunc->glEnd();
}
//show trihedrons?
if (m_showTrihedrons)
{
for (ccIndexedTransformationBuffer::const_iterator it=begin(); it!=end(); ++it)
{
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
glFunc->glMultMatrixf(it->data());
//force line width
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(2.0f);
glFunc->glBegin(GL_LINES);
glFunc->glColor3f(1.0f,0.0f,0.0f);
glFunc->glVertex3f(0.0f,0.0f,0.0f);
glFunc->glVertex3f(m_trihedronsScale,0.0f,0.0f);
glFunc->glColor3f(0.0f,1.0f,0.0f);
glFunc->glVertex3f(0.0f,0.0f,0.0f);
glFunc->glVertex3f(0.0f,m_trihedronsScale,0.0f);
glFunc->glColor3f(0.0f,0.7f,1.0f);
glFunc->glVertex3f(0.0f,0.0f,0.0f);
glFunc->glVertex3f(0.0f,0.0f,m_trihedronsScale);
glFunc->glEnd();
glFunc->glPopAttrib(); //GL_LINE_BIT
glFunc->glPopMatrix();
}
}
}
示例2: DrawColorRamp
//.........这里部分代码省略.........
&& (nLabels.second == drawnLabels.end() || nLabels.second->yMin >= yScale + minGap))
{
//insert it at the right place (so as to keep a sorted list!)
drawnLabels.insert(nLabels.second,vlabel(yScale,yScale-strHeight/2,yScale+strHeight/2,sortedKeyValues[i]));
}
}
}
//now we recursively display labels for which we have some room left
if (!customLabels && drawnLabels.size() > 1)
{
const int minGap = strHeight*2;
size_t drawnLabelsBefore = 0; //just to init the loop
size_t drawnLabelsAfter = drawnLabels.size();
//proceed until no more label can be inserted
while (drawnLabelsAfter > drawnLabelsBefore)
{
drawnLabelsBefore = drawnLabelsAfter;
vlabelSet::iterator it1 = drawnLabels.begin();
vlabelSet::iterator it2 = it1; ++it2;
for (; it2 != drawnLabels.end(); ++it2)
{
if (it1->yMax + 2*minGap < it2->yMin)
{
//insert label
double val = (it1->val + it2->val)/2.0;
int yScale = static_cast<int>((val-sortedKeyValues[0]) * scaleMaxHeight / maxRange);
//insert it at the right place (so as to keep a sorted list!)
drawnLabels.insert(it2,vlabel(yScale,yScale-strHeight/2,yScale+strHeight/2,val));
}
it1 = it2;
}
drawnLabelsAfter = drawnLabels.size();
}
}
//display labels
//Some versions of Qt seem to need glColorf instead of glColorub! (see https://bugreports.qt-project.org/browse/QTBUG-6217)
glFunc->glColor3f(textColor.r / 255.0f, textColor.g / 255.0f, textColor.b / 255.0f);
//Scalar field name
const char* sfName = sf->getName();
if (sfName)
{
//QString sfTitle = QString("[%1]").arg(sfName);
QString sfTitle(sfName);
if (sf->getGlobalShift() != 0)
sfTitle += QString("[Shifted]");
if (logScale)
sfTitle += QString("[Log scale]");
//we leave some (vertical) space for the top-most label!
win->displayText(sfTitle, glW-xShift, glH-yShift+strHeight, ccGLWindow::ALIGN_HRIGHT | ccGLWindow::ALIGN_VTOP, 0, 0, &font);
}
//precision (same as color scale)
const unsigned precision = displayParams.displayedNumPrecision;
//format
const char format = (sf->logScale() ? 'E' : 'f');
//tick
const int tickSize = static_cast<int>(4 * renderZoom);
//for labels
const int x = glW-xShift-scaleWidth-2*tickSize-1;
const int y = glH-yShift-scaleMaxHeight;
//for ticks
const int xTick = halfW-xShift-scaleWidth-tickSize-1;
const int yTick = halfH-yShift-scaleMaxHeight;
for (vlabelSet::iterator it = drawnLabels.begin(); it != drawnLabels.end(); ++it)
{
vlabelSet::iterator itNext = it; ++itNext;
//position
unsigned char align = ccGLWindow::ALIGN_HRIGHT;
if (it == drawnLabels.begin())
align |= ccGLWindow::ALIGN_VTOP;
else if (itNext == drawnLabels.end())
align |= ccGLWindow::ALIGN_VBOTTOM;
else
align |= ccGLWindow::ALIGN_VMIDDLE;
double value = it->val;
if (logScale)
value = exp(value*c_log10);
win->displayText(QString::number(value,format,precision), x, y+it->yPos, align, 0, 0, &font);
glFunc->glBegin(GL_LINES);
glFunc->glVertex2i(xTick,yTick+it->yPos);
glFunc->glVertex2i(xTick+tickSize,yTick+it->yPos);
glFunc->glEnd();
}
}
glFunc->glPopAttrib();
}