void TestEngine::KeyPressed(int code) { if (code == 'R') shaders.ReloadShaders(); if (code == GLFW_KEY_ESC) Exit(); if (code == 'L') LoadTexture(); if (code == 'S') simulate = !simulate; if (code == 'T') Step(); if (code >= '1' && code <= '9') { currentTexture = ('1' - code) % baseTextures.size(); CreateFBOs(); LoadTexture(); } if (code == '[') --currentEq; if (code == ']') ++currentEq; if (code == 'F') LimitFPS = !LimitFPS; }
// --------------------------------------------------------------- bool MyPVRDemo::InitView() { CPVRTString ErrorStr; LoadVBOs(); bool bResult = true; bResult &= LoadTextures(&ErrorStr); bResult &= LoadShaders(&ErrorStr); bResult &= CreateFBOs(&ErrorStr); if(!bResult) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } m_bRotated = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); // --- Set up light position, projection and view m_vLightPos = PVRTVec3(0, 125, 200); m_mxLightProj = PVRTMat4::PerspectiveFovRH(PVRT_PI / 4, 1.0f, 10.0f, 1000.0f, PVRTMat4::OGL, m_bRotated); m_mxLightView = PVRTMat4::LookAtRH(m_vLightPos, PVRTVec3(0,25,0), PVRTVec3(0,1,0)); m_mxLightBias = PVRTMat4(0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f); // --- Set up Camera projection and view float fAspect = PVRShellGet(prefWidth) / (float)PVRShellGet(prefHeight); m_mxProjection = PVRTMat4::PerspectiveFovFloatDepthRH(0.75f, fAspect, 10.0f, PVRTMat4::OGL, m_bRotated); m_mxCam = PVRTMat4::LookAtRH(PVRTVec3(0, 55, 150), PVRTVec3(0, 35, 0), PVRTVec3(0, 1, 0)); // --- Set GL states glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_GEQUAL); glClearDepthf(0.0f); glClearColor(0,0,0,1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); return true; }
void TestEngine::Setup() { baseTextures.push_back(new BasicTexture("Assets/Textures/landscape.jpg")); baseTextures.push_back(new BasicTexture("Assets/Textures/spiderpic.png")); baseTextures.push_back(new BasicTexture("Assets/Textures/moon.png")); textDraw = new Shader("Assets/Shaders/textDraw.vert", "Assets/Shaders/textDraw.frag", "Print Text"); shaders.Add(textDraw); shaders.Add(new Shader("Assets/Shaders/copy.vert", "Assets/Shaders/copyRGBAtoR.frag", "CopyRGBAtoR")); shaders.Add(new Shader("Assets/Shaders/copy.vert", "Assets/Shaders/RtoRGB.frag", "RtoRGB")); equationShaders.push_back(new Shader("Assets/Shaders/copy.vert", "Assets/Shaders/heatEquation.frag", "Heat Equation")); equationShaders.push_back(new Shader("Assets/Shaders/copy.vert", "Assets/Shaders/waveEquation.frag", "Wave Equation")); equationShaders.push_back(new Shader("Assets/Shaders/copy.vert", "Assets/Shaders/reverseHeat.frag", "Reverse Heat Equation")); for (int i = 0; i < equationShaders.size(); ++i) { shaders.Add(equationShaders[i]); } SetTextShader(textDraw); ShaderManager::GetSingletonPtr()->CompileShaders(); for (int i = 0; i < baseTextures.size(); ++i) { baseTextures[i]->Load(); } currentTexture = 0; CreateFBOs(); LoadTexture(); simulate = false; spaceStep = 0.1; timeStep = 0.002; currentEq = 0; }