本文整理汇总了C++中QOpenGLFunctions_2_1::glScalef方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions_2_1::glScalef方法的具体用法?C++ QOpenGLFunctions_2_1::glScalef怎么用?C++ QOpenGLFunctions_2_1::glScalef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions_2_1
的用法示例。
在下文中一共展示了QOpenGLFunctions_2_1::glScalef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMeOnly
//.........这里部分代码省略.........
{
if (m_width != 0)
{
glFunc->glPushAttrib(GL_LINE_BIT);
glFunc->glLineWidth(static_cast<GLfloat>(m_width));
}
//DGM: we do the 'GL_LINE_LOOP' manually as I have a strange bug
//on one on my graphic card with this mode!
//glBegin(m_isClosed ? GL_LINE_LOOP : GL_LINE_STRIP);
glFunc->glBegin(GL_LINE_STRIP);
for (unsigned i = 0; i < vertCount; ++i)
{
ccGL::Vertex3v(glFunc, getPoint(i)->u);
}
if (m_isClosed)
{
ccGL::Vertex3v(glFunc, getPoint(0)->u);
}
glFunc->glEnd();
//display arrow
if (m_showArrow && m_arrowIndex < vertCount && (m_arrowIndex > 0 || m_isClosed))
{
const CCVector3* P0 = getPoint(m_arrowIndex == 0 ? vertCount - 1 : m_arrowIndex - 1);
const CCVector3* P1 = getPoint(m_arrowIndex);
//direction of the last polyline chunk
CCVector3 u = *P1 - *P0;
u.normalize();
if (m_mode2D)
{
u *= -m_arrowLength;
static const PointCoordinateType s_defaultArrowAngle = static_cast<PointCoordinateType>(15.0 * CC_DEG_TO_RAD);
static const PointCoordinateType cost = cos(s_defaultArrowAngle);
static const PointCoordinateType sint = sin(s_defaultArrowAngle);
CCVector3 A(cost * u.x - sint * u.y, sint * u.x + cost * u.y, 0);
CCVector3 B(cost * u.x + sint * u.y, -sint * u.x + cost * u.y, 0);
glFunc->glBegin(GL_POLYGON);
ccGL::Vertex3v(glFunc, (A + *P1).u);
ccGL::Vertex3v(glFunc, (B + *P1).u);
ccGL::Vertex3v(glFunc, (*P1).u);
glFunc->glEnd();
}
else
{
if (!c_unitArrow)
{
c_unitArrow = QSharedPointer<ccCone>(new ccCone(0.5, 0.0, 1.0));
c_unitArrow->showColors(true);
c_unitArrow->showNormals(false);
c_unitArrow->setVisible(true);
c_unitArrow->setEnabled(true);
}
if (colorsShown())
c_unitArrow->setTempColor(m_rgbColor);
else
c_unitArrow->setTempColor(context.pointsDefaultCol);
//build-up unit arrow 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;
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
ccGL::Translate(glFunc, P1->x, P1->y, P1->z);
ccGLMatrix rotMat = ccGLMatrix::FromToRotation(u, CCVector3(0, 0, PC_ONE));
glFunc->glMultMatrixf(rotMat.inverse().data());
glFunc->glScalef(m_arrowLength, m_arrowLength, m_arrowLength);
ccGL::Translate(glFunc, 0.0, 0.0, -0.5);
c_unitArrow->draw(markerContext);
glFunc->glPopMatrix();
}
}
if (m_width != 0)
{
glFunc->glPopAttrib();
}
}
//display vertices
if (m_showVertices)
{
glFunc->glPushAttrib(GL_POINT_BIT);
glFunc->glPointSize((GLfloat)m_vertMarkWidth);
glFunc->glBegin(GL_POINTS);
for (unsigned i = 0; i < vertCount; ++i)
{
ccGL::Vertex3v(glFunc, getPoint(i)->u);
}
glFunc->glEnd();
glFunc->glPopAttrib();
}
if (pushName)
glFunc->glPopName();
}
示例2: font
//.........这里部分代码省略.........
}
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);
float scale = context.labelMarkerSize * m_relMarkerScale;
if (viewPortParams.perspectiveView && viewPortParams.zFar > 0)
{
//in perspective view, the actual scale depends on the distance to the camera!
const double* M = camera.modelViewMat.data();
double d = (camera.modelViewMat * CCVector3d::fromArray(P->u)).norm();
double unitD = viewPortParams.zFar / 2; //we consider that the 'standard' scale is at half the depth
scale = static_cast<float>(scale * sqrt(d / unitD)); //sqrt = empirical (probably because the marker size is already partly compensated by ccGLWindow::computeActualPixelSize())
}
glFunc->glScalef(scale, scale, scale);
c_unitPointMarker->draw(markerContext);
glFunc->glPopMatrix();
}
}
if (m_dispIn3D && !pushName) //no need to display label in point picking mode
{
QFont font(context.display->getTextDisplayFont()); //takes rendering zoom into account!
//font.setPointSize(font.pointSize()+2);
font.setBold(true);
static const QChar ABC[3] = {'A','B','C'};
//we can't use the context 'ccGLCameraParameters' (viewport, modelView matrix, etc. )
//because it doesn't take the temporary 'GL transformation' into account!
ccGLCameraParameters camera;
//context.display->getGLCameraParameters(camera);
glFunc->glGetIntegerv(GL_VIEWPORT, camera.viewport);
glFunc->glGetDoublev(GL_PROJECTION_MATRIX, camera.projectionMat.data());
glFunc->glGetDoublev(GL_MODELVIEW_MATRIX, camera.modelViewMat.data());
//draw their name
glFunc->glPushAttrib(GL_DEPTH_BUFFER_BIT);
glFunc->glDisable(GL_DEPTH_TEST);
for (unsigned j=0; j<count; j++)
{
const CCVector3* P = m_points[j].cloud->getPoint(m_points[j].index);
QString title;
if (count == 1)
title = getName(); //for single-point labels we prefer the name
else if (count == 3)
title = ABC[j]; //for triangle-labels, we only display "A","B","C"
else
title = QString("P#%0").arg(m_points[j].index);
//project it in 2D screen coordinates
CCVector3d Q2D;
camera.project(*P, Q2D);
context.display->displayText( title,
static_cast<int>(Q2D.x) + context.labelMarkerTextShift_pix,
static_cast<int>(Q2D.y) + context.labelMarkerTextShift_pix,
ccGenericGLDisplay::ALIGN_DEFAULT,
context.labelOpacity / 100.0f,
ccColor::white.rgba,
&font );
}
glFunc->glPopAttrib();
}
}
}
if (pushName)
{
glFunc->glPopName();
}
}
示例3: drawMeOnly
void ccSample::drawMeOnly(CC_DRAW_CONTEXT& context)
{
if (MACRO_Draw3D(context)) {
if (!this->getSample())
return;
QOpenGLFunctions_2_1* glFunc = context.glFunctions<QOpenGLFunctions_2_1>();
assert(glFunc != nullptr);
bool pushName = MACRO_DrawEntityNames(context);
if (pushName) {
// not particularily fast
if (MACRO_DrawFastNamesOnly(context))
return;
glFunc->glPushName(getUniqueIDForDisplay());
}
if (!c_unitPointMarker) {
c_unitPointMarker = QSharedPointer<ccSphere>(new ccSphere(m_radius_, 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 = nullptr;
if (isSelected() && !pushName) {
c_unitPointMarker->setTempColor(ccColor::red);
c_unitPointMarker->setRadius(2 * m_radius_);
}
else {
c_unitPointMarker->setTempColor(ccColor::magenta);
c_unitPointMarker->setRadius(m_radius_);
}
glFunc->glMatrixMode(GL_MODELVIEW);
glFunc->glPushMatrix();
float x, y, z;
Eigen::Vector3f p = this->getSample()->getPosition();
// const CCVector3* P = m_points[i].cloud->getPoint(m_points[i].index);
// ccGL::Translate();
glFunc->glTranslatef(p(0), p(1), p(2));
glFunc->glScalef(context.labelMarkerSize, context.labelMarkerSize,
context.labelMarkerSize);
m_current_scaling_ = context.labelMarkerSize;
c_unitPointMarker->draw(markerContext);
glFunc->glPopMatrix();
drawStratPos(context);
if (pushName)
glFunc->glPopName();
}
}