本文整理汇总了C++中CPVRTPrint3D::Flush方法的典型用法代码示例。如果您正苦于以下问题:C++ CPVRTPrint3D::Flush方法的具体用法?C++ CPVRTPrint3D::Flush怎么用?C++ CPVRTPrint3D::Flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPVRTPrint3D
的用法示例。
在下文中一共展示了CPVRTPrint3D::Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*!****************************************************************************
@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 OGLES3PerturbedUvs::RenderScene()
{
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiReflectTex);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_uiNormalTex);
// Rotate and translate the model matrix
PVRTMat4 mModel;
mModel = PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += PVRT_PI / 210;
// Set model view projection matrix
PVRTMat4 mModelView, mMVP;
mModelView = m_mView * mModel;
mMVP = m_mProjection * mModelView;
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());
// Set eye position in model space
PVRTVec4 vEyePosModel;
vEyePosModel = mModelView.inverse() * PVRTVec4(0, 0, 0, 1);
glUniform3fv(m_ShaderProgram.auiLoc[eEyePosModel], 1, &vEyePosModel.x);
/*
Now that the uniforms are set, call another function to actually draw the mesh.
*/
DrawMesh(0);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("PerturbedUvs", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例2: transpose
/*!****************************************************************************
@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 OGLES3Bumpmap::RenderScene()
{
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiBaseTex);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_uiNormalMap);
// Calculate the model matrix
PVRTMat4 mModel = PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += PVRT_PI / 150;
// Set model view projection matrix
PVRTMat4 mMVP = m_mViewProj * mModel;
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());
// Set light position in model space
/*
The inverse of a rotation matrix is the transposed matrix
Because of v * M = transpose(M) * v, this means:
v * R == inverse(R) * v
So we don't have to actually invert or transpose the matrix
to transform back from world space to model space
*/
PVRTVec4 vMsLightPos = PVRTVec4(50, 20, 40, 1) * mModel;
glUniform3fv(m_ShaderProgram.auiLoc[eLightPos], 1, &vMsLightPos.x);
DrawMesh(0);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("Bumpmap", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例3:
/*!****************************************************************************
@Function RenderScene
@Return bool true if no error occurred
@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 relevant OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2Shaders::RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Keyboard input (cursor to change shaders and meshes)
if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
{
m_nCurrentShader--;
if(m_nCurrentShader<0) m_nCurrentShader=(g_numShaders-1);
}
if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
m_nCurrentShader++;
if(m_nCurrentShader>(g_numShaders-1)) m_nCurrentShader=0;
}
if (PVRShellIsKeyPressed(PVRShellKeyNameDOWN))
{
m_nCurrentSurface--;
if(m_nCurrentSurface<0) m_nCurrentSurface=(g_numSurfaces-1);
ComputeSurface(m_nCurrentSurface);
}
if (PVRShellIsKeyPressed(PVRShellKeyNameUP))
{
m_nCurrentSurface++;
if(m_nCurrentSurface>(g_numSurfaces-1)) m_nCurrentSurface=0;
ComputeSurface(m_nCurrentSurface);
}
// Draw the mesh
ComputeViewMatrix();
DrawModel();
// Display screen info
m_Print3D.DisplayDefaultTitle("Shaders", NULL, ePVRTPrint3DSDKLogo);
m_Print3D.Print3D(0.3f, 7.5f, 0.75f, 0xFFFFFFFF, "Shader: %s\nMesh: %s", g_ShaderList[m_nCurrentShader], g_SurfacesList[m_nCurrentSurface]);
m_Print3D.Flush();
return true;
}
示例4: PVRShellGetTime
/*!****************************************************************************
@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 OGLES2ParticleSystem::RenderScene()
{
HandleInput();
UpdateParticles();
UpdateFramerateCounter();
float time_delta = PVRShellGetTime() / 10000.0f;
PVRTVec3 vFrom = PVRTVec3((float) sin(time_delta) * 50.0f, 30.0f, (float) cos(time_delta) * 50.0f);
m_mView = PVRTMat4::LookAtRH(vFrom, PVRTVec3(0.0f, 5.0f, 0.0f), PVRTVec3(0.0f, 1.0f, 0.0f));
m_mViewProjection = m_mProjection * m_mView;
// Clear colour and depth buffers
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Enables depth testing
glEnable(GL_DEPTH_TEST);
// Render floor
RenderFloor();
for (unsigned int i=0; i < g_cuiNumSpheres; i++)
RenderSphere(g_caSpheres[i].aPosition, g_caSpheres[i].fRadius);
// Render particles
RenderParticles();
// Display info text.
char lower_buffer[64];
unsigned int numParticles = m_pParticleSystem->GetNumberOfParticles();
sprintf(lower_buffer, "No. of Particles: %d", numParticles);
m_Print3D.DisplayDefaultTitle("Particle System", NULL, ePVRTPrint3DSDKLogo);
m_Print3D.Print3D(2.0f, 90.0f, 1.0f, 0xFFFFFFFF, "No. of Particles: %d", numParticles);
m_Print3D.Flush();
return true;
}
示例5:
/*!****************************************************************************
@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 OGLES3CellShading::RenderScene()
{
// Clears the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use the loaded shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiShadingTex);
// Calculate the model matrix
PVRTMat4 mModel = PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += PVRT_PI / 210;
// Set model view projection matrix
PVRTMat4 mMVP = m_mViewProj * mModel;
glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());
// Set eye position in model space
PVRTVec4 vMsEyePos = PVRTVec4(0, 0, 125, 1) * mModel;
glUniform3fv(m_ShaderProgram.uiEyePosLoc, 1, vMsEyePos.ptr());
// transform directional light from world space to model space
PVRTVec3 vMsLightDir = PVRTVec3(PVRTVec4(1, 2, 1, 0) * mModel).normalized();
glUniform3fv(m_ShaderProgram.uiLightDirLoc, 1, vMsLightDir.ptr());
DrawMesh(0);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("CellShading", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例6: glBlendFunc
/*!****************************************************************************
@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 OGLES3AlphaBlend::RenderScene()
{
// Do our clear
glClear(GL_COLOR_BUFFER_BIT);
// Use the loaded shader program
glUseProgram(m_ShaderProgram.uiId);
// Draws the background
glDisable(GL_BLEND);
DrawQuad(-1, -1, +1, +1, m_uiTexBackground);
/*
Prepares to draw the different blend modes, activate blending.
Now we can use glBlendFunc() to specify the blending mode wanted.
*/
glEnable(GL_BLEND);
// Prepares the variables used to divide the screen in NUM_BLEND x NUM_BLEND rectangles
float fX1 = -1;
float fX2 = +1;
float fY1 = -1;
float fY2 = +.85f;
float fPosX = fX1;
float fPosY = fY1;
float fMarginX = .25f;
float fMarginY = .25f;
float fBlockWidth = ((fX2-fX1) - fMarginX * 3.0f) * 0.5f;
float fBlockHeight= ((fY2-fY1) - fMarginY * 3.0f) * 0.5f;
//Position and draw the first quad (Transparency)
fPosY = fY2 - fBlockHeight - fMarginY;
fPosX += fMarginX;
//Set up the blend function for this quad
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawQuad(fPosX, fPosY, fPosX + fBlockWidth, fPosY + fBlockHeight, m_uiTexForeground);
//Draw the text for this quad to the screen.
m_Print3D.Print3D(18,12, 0.6f, 0xff00ffff, "Transparency");
m_Print3D.Print3D(7,16, 0.6f, 0xff00ffff, "(SRC_ALPHA, 1 - SRC_ALPHA)");
//Position and draw the second quad (Additive)
fPosX += fMarginX + fBlockWidth;
glBlendFunc(GL_ONE, GL_ONE);
DrawQuad(fPosX, fPosY, fPosX + fBlockWidth, fPosY + fBlockHeight, m_uiTexForeground);
m_Print3D.Print3D(66,12, 0.6f, 0xff00ffff, "Additive");
m_Print3D.Print3D(64,16, 0.6f, 0xff00ffff, "(ONE, ONE)");
//Position and draw the third quad (Modulate)
fPosX = fX1 + fMarginX;
fPosY -= fMarginY + fBlockHeight;
glBlendFunc(GL_DST_COLOR, GL_ZERO);
DrawQuad(fPosX, fPosY, fPosX + fBlockWidth, fPosY + fBlockHeight, m_uiTexForeground);
m_Print3D.Print3D(22,52, 0.6f, 0xff00ffff, "Modulate");
m_Print3D.Print3D(14,56, 0.6f, 0xff00ffff, "(DST_COLOR, ZERO)");
//Position and draw the fourth quad (Modulate X 2)
fPosX += fMarginX + fBlockWidth;
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
DrawQuad(fPosX, fPosY, fPosX + fBlockWidth, fPosY + fBlockHeight, m_uiTexForeground);
m_Print3D.Print3D(64,52, 0.6f, 0xff00ffff, "Modulate X2");
m_Print3D.Print3D(53,56, 0.6f, 0xff00ffff, "(DST_COLOR, SRC_COLOR)");
/* Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools */
m_Print3D.DisplayDefaultTitle("AlphaBlend", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例7: cos
//.........这里部分代码省略.........
Will also manage relevent OS events. The user has access to
these events through an abstraction layer provided by PVRShell.
******************************************************************************/
bool OGLES2ShadowMapping::RenderScene()
{
//rotate light position
m_fLightAngle += 0.01f;
m_vLightPosition.x = m_fLightDistance * (float) cos(m_fLightAngle);
m_vLightPosition.z = m_fLightDistance * (float) sin(m_fLightAngle);
m_vLightDirection.x = -m_vLightPosition.x;
m_vLightDirection.z = -m_vLightPosition.z;
SetUpMatrices();
glEnable(GL_DEPTH_TEST);
// Bind the frame buffer object
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
{
// Clear the screen and depth buffer so we can render from the light's view
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Set the current viewport to our texture size
glViewport(0, 0, m_ui32ShadowMapSize, m_ui32ShadowMapSize);
// Since we don't care about colour when rendering the depth values to
// the shadow-map texture, we disable color writing to increase speed.
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// Enable the simple shader for the light view pass. This render will not be shown to the user
// so only the simplest render needs to be implemented
glUseProgram(m_SimpleShaderProgram.uiId);
// Set the light projection matrix
glUniformMatrix4fv(m_SimpleShaderProgram.uiProjectionMatrixLoc, 1, GL_FALSE, m_LightProjection.f);
// Render the world according to the light's view
DrawScene(m_LightView);
// We can turn color writing back on since we already stored the depth values
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
// Restore our normal viewport size to our screen width and height
glViewport(0, 0,PVRShellGet(prefWidth),PVRShellGet(prefHeight));
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Clear the colour and depth buffers, we are now going to render the scene again from scratch
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Load the shadow shader. This shader requires additional parameters; texProjMatrix for the depth buffer
// look up and the light direction for diffuse light (the effect is a lot nicer with the additon of the
// diffuse light).
glUseProgram(m_ShadowShaderProgram.uiId);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiShadowMapTexture);
glUniformMatrix4fv(m_ShadowShaderProgram.uiProjectionMatrixLoc, 1, GL_FALSE, m_Projection.f);
PVRTMat4 mViewInv, mTextureMatrix, mMatrix;
mViewInv = m_View.inverse();
// We need to calculate the texture projection matrix. This matrix takes the pixels from world space to previously rendered light projection space
//where we can look up values from our saved depth buffer. The matrix is constructed from the light view and projection matrices as used for the previous render and
//then multiplied by the inverse of the current view matrix.
mTextureMatrix = m_BiasMatrix * m_LightProjection * m_LightView * mViewInv;
glUniformMatrix4fv(m_ShadowShaderProgram.uiTexProjMatrixLoc, 1, GL_FALSE, mTextureMatrix.f);
DrawSceneWithShadow(m_View);
// Re-enable the simple shader to draw the light source object
glUseProgram(m_SimpleShaderProgram.uiId);
SPODNode& Node = m_Scene.pNode[1];
PVRTMat4 mWorld, mModelView;
m_Scene.GetWorldMatrix(mWorld, Node);
mWorld.f[12] = m_vLightPosition.x;
mWorld.f[13] = m_vLightPosition.y;
mWorld.f[14] = m_vLightPosition.z;
mModelView = m_View * mWorld;
glUniformMatrix4fv(m_SimpleShaderProgram.uiModelViewMatrixLoc, 1, GL_FALSE, mModelView.f);
glUniformMatrix4fv(m_SimpleShaderProgram.uiProjectionMatrixLoc, 1, GL_FALSE, m_LightProjection.f);
DrawMesh(1);
m_Print3D.DisplayDefaultTitle("ShadowMap", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例8: RenderScene
//.........这里部分代码省略.........
+ (m_pDiffVertices[3][i] * m_fSkullWeights[3]));
}
// Buffer Clear
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render Skull and Jaw Opaque with Lighting
glDisable(GL_BLEND); // Opaque = No Blending
glEnable(GL_LIGHTING); // Lighting On
// Set skull and jaw texture
glBindTexture(GL_TEXTURE_2D, m_ui32Texture[1]);
// Enable and set vertices, normals and index data
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// Render Animated Jaw - Rotation Only
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
myglMultMatrix(m_mView.f);
myglTranslate(f2vt(0),f2vt(-50.0f),f2vt(-50.0f));
myglRotate(f2vt(-fCurrentfJawRotation), f2vt(1.0f), f2vt(0.0f), f2vt(0.0f));
myglRotate(f2vt(fCurrentfJawRotation) - f2vt(30.0f), f2vt(0), f2vt(1.0f), f2vt(-1.0f));
RenderJaw();
glPopMatrix();
// Render Morphed Skull
glPushMatrix();
myglRotate(f2vt(fCurrentfJawRotation) - f2vt(30.0f), f2vt(0), f2vt(1.0f), f2vt(-1.0f));
RenderSkull();
// Render Eyes and Background with Alpha Blending and No Lighting
glEnable(GL_BLEND); // Enable Alpha Blending
glDisable(GL_LIGHTING); // Disable Lighting
// Disable the normals as they aren't needed anymore
glDisableClientState(GL_NORMAL_ARRAY);
// Render Eyes using Skull Model Matrix
DrawQuad(-30.0f ,0.0f ,50.0f ,20.0f , m_ui32Texture[0]);
DrawQuad( 33.0f ,0.0f ,50.0f ,20.0f , m_ui32Texture[0]);
glPopMatrix();
// Render Dual Texture Background with different base color, rotation, and texture rotation
glPushMatrix();
glDisable(GL_BLEND); // Disable Alpha Blending
myglColor4(f2vt(0.7f+0.3f*((m_fSkullWeights[0]))), f2vt(0.7f), f2vt(0.7f), f2vt(1.0f)); // Animated Base Color
myglTranslate(f2vt(10.0f), f2vt(-50.0f), f2vt(0.0f));
myglRotate(f2vt(fCurrentfBackRotation*4.0f),f2vt(0),f2vt(0),f2vt(-1.0f)); // Rotation of Quad
// Animated Texture Matrix
glActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
myglTranslate(f2vt(-0.5f), f2vt(-0.5f), f2vt(0.0f));
myglRotate(f2vt(fCurrentfBackRotation*-8.0f), f2vt(0), f2vt(0), f2vt(-1.0f));
myglTranslate(f2vt(-0.5f), f2vt(-0.5f), f2vt(0.0f));
// Draw Geometry
DrawDualTexQuad (0.0f ,0.0f ,-100.0f ,300.0f, m_ui32Texture[3], m_ui32Texture[2]);
// Disable Animated Texture Matrix
glActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
// Make sure to disable the arrays
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
// Reset Colour
myglColor4(f2vt(1.0f), f2vt(1.0f), f2vt(1.0f), f2vt(1.0f));
// Display info text
m_Print3D.DisplayDefaultTitle("EvilSkull", "Morphing.", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例9: RenderScene
//.........这里部分代码省略.........
glEnableVertexAttribArray(m_psUniforms[j].nLocation);
}
break;
case eUsUV:
{
glVertexAttribPointer(m_psUniforms[j].nLocation, 2, GL_FLOAT, GL_FALSE, pMesh->psUVW[0].nStride, pMesh->psUVW[0].pData);
glEnableVertexAttribArray(m_psUniforms[j].nLocation);
}
break;
case eUsWORLDVIEWPROJECTION:
{
PVRTMat4 mWVP;
/* Passes the world-view-projection matrix (WVP) to the shader to transform the vertices */
mWVP = m_mProjection * mWorldView;
glUniformMatrix4fv(m_psUniforms[j].nLocation, 1, GL_FALSE, mWVP.f);
}
break;
case eUsWORLDVIEWIT:
{
PVRTMat4 mWorldViewI, mWorldViewIT;
/* Passes the inverse transpose of the world-view matrix to the shader to transform the normals */
mWorldViewI = mWorldView.inverse();
mWorldViewIT = mWorldViewI.transpose();
PVRTMat3 WorldViewIT = PVRTMat3(mWorldViewIT);
glUniformMatrix3fv(m_psUniforms[j].nLocation, 1, GL_FALSE, WorldViewIT.f);
}
break;
case eUsLIGHTDIREYE:
{
// Reads the light direction from the scene.
PVRTVec4 vLightDirection;
PVRTVec3 vPos;
vLightDirection = m_Scene.GetLightDirection(0);
vLightDirection.x = -vLightDirection.x;
vLightDirection.y = -vLightDirection.y;
vLightDirection.z = -vLightDirection.z;
/*
Sets the w component to 0, so when passing it to glLight(), it is
considered as a directional light (as opposed to a spot light).
*/
vLightDirection.w = 0;
// Passes the light direction in eye space to the shader
PVRTVec4 vLightDirectionEyeSpace;
vLightDirectionEyeSpace = m_mView * vLightDirection;
glUniform3f(m_psUniforms[j].nLocation, vLightDirectionEyeSpace.x, vLightDirectionEyeSpace.y, vLightDirectionEyeSpace.z);
}
break;
case eUsTEXTURE:
{
// Set the sampler variable to the texture unit
glUniform1i(m_psUniforms[j].nLocation, m_psUniforms[j].nIdx);
}
break;
}
}
/*
Now that the model-view matrix is set and the materials ready,
call another function to actually draw the mesh.
*/
DrawMesh(pMesh);
glBindBuffer(GL_ARRAY_BUFFER, 0);
for(unsigned int j = 0; j < m_nUniformCnt; ++j)
{
switch(m_psUniforms[j].nSemantic)
{
case eUsPOSITION:
{
glDisableVertexAttribArray(m_psUniforms[j].nLocation);
}
break;
case eUsNORMAL:
{
glDisableVertexAttribArray(m_psUniforms[j].nLocation);
}
break;
case eUsUV:
{
glDisableVertexAttribArray(m_psUniforms[j].nLocation);
}
break;
}
}
}
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("IntroducingPFX", "", ePVRTPrint3DLogoIMG);
m_Print3D.Flush();
return true;
}
示例10:
//.........这里部分代码省略.........
if(m_i32Counter > (int) m_pScopeGraph->GetCounterNum())
m_i32Counter = m_pScopeGraph->GetCounterNum();
}
if(PVRShellIsKeyPressed(PVRShellKeyNameDOWN))
{
m_i32Counter--;
if(m_i32Counter < 0)
m_i32Counter = 0;
}
if(PVRShellIsKeyPressed(PVRShellKeyNameACTION2))
m_pScopeGraph->ShowCounter(m_i32Counter, !m_pScopeGraph->IsCounterShown(m_i32Counter));
// Keyboard input (cursor left/right to change active group)
if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
m_pScopeGraph->SetActiveGroup(m_pScopeGraph->GetActiveGroup()+1);
}
if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
{
m_pScopeGraph->SetActiveGroup(m_pScopeGraph->GetActiveGroup()-1);
}
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
// Rotate and Translation the model matrix
PVRTMat4 mModel;
mModel = PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += (2*PVRT_PI/60)/7;
// Set model view projection matrix
PVRTMat4 mModelView, mMVP;
mModelView = m_mView * mModel;
mMVP = m_mProjection * mModelView;
glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());
// Set light direction in model space
PVRTVec4 vLightDirModel;
vLightDirModel = mModel.inverse() * PVRTVec4(1, 1, 1, 0);
glUniform3fv(m_ShaderProgram.uiLightDirLoc, 1, &vLightDirModel.x);
// Set eye position in model space
PVRTVec4 vEyePosModel;
vEyePosModel = mModelView.inverse() * PVRTVec4(0, 0, 0, 1);
glUniform3fv(m_ShaderProgram.uiEyePosLoc, 1, &vEyePosModel.x);
/*
Set the iridescent shading parameters
*/
// Set the minimum thickness of the coating in nm
glUniform1f(m_ShaderProgram.uiMinThicknessLoc, m_fMinThickness);
// Set the maximum variation in thickness of the coating in nm
glUniform1f(m_ShaderProgram.uiMaxVariationLoc, m_fMaxVariation);
/*
Now that the uniforms are set, call another function to actually draw the mesh.
*/
DrawMesh(0);
char Description[256];
if(m_pScopeGraph->GetCounterNum())
{
sprintf(Description, "Active Grp %i\n\nCounter %i (Grp %i) \nName: %s\nShown: %s\nuser y-axis: %.2f max: %.2f%s",
m_pScopeGraph->GetActiveGroup(), m_i32Counter,
m_pScopeGraph->GetCounterGroup(m_i32Counter),
m_pScopeGraph->GetCounterName(m_i32Counter),
m_pScopeGraph->IsCounterShown(m_i32Counter) ? "Yes" : "No",
m_pScopeGraph->GetMaximum(m_i32Counter),
m_pScopeGraph->GetMaximumOfData(m_i32Counter),
m_pScopeGraph->IsCounterPercentage(m_i32Counter) ? "%%" : "");
}
else
{
sprintf(Description, "No counters present");
}
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("PVRScopeExample", Description, ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
// Update counters and draw the graph
m_pScopeGraph->Ping();
return true;
}
示例11: glClear
//.........这里部分代码省略.........
MVPLoc = m_SHShaderProgram.auiLoc[eSHMVPMatrix];
ModelLoc = m_SHShaderProgram.auiLoc[eSHModel];
}
else
{
ProgramID = m_DiffuseShaderProgram.uiId;
MVPLoc = m_DiffuseShaderProgram.auiLoc[eDifMVPMatrix];
ModelLoc = m_DiffuseShaderProgram.auiLoc[eDifModel];
}
glUseProgram(ProgramID);
/*
Calculates the frame number to animate in a time-based manner.
Uses the shell function PVRShellGetTime() to get the time in milliseconds.
*/
unsigned long ulTime = PVRShellGetTime();
if(ulTime > m_ulTimePrev)
{
unsigned long ulDeltaTime = ulTime - m_ulTimePrev;
m_fFrame += (float)ulDeltaTime * g_fDemoFrameRate;
if(m_fFrame > m_Scene.nNumFrame - 1)
m_fFrame = 0;
// Sets the scene animation to this frame
m_Scene.SetFrame(m_fFrame);
}
m_ulTimePrev = ulTime;
/*
Set up the view and projection matrices from the camera
*/
PVRTMat4 mView, mProjection;
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Setup the camera
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
// Camera nodes are after the mesh and light nodes in the array
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + g_ui32Camera].nIdx;
// Get the camera position, target and field of view (fov)
if(m_Scene.pCamera[i32CamID].nIdxTarget != -1) // Does the camera have a target?
fFOV = m_Scene.GetCameraPos( vFrom, vTo, g_ui32Camera); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, g_ui32Camera); // vTo is calculated from the rotation
fFOV *= bRotate ? (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight) : (float)PVRShellGet(prefHeight)/(float)PVRShellGet(prefWidth);
// We can build the model view matrix from the camera position, target and an up vector.
// For this we usePVRTMat4LookAtRH()
mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
// Calculate the projection matrix
mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), g_fCameraNear, g_fCameraFar, PVRTMat4::OGL, bRotate);
SPODNode& Node = m_Scene.pNode[0];
// Get the node model matrix
PVRTMat4 mWorld;
mWorld = m_Scene.GetWorldMatrix(Node);
// Set the model inverse transpose matrix
PVRTMat3 mMat3 = PVRTMat3(mWorld);
if(m_bEnableSH)
mMat3 *= PVRTMat3::RotationY(-1.047197f);
glUniformMatrix3fv(ModelLoc, 1, GL_FALSE, mMat3.f);
// Pass the model-view-projection matrix (MVP) to the shader to transform the vertices
PVRTMat4 mModelView, mMVP;
mModelView = mView * mWorld;
mMVP = mProjection * mModelView;
glUniformMatrix4fv(MVPLoc, 1, GL_FALSE, mMVP.f);
glBindTexture(GL_TEXTURE_2D, m_ui32TexMask);
DrawMesh(Node.nIdx);
// Print text on screen
if(m_bEnableSH)
{
// Base
m_Print3D.DisplayDefaultTitle("PhantomMask", "Spherical Harmonics Lighting", ePVRTPrint3DSDKLogo);
}
else
{
// Base
m_Print3D.DisplayDefaultTitle("PhantomMask", "Vertex Lighting", ePVRTPrint3DSDKLogo);
}
m_Print3D.Flush();
return true;
}
示例12:
/*!****************************************************************************
@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 OGLES3Refraction::RenderScene()
{
// Keyboard input (cursor to change Reflection Flag)
if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT) || PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
m_bSpecular = !m_bSpecular;
}
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_Background.Draw(m_uiTexture);
// Enable backface culling and depth test
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
// Calculate the model matrix
PVRTMat4 mRotX, mRotY, mModel;
mRotX = PVRTMat4::RotationX(m_fAngleX);
mRotY = PVRTMat4::RotationY(m_fAngleY);
mModel = mRotX * mRotY;
m_fAngleX += PVRT_PI / 111;
m_fAngleY += PVRT_PI / 150;
// Set model view projection matrix
PVRTMat4 mModelView, mMVP;
mModelView = m_mView * mModel;
mMVP = m_mProjection * mModelView;
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());
// Set light direction in model space
PVRTVec4 vLightDirModel;
vLightDirModel = mModelView.inverse() * PVRTVec4(0.57735f, 0.57735f, 0.57735f, 0);
glUniform3fv(m_ShaderProgram.auiLoc[eLightDirModel], 1, &vLightDirModel.x);
// Set eye position in model space
PVRTVec4 vEyePosModel;
vEyePosModel = mModelView.inverse() * PVRTVec4(0, 0, 0, 1);
glUniform3fv(m_ShaderProgram.auiLoc[eEyePosModel], 1, &vEyePosModel.x);
// Set specular flag
glUniform1i(m_ShaderProgram.auiLoc[eSpecular], m_bSpecular);
// Set rotation flag
glUniform1i(m_ShaderProgram.auiLoc[eRotate], m_bRotate);
/*
Now that the uniforms are set, call another function to actually draw the mesh.
*/
DrawMesh(0);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("Refraction", m_bSpecular ? "Specular reflection: on" : "Specular reflection: off", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例13: RenderScene
/*!****************************************************************************
@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 OGLESIntroducingPVRTools::RenderScene()
{
// Clears the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Binds the loaded texture
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
// Use the loaded shader program
glUseProgram(m_ShaderProgram.uiId);
/*
Creates the Model View Projection (MVP) matrix using the PVRTMat4 class from the tools.
The tools contain a complete set of functions to operate on 4x4 matrices.
*/
PVRTMat4 mMVP = PVRTMat4::Identity();
if(PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen)) // If the screen is rotated
mMVP = PVRTMat4::RotationZ(-1.57f);
/*
Pass this matrix to the shader.
The .m field of a PVRTMat4 contains the array of float used to
communicate with OpenGL ES.
*/
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());
/*
Draw a triangle.
Please refer to the training course IntroducingPVRShell for a detailed explanation.
*/
// Bind the VBO
glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);
// Pass the vertex data
glEnableVertexAttribArray(VERTEX_ARRAY);
glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, m_ui32VertexStride, 0);
// Pass the texture coordinates data
glEnableVertexAttribArray(TEXCOORD_ARRAY);
glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (sizeof(GLfloat) * 3) /* Uvs start after the position */);
// Draws a non-indexed triangle array
glDrawArrays(GL_TRIANGLES, 0, 3);
/*
Display some text.
Print3D() function allows to draw text anywhere on the screen using any color.
Param 1: Position of the text along X (from 0 to 100 scale independent)
Param 2: Position of the text along Y (from 0 to 100 scale independent)
Param 3: Scale of the text
Param 4: Colour of the text (0xAABBGGRR format)
Param 5: Formated string (uses the same syntax as printf)
*/
m_Print3D.Print3D(8.0f, 30.0f, 1.0f, 0xFFAA4040, "example");
/*
DisplayDefaultTitle() writes a title and description text on the top left of the screen.
It can also display the PVR logo (ePVRTPrint3DLogoPVR), the IMG logo (ePVRTPrint3DLogoIMG) or both (ePVRTPrint3DLogoPVR | ePVRTPrint3DLogoIMG).
Set this last parameter to NULL not to display the logos.
*/
m_Print3D.DisplayDefaultTitle("IntroducingPVRTools", "Description", ePVRTPrint3DLogoIMG);
// Tells Print3D to do all the pending text rendering now
m_Print3D.Flush();
return true;
}
示例14: RenderScene
//.........这里部分代码省略.........
// Reset the states that print3D changes
glDisable(GL_CULL_FACE);
glEnable(GL_FOG);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
// User input
bool bNewPage = false;
if(PVRShellIsKeyPressed(PVRShellKeyNameSELECT))
m_bPause = !m_bPause;
if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
{
if(--m_i32WndPage < 0)
m_i32WndPage = 5;
bNewPage = true;
}
if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
if(++m_i32WndPage > 5)
m_i32WndPage = 0;
bNewPage = true;
}
if(bNewPage)
{
switch(m_i32WndPage)
{
case 0:
m_bViewMode = false;
m_i32FurShellNo = 7;
break;
case 1:
m_bViewMode = true;
m_i32FurShellNo = 0;
break;
case 2:
m_bViewMode = true;
m_i32FurShellNo = 1;
break;
case 3:
m_bViewMode = true;
m_i32FurShellNo = 2;
break;
case 4:
m_bViewMode = true;
m_i32FurShellNo = 7;
break;
case 5:
m_bViewMode = false;
m_i32FurShellNo = 7;
break;
}
// Since the number of fur shells has changed, update them
UpdateFurShells();
}
// Clear
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Animation
DoAnimation();
// View matrix
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(m_mView.f);
// Enable the vertex and normal arrays
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// Begin Scene
if(!m_bViewMode)
DrawEnvironment();
// Draw the Duck
DrawDuck();
// Display Paused if the app is paused
if(m_bPause)
m_Print3D.Print3D(78.0f, 2.0f, 1.0f, PVRTRGBA(255,255,255,255), "Paused");
// Disable the normals before our drawing of the print3D content
glDisableClientState(GL_NORMAL_ARRAY);
char szDesc[256];
snprintf(szDesc, 256, "Displaying %d shells", m_i32FurShellNo);
// Display the IMG logo
m_Print3D.DisplayDefaultTitle("Fur", szDesc, ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例15: RenderScene
/*!****************************************************************************
@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 OGLESCoverflow::RenderScene()
{
// Clears the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_CULL_FACE);
if(PVRShellIsKeyPressed(PVRShellKeyNameRIGHT)) //input permmanently set for demo purposes
m_bGoRight = true;
if(PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
m_bGoRight = false;
m_fLerpDir = m_bGoRight ? 1.0f : -1.0f;
unsigned long ulTime = PVRShellGetTime();
unsigned long ulDeltaTime = ulTime - m_ulTimePrev;
m_ulTimePrev = ulTime;
m_fLerp += (ulDeltaTime*.0001f)*m_fCyclesPerSecond*m_fLerpDir;
if(m_fLerpDir && (m_fLerp >= 1.0 || m_fLerp <= -1.0))
{
if(m_fLerpDir < 0)
{
m_iCoverIndex++;
if(m_iCoverIndex > g_i32CoverNo)
m_iCoverIndex = 1;
}
else
{
m_iCoverIndex--;
if(m_iCoverIndex < 0)
m_iCoverIndex = g_i32CoverNo-1;
}
m_fLerpDir = 0.f;
m_fLerp = 0;
}
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//the order in which the covers are drawn is very important for the transparency here. As the covers flip from
//one position to the next there is a point in the cycle where the center cover moves from being in front of the
//position following it to behind it. The draw order needs to reflect this so that the blend is still drawn correctly.
if(m_fLerp < -0.5)
{
DrawLeftCovers();
DrawInPosition(eFront, m_fLerp, m_iCoverIndex);
DrawRightCovers();
}
else if(m_fLerp > 0.5)
{
DrawRightCovers();
DrawInPosition(eFront, m_fLerp, m_iCoverIndex);
DrawLeftCovers();
}
else
{
DrawRightCovers();
DrawLeftCovers();
DrawInPosition(eFront, m_fLerp, m_iCoverIndex);
}
// unbind the vertex buffers as we don't need them bound anymore
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
m_Print3D.DisplayDefaultTitle("Coverflow", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}