本文整理汇总了C++中QOpenGLFunctions_2_1::glColor4ub方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glColor4ub方法的具体用法?C++ QOpenGLFunctions_2_1::glColor4ub怎么用?C++ QOpenGLFunctions_2_1::glColor4ub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glColor4ub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void ccGLUtils::DisplayTexture2DPosition(GLuint texID, int x, int y, int w, int h, unsigned char alpha/*=255*/)
{
QOpenGLContext* context = QOpenGLContext::currentContext();
if (!context)
{
assert(false);
return;
}
QOpenGLFunctions_2_1* glFunc = context->versionFunctions<QOpenGLFunctions_2_1>();
if (glFunc)
{
glFunc->glBindTexture(GL_TEXTURE_2D, texID);
glFunc->glPushAttrib(GL_ENABLE_BIT);
glFunc->glEnable(GL_TEXTURE_2D);
glFunc->glColor4ub(255, 255, 255, alpha);
glFunc->glBegin(GL_QUADS);
glFunc->glTexCoord2f(0.0, 1.0);
glFunc->glVertex2i(x, y + h);
glFunc->glTexCoord2f(0.0, 0.0);
glFunc->glVertex2i(x, y);
glFunc->glTexCoord2f(1.0, 0.0);
glFunc->glVertex2i(x + w, y);
glFunc->glTexCoord2f(1.0, 1.0);
glFunc->glVertex2i(x + w, y + h);
glFunc->glEnd();
glFunc->glBindTexture(GL_TEXTURE_2D, 0);
glFunc->glPopAttrib();
glFunc->glBindTexture(GL_TEXTURE_2D, 0);
}
}
示例2: font
void cc2DLabel::drawMeOnly3D(CC_DRAW_CONTEXT& context)
{
assert(!m_points.empty());
//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;
//standard case: list names pushing
bool pushName = MACRO_DrawEntityNames(context);
if (pushName)
{
//not particularily fast
if (MACRO_DrawFastNamesOnly(context))
return;
glFunc->glPushName(getUniqueIDForDisplay());
}
const float c_sizeFactor = 4.0f;
bool loop = false;
size_t count = m_points.size();
switch (count)
{
case 3:
{
glFunc->glPushAttrib(GL_COLOR_BUFFER_BIT);
glFunc->glEnable(GL_BLEND);
//we draw the triangle
glFunc->glColor4ub(255,255,0,128);
glFunc->glBegin(GL_TRIANGLES);
ccGL::Vertex3v(glFunc, m_points[0].cloud->getPoint(m_points[0].index)->u);
ccGL::Vertex3v(glFunc, m_points[1].cloud->getPoint(m_points[1].index)->u);
ccGL::Vertex3v(glFunc, m_points[2].cloud->getPoint(m_points[2].index)->u);
glFunc->glEnd();
glFunc->glPopAttrib();
loop = true;
}
case 2:
{
//segment width
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(c_sizeFactor * context.renderZoom);
//we draw the segments
if (isSelected())
ccGL::Color3v(glFunc, ccColor::red.rgba);
else
ccGL::Color3v(glFunc, ccColor::green.rgba);
glFunc->glBegin(GL_LINES);
for (unsigned i=0; i<count; i++)
{
if (i+1<count || loop)
{
ccGL::Vertex3v(glFunc, m_points[i].cloud->getPoint(m_points[i].index)->u);
ccGL::Vertex3v(glFunc, m_points[(i+1)%count].cloud->getPoint(m_points[(i+1)%count].index)->u);
}
}
glFunc->glEnd();
glFunc->glPopAttrib();
}
case 1:
{
//display point marker as spheres
{
if (!c_unitPointMarker)
{
c_unitPointMarker = QSharedPointer<ccSphere>(new ccSphere(1.0f, 0, "PointMarker", 12));
c_unitPointMarker->showColors(true);
c_unitPointMarker->setVisible(true);
c_unitPointMarker->setEnabled(true);
}
//build-up point maker own 'context'
CC_DRAW_CONTEXT markerContext = context;
markerContext.drawingFlags &= (~CC_DRAW_ENTITY_NAMES); //we must remove the 'push name flag' so that the sphere doesn't push its own!
markerContext.display = 0;
if (isSelected() && !pushName)
c_unitPointMarker->setTempColor(ccColor::red);
else
c_unitPointMarker->setTempColor(context.labelDefaultMarkerCol);
const ccViewportParameters& viewPortParams = context.display->getViewportParameters();
ccGLCameraParameters camera;
context.display->getGLCameraParameters(camera);
for (unsigned i = 0; i<count; i++)
{
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
const CCVector3* P = m_points[i].cloud->getPoint(m_points[i].index);
ccGL::Translate(glFunc, P->x, P->y, P->z);
//.........这里部分代码省略.........