当前位置: 首页>>代码示例>>C++>>正文


C++ GLMatrix类代码示例

本文整理汇总了C++中GLMatrix的典型用法代码示例。如果您正苦于以下问题:C++ GLMatrix类的具体用法?C++ GLMatrix怎么用?C++ GLMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GLMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: inverse

GLMatrix
inverse( const GLMatrix & mat )
{
	GLMatrix result;
	GLfloat d = det(mat);

	if (fabs(d) < 0.0005)
	{
		result.setIdentity();
	}
	else
	{
		d = 1.0f/d;

		result.data[0] =  (mat.data[5] * mat.data[10] - mat.data[6] * mat.data[9]) * d;
		result.data[1] = -(mat.data[1] * mat.data[10] - mat.data[9] * mat.data[2]) * d;
		result.data[2] =  (mat.data[1] * mat.data[6] - mat.data[5] * mat.data[2]) * d;

		result.data[3] = -(mat.data[4] * mat.data[10] - mat.data[6] * mat.data[8]) * d;
		result.data[4] =  (mat.data[0] * mat.data[10] - mat.data[2] * mat.data[8]) * d;
		result.data[5] = -(mat.data[0] * mat.data[6] - mat.data[2] * mat.data[4]) * d;

		result.data[6] =  (mat.data[4] * mat.data[9] - mat.data[5] * mat.data[8]) * d;
		result.data[7] = -(mat.data[0] * mat.data[9] - mat.data[1] * mat.data[8]) * d;
		result.data[8] =  (mat.data[0] * mat.data[5] - mat.data[1] * mat.data[4]) * d;
	}

	return result;
}
开发者ID:arktic,项目名称:Particule,代码行数:29,代码来源:GlFramework.cpp

示例2: WRAPABLE_HND_FUNCTN_RETURN

bool
GLScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
			 const GLMatrix            &transform,
			 const CompRegion          &region,
			 CompOutput                *output,
			 unsigned int              mask)
{
    WRAPABLE_HND_FUNCTN_RETURN (bool, glPaintOutput, sAttrib, transform,
			      region, output, mask)

    GLMatrix sTransform = transform;

    if (mask & PAINT_SCREEN_REGION_MASK)
    {
	if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
	{
	    if (mask & PAINT_SCREEN_FULL_MASK)
	    {
		glPaintTransformedOutput (sAttrib, sTransform,
					  CompRegion (*output), output, mask);

		return true;
	    }

	    return false;
	}

	setLighting (false);

	sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);

	/*
	 * Sometimes region might be empty but we still need to force the
	 * repaint. This can happen when a fullscreen window is unredirected,
	 * and damageScreen is called. CompositeScreen::handlePaintTimeout
	 * then subtracts the whole screen of damage because it's an overlay
	 * and we're left with an empty damage region.
	 * Even when this happens we may want to force the repaint if
	 * windows are getting transformed (and so the unredirected window
	 * needs to be redirected again).
	 */
	if (!region.isEmpty () ||
	    (mask & PAINT_SCREEN_FULL_MASK) ||
	    (mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK))
	    priv->paintOutputRegion (sTransform, region, output, mask);

	return true;
    }
    else if (mask & PAINT_SCREEN_FULL_MASK)
    {
	glPaintTransformedOutput (sAttrib, sTransform, CompRegion (*output),
				  output, mask);

	return true;
    }
    else
    {
	return false;
    }
}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-compiz,代码行数:60,代码来源:paint.cpp

示例3: getProgress

void
ExpandAnim::applyTransform ()
{
    GLMatrix *transform = &mTransform;
    float defaultXScale = 0.3f;
    float forwardProgress;
    float expandProgress;
    const float expandPhaseEnd = 0.5f;

    forwardProgress = getProgress ();

    if ((1 - forwardProgress) < expandPhaseEnd)
	expandProgress = (1 - forwardProgress) / expandPhaseEnd;
    else
	expandProgress = 1.0f;

    // animation movement
    transform->translate (WIN_X (mWindow) + WIN_W (mWindow) / 2.0f,
			  WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f,
			  0.0f); 

    transform->scale (defaultXScale + (1.0f - defaultXScale) *
		      expandProgress,
		      (1 - forwardProgress), 0.0f);

    transform->translate (-(WIN_X (mWindow) + WIN_W (mWindow) / 2.0f),
		      	  -(WIN_Y (mWindow) + WIN_H (mWindow) / 2.0f),
		      	  0.0f);

}
开发者ID:hedmo,项目名称:compiz,代码行数:30,代码来源:expand.cpp

示例4: RotCamBase

bool GLCamera::RotCamBase(double angle)
{
  GLVertex3 org;
  GLMatrix  mx  = fCamBase*fCamTrans;
  GLVector3 fwd = mx.GetBaseVec(1);
  fCamBase.Rotate(org, fwd, angle);
  return (angle != 0);
}
开发者ID:krafczyk,项目名称:AMS,代码行数:8,代码来源:glcamera.cpp

示例5: GLVector3

void GLCamera::SetCenterVec(double x, double y, double z)
{
  // Set camera center vector.

  GLMatrix bt = fCamBase*fCamTrans;
  fCamBase.SetBaseVec(4, GLVector3(x, y, z));

  GLMatrix binv = fCamBase; binv.Invert();
  fCamTrans = binv*bt;
}
开发者ID:krafczyk,项目名称:AMS,代码行数:10,代码来源:glcamera.cpp

示例6: wTransform

bool
ResizeWindow::glPaint (const GLWindowPaintAttrib &attrib,
		       const GLMatrix            &transform,
		       const CompRegion          &region,
		       unsigned int              mask)
{
    bool       status;

    if (window == static_cast<resize::CompWindowImpl*>(rScreen->logic.w)->impl ()
	&& rScreen->logic.mode == ResizeOptions::ModeStretch)
    {
	GLMatrix       wTransform (transform);
	BoxRec	       box;
	float	       xOrigin, yOrigin;
	float	       xScale, yScale;
	int            x, y;

	if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
	    return false;

	status = gWindow->glPaint (attrib, transform, region,
				   mask | PAINT_WINDOW_NO_CORE_INSTANCE_MASK);

	GLWindowPaintAttrib lastAttrib (gWindow->lastPaintAttrib ());

	if (window->alpha () || lastAttrib.opacity != OPAQUE)
	    mask |= PAINT_WINDOW_TRANSLUCENT_MASK;

	rScreen->logic.getPaintRectangle (&box);
	getStretchScale (&box, &xScale, &yScale);

	x = window->geometry (). x ();
	y = window->geometry (). y ();

	xOrigin = x - window->border ().left;
	yOrigin = y - window->border ().top;

	wTransform.translate (xOrigin, yOrigin, 0.0f);
	wTransform.scale (xScale, yScale, 1.0f);
	wTransform.translate ((rScreen->logic.geometry.x - x) / xScale - xOrigin,
			      (rScreen->logic.geometry.y - y) / yScale - yOrigin,
			      0.0f);

	gWindow->glDraw (wTransform, lastAttrib, region,
			 mask | PAINT_WINDOW_TRANSFORMED_MASK);
    }
    else
    {
	status = gWindow->glPaint (attrib, transform, region, mask);
    }

    return status;
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:53,代码来源:resize.cpp

示例7:

void MythRenderOpenGL2::PushTransformation(const UIEffects &fx, QPointF &center)
{
    GLMatrix newtop = m_transforms.top();
    if (fx.hzoom != 1.0 || fx.vzoom != 1.0 || fx.angle != 0.0)
    {
        newtop.translate(-center.x(), -center.y());
        newtop.scale(fx.hzoom, fx.vzoom);
        newtop.rotate(fx.angle);
        newtop.translate(center.x(), center.y());
    }
    m_transforms.push(newtop);
}
开发者ID:mikkle,项目名称:mythtv,代码行数:12,代码来源:mythrender_opengl2.cpp

示例8: fabs

void
GLScreen::glEnableOutputClipping (const GLMatrix   &transform,
				  const CompRegion &region,
				  CompOutput       *output)
{
    WRAPABLE_HND_FUNCTN (glEnableOutputClipping, transform, region, output)

    // Bottom-left corner of the output:
    const GLint x = output->x1 ();
    const GLint y = screen->height () - output->y2 ();
    const GLsizei w = output->width ();
    const GLsizei h = output->height ();

    // Transformed (only scale and translation is supported!)
    const float *t = transform.getMatrix ();
    const GLfloat scalex = t[0], scaley = t[5], transx = t[12], transy = t[13];
    const GLfloat centrex = x + w / 2.0f;
    const GLfloat centrey = y + h / 2.0f;
    GLfloat scaledw = fabs (w * scalex);
    GLfloat scaledh = fabs (h * scaley);
    GLfloat tx = centrex - (scaledw / 2.0f) + transx * w;
    GLfloat ty = centrey - (scaledh / 2.0f) + transy * h;

    glScissor (tx, ty, roundf (scaledw), roundf (scaledh));
    glEnable (GL_SCISSOR_TEST);
}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-compiz,代码行数:26,代码来源:paint.cpp

示例9: optionGetIntensity

bool
ShowrepaintScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
				  const GLMatrix            &transform,
				  const CompRegion          &region,
				  CompOutput                *output,
				  unsigned int               mask)
{
    bool           status;
    GLMatrix       sTransform; // initially identity matrix
    unsigned short color[4];

    status = gScreen->glPaintOutput (attrib, transform, region, output, mask);

    tmpRegion = region.intersected (*output);

    if (tmpRegion.isEmpty ())
	return status;

    sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);

    color[3] = optionGetIntensity () * 0xffff / 100;
    color[0] = (rand () & 7) * color[3] / 8;
    color[1] = (rand () & 7) * color[3] / 8;
    color[2] = (rand () & 7) * color[3] / 8;

    glColor4usv (color);
    glPushMatrix ();
    glLoadMatrixf (sTransform.getMatrix ());
    glEnable (GL_BLEND);

    glBegin (GL_QUADS);
    foreach (const CompRect &box, tmpRegion.rects ())
    {
	glVertex2i (box.x1 (), box.y1 ());
	glVertex2i (box.x1 (), box.y2 ());
	glVertex2i (box.x2 (), box.y2 ());
	glVertex2i (box.x2 (), box.y1 ());
    }
    glEnd ();

    glDisable (GL_BLEND);
    glPopMatrix();

    glColor4usv (defaultColor);

    return status;
}
开发者ID:adrianobalani,项目名称:compiz-2,代码行数:47,代码来源:showrepaint.cpp

示例10: WRAPABLE_HND_FUNCTN_RETURN

bool
CubeScreen::cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib,
				  const GLMatrix            &transform,
				  CompOutput                *output,
				  std::vector<GLVector>     &points)
{
    WRAPABLE_HND_FUNCTN_RETURN (bool, cubeCheckOrientation, sAttrib, transform, output, points)
    GLMatrix sTransform = transform;
    GLMatrix mvp, pm (priv->gScreen->projectionMatrix ()->getMatrix ());
    GLVector pntA, pntB, pntC;
    GLVector vecA, vecB, ortho;
    bool     rv = false;

    priv->gScreen->glApplyTransform (sAttrib, output, &sTransform);
    sTransform.translate (priv->mOutputXOffset, -priv->mOutputYOffset, 0.0f);
    sTransform.scale (priv->mOutputXScale, priv->mOutputYScale, 1.0f);

    mvp = pm * sTransform;

    pntA = mvp * points[0];

    if (pntA[3] < 0.0f)
	rv = !rv;

    pntA.homogenize ();

    pntB = mvp * points[1];

    if (pntB[3] < 0.0f)
	rv = !rv;

    pntB.homogenize ();

    pntC = mvp * points[2];
    pntC.homogenize ();

    vecA = pntC - pntA;
    vecB = pntC - pntB;

    ortho = vecA ^ vecB;

    if (ortho[2] > 0.0f)
	rv = !rv;

    return rv;
}
开发者ID:adrianobalani,项目名称:compiz-2,代码行数:46,代码来源:cube.cpp

示例11: setUniform

bool GLProgram::setUniform (const char *name, const GLMatrix &value)
{
    GLint location = (*GL::getUniformLocation) (priv->program, name);
    if (location == -1)
	return false;

    (*GL::uniformMatrix4fv) (location, 1, GL_FALSE, value.getMatrix ());
    return true;
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:9,代码来源:program.cpp

示例12:

bool 
RotateScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib,
			     const GLMatrix            &transform, 
			     const CompRegion          &region, 
			     CompOutput                *output,
			     unsigned int              mask)
{
    if (mGrabIndex || mMoving || mProgress != 0.0f)
    {
	GLMatrix sTransform = transform;

	sTransform.translate (0.0f, 0.0f, -mZoomTranslate);

	mask &= ~PAINT_SCREEN_REGION_MASK;
	mask |= PAINT_SCREEN_TRANSFORMED_MASK;
	
	return gScreen->glPaintOutput (sAttrib, sTransform, region, output, mask);
    }

    return gScreen->glPaintOutput (sAttrib, transform, region, output, mask);
}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-compiz,代码行数:21,代码来源:rotate.cpp

示例13: sTransform

bool
WSNamesScreen::glPaintOutput (const GLScreenPaintAttrib	&attrib,
                              const GLMatrix		&transform,
                              const CompRegion		&region,
                              CompOutput		*output,
                              unsigned int		mask)
{
    bool status;

    status = gScreen->glPaintOutput (attrib, transform, region, output, mask);

    if (textData.getWidth () && textData.getHeight ())
    {
        GLMatrix sTransform (transform);

        sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);

        drawText (sTransform);
    }

    return status;
}
开发者ID:pfreris,项目名称:compiz,代码行数:22,代码来源:workspacenames.cpp

示例14: glGetDoublev

void GLCamera::UpdateCache()
{
  GLMatrix projm;
  glGetDoublev(GL_PROJECTION_MATRIX, projm.Arr());

  GLMatrix modvm;
  glGetDoublev(GL_MODELVIEW_MATRIX,  modvm.Arr());

  GLMatrix clipm = projm;
  clipm *= modvm;

  fFrustumPlanes[kRight] .Set(clipm[ 3]-clipm[ 0], clipm[ 7]-clipm[ 4],
			      clipm[11]-clipm[ 8], clipm[15]-clipm[12]);
  fFrustumPlanes[kLeft]  .Set(clipm[ 3]+clipm[ 0], clipm[ 7]+clipm[ 4],
			      clipm[11]+clipm[ 8], clipm[15]+clipm[12]);
  fFrustumPlanes[kBottom].Set(clipm[ 3]+clipm[ 1], clipm[ 7]+clipm[ 5],
			      clipm[11]+clipm[ 9], clipm[15]+clipm[13]);
  fFrustumPlanes[kTop]   .Set(clipm[ 3]-clipm[ 1], clipm[ 7]-clipm[ 5],
			      clipm[11]-clipm[ 9], clipm[15]-clipm[13]);
  fFrustumPlanes[kFar]   .Set(clipm[ 3]-clipm[ 2], clipm[ 7]-clipm[ 6],
			      clipm[11]-clipm[10], clipm[15]-clipm[14]);
  fFrustumPlanes[kNear]  .Set(clipm[ 3]+clipm[ 2], clipm[ 7]+clipm[ 6],
			      clipm[11]+clipm[10], clipm[15]+clipm[14]);
}
开发者ID:krafczyk,项目名称:AMS,代码行数:24,代码来源:glcamera.cpp

示例15: transformIsSimple

// transformIsSimple tells you if it's simple enough to use scissoring
static bool
transformIsSimple (const GLMatrix &transform)
{
    const float *t = transform.getMatrix ();
    return // t[0] can be anything (x scale)
           t[1] == 0.0f &&
           t[2] == 0.0f &&
           t[3] == 0.0f &&
           t[4] == 0.0f &&
           // t[5] can be anything (y scale)
           t[6] == 0.0f &&
           t[7] == 0.0f &&
           t[8] == 0.0f &&
           t[9] == 0.0f &&
           // t[10] can be anything (z scale)
           t[11] == 0.0f &&
           // t[12]..t[14] can be anything (translation)
           t[15] == 1.0f;
}
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-compiz,代码行数:20,代码来源:paint.cpp


注:本文中的GLMatrix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。