本文整理汇总了C++中CModel::DrawMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ CModel::DrawMesh方法的具体用法?C++ CModel::DrawMesh怎么用?C++ CModel::DrawMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModel
的用法示例。
在下文中一共展示了CModel::DrawMesh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shapes
/*!****************************************************************************
@Function RenderScene
@Return bool true if no error occured
@Description Main rendering loop function of the program. The shell will
call this function every frame.
eglSwapBuffers() will be performed by PVRShell automatically.
PVRShell will also manage important OS events.
Will also manage relevent OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2StencilBuffer::RenderScene()
{
m_fAngle += 0.005f;
// Clear the color, depth and stencil buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
/*
Set up the transformation matrices for our two shapes (the cylinder and the sphere)
*/
PVRTMat4 mSphere, mCylinder;
PVRTMat4 mTrans, mRotZ, mRotX, mScale;
mScale = PVRTMat4::Scale((float)PVRShellGet(prefHeight)/(float)PVRShellGet(prefWidth), 1.0f, 1.0f);
mRotZ = PVRTMat4::RotationX(m_fAngle);
mSphere = mRotZ * mScale;
mTrans = PVRTMat4::Translation(-0.4f, -0.5f, 0.0f);
mRotZ = PVRTMat4::RotationZ(m_fAngle);
mRotX = PVRTMat4::RotationX(m_fAngle);
mCylinder = mScale * mRotX * mRotZ * mTrans;
// Bind texture and set transform
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiStoneTex);
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mSphere.ptr());
// Set culling to cull the back faces
glCullFace(GL_BACK);
/*
Draw the sphere
This sphere is textured with the stone texture and will be visible outside the stencil volume as
we are drawing a second sphere with a green tiles texture everywhere within the stencil
geometry.
Also this sphere is used to set the depth values in the Z-Buffer.
*/
m_Sphere.DrawMesh(0);
/*
Enable the stencil test, disable color and depth writes
*/
glEnable(GL_STENCIL_TEST);
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
glDepthMask(GL_FALSE);
/*
What we are going to do is draw a volume (a cylinder) so that all front faces that are in front of
the already rendered geometry (the sphere) increase the stencil value by one, while all back faces
that are in front of the rendered geometry decrease the stencil value. This way only surfaces that
intersect the stencil volume will get a stencil value != 0.
Since OpenGL ES 2.0 offers two-sided stencil, we can do this in a single pass.
*/
// Disable culling as we want to use the back and front faces of the geometry.
glDisable(GL_CULL_FACE);
/*
glStencilFunc tells OGLES2 the type of per-pixel test that we want to do. In the case below GL_ALWAYS says we
want the test to always pass. The third value is the mask value which is ANDed with the second value
(the reference value) to create the value that is put in the stencil buffer.
Alternative values for the first value are
GL_NEVER which causes the test to never pass.
GL_LESS Passes if ( ref & mask ) < ( stencil & mask ).
GL_LEQUAL Passes if ( ref & mask ) < ( stencil & mask ).
GL_GREATER Passes if ( ref & mask ) > ( stencil & mask ).
GL_GEQUAL Passes if ( ref & mask ) > ( stencil & mask ).
GL_EQUAL Passes if ( ref & mask ) = ( stencil & mask ).
GL_NOTEQUAL Passes if ( ref & mask ) / ( stencil & mask ).
A call to glStencilFunc is the same as calling glStencilFuncSeparate with GL_FRONT_AND_BACK
*/
glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
/*
glStencilOp has 3 parameters. The first parameter specifies the action to take if the
stencil test fails. The second specifies the stencil action to take if the stencil test passes
but the depth test fails. The third one specifies the stencil action when the stencil test and
the depth test pass, or when the stencil test passes and their is no depth testing done.
//.........这里部分代码省略.........