void loadAssets() { // Read in an asset file, and do some post-processing. There is much // more you can do with this asset loader, including load textures. // More info is here: // http://assimp.sourceforge.net/lib_html/usage.html cathedralScene = cathedralImporter.ReadFile(CATHEDRAL_MODEL_PATH, aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcessPreset_TargetRealtime_Quality); if (!cathedralScene || cathedralScene->mNumMeshes <= 0) { std::cerr << cathedralImporter.GetErrorString() << std::endl; exit(-1); } armadilloScene = armadilloImporter.ReadFile(ARMADILLO_MODEL_PATH, aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcessPreset_TargetRealtime_Quality); if (!armadilloScene || armadilloScene->mNumMeshes <= 0) { std::cerr << armadilloImporter.GetErrorString() << std::endl; exit(-1); } ////////////////////////////////////////////////////////////////////////// // TODO: LOAD YOUR SHADERS/TEXTURES ////////////////////////////////////////////////////////////////////////// // Load the vertex shader phongShader = new Shader("Shaders/phong"); if (!phongShader->loaded()) { std::cerr << "Shader failed to load" << std::endl; std::cerr << phongShader->errors() << std::endl; exit(-1); } simpleShader = new Shader("Shaders/simple"); if (!simpleShader->loaded()) { std::cerr << "Shader failed to load" << std::endl; std::cerr << simpleShader->errors() << std::endl; exit(-1); } envMapShader = new Shader("Shaders/envmap"); if (!envMapShader->loaded()) { std::cerr << "Shader failed to load" << std::endl; std::cerr << envMapShader->errors() << std::endl; exit(-1); } loadTexturesAndMeshIndices(cathedralScene); loadTexturesAndMeshIndices(armadilloScene); whiteImage = sf::Image(1, 1, sf::Color::White); generateCubeMap(); }
void WaterRenderer:: init() { // initialize parent TrackballViewer::init(); m_water = *createPlane(); m_skybox = *createCube(); waterColor = Vector4(0.1,0.2,0.3,0.5); watch.start(); startingTime = watch.stop(); // set camera to look at world coordinate center sceneSize = 4; set_scene_pos(Vector3(0.0, 0.0, 0.0), sceneSize); isRadial = false; amplitude1 = 0.01f; wavelength1 = 2.0f; speed1 = 1.0f; direction1 = Vector2(1, -1); amplitude2 = 1.0f; wavelength2 = 8.0f; speed2 = 2.0f; direction2 = Vector2(1, 0); amplitude3 = 0.5f; wavelength3 = 15.0f; speed3 = 1.0f; direction3 = Vector2(0, 1); amplitude4 = 15; wavelength4 = 30; speed4 = 3.0; direction4 = Vector2(1,0); time4 = -1000; generateCubeMap(); // load shaders m_skyShader.create("skybox.vs", "skybox.fs"); m_waterShader.create("water.vs", "water.fs"); }
void sgct_core::NonLinearProjection::initTextures() { if (sgct::Engine::instance()->getRunMode() <= sgct::Engine::OpenGL_Compablity_Profile) { glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT); glEnable(GL_TEXTURE_2D); } generateCubeMap(CubeMapColor, mTextureInternalFormat, mTextureFormat, mTextureType); if (sgct::Engine::checkForOGLErrors()) sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_DEBUG, "NonLinearProjection: %dx%d color cube map texture (id: %d) generated!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapColor]); else sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "NonLinearProjection: Error occured while generating %dx%d color cube texture (id: %d)!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapColor]); if (sgct::SGCTSettings::instance()->useDepthTexture()) { generateCubeMap(CubeMapDepth, GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_FLOAT); if (sgct::Engine::checkForOGLErrors()) sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_DEBUG, "NonLinearProjection: %dx%d depth cube map texture (id: %d) generated!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapDepth]); else sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "NonLinearProjection: Error occured while generating %dx%d depth cube texture (id: %d)!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapDepth]); if (mUseDepthTransformation) { //generate swap textures generateMap(DepthSwap, GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_FLOAT); if (sgct::Engine::checkForOGLErrors()) sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_DEBUG, "NonLinearProjection: %dx%d depth swap map texture (id: %d) generated!\n", mCubemapResolution, mCubemapResolution, mTextures[DepthSwap]); else sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "NonLinearProjection: Error occured while generating %dx%d depth swap texture (id: %d)!\n", mCubemapResolution, mCubemapResolution, mTextures[DepthSwap]); generateMap(ColorSwap, mTextureInternalFormat, mTextureFormat, mTextureType); if (sgct::Engine::checkForOGLErrors()) sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_DEBUG, "NonLinearProjection: %dx%d color swap map texture (id: %d) generated!\n", mCubemapResolution, mCubemapResolution, mTextures[ColorSwap]); else sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "NonLinearProjection: Error occured while generating %dx%d color swap texture (id: %d)!\n", mCubemapResolution, mCubemapResolution, mTextures[ColorSwap]); } } if (sgct::SGCTSettings::instance()->useNormalTexture()) { generateCubeMap(CubeMapNormals, sgct::SGCTSettings::instance()->getBufferFloatPrecisionAsGLint(), GL_BGR, GL_FLOAT); if (sgct::Engine::checkForOGLErrors()) sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_DEBUG, "NonLinearProjection: %dx%d normal cube map texture (id: %d) generated!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapNormals]); else sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "NonLinearProjection: Error occured while generating %dx%d normal cube texture (id: %d)!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapNormals]); } if (sgct::SGCTSettings::instance()->usePositionTexture()) { generateCubeMap(CubeMapPositions, sgct::SGCTSettings::instance()->getBufferFloatPrecisionAsGLint(), GL_BGR, GL_FLOAT); if (sgct::Engine::checkForOGLErrors()) sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_DEBUG, "NonLinearProjection: %dx%d position cube map texture (id: %d) generated!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapPositions]); else sgct::MessageHandler::instance()->print(sgct::MessageHandler::NOTIFY_ERROR, "NonLinearProjection: Error occured while generating %dx%d position cube texture (id: %d)!\n", mCubemapResolution, mCubemapResolution, mTextures[CubeMapPositions]); } if (sgct::Engine::instance()->getRunMode() <= sgct::Engine::OpenGL_Compablity_Profile) glPopAttrib(); }