本文整理汇总了C++中CPVRTPrint3D类的典型用法代码示例。如果您正苦于以下问题:C++ CPVRTPrint3D类的具体用法?C++ CPVRTPrint3D怎么用?C++ CPVRTPrint3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPVRTPrint3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool PVRESettings::InitPrint3D(CPVRTPrint3D& sPrint3d,
const unsigned int u32Width,
const unsigned int u32Height,
const bool bRotate)
{
return sPrint3d.SetTextures(m_pContext,u32Width,u32Height,bRotate) == PVR_SUCCESS;
}
示例2: ReleaseView
/*!****************************************************************************
@Function ReleaseView
@Return bool true if no error occured
@Description Code in ReleaseView() will be called by PVRShell when the
application quits or before a change in the rendering context.
******************************************************************************/
bool OGLES2MultiThreading::ReleaseView()
{
// Frees the OpenGL handles for the program and the 2 shaders
if(handles.uiProgramObject) glDeleteProgram(handles.uiProgramObject);
if(handles.uiFragShader) glDeleteShader(handles.uiFragShader);
if(handles.uiVertShader) glDeleteShader(handles.uiVertShader);
if(handles.uiLoadProgram) glDeleteProgram(handles.uiLoadProgram);
if(handles.uiLoadFragShader) glDeleteShader(handles.uiLoadFragShader);
if(handles.uiLoadVertShader) glDeleteShader(handles.uiLoadVertShader);
// Delete the VBO as it is no longer needed
if(handles.uiLoadVbo) glDeleteBuffers(1, &handles.uiLoadVbo);
if(handles.uiVbo) glDeleteBuffers(1, &handles.uiVbo);
if(handles.uiTexture) glDeleteTextures(1, &handles.uiTexture);
// Clean up Print3D
print3D.ReleaseTextures();
loadingText.ReleaseTextures();
// Destroy the pthread mutex.
DeleteCriticalSection(&handles.mutex);
return true;
}
示例3:
/*!****************************************************************************
@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 OGLES2Glass::RenderScene()
{
if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT)) m_iEffect -= 1;
if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT)) m_iEffect += 1;
m_iEffect = (m_iEffect + g_iNumEffects) % g_iNumEffects;
UpdateScene();
DrawIntoParaboloids(PVRTVec3(0, 0, 0));
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw the ball
DrawBall();
// Draw the balloons
DrawBalloons(&m_DefaultProgram, m_mProjection, m_mView, m_mModels, 2);
// Draw the skybox
DrawSkybox();
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("Glass", g_aszEffectNames[m_iEffect], ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例4:
/*!****************************************************************************
@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 OGLES3ShadowMapping::RenderScene()
{
Update();
// Bind the frame buffer object
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);
// Clear the screen and depth buffer so we can render from the light's view
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
// Set the current viewport to our texture size but leave a one pixel margin.
// As we are clamping to the edge of the texture when shadow mapping, no object
// should be rendered to the border, otherwise stretching artefacts might occur
// outside of the coverage of the shadow map.
glViewport(1, 1, m_ui32ShadowMapSize-2, m_ui32ShadowMapSize-2);
// 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);
// Cull the front faces, so that only the backfaces are rendered into the shadowmap
glCullFace(GL_FRONT);
// Draw everything that we would like to cast a shadow
RenderSceneWithEffect(INDEX_RENDERSHADOW, m_mLightProjection, m_mLightView);
// Set the culling mode for the normal rendering
glCullFace(GL_BACK);
// Turn colour buffer writes back on again
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));
//Invalidate the framebuffer attachments we don't need to avoid unnecessary copying to system memory
const GLenum attachment = GL_COLOR_ATTACHMENT0;
glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &attachment);
glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFbo);
// 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 addition of the
// diffuse light).
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_uiShadowMapTexture);
glActiveTexture(GL_TEXTURE0);
RenderSceneWithEffect(INDEX_RENDERSCENE, m_mProjection, m_mView);
m_Print3D.DisplayDefaultTitle("ShadowMap", "", ePVRTPrint3DSDKLogo);
m_Print3D.Print3D(5.0f, 90.0f, 1.0f, 0xFFFFFFFF, "Bias: %f", m_fBias);
m_Print3D.Flush();
return true;
}
示例5: PVRShellGet
/*!****************************************************************************
@Function RenderLoadingScene
@Input iFrame
@Description Renders an animated loading screen.
******************************************************************************/
void OGLES2MultiThreading::RenderLoadingScene(int iFrame)
{
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
float fHW = PVRShellGet(prefWidth) / 2.0f;
float fHH = PVRShellGet(prefHeight) / 2.0f;
PVRTMat4 mxProjection = PVRTMat4::Ortho(-fHW, fHH, fHW, -fHH, -1.0f, 1.0f, PVRTMat4::OGL, bRotate);
/*
Clears the color buffer.
*/
glClear(GL_COLOR_BUFFER_BIT);
// Actually use the created program
glUseProgram(handles.uiLoadProgram);
// First gets the location of that variable in the shader using its name
int i32MVPLocation = glGetUniformLocation(handles.uiLoadProgram, "myPMVMatrix");
int i32ColLocation = glGetUniformLocation(handles.uiLoadProgram, "myCol");
for(int iCircleIdx = 0; iCircleIdx < c_iNumCircles; ++iCircleIdx)
{
int iProg = iFrame+iCircleIdx*4;
float fScale = (0.75f + cos(iProg * 0.1f) * 0.25f);
float fY = sin(iProg * 0.1f) * 25.0f;
// Then passes the matrix to that variable
PVRTMat4 mxMVP = mxProjection * PVRTMat4::Translation(-175.0f + iCircleIdx * 50.0f, fY, 0.0f) * PVRTMat4::Scale(fScale,fScale,1.0f);
glUniformMatrix4fv(i32MVPLocation, 1, GL_FALSE, mxMVP.ptr());
// Pass the colour
glUniform3f(i32ColLocation, c_vCircleCols[iCircleIdx].x, c_vCircleCols[iCircleIdx].y, c_vCircleCols[iCircleIdx].z);
// Draw the loading circle
glBindBuffer(GL_ARRAY_BUFFER, handles.uiLoadVbo);
glEnableVertexAttribArray(VERTEX_ARRAY);
glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);
// Submit
glDrawArrays(GL_TRIANGLE_FAN, 0, c_iNumCirclePoints+2);
glDisableVertexAttribArray(VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
float fW;
loadingText.SetProjection(mxProjection);
ELoadingProgress eProgress = eProgress_Init;
EnterCriticalSection(&handles.mutex);
eProgress = g_eProgress;
LeaveCriticalSection(&handles.mutex);
loadingText.MeasureText(&fW, NULL, 1.0f, c_pszLoadingProgress[eProgress]);
loadingText.Print3D(-fW*0.5f, -50.0f, 1.0f, 0xFFFFFFFF, c_pszLoadingProgress[eProgress]);
loadingText.Flush();
}
示例6: EFogMode
/*!****************************************************************************
@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 OGLES2Fog::RenderScene()
{
// Clear the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Keyboard input (cursor to change fog function)
if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
{
m_eFogMode = EFogMode((m_eFogMode + eNumFogModes - 1) % eNumFogModes);
}
if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
m_eFogMode = EFogMode((m_eFogMode + 1) % eNumFogModes);
}
// Use the loaded shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
// Set uniforms
glUniform1i(m_ShaderProgram.uiFogFuncLoc, m_eFogMode);
// Rotate and translate the model matrix
PVRTMat4 mModel = PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += PVRT_PI / 90;
mModel.preTranslate(0, 0, 500 * cos(m_fPositionZ) - 450);
m_fPositionZ += (2*PVRT_PI)*0.0008f;
// Feed Projection and Model View matrices to the shaders
PVRTMat4 mModelView = m_mView * mModel;
PVRTMat4 mMVP = m_mProjection * mModelView;
glUniformMatrix4fv(m_ShaderProgram.uiModelViewLoc, 1, GL_FALSE, mModelView.ptr());
glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());
// Pass the light direction transformed with the inverse of the ModelView matrix
// This saves the transformation of the normals per vertex. A simple dot3 between this direction
// and the un-transformed normal will allow proper smooth shading.
PVRTVec3 vMsLightDir = (PVRTMat3(mModel).inverse() * PVRTVec3(1, 1, 1)).normalized();
glUniform3fv(m_ShaderProgram.uiLightDirLoc, 1, vMsLightDir.ptr());
/*
Now that the model-view matrix is set and the materials ready,
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("Fog", "", ePVRTPrint3DLogoIMG);
m_Print3D.Print3D(0.3f, 7.5f, 0.75f, PVRTRGBA(255,255,255,255), "Fog Mode: %s", g_FogFunctionList[m_eFogMode]);
m_Print3D.Flush();
return true;
}
示例7: ReleaseView
/*******************************************************************************
* Function Name : ReleaseView
* Returns : Nothing
* Description : Code in ReleaseView() will be called by the Shell before
* changing to a new rendering context.
*******************************************************************************/
bool OGLESOptimizeMesh::ReleaseView()
{
// Release all Textures
glDeleteTextures(1, &m_Texture);
// Release the Print3D textures and windows
m_Print3D.DeleteAllWindows();
m_Print3D.ReleaseTextures();
return true;
}
示例8: CalcMiniCameraView
/*!****************************************************************************
@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 OGLES2FilmTV::RenderScene()
{
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
// Enable the vertex attribute arrays
glEnableVertexAttribArray(VERTEX_ARRAY);
glEnableVertexAttribArray(NORMAL_ARRAY);
// Render everything from the mini-camera's point of view if we have the FBOs
CalcMiniCameraView();
if(m_bFBOsCreated)
{
// Setup the Viewport to the dimensions of the texture
glViewport(0, 0, m_i32TexSize, m_i32TexSize);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFbo[m_i32CurrentFBO]);
DrawPODScene(m_MiniCamViewProj, false);
if(m_bDiscard) // Was GL_EXT_discard_framebuffer supported?
{
/*
Give the drivers a hint that we don't want the depth and stencil information stored for future use.
Note: This training course doesn't have any stencil information so the STENCIL_ATTACHMENT enum
is used for demonstrations purposes only and will be ignored by the driver.
*/
const GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
m_Extensions.glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, attachments);
}
glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFB);
// Render everything
// Setup the Viewport to the dimensions of the screen
glViewport(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight));
}
DrawPODScene(m_ViewProjection, true);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("FilmTV", "", ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
// Swap the FBO that we want to render to
m_i32CurrentFBO = 1 - m_i32CurrentFBO;
++m_i32Frame;
return true;
}
示例9: 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 OGLES3TextureStreaming::RenderScene()
{
// Clears the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Time based animation and locks the app to 60 FPS.
// Uses the shell function PVRShellGetTime() to get the time in milliseconds.
unsigned long ulTime = PVRShellGetTime();
unsigned long ulDeltaTime = ulTime - m_ulTimePrev;
m_ulTimePrev = ulTime;
m_fFrame += (float)ulDeltaTime * (60.0f/1000.0f);
m_fBandScroll += (float)ulDeltaTime * (60.0f/1000.0f) * c_fBandScrollSpeed;
if(m_fFrame > m_Scene.nNumFrame - 1)
m_fFrame = 0.0f;
if(m_fBandScroll > 1.0f)
m_fBandScroll = -c_fBandWidth;
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
m_Scene.SetFrame(m_fFrame);
// Setup the main camera
PVRTVec3 vFrom, vTo(0.0f), vUp(0.0f, 1.0f, 0.0f);
float fFOV;
// Camera nodes are after the mesh and light nodes in the array
int i32CamID = m_Scene.pNode[m_Scene.nNumMeshNode + m_Scene.nNumLight + c_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, c_ui32Camera); // vTo is taken from the target node
else
fFOV = m_Scene.GetCamera( vFrom, vTo, vUp, c_ui32Camera); // vTo is calculated from the rotation
float fTargetAspect = 960.0f/640.0f;
float fAspect = (float)PVRShellGet(prefWidth) / (float)PVRShellGet(prefHeight);
fFOV *= fTargetAspect / fAspect;
PVRTMat4 mView = PVRTMat4::LookAtRH(vFrom, vTo, vUp);
PVRTMat4 mProjection = PVRTMat4::PerspectiveFovRH(fFOV, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), c_fCameraNear,
c_fCameraFar, PVRTMat4::OGL, bRotate);
PVRTMat4 mViewProjection = mProjection * mView;
DrawPODScene(mViewProjection);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("Texture Streaming", c_pszDescription, ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
++m_i32Frame;
return true;
}
示例10: if
/*!****************************************************************************
@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 OGLES2MultiThreading::RenderScene()
{
// Render the loading screen while we wait for resources to load.
if(bLoading)
{
// Render the animated loading scene.
RenderLoadingScene(iFrame++);
/*
Check if the resources are still being loaded.
This is performed by querying EGL to determine if a sync object has been signalled.
*/
EnterCriticalSection(&handles.mutex);
if(handles.eglSync != EGL_NO_SYNC_KHR)
{
// Perform a non-blocking poll to check if the shared egl sync object has been signalled.
EGLint status = eglClientWaitSyncKHR(handles.eglDisplay, handles.eglSync, 0, 0);
if(status == EGL_CONDITION_SATISFIED_KHR)
{
// Destroy the egl sync object as soon as we aware of it's signal status.
if(eglDestroySyncKHR(handles.eglDisplay, handles.eglSync) != EGL_TRUE)
{
PVRShellSet(prefExitMessage, "eglDestroySyncKHR returned unexpected EGL_FALSE.\n");
return false;
}
bLoading = false;
}
else if(status == EGL_FALSE)
{
PVRShellSet(prefExitMessage, "eglClientWaitSyncKHR returned unexpected EGL_FALSE.\n");
return false;
}
}
LeaveCriticalSection(&handles.mutex);
}
else
{
glEnable(GL_DEPTH_TEST);
// Render the pre-loaded scene
RenderCubeScene(iFrame++);
glDisable(GL_DEPTH_TEST);
}
print3D.DisplayDefaultTitle("MultiThreading", "", ePVRTPrint3DSDKLogo);
print3D.Flush();
return true;
}
示例11:
/*!****************************************************************************
@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 OGLES2ParallaxBumpMap::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);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, m_uiHeightMap);
// Calculate the model matrix
PVRTMat4 mModel = PVRTMat4::Scale(g_CubeScale);
mModel *= PVRTMat4::Translation(g_CubeTranslation);
mModel *= PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += PVRT_PI / 450;
// Set the Model View matrix
PVRTMat4 mMV = m_mView * mModel;
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eModelViewMatrix], 1, GL_FALSE, mMV.ptr());
// Set the ModelViewIT Matrix
PVRTMat4 mMIT = mMV.transpose();
mMIT = mMIT.inverseEx();
PVRTMat3 mMIT3x3 = PVRTMat3(mMIT);
glUniformMatrix3fv(m_ShaderProgram.auiLoc[eNormal], 1, GL_FALSE, mMIT3x3.ptr());
// Set model view projection matrix
PVRTMat4 mMVP = m_mViewProj * mModel;
glUniformMatrix4fv(m_ShaderProgram.auiLoc[eModelViewProj], 1, GL_FALSE, mMVP.ptr());
// Set light position in eye space
PVRTVec4 vEyeSpaceLightPos = m_mView * g_LightPos;
glUniform3fv(m_ShaderProgram.auiLoc[eLightEyeSpacePos], 1, vEyeSpaceLightPos.ptr());
DrawMesh(0);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("Parallax Bumpmap", "", 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 OGLES2ProceduralTextures::RenderScene()
{
if (!HandleInput())
{ return false; }
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_ui32ColourSplineTexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_FnTexture);
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glUseProgram(m_auiShaderProgramId[m_uiVisualisation]);
const float fIndex = m_uiGenerator / (float)(NUM_GENERATORS - 1);
glUniform1f(m_aiColourSplineIndices[m_uiGenerator], fIndex);
glEnableVertexAttribArray(VERTEX_ARRAY);
glEnableVertexAttribArray(TEXTURE_ARRAY);
// Pass the vertex data
GLfloat pfVertices[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 0.0f };
glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, pfVertices);
// Pass the texture coordinates data
GLfloat pfTexCoord[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
glVertexAttribPointer(TEXTURE_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, pfTexCoord);
unsigned short indices[] = { 0, 1, 3, 1, 2, 3 };
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
glDisableVertexAttribArray(VERTEX_ARRAY);
glDisableVertexAttribArray(TEXTURE_ARRAY);
glUseProgram(0);
m_Print3D.DisplayDefaultTitle("OpenGL ES Compute Shader Procedural Textures", NULL, ePVRTPrint3DSDKLogo);
m_Print3D.Print3D(1.0f, 80.0f, 1.0f, 0xFFFFFFFF, "Metric: %s", m_pProceduralTextures->GetModeDescription((eGenerator)m_uiGenerator));
m_Print3D.Print3D(1.0f, 90.0f, 1.0f, 0xFFFFFFFF, "Evaluator: %s", c_szVisualisationsDescriptions[m_uiVisualisation]);
m_Print3D.Flush();
return true;
}
示例13: ELightType
/*!****************************************************************************
@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 OGLES3ComplexLighting::RenderScene()
{
// Clears the color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Keyboard input (cursor to change light)
if (PVRShellIsKeyPressed(PVRShellKeyNameLEFT))
{
m_eLightType = ELightType((m_eLightType + eNumLightTypes - 1) % eNumLightTypes);
}
if (PVRShellIsKeyPressed(PVRShellKeyNameRIGHT))
{
m_eLightType = ELightType((m_eLightType + 1) % eNumLightTypes);
}
// Use shader program
glUseProgram(m_ShaderProgram.uiId);
// Bind texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
glUniform1i(m_ShaderProgram.uiLightSelLoc, m_eLightType);
// Rotate and Translation the model matrix
PVRTMat4 mModel = PVRTMat4::RotationY(m_fAngleY);
m_fAngleY += PVRT_PI / 150;
// Set model view projection matrix
PVRTMat4 mModelView = m_mView * mModel;
PVRTMat4 mMVP = m_mProjection * mModelView;
glUniformMatrix4fv(m_ShaderProgram.uiMVPMatrixLoc, 1, GL_FALSE, mMVP.ptr());
// Set model view matrix
glUniformMatrix4fv(m_ShaderProgram.uiModelViewLoc, 1, GL_FALSE, mModelView.ptr());
// Set model view inverse transpose matrix
PVRTMat3 mModelViewIT = PVRTMat3(mModelView).inverse().transpose();
glUniformMatrix3fv(m_ShaderProgram.uiModelViewITLoc, 1, GL_FALSE, mModelViewIT.ptr());
DrawMesh(0);
// Displays the demo name using the tools. For a detailed explanation, see the training course IntroducingPVRTools
m_Print3D.DisplayDefaultTitle("ComplexLighting", c_aszLightTypeList[m_eLightType], ePVRTPrint3DSDKLogo);
m_Print3D.Flush();
return true;
}
示例14: InitView
/*!****************************************************************************
@Function InitView
@Return bool true if no error occured
@Description Code in InitView() will be called by PVRShell upon
initialization or after a change in the rendering context.
Used to initialize variables that are dependant on the rendering
context (e.g. textures, vertex buffers, etc.)
******************************************************************************/
bool OGLES2ShadowMapping::InitView()
{
CPVRTString ErrorStr;
if(!CPVRTgles2Ext::IsGLExtensionSupported("GL_OES_depth_texture"))
{
PVRShellSet(prefExitMessage, "Error: Unable to run this training course as it requires extension 'GL_OES_depth_texture'");
return false;
}
m_bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
// Initialize VBO data
if(!LoadVbos(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Load textures
if (!LoadTextures(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Load and compile the shaders & link programs
if (!LoadShaders(&ErrorStr))
{
PVRShellSet(prefExitMessage, ErrorStr.c_str());
return false;
}
// Create a frame buffer with only the depth buffer attached
glGenFramebuffers(1, &m_uiFrameBufferObject);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_uiShadowMapTexture, 0);
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
PVRShellSet(prefExitMessage, "ERROR: Frame buffer not set up correctly\n");
return false;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Initialize Print3D
if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight),m_bRotate) != PVR_SUCCESS)
{
PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n");
return false;
}
// Use a nice bright blue as clear colour
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
return true;
}
示例15: ReleaseView
/*!****************************************************************************
@Function ReleaseView
@Return bool true if no error occured
@Description Code in ReleaseView() will be called by PVRShell when the
application quits or before a change in the rendering context.
******************************************************************************/
bool OGLESIntroducingPFX::ReleaseView()
{
// Release textures
{
const SPVRTPFXTexture *psTex;
unsigned int nCnt, i;
psTex = m_pEffect->GetTextureArray(nCnt);
for(i = 0; i < nCnt; ++i)
{
glDeleteTextures(1, &psTex[i].ui);
}
}
// Release the effect[s] then the parser
delete m_pEffect;
delete m_pEffectParser;
FREE(m_psUniforms);
// Release Print3D Textures
m_Print3D.ReleaseTextures();
// Release Vertex buffer objects.
glDeleteBuffers(m_Scene.nNumMeshNode, m_aiVboID);
delete[] m_aiVboID;
return true;
}