本文整理汇总了C++中QMatrix4x4::constData方法的典型用法代码示例。如果您正苦于以下问题:C++ QMatrix4x4::constData方法的具体用法?C++ QMatrix4x4::constData怎么用?C++ QMatrix4x4::constData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMatrix4x4
的用法示例。
在下文中一共展示了QMatrix4x4::constData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void QVROSGViewer::render(QVRWindow* /* w */,
const QVRRenderContext& context, int viewPass, unsigned int texture)
{
// Set up framebuffer object to render into
GLint width, height;
glBindTexture(GL_TEXTURE_2D, texture);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
glBindTexture(GL_TEXTURE_2D, _fboDepthTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height,
0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glBindFramebuffer(GL_FRAMEBUFFER, _fbo);
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);
// Set up OSG graphics window
_graphicsWindow->resized(0, 0, width, height);
// Set up OSG camera
QMatrix4x4 P = context.frustum(viewPass).toMatrix4x4();
_viewer.getCamera()->setProjectionMatrix(osg::Matrix(P.constData()));
QMatrix4x4 V = context.viewMatrix(viewPass);
_viewer.getCamera()->setViewMatrix(osg::Matrix(V.constData()));
// Render
_viewer.frame();
}
示例2: setArg
/*!
Sets argument \a index for this kernel to \a value.
The argument is assumed to have been declared with the
type \c float16.
*/
void QCLKernel::setArg(int index, const QMatrix4x4 &value)
{
if (sizeof(qreal) == sizeof(float)) {
clSetKernelArg(m_kernelId, index, sizeof(float) * 16, value.constData());
} else {
float values[16];
for (int posn = 0; posn < 16; ++posn)
values[posn] = float(value.constData()[posn]);
clSetKernelArg(m_kernelId, index, sizeof(values), values);
}
}
示例3: setMatrix
static void setMatrix(GLenum type, const QMatrix4x4 &matrix)
{
glMatrixMode(type);
if (sizeof(qreal) == sizeof(GLfloat)) {
glLoadMatrixf(reinterpret_cast<const GLfloat *>(matrix.constData()));
} else {
GLfloat mat[16];
const qreal *m = matrix.constData();
for (int index = 0; index < 16; ++index)
mat[index] = m[index];
glLoadMatrixf(mat);
}
}
示例4: if
static inline void qMultMatrix( const QMatrix4x4 &mat )
{
if (sizeof(qreal) == sizeof(GLfloat))
glMultMatrixf( (GLfloat*) mat.constData() );
#ifndef QT_OPENGL_ES
else if (sizeof(qreal) == sizeof(GLdouble))
glMultMatrixd( (GLdouble*) mat.constData() );
#endif
else {
GLfloat fmat[16];
qreal const *r = mat.constData();
for (int i = 0; i < 16; ++i)
fmat[i] = r[i];
glMultMatrixf( fmat );
}
}
示例5: draw
void ProjectileNode::draw(std::stack<QMatrix4x4> &MVStack, QMatrix4x4 cameraMatrix, QMatrix4x4 projectionMatrix, QOpenGLShaderProgram *shader) {
Shaders::bind(shader);
MVStack.push(MVStack.top());
MVStack.top().translate(this->translation);
//Convert the quat to a matrix, may be a performance leak.
QMatrix4x4 tempRot;
tempRot.rotate(this->rotation.normalized());
MVStack.top() *= tempRot;
//If the node is a leaf, draw its contents
if(leaf) {
glUniformMatrix4fv(shader->uniformLocation("modelViewMatrix"), 1, GL_FALSE, MVStack.top().constData());
glUniformMatrix4fv(shader->uniformLocation("perspectiveMatrix"), 1, GL_FALSE, projectionMatrix.constData());
glUniformMatrix4fv(shader->uniformLocation("normalMatrix"), 1, GL_FALSE, MVStack.top().inverted().transposed().constData());
int r = (id & 0x000000FF) >> 0;
int g = (id & 0x0000FF00) >> 8;
int b = (id & 0x00FF0000) >> 16;
glUniform4f(shader->uniformLocation("id"), r/255.0f, g/255.0f, b/255.0f, 1.0f);
glUniform4fv(shader->uniformLocation("color"), 1, color);
this->primitive->draw();
} else {
示例6:
QString Qgs3DUtils::matrix4x4toString( const QMatrix4x4 &m )
{
const float *d = m.constData();
QStringList elems;
elems.reserve( 16 );
for ( int i = 0; i < 16; ++i )
elems << QString::number( d[i] );
return elems.join( ' ' );
}
示例7: draw
//! [2]
void Patch::draw() const
{
glPushMatrix();
glMultMatrixf(mat.constData());
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, faceColor);
const GLushort *indices = geom->faces.constData();
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, indices + start);
glPopMatrix();
}
示例8: mulMatrix
static void mulMatrix(QMatrix4x4 const& mat)
{
double static_mat[16];
qreal const* mat_data = mat.constData();
for (int i = 0; i < 16; ++i)
{
static_mat[i] = mat_data[i];
}
glMultMatrixd(static_mat);
}
示例9: drawNodeGeometry
void GeometryEngine::drawNodeGeometry(Node* n)
{
int m44size = 4 * sizeof(QVector4D);
QMatrix4x4 m;
m.setToIdentity();
m.translate( n->m_position.x(), n->m_position.y(), 0 );
m_modelsBuffer.write(((char*)m.constData()), m44size);
m_numNodesToRender++;
}
示例10: render
void MyWindow::render()
{
if(!isVisible() || !isExposed())
return;
if (!mContext->makeCurrent(this))
return;
static bool initialized = false;
if (!initialized) {
initialize();
initialized = true;
}
if (mUpdateSize) {
glViewport(0, 0, size().width(), size().height());
mUpdateSize = false;
}
static float EvolvingVal = 0;
EvolvingVal += 0.1f;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QMatrix4x4 RotationMatrix;
RotationMatrix.rotate(EvolvingVal, QVector3D(0.0f, 0.0f, 0.1f));
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
mFuncs->glBindVertexBuffer(0, mPositionBufferHandle, 0, sizeof(GLfloat) * 3);
mFuncs->glBindVertexBuffer(1, mColorBufferHandle, 0, sizeof(GLfloat) * 3);
mFuncs->glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, 0);
mFuncs->glVertexAttribBinding(0, 0);
mFuncs->glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, 0);
mFuncs->glVertexAttribBinding(1, 1);
mProgram->bind();
{
glUniformMatrix4fv(mRotationMatrixLocation, 1, GL_FALSE, RotationMatrix.constData());
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
mProgram->release();
mContext->swapBuffers(this);
}
示例11: renderWorld
void GameScene::renderWorld(const QMatrix4x4 &view,const QMatrix4x4 &rview)
{
if(glActiveTexture){
glActiveTexture(GL_TEXTURE0);
blockTexture->bind();
}
glLineWidth(2.0f);
lineProgram->bind();
line->draw(); //画十字准心
lineProgram->release();
glLoadMatrixf(rview.constData());
glMultMatrixf(view.constData());
blockProgram->bind();
blockProgram->setUniformValue("tex",GLint(0));
blockProgram->setUniformValue("view",view*rview);
world->draw();
blockProgram->release();
QVector3D keyPosition=camera->getKeyPosition();
if(keyPosition.y()>=0){
lineQua->clear();
for(int i=0;i<12;i++){
lineQua->addLine(linePoints[i][0]+keyPosition,linePoints[i][1]+keyPosition);
}
lineProgram->bind();
lineQua->draw();
lineProgram->release();
}
if(glActiveTexture){
glActiveTexture(GL_TEXTURE0);
blockTexture->unbind();
}
}
示例12: glClear
void Scene3D::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// glTranslatef(xTra, yTra, zTra);
glScalef(nSca, nSca, nSca);
/*glRotatef(xRot, 1, 0, 0);
glRotatef(yRot, 0, 1, 0);
glRotatef(zRot, 0, 0, 1);*/
QMatrix4x4 m;
m.rotate(trackball.rotation());
glMultMatrixf(m.constData());
drawAxis();
drawFigure();
}
示例13: draw
void SeaNode::draw(std::stack<QMatrix4x4> &MVStack, QMatrix4x4 cameraMatrix, QMatrix4x4 projectionMatrix, QOpenGLShaderProgram *shader) {
QOpenGLShaderProgram *sh = Shaders::waterGeometryProgram;
MVStack.push(MVStack.top());
MVStack.top().translate(this->translation);
//Convert the quat to a matrix, may be a performance leak.
QMatrix4x4 tempRot;
tempRot.rotate(this->rotation.normalized());
MVStack.top() *= tempRot;
//If the node is a leaf, draw its contents
if(leaf) {
Shaders::bind(sh);
glUniformMatrix4fv(sh->uniformLocation("modelViewMatrix"), 1, GL_FALSE, MVStack.top().constData());
glUniformMatrix4fv(sh->uniformLocation("cameraInverseMatrix"), 1, GL_FALSE, cameraMatrix.inverted().constData());
glUniformMatrix4fv(sh->uniformLocation("perspectiveMatrix"), 1, GL_FALSE, projectionMatrix.constData());
glUniformMatrix4fv(sh->uniformLocation("normalMatrix"), 1, GL_FALSE, MVStack.top().inverted().transposed().constData());
int r = (id & 0x000000FF) >> 0;
int g = (id & 0x0000FF00) >> 8;
int b = (id & 0x00FF0000) >> 16;
glUniform4f(sh->uniformLocation("id"), r/255.0f, g/255.0f, b/255.0f, 1.0f);
glUniform4fv(sh->uniformLocation("color"), 1, color);
struct timeval start;
gettimeofday(&start, NULL);
float seconds = ((start.tv_sec % (int) periodicity) + start.tv_usec / 1000000.0) / (periodicity / 4);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_3D, noiseTexture);
//glUniform1i(sh->uniformLocation("noiseTexture"), 5);
glUniform1i(sh->uniformLocation("seaWidth"), seaWidth);
glUniform1i(sh->uniformLocation("seaHeight"), seaHeight);
glUniform1f(sh->uniformLocation("time"), seconds);
this->primitive->draw();
Shaders::release(sh);
} else {
示例14: glMatrixMode
void Visu3D::makeLandMark(QMatrix4x4 mTransformation){
// repere
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(mTransformation.constData());
glLineWidth(2.5);
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(1, 0, 0);
glEnd();
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0, 1, 0);
glEnd();
glColor3f(0.0, 0.0, 1.0);
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0, 0, 1);
glEnd();
}
示例15: render
void OculusRiftNode::render( qint64 pTimeStamp, QUuid pSourcePinId )
{
Q_UNUSED( pSourcePinId )
#if !defined( OCULUS_PLUGIN_SUPPORTED )
Q_UNUSED( pTimeStamp )
#else
fugio::Performance Perf( mNode, "drawGeometry", pTimeStamp );
if( !mNode->isInitialised() )
{
return;
}
if( !mOculusRift->hmd() )
{
return;
}
// We need to keep a reference to ourselves here as ovr_SubmitFrame can
// call the main app event loop, which can close the context and delete us!
QSharedPointer<fugio::NodeControlInterface> C = mNode->control();
mOculusRift->drawStart();
const float NearPlane = variant( mPinNearPlane ).toFloat();
const float FarPlane = variant( mPinFarPlane ).toFloat();
// float Yaw(3.141592f);
// Vector3f Pos2(0.0f,1.6f,-5.0f);
// Pos2.y = ovrHmd_GetFloat(mHMD, OVR_KEY_EYE_HEIGHT, Pos2.y);
QMatrix4x4 MatEye = variant( mPinViewMatrix ).value<QMatrix4x4>();
QVector3D TrnEye = MatEye.column( 3 ).toVector3D();
MatEye.setColumn( 3, QVector4D( 0, 0, 0, 1 ) );
const Vector3f Pos2( TrnEye.x(), TrnEye.y(), TrnEye.z() );
Matrix4f tempRollPitchYaw;
memcpy( tempRollPitchYaw.M, MatEye.constData(), sizeof( float ) * 16 );
const Matrix4f rollPitchYaw = tempRollPitchYaw;
// Render Scene to Eye Buffers
for (int eye = 0; eye < 2; eye++)
{
mOculusRift->drawEyeStart( eye );
// Get view and projection matrices
//Matrix4f rollPitchYaw = Matrix4f( MatEye.transposed().data() );
Matrix4f finalRollPitchYaw = rollPitchYaw * Matrix4f( mOculusRift->eyeRenderPos( eye ).Orientation);
Vector3f finalUp = finalRollPitchYaw.Transform(Vector3f(0, 1, 0));
Vector3f finalForward = finalRollPitchYaw.Transform(Vector3f(0, 0, -1));
Vector3f shiftedEyePos = Pos2 + rollPitchYaw.Transform( mOculusRift->eyeRenderPos( eye ).Position );
Matrix4f view = Matrix4f::LookAtRH(shiftedEyePos, shiftedEyePos + finalForward, finalUp);
Matrix4f proj = ovrMatrix4f_Projection( mOculusRift->defaultEyeFOV( eye ), NearPlane, FarPlane, ovrProjection_None );
mProjection->setVariant( QMatrix4x4( &proj.M[ 0 ][ 0 ], 4, 4 ).transposed() );
mView->setVariant( QMatrix4x4( &view.M[ 0 ][ 0 ], 4, 4 ).transposed() );
fugio::OpenGLStateInterface *CurrentState = 0;
for( QSharedPointer<fugio::PinInterface> P : mNode->enumInputPins() )
{
if( !P->isConnected() )
{
continue;
}
if( P->connectedPin().isNull() )
{
continue;
}
if( P->connectedPin()->control().isNull() )
{
continue;
}
QObject *O = P->connectedPin()->control()->qobject();
if( !O )
{
continue;
}
if( true )
{
fugio::RenderInterface *Geometry = qobject_cast<fugio::RenderInterface *>( O );
if( Geometry )
{
Geometry->render( pTimeStamp );
continue;
//.........这里部分代码省略.........