Exemple #1
0
void init()
{
	glewInit();
	glEnable (GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

	glClearColor(.4, .4, .4, 1);
	initFBO(fbo1, depthBuffer1, img1);
	initFBO(fbo2, depthBuffer2, img2);

	checkboard = pngBind("checkboard.png", PNG_NOMIPMAP, PNG_ALPHA, NULL, GL_REPEAT, GL_NEAREST, GL_NEAREST);
	glBindTexture(GL_TEXTURE_2D, checkboard);
	glEnable(GL_TEXTURE_2D);

	extern GLuint setShaders(char* vert_file, char* frag_file);
	greyFilter = setShaders("greyFilter.vert", "greyFilter.frag");
	mosaicFilter = setShaders("mosaicFilter.vert", "mosaicFilter.frag");

	// load OBJ model
	m1 = glmReadOBJ ("al.obj");
	glmUnitize (m1);
	glmFacetNormals (m1);
	glmVertexNormals (m1, 90);
}
Exemple #2
0
void reshape(int w, int h)
{
	gw = w; gh = h;
	
	glViewport(0,0,w,h);
	ViewerReshape(viewer);
	initFBO(fbo1, depthBuffer1, img1);
	initFBO(fbo2, depthBuffer2, img2);
}
void ClientGame::event(const sf::Event &e)
{
    //print(format("player_ship=%1%\n") % player_ship);
    if(player_ship)
        player_ship->event(e);

    cam->event(e);

    if(e.Type == sf::Event::KeyPressed)
    {
        if(e.Key.Code == sf::Key::C)
        {
            if(cam == ship_cam)
            {
                cam = free_cam;
                free_cam->setPosition(ship_cam->getPosition());
                free_cam->setScale(5.0f);
            }
            else
                cam = ship_cam;
        }
        else if(e.Key.Code == sf::Key::Num1)
            draw_names = !draw_names;
        else if(e.Key.Code == sf::Key::Num2)
            draw_glow = !draw_glow;
        else if(e.Key.Code == sf::Key::Tab)
            draw_scores = true;
    }
    else if(e.Type == sf::Event::KeyReleased)
    {
        if(e.Key.Code == sf::Key::Tab)
            draw_scores = false;
    }
    else if(e.Type == sf::Event::Resized)
    {
        if(has_shaders)
        {
            glBindFramebuffer(GL_FRAMEBUFFER, main_fb);
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
            glBindFramebuffer(GL_FRAMEBUFFER, framebuffers[0]);
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
            glBindFramebuffer(GL_FRAMEBUFFER, framebuffers[1]);
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);

            glDeleteTextures(1, &main_fb_texture);
            glDeleteTextures(2, framebuffer_textures);
            glDeleteFramebuffers(1, &main_fb);
            glDeleteFramebuffers(2, framebuffers);

            int w = e.Size.Width;
            int h = e.Size.Height;
            initFBO(&main_fb, &main_fb_texture, w, h);
            initFBO(&framebuffers[0], &framebuffer_textures[0], w, h);
            initFBO(&framebuffers[1], &framebuffer_textures[1], w, h);
        }
    }
}
ClientGame::ClientGame(RenderWindowPtr win, GameStateData gamestate_data, ClientPtr client)
{
    this->client = client;
    this->window = win;

    physics = b2WorldPtr(new b2World(b2Vec2(0.0f, 0.0f), true));
    game_bounds = gamestate_data.game_bounds;

    ship_cam = ShipCameraPtr(new ShipCamera());
    free_cam = FreeCameraPtr(new FreeCamera(0, 0));
    cam = ship_cam;

    asteroid_data.load("asteroids.dat");

    asteroid_explosions.push_back("sounds/explosion1.wav");
    asteroid_explosions.push_back("sounds/explosion2.wav");
    asteroid_explosions.push_back("sounds/explosion3.wav");

    musics.push_back("sounds/stitchesinthecorpse_mymountaininstrumentalversion.ogg");
    musics.push_back("sounds/alone_to_die.ogg");

    stars.resize(256);
    for(int i = 0; i < stars.size(); i++)
        stars[i].set(float(rand())/RAND_MAX * game_bounds.getWidth(), float(rand())/RAND_MAX * game_bounds.getHeight());

    particle_system = ParticleSystemPtr(new ParticleSystem());

    if(sf::PostFX::CanUsePostFX())
    {
        if(glow_fx.LoadFromFile("glow.sfx"))
        {
            has_shaders = true;

            //glow_fx.SetTexture("framebuffer", NULL);
        }
        else
        {
            warning("failed to load glow.sfx\n");
            has_shaders = false;
        }

        int w = window->GetWidth();
        int h = window->GetHeight();
        initFBO(&main_fb, &main_fb_texture, w, h);
        initFBO(&framebuffers[0], &framebuffer_textures[0], w, h);
        initFBO(&framebuffers[1], &framebuffer_textures[1], w, h);
    }
    else
    {
        has_shaders = false;
    }

    draw_names = false;
    draw_scores = false;
    draw_glow = true;
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------
//
bool ofxOculusRift::init( int _width, int _height, int _fboNumSamples )
{
	initFBO( _width, _height );
	
	hmdWarpShader.load("Shaders/HmdWarp");
	
	ofDisableArbTex();

		ofFbo::Settings tmpSettings = ofFbo::Settings();
		tmpSettings.width			= _width/2;
		tmpSettings.height			= _height;
		tmpSettings.internalformat	= GL_RGB;
		tmpSettings.textureTarget	= GL_TEXTURE_2D;
		tmpSettings.numSamples		= _fboNumSamples;
		
		eyeFboLeft.allocate( tmpSettings );
		eyeFboRight.allocate( tmpSettings );
	
	ofEnableArbTex();
	
	setNearClip( 0.001f );
	setFarClip( 2048.0f );
	setFov( 90.0f );

	setInterOcularDistance( -0.6f );
	setShaderScaleFactor( 1.0f );
	setDoWarping( true );

	
	return initSensor();
}
Session::Session() {
   window = new Window(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE);
   initGL();
   loadAllTextures();
   initFBO();
   camera = new Camera(h_uP, h_uV, h_uView);
   world = new World(shaders[SHADER_DEFAULT]->getPID(), camera);
   clicks = new Clicks();
   fontEngine = new FontEngine(WINDOW_WIDTH, WINDOW_HEIGHT, shaders[SHADER_TEXT], shaders[SHADER_DEFAULT]);
   sound = new Sound();
   sound->initSound();
   camera->booths = world->booths;
   camera->structures = world->structures;
   minigame = new Minigame();
   game_state = TITLE_STATE;
   game_start = false;
   global_points = 0;
   xInc = 1.0f;
   startTime = 25.0;
   punLine = 0;
   
   world->initParticles(shaders[SHADER_BILLBOARD]);
   fontEngine->init(shaders[SHADER_TEXT]->getPID());

   camera->pov = false;
}
Exemple #7
0
void init()
{
	//init shader
	light.compileShader("./../light.vs", GLSLShader::VERTEX);
	light.compileShader("./../light.frag", GLSLShader::FRAGMENT);
	if(!light.link()){
		std::cout << "light shader link failed" << std::endl;
	}
	std::cout  << light.log() << std::endl;

	depth.compileShader("./../depth.vs", GLSLShader::VERTEX);
	depth.compileShader("./../depth.frag", GLSLShader::FRAGMENT);
	if (!depth.link()){
		std::cout << "depth shader not linked" << std::endl;
	}
	std::cout << depth.log() << std::endl;

	debugDepthQuad.compileShader("./../debugDepth.vs", GLSLShader::VERTEX);
	debugDepthQuad.compileShader("./../debugDepth.frag", GLSLShader::FRAGMENT);
	if (!debugDepthQuad.link()){
		std::cout << "debug shader not linked" << std::endl;
	}
	std::cout << debugDepthQuad.log() << std::endl;
	initVBO();
	initFBO();
	initLight();
	initTexture();
}
Exemple #8
0
	bool MiniMap::init()
	{
		size = 200;

		GLuint tmpHandle;
		glGenTextures(1, &tmpHandle);
		mmTexture = TextureManager::shared().createTextureFromHandle("minimap", tmpHandle);

		if(!initShader()) {
			LOG_ERROR("Could not initialize mini-map shaders");
			return false;
		}
		if(!initFBO()) {
			LOG_ERROR("Could not initialize mini-map fbo");
		   	return false;
		}
		if(!initVAOs()) {
			LOG_ERROR("Could not initialize mini-map vao");
			return false;
		}

		mmWindow = new Window(
				vec2(-1.0, -1.0), vec2(0.0, 0.0), vec2(size),
				mmTexture, WINDOW_DRAGGABLE, "Minimap");
		Interface::shared().makeActive(mmWindow);

		return true;
	}
Exemple #9
0
int main (int argc, char **argv) {
  
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
  
  windowWidth = 512;
  windowHeight = 512;
  
  zNear = 0.1f;
  zFar = 1000.0f;
  fov = 45.0f;

  glutInitWindowSize (windowWidth, windowHeight);
  glutInitWindowPosition (100, 100);
  glutCreateWindow("Exercise 10");
  
  glutReshapeFunc(resizeGL);
  glutDisplayFunc(updateGL);
  glutIdleFunc(idle);
  glutKeyboardFunc(keyboardEvent);
  glutMouseFunc(mouseEvent);
  glutMotionFunc(mouseMoveEvent);
  
  GLenum err = glewInit();
  if (GLEW_OK != err) {
    fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
  }
  fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
  
  initGL();
  initFBO();
  initScene();
  
  // this path defines a looped circular curve //
  std::vector<ControlPoint> p;
  p.push_back(ControlPoint( 1.0, 0.0, 0.0, 0.0));
  p.push_back(ControlPoint( 0.7, 0.0, 0.7, 0.5));
  p.push_back(ControlPoint( 0.0, 0.0, 1.0, 1.0));
  p.push_back(ControlPoint(-0.7, 0.0, 0.7, 1.5));
  p.push_back(ControlPoint(-1.0, 0.0, 0.0, 2.0));
  p.push_back(ControlPoint(-0.7, 0.0,-0.7, 2.5));
  p.push_back(ControlPoint( 0.0, 0.0,-1.0, 3.0));
  p.push_back(ControlPoint( 0.7, 0.0,-0.7, 3.5));
  p.push_back(ControlPoint( 1.0, 0.0, 0.0, 4.0));
  
  mPath.setFirstControlPoint(p[p.size() - 2]);
  mPath.setLastControlPoint(p[1]);
  for (unsigned int i = 0; i < p.size(); ++i) {
    mPath.addIntermediateControlPoint(p[i]);
  }
  mPath.setLooped(true);
  // ----------------------------------------- // 
  
  glutMainLoop();
  
  delete mNormalMapShader;
  
  return 0;
}
Exemple #10
0
 SourcePass::SourcePass(QSize res, vector<Texture*> &targets, ShaderProgram * shader) : DrawPass(res) {
   typeName = "SourcePass";
   this->targets = targets;
   this->shader = shader;
   initFBO();
   if(targets.size() > 1)
     shader->initRenderTargets(targets);
 }
Exemple #11
0
    void FXAA::resize(int width, int height)
    {
        m_technique->setUniformAttribute("screenWidth", static_cast<GLfloat>(width));
        m_technique->setUniformAttribute("screenHeight", static_cast<GLfloat>(height));

        cleanUpFBO();
        initFBO(width, height);
    }
Exemple #12
0
void initDisplay() {

	for(int i=0;i<10;i++) {
		flag_dessin[i] = false;
	}
	flag_dessin[0] = true;

	instantPrec = glutGet(GLUT_ELAPSED_TIME);

	sepiaColor[0] = 0.2;
	sepiaColor[1] = 0.1;
	sepiaColor[2] = 0;

	/// INITIALISATION DES TEXTURES ...
	initTexture();

	/// INITIALISATION DES SHADERS ...
	if(!RTShaders::areShadersSupported(true)) {
		std::cerr<<"[In initDisplay] : Shaders are not supported..."<<std::endl;
		exit(5);
	}
	testShader = RTShaders::loadShader("./shaders/tstshader.vert","./shaders/tstshader.frag",true);

	/// INITIALISATION DES FBOS ...
	if (USE_FBO) {
		if(initFBO()==false){
			cerr<<"FBO not supported ! Exiting"<<endl;
			exit(5);
		}

		glGenFramebuffersEXT(1, &fbo_handler);
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo_handler);
		GLuint depth_rb;
		glGenRenderbuffersEXT(1, &depth_rb);
		glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);
		glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT,image_base->tailu,image_base->tailv);
		glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);
		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, image_base->indbind , 0);
		checkFramebufferStatus();
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0);
	}

	/// INITIALISATION CLASSIQUE OPENGL ...
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glMatrixMode(GL_TEXTURE);
		glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);

	glShadeModel( GL_SMOOTH );
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);
	glDisable(GL_FOG);
	CHECK_GL;


	glUseProgramObjectARB(0);
}
Exemple #13
0
////////////////////////////////////////////////////////
// renderGL
//
/////////////////////////////////////////////////////////
void gemcubeframebuffer :: render(GemState *state)
{
  gem::GLStack*stacks=NULL;
  if(state) {
    state->get(GemState::_GL_STACKS, stacks);
  }

  if(!m_width || !m_height) {
    error("width and height must be present!");
  }

  glActiveTexture(GL_TEXTURE0_ARB + m_texunit);

  if (m_wantinit) {
    initFBO();
  }

  // store the window viewport dimensions so we can reset them,
  // and set the viewport to the dimensions of our texture
  glGetIntegerv(GL_VIEWPORT, m_vp);
  glGetFloatv( GL_COLOR_CLEAR_VALUE, m_color );

  glBindTexture( m_texTarget, 0 );
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBufferIndex);
  // Bind the texture to the frame buffer.
  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                            /*m_texTarget*/ GL_TEXTURE_CUBE_MAP_POSITIVE_X + m_face, m_offScreenID, 0);
  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
                               GL_RENDERBUFFER_EXT, m_depthBufferIndex);

  // debug yellow color
  // glClearColor( 1,1,0,0);
  glClearColor( m_FBOcolor[0], m_FBOcolor[1], m_FBOcolor[2], m_FBOcolor[3] );

  // Clear the buffers and reset the model view matrix.
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // We need a one-to-one mapping of pixels to texels in order to
  // ensure every element of our texture is processed. By setting our
  // viewport to the dimensions of our destination texture and drawing
  // a screen-sized quad (see below), we ensure that every pixel of our
  // texel is generated and processed in the fragment program.
  glViewport(0,0, m_width, m_height);

  if(stacks) {
    stacks->push(gem::GLStack::PROJECTION);
  }
  glLoadIdentity();
  glFrustum( m_perspect[0],  m_perspect[1],  m_perspect[2],  m_perspect[3],
             m_perspect[4], m_perspect[5]);

  if(stacks) {
    stacks->push(gem::GLStack::MODELVIEW);
  }
  glLoadIdentity();
}
Exemple #14
0
void Scene::Initialize()
{
	initOpengl();
	initLight();
	initSceneObjs();
	initShader();
	initTexture();
	initFBO();
	initThisDemo();
}
Exemple #15
0
    void FXAA::init(int width, int height)
    {
        m_technique->setUniformAttribute("screenWidth", static_cast<GLfloat>(width));
        m_technique->setUniformAttribute("screenHeight", static_cast<GLfloat>(height));

        m_sampler = m_renderer->getTextureManager()->getSamplerPreset(TextureManager::NearestClamp);
    
        initFBO(width, height);
        initVAO();
    }
Exemple #16
0
/**
 * @brief ParticleSystem resize method
 * @param width
 * @param height
 */
bool ParticleSystem::Resize(int width, int height) {
  wWidth = width;
  wHeight = height;
  viewAspect = wWidth / static_cast<float>(wHeight);

  initFBO();
  Render();

  return true;
}
void SeedGLWidget::initializeGL()
{
	GLWidget::initializeGL();
	//glDepthFunc(GL_LEQUAL);
	initTess();
	if (!initFBO())
	{
		QMessageBox::warning(this, "FBO error", "Cannot initialize FBO");
	}
}
Exemple #18
0
/*!
Init the non linear projection. The arguments should match the texture settings for the parent window's FBO target.
*/
void sgct_core::NonLinearProjection::init(int internalTextureFormat, unsigned int textureFormat, unsigned int textureType, int samples)
{
	mTextureInternalFormat = internalTextureFormat;
	mTextureFormat = textureFormat;
	mTextureType = textureType;
	mSamples = samples;

	for (std::size_t i = 0; i < 20; i++)
		mVerts[i] = 0.0f;

	initViewports();
	initTextures();
	initFBO();
	initVBO();
	initShaders();
}
DrawableManager::DrawableManager(core::Camera & cam, const glm::uvec2 & size)
  : m_cam{cam},
	m_screenSize{size},
  	m_maxNumObjects{k_maxNumObjects}
{
	GLint maxBufferSize;
#ifdef LEGACY_MODE
	glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &maxBufferSize);
#else
	glGetIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &maxBufferSize);
#endif
	maxBufferSize /= static_cast<GLint>(sizeof(glm::mat4));
	m_maxNumObjects = std::min(static_cast<unsigned int>(maxBufferSize), m_maxNumObjects);

	initRenderTypes();
	initFBO();
}
Exemple #20
0
void MotionBlur::reshape(int32_t width, int32_t height)
{
    glViewport(0, 0, NvSampleApp::m_width, NvSampleApp::m_height);

    initFBO();

    //setting the perspective projection matrix
    nv::perspective(mProjectionMatrix, NV_PI / 3.0f,
                    static_cast<float>(width) /
                    static_cast<float>(height),
                    1.0f, 150.0f);

    //setting the inverse perspective projection matrix
    nv::perspective(mInverseProjMatrix, NV_PI / 3.0f,
                    static_cast<float>(NvSampleApp::m_width) /
                    static_cast<float>(NvSampleApp::m_height),
                    1.0f, 150.0f);
    mInverseProjMatrix = nv::inverse(mInverseProjMatrix);

    CHECK_GL_ERROR();
}
	bool EtoileGLMeshRenderPassPlugin::loadFile(const std::string& filename)
	{
		if(filename.empty()) return false;
		std::string ext = File::getFileExtension(filename);
		std::string path = File::getFilePath(filename);
		TiXmlDocument doc(filename.c_str());
		if(!doc.LoadFile())
		{
			std::cout << "erreur while loading: " << filename<<std::endl;
			std::cout << "error #" << doc.ErrorId() << " : " << doc.ErrorDesc() << std::endl;
			return false;
		}
		this->getInputSockets().clear();
		this->addInputSocket(_pinputmesh);
		this->addInputSocket(_pinputmeshunit);
		if(_pview != NULL)
		{
			this->addInputSocket(_pview);
		}
		if(_pproj != NULL)
		{
			this->addInputSocket(_pproj);
		}
		if(_pviewproj != NULL)
		{
			this->addInputSocket(_pviewproj);
		}
		AABBWidget* aabbw = new AABBWidget();
		aabbw->bindPass(this);
		widget->addWidget(aabbw);
		TiXmlHandle hdl(&doc);

		TiXmlElement *elemRoot = hdl.FirstChildElement("Etoile").Element();
		while (elemRoot)
		{
			TiXmlElement *passElement = elemRoot->FirstChildElement("MeshPass");
			while (passElement)
			{
				std::string name = passElement->Attribute("name");
				this->getType()._description = name;
		
				int x;
				if(TIXML_NO_ATTRIBUTE!=passElement->QueryIntAttribute("x", &x))
				{
					this->_x = x;
				}
				int y;
				if(TIXML_NO_ATTRIBUTE!=passElement->QueryIntAttribute("y", &y))
				{
					this->_y = y;
				}
				int w;
				if(TIXML_NO_ATTRIBUTE!=passElement->QueryIntAttribute("w", &w))
				{
					this->_w = w;
				}
				int h;
				if(TIXML_NO_ATTRIBUTE!=passElement->QueryIntAttribute("h", &h))
				{
					this->_h = h;
				}
				initFBO();
				TiXmlElement *gpuElement = passElement->FirstChildElement("GPU");
				while (gpuElement)
				{
					const char* name = gpuElement->Attribute("name");
					std::map<ShaderType, std::string> files;
					TiXmlElement *vertexElement = gpuElement->FirstChildElement("vertex");
					if(vertexElement != NULL)
					{
						const char* file = vertexElement->Attribute("file");
						files[ShaderType::SHADERTYPE_VERTEX] = path + file;
					}
					TiXmlElement *fragElement = gpuElement->FirstChildElement("fragment");
					if(fragElement != NULL)
					{
						const char* file = fragElement->Attribute("file");
						files[SHADERTYPE_FRAGMENT] = path + file;
					}
					TiXmlElement *geometryElement = gpuElement->FirstChildElement("geometry");
					if(geometryElement != NULL)
					{
						const char* file = geometryElement->Attribute("file");
						files[SHADERTYPE_GEOMETRY] = path + file;
					}
					TiXmlElement *computeElement = gpuElement->FirstChildElement("compute");
					if(computeElement != NULL)
					{
						const char* file = computeElement->Attribute("file");
						files[SHADERTYPE_COMPUTE] = path + file;
					}
					TiXmlElement *tessCtrElement = gpuElement->FirstChildElement("tessctrl");
					if(tessCtrElement != NULL)
					{
						const char* file = tessCtrElement->Attribute("file");
						files[SHADERTYPE_TESSELLATION_CTRL] = path + file;
					}
					TiXmlElement *tessEvaElement = gpuElement->FirstChildElement("tesseval");
					if(tessEvaElement != NULL)
					{
						const char* file = tessEvaElement->Attribute("file");
						files[SHADERTYPE_TESSELLATION_EVAL] = path + file;
					}
					GLSLGpuProgram* glsl = new GLSLGpuProgram(name);
					glsl->loadShaderFiles(files);
					this->setCommonGpuProgram(glsl);
					GpuCompileWidget* gwidget = new GpuCompileWidget();
					gwidget->bindPass(this);
					widget->addWidget(gwidget);
					gpuElement = gpuElement->NextSiblingElement("GPU"); // iteration
				}

				TiXmlElement *outputsElement = passElement->FirstChildElement("Output");
				while (outputsElement)
				{
					std::string type = outputsElement->Attribute("type");
					std::string name = outputsElement->Attribute("name");
					if(type.compare("texture2d")==0)
					{
						TextureRenderTarget* tt = new TextureRenderTarget(name);
						GLTexture2D* t = new GLTexture2D(name);
						t->create(w,h,1);
						tt->set(t);
						this->addOutputSocket(tt);
					}

					outputsElement = outputsElement->NextSiblingElement("Output"); // iteration
				}

				TiXmlElement *inputsElement = passElement->FirstChildElement("Input");
				while (inputsElement)
				{
					std::string type = inputsElement->Attribute("type");
					std::string name = inputsElement->Attribute("name");
					if(type.compare("texture2d")==0)
					{
						EtoileMeshPassTextureInputSocket* in = new EtoileMeshPassTextureInputSocket(name);
						this->addInputSocket(in);
					}
					else if(type.compare("float")==0)
					{
						EtoileMeshPassFloatInputSocket* in = new EtoileMeshPassFloatInputSocket(name);
						in->setNode(this);
						//this->addInputSocket(in);
						FloatInputSocketWidget* socketwidget = new FloatInputSocketWidget(widget);
						float value;
						if(TIXML_NO_ATTRIBUTE!=inputsElement->QueryFloatAttribute("value", &value))
						{
							in->perform(&value);
						}
						socketwidget->bindParameter(in, value);
						widget->addWidget(socketwidget);
					}
					else if(type.compare("int")==0)
					{
						EtoileMeshPassIntInputSocket* in = new EtoileMeshPassIntInputSocket(name);
						in->setNode(this);
						//this->addInputSocket(in);
						IntInputSocketWidget* socketwidget = new IntInputSocketWidget(widget);
						int value = 0;
						if(TIXML_NO_ATTRIBUTE!=inputsElement->QueryIntAttribute("value", &value))
						{
							in->perform(&value);
						}
						socketwidget->bindParameter(in, value);
						widget->addWidget(socketwidget);
					}

					inputsElement = inputsElement->NextSiblingElement("Input"); // iteration
				}

				
				passElement = passElement->NextSiblingElement("MeshPass"); // iteration
			}

			elemRoot = elemRoot->NextSiblingElement("Etoile"); // iteration
		}
		
		return true;
	}
void BlendShapeViewer::initializeGL() {
	GL3DCanvas::initializeGL();
	initFBO();
	//recon.bindFBO(fbo);
}
Exemple #23
0
	void DefaultSceneRenderer::render(task_t &task) {
		glClearColor(0.9f, 0.9f, 0.9f, 1.f); // default background color

		glEnable(GL_DEPTH_TEST);
		glDepthFunc(GL_LESS);

		auto size = task.size;

		if (size == size2i(0, 0)) return;

		initFBO(size);

		glViewport(0, 0, size.w, size.h);

		// draw material properties to scene buffer
		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo_scene);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


		// draw everything in the draw queue
		//
		for (; !task.drawQueue.empty(); task.drawQueue.pop()) {
			auto d = task.drawQueue.top();
			// Bind shader program
			// Bind material properties
			// Bind Geometry
			// Then render

			material_ptr m = d->material();
			m->shader->bind();
			m->bind(task.projectionMatrix, task.zfar);
			d->draw();
		}

		static GLuint prog_deferred0 = 0;
		if (!prog_deferred0) {
			prog_deferred0 = gecom::makeShaderProgram("330 core", { GL_VERTEX_SHADER, GL_GEOMETRY_SHADER, GL_FRAGMENT_SHADER }, shader_deferred0_source);
		}

		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
		glDisable(GL_DEPTH_TEST);
		glUseProgram(prog_deferred0);

		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, m_tex_scene_depth);
		glActiveTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_2D, m_tex_scene_color);
		glActiveTexture(GL_TEXTURE2);
		glBindTexture(GL_TEXTURE_2D, m_tex_scene_normal);

		glUniform1i(glGetUniformLocation(prog_deferred0, "sampler_depth"), 0);
		glUniform1i(glGetUniformLocation(prog_deferred0, "sampler_color"), 1);
		glUniform1i(glGetUniformLocation(prog_deferred0, "sampler_normal"), 2);

		draw_dummy();

		glUseProgram(0);
		glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_scene);
		glBlitFramebuffer(0, 0, size.w, size.h, 0, 0, size.w, size.h, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
		glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);

		// glEnable(GL_DEPTH_TEST);
		// glDepthFunc(GL_LEQUAL);
		// s.physicsSystem().debugDraw(s);
	}
PostProcessSSAO::PostProcessSSAO()
{
    initShaders();
    resetGeometry();
    initFBO();
}
void init(void)
{
	dumpInfo();  // shader info

	// GL inits
	glClearColor(0.1, 0.1, 0.3, 0);
	glClearDepth(1.0);

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);


    // Load shader
    shader = loadShaders("shaders/projekt.vert", "shaders/projekt.frag");
    phongshader = loadShaders("shaders/phong.vert", "shaders/phong.frag");
    passShader = loadShaders("shaders/plaintextureshader.vert", "shaders/plaintextureshader.frag");
    joinshader = loadShaders("shaders/joinshader.vert", "shaders/joinshader.frag");
    lightShader = loadShaders("shaders/illuminati.vert", "shaders/illuminati.frag");
    cameraDepthShader = loadShaders("shaders/cameraDepth.vert", "shaders/cameraDepth.frag");
    lightDepthShader = loadShaders("shaders/lightDepth.vert", "shaders/lightDepth.frag");
    thickness = loadShaders("shaders/thickness.vert", "shaders/thickness.frag");

    //shadow shaders

    projTexShaderId = loadShaders("shaders/depth1V.vert", "shaders/depth1F.frag");
    projTexShaderId2 = loadShaders("shaders/depth2V.vert", "shaders/depth2F.frag");
    projTexMapUniform = glGetUniformLocation(projTexShaderId,"textureUnit");
    plainShaderId = loadShaders("shaders/plain.vert", "shaders/plain.frag");


    // Init FBOs
	fbo_phong = initFBO(W, H, 0);
	//fbo2 = initFBO(W, H, 0);
    fbo_depth = initFBO2(W,H, 0, 1);
    fbo_depth2 = initFBO2(W,H, 0, 1);
	fbo3 = initFBO(W, H, 0);
    fbo_sub = initFBO(W,H,0);
    fbo_lightDepth = initFBO(W,H,0);


    squareModel = LoadDataToModel(
            square, NULL, squareTexCoord, NULL,
            squareIndices, 4, 6);

    cam = SetVector(0, 0, 0.01);
    point = SetVector(0, 0, -10);
    axis = SetVector(0, 1, 0);


	// load the model
    bunny = LoadModelPlus("objects/bunny2/bunny_unwrap_noextras_blender.obj");
    LoadTGATextureSimple("textures/badBunny.tga", &thicknessBunny);
    modelMatrix = Mult( modelMatrix, ArbRotate(axis, -0.6));
    statue = LoadModelPlus("good_objects/statue_unwrapped_blender.obj");
    LoadTGATextureSimple("textures/statue.tga", &thicknessStatue);

    box = LoadModelPlus("good_objects/box_standard_blender.obj");
    LoadTGATextureSimple("textures/box.tga", &thicknessBox);

    box_bulge = LoadModelPlus("good_objects/box_bulge.obj");
    box_valley = LoadModelPlus("good_objects/box_valley.obj");
    box_stretched = LoadModelPlus("good_objects/box_stretched.obj");

    // load the scenemodels
    bottom = LoadModelPlus("objects/bottom.obj");
    side1 = LoadModelPlus("objects/side1.obj");
    side2 = LoadModelPlus("objects/side2.obj");

    // load sphere
    sphere = LoadModelPlus("objects/sphere.obj");
    printf("%d vertices\n", sphere->numVertices);
    printf("%d indices\n", sphere->numIndices);

    //Light stuff
    lightPosition = SetVector(-5.0,5.0,-4.0);
    sphereModelMatrix = Mult(T(lightPosition.x, lightPosition.y, lightPosition.z), sphereModelMatrix);
    lightColor = SetVector(1.0,1.0,1.0);

    //Colors
    bunnyColor = SetVector(1.0,0.4,1.0);
    sceneColor = SetVector(0.2,0.2,0.7);

    glutTimerFunc(5, &OnTimer, 0);

    moveValue = 0.002;
    moveX = moveValue;

	zprInit(&viewMatrix, cam, point);


    //modelMatrix = Mult( T(0.0, -2.4,0.0),modelMatrix);

}
Exemple #26
0
void PCSSShadowMap::render(RenderActionBase *action)
{
    Window  *win = action->getWindow();
    initialize(win);

    if(!_useGLSL || !_useShadowExt)
        _shadowVP->Viewport::render(action);
    else
    {
        glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);

        if(!_initTexturesDone)
            initTextures(win);

        if(_useFBO)
        {
            if(!initFBO(win))
                printf("ERROR with FBOBJECT\n");
        }

        GLfloat globalAmbient[] =
        {
            0.0, 0.0, 0.0, 1.0
        };
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);
        _firstRun = 1;

        for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
        {
            beginEditCP(_shadowVP->_texChunks[i]);
            {
                _shadowVP->_texChunks[i]->setMinFilter(GL_NEAREST);
                _shadowVP->_texChunks[i]->setMagFilter(GL_NEAREST);
            }
            endEditCP(_shadowVP->_texChunks[i]);
        }

        if(_shadowVP->getPixelWidth() != _width ||
           _shadowVP->getPixelHeight() != _height)
        {
            _width = _shadowVP->getPixelWidth();
            _height = _shadowVP->getPixelHeight();

            if(_useNPOTTextures)
            {
                beginEditCP(_colorMap);
                beginEditCP(_colorMapImage);
                _colorMapImage->set(COLORMAP_FORMAT, _width, _height);
                endEditCP(_colorMapImage);
                endEditCP(_colorMap);

                beginEditCP(_shadowFactorMap);
                beginEditCP(_shadowFactorMapImage);
                _shadowFactorMapImage->set(GL_RGB, _width, _height);
                endEditCP(_shadowFactorMapImage);
                endEditCP(_shadowFactorMap);

                reInit(win);
            }
            else
            {
                if(_width > _height)
                    _widthHeightPOT = osgnextpower2(_width - 1);
                else
                    _widthHeightPOT = osgnextpower2(_height - 1);

                beginEditCP(_colorMap);
                beginEditCP(_colorMapImage);
                _colorMapImage->set(COLORMAP_FORMAT, _widthHeightPOT, _widthHeightPOT);
                endEditCP(_colorMapImage);
                endEditCP(_colorMap);

                beginEditCP(_shadowFactorMap);
                beginEditCP(_shadowFactorMapImage);
                _shadowFactorMapImage->set(GL_RGB, _widthHeightPOT,
                                           _widthHeightPOT);
                endEditCP(_shadowFactorMapImage);
                endEditCP(_shadowFactorMap);
            }
        }
		
		// need possibility to tell cores like billboard not to change state
		RenderAction *rAct = dynamic_cast<RenderAction*>(action);
		bool effectsPassSave = rAct ? rAct->getEffectsPass() : false;

        if(_shadowVP->getMapAutoUpdate())
        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
            if(_useFBO && _useNPOTTextures)
                createColorMapFBO(action);
            else
#endif
                createColorMap(action);

            //deactivate transparent Nodes
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setActive(false);
			
			rAct->setEffectsPass(true);

            if(_useFBO)
                createShadowMapsFBO(action);
            else
                createShadowMaps(action);

            // switch on all transparent geos
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setActive(true);

            for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
            {
                if(_shadowVP->_lightStates[i] != 0)
                {
                    if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                       _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                    {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                        if(_useFBO && _useNPOTTextures)
                            createShadowFactorMapFBO(action, i);
                        else
#endif
                            createShadowFactorMap(action, i);
                        //_firstRun = 0;
                    }
                }
            }
        }
        else
        {
            if(_shadowVP->_trigger_update)
            {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                if(_useFBO && _useNPOTTextures)
                    createColorMapFBO(action);
                else
#endif
                    createColorMap(action);

                //deactivate transparent Nodes
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setActive(false);
				
				rAct->setEffectsPass(true);

                if(_useFBO)
                    createShadowMapsFBO(action);
                else
                    createShadowMaps(action);

                // switch on all transparent geos
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setActive(true);

                for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
                {
                    if(_shadowVP->_lightStates[i] != 0)
                    {
                        if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                           _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                            if(_useFBO && _useNPOTTextures)
                                createShadowFactorMapFBO(action, i);
                            else
#endif
                                createShadowFactorMap(action, i);
                        }
                    }
                }
                _shadowVP->_trigger_update = false;
            }
        }
		
		rAct->setEffectsPass(effectsPassSave);

        drawCombineMap(action);

        glPopAttrib();
        // render the foregrounds.
        for(UInt16 i = 0;i < _shadowVP->getMFForegrounds()->size();++i)
        {
            _shadowVP->getForegrounds(i)->draw(action, _shadowVP);
        }
    }
}
PostProcessFog::PostProcessFog()
{
    initShaders();
    resetGeometry();
    initFBO();
}
void PCSSShadowMap::render(DrawEnv *pEnv)
{
    Window  *win = pEnv->getWindow();
    initialize(win);

    if(!_useGLSL || !_useShadowExt)
        _shadowVP->Viewport::render(pEnv->getAction());
    else
    {
        glPushAttrib(GL_ENABLE_BIT);

        if(!_initTexturesDone)
            initTextures(win);

        if(_useFBO)
        {
            if(!initFBO(pEnv))
                printf("ERROR with FBOBJECT\n");
        }

        GLfloat globalAmbient[] =
        {
            0.0, 0.0, 0.0, 1.0
        };
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);
        _firstRun = 1;

#if 0
        for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
        {
            {
                _shadowVP->_texChunks[i]->setMinFilter(GL_NEAREST);
                _shadowVP->_texChunks[i]->setMagFilter(GL_NEAREST);
            }
        }
#endif

        if(_shadowVP->getPixelWidth() != _width ||
           _shadowVP->getPixelHeight() != _height)
        {
            _width = _shadowVP->getPixelWidth();
            _height = _shadowVP->getPixelHeight();

            if(_useNPOTTextures)
            {
                _colorMapImage->set(GL_RGB, _width, _height);

                _shadowFactorMapImage->set(GL_RGB, _width, _height);

                reInit(pEnv);
            }
            else
            {
                if(_width > _height)
                    _widthHeightPOT = osgNextPower2(_width - 1);
                else
                    _widthHeightPOT = osgNextPower2(_height - 1);

                _colorMapImage->set(GL_RGB, _widthHeightPOT, _widthHeightPOT);

                _shadowFactorMapImage->set(GL_RGB, _widthHeightPOT,
                                           _widthHeightPOT);
            }
        }

        commitChanges();

        if(_shadowVP->getMapAutoUpdate())
        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
            if(_useFBO && _useNPOTTextures)
                createColorMapFBO(pEnv);
            else
#endif
                createColorMap(pEnv);

            //deactivate transparent Nodes
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setTravMask(0);

            if(_useFBO)
                createShadowMapsFBO(pEnv);
            else
                createShadowMaps(pEnv);

            // switch on all transparent geos
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setTravMask(TypeTraits<UInt32>::BitsSet);

            for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
            {
                if(_shadowVP->_lightStates[i] != 0)
                {
                    if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                       _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                    {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                        if(_useFBO && _useNPOTTextures)
                            createShadowFactorMapFBO(pEnv, i);
                        else
#endif
                            createShadowFactorMap(pEnv, i);
                        //_firstRun = 0;
                    }
                }
            }
        }
        else
        {
            if(_shadowVP->_trigger_update)
            {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                if(_useFBO && _useNPOTTextures)
                    createColorMapFBO(pEnv);
                else
#endif
                    createColorMap(pEnv);

                //deactivate transparent Nodes
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setTravMask(0);

                if(_useFBO)
                    createShadowMapsFBO(pEnv);
                else
                    createShadowMaps(pEnv);

                // switch on all transparent geos
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setTravMask(TypeTraits<UInt32>::BitsSet);

                for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
                {
                    if(_shadowVP->_lightStates[i] != 0)
                    {
                        if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                           _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                            if(_useFBO && _useNPOTTextures)
                                createShadowFactorMapFBO(pEnv, i);
                            else
#endif
                                createShadowFactorMap(pEnv, i);
                        }
                    }
                }
                _shadowVP->_trigger_update = false;
            }
        }

        drawCombineMap(pEnv);

        glPopAttrib();
        // render the foregrounds.
        for(UInt16 i = 0;i < _shadowVP->getMFForegrounds()->size();++i)
        {
            _shadowVP->getForegrounds(i)->draw(pEnv, _shadowVP);
        }
    }
}
Exemple #29
0
/**
 * @brief ParticleSystem activate method
 */
bool ParticleSystem::Activate(void) {
  // --------------------------------------------------
  //  Get the path name of the plugin folder, e.g.
  //  "/path/to/oglcore/Plugins/PCVC/ParticleSystem"
  // --------------------------------------------------
  std::string pathName = this->GetCurrentPluginPath();

  // --------------------------------------------------
  //  Initialize manipulator for camera view
  // --------------------------------------------------
  int camHandle = this->AddManipulator("View", &this->viewMX,
                                       Manipulator::MANIPULATOR_ORBIT_VIEW_3D);
  this->SelectCurrentManipulator(camHandle);
  this->SetManipulatorRotation(camHandle, glm::vec3(0, 1, 0), 180.0f);
  this->SetManipulatorRotation(camHandle, glm::vec3(1, 0, 0), 180.0f);
  this->SetManipulatorDolly(camHandle, -1.5f);
  modelMX = glm::scale(glm::translate(glm::mat4(), glm::vec3(0.0f, -0.25f, 0.0f)), glm::vec3(0.5f, 0.5f, 0.5f));

  // --------------------------------------------------
  //  Initialize API variables here
  // --------------------------------------------------
  fovY.Set(this, "FoVy");
  fovY.Register();
  fovY.SetMinMax(5.0f, 90.0f);
  fovY = 45.0f;

  simulationSpeed.Set(this, "simulationSpeed");
  simulationSpeed.Register("step=0.01 min=0.01 max=1.0");
  simulationSpeed = 0.2f;

  num_points.Set(this, "numOfPoints", &OnnumPointsChanged);
  num_points.Register("step=1000 min=1 max=500000");
  num_points = 100000;

  num_instances.Set(this, "num_instances");
  num_instances.Register("step=1 min=1 max=3");
  num_instances = 1;

  pointSize.Set(this, "pointSize");
  pointSize.Register("step=0.1 min=0.1 max=10.0");
  pointSize = 0.1f;

  scale.Set(this, "scale");
  scale.Register("step=0.01 min=0.0 max=2.0");
  scale = 0.5f;

  velocity.Set(this, "velocity", &OnColorChanged);
  velocity.Register();
  velocity = glm::vec3(0.01f, 0.01f, 0.01f);
  targetSpeed = velocity;

  showBox.Set(this, "showBox");
  showBox.Register();
  showBox = true;

  stopMotion.Set(this, "stopMotion");
  stopMotion.Register();
  stopMotion = false;

  EnumPair ep[] = {{0, "None"},{1, "cube"}, {2, "sphere"}, {3, "torus"}, {4, "ef"}, {5, "ef5"}};
  importObject.Set(this, "importObject", ep, 6, &onObjectChanged);
  importObject.Register();

  // --------------------------------------------------
  //  Initialize shaders and VAs
  // --------------------------------------------------
  vsQuad = pathName + std::string("/resources/quad.vert");
  fsQuad = pathName + std::string("/resources/quad.frag");
  shaderQuad.CreateProgramFromFile(vsQuad.c_str(),
                                   fsQuad.c_str());
  vaQuad.Create(4);
  vaQuad.SetArrayBuffer(0, GL_FLOAT, 2, ogl4_2dQuadVerts);

  vsBox = pathName + std::string("/resources/box.vert");
  fsBox = pathName + std::string("/resources/box.frag");
  shaderBox.CreateProgramFromFile(vsBox.c_str(),
                                  fsBox.c_str());

  vsCube = pathName + std::string("/resources/cube.vert");
  gsCube = pathName + std::string("/resources/cube.geom");
  fsCube = pathName + std::string("/resources/cube.frag");
  shaderCube.CreateProgramFromFile( vsCube.c_str(), gsCube.c_str(), fsCube.c_str() );
  createCube();

  vsObject = pathName + std::string("/resources/object.vert");
  gsObject = pathName + std::string("/resources/object.geom");
  fsObject = pathName + std::string("/resources/object.frag");
  shaderObject.CreateProgramFromFile( vsObject.c_str(), fsObject.c_str() );//gsObject.c_str(),

  createTransformProgram(pathName);
  createBox();
  createSphere();
  createTorus();
  createCube();
  createEF(pathName, true);
  createEF(pathName, false);


  if(!checkProgram(pathName, "/resources/ctrlPoints.vert",
                   "/resources/ctrlPoints.frag")){//, "/resources/ctrlPoints.geom"
      std::cout.flush();
      std::cout << "******** shader error ********" <<std::endl;
      exit(0);
  }
  createCtrlPoints();
  vsCtrlPoints = pathName + std::string("/resources/ctrlPoints.vert");
  fsCtrlPoints = pathName + std::string("/resources/ctrlPoints.frag");
  shaderCtrlPoints.CreateProgramFromFile(vsCtrlPoints.c_str(),//gsCtrlPoints.c_str(),
                                         fsCtrlPoints.c_str());


  // --------------------------------------------------
  //  fbo and textures
  // --------------------------------------------------
  initFBO();

  // --------------------------------------------------
  //  random textures
  // --------------------------------------------------
  srand (time(NULL));
  for(int i = 0; i < random_tex_size; i++) {
      for(int j = 0; j < random_tex_size; j++) {
          texdata[4 * (i * random_tex_size + j) + 0] = (static_cast <float> (rand()) / static_cast <float> (RAND_MAX));// - 0.5f;
          texdata[4 * (i * random_tex_size + j) + 1] = (static_cast <float> (rand()) / static_cast <float> (RAND_MAX));// - 0.5f;
          texdata[4 * (i * random_tex_size + j) + 2] = (static_cast <float> (rand()) / static_cast <float> (RAND_MAX));// - 0.5f;
          texdata[4 * (i * random_tex_size + j) + 3] = 1.0f;
      }
  }

  glGenTextures(1, &randomTex);
  glBindTexture(GL_TEXTURE_2D, randomTex);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, random_tex_size, random_tex_size, 0, GL_RGBA, GL_FLOAT, texdata);

  int tex_cube_width = 800;
  int tex_cube_height = 400;
  char *texpathBoard = (pathName + std::string("/resources/textures/board.ppm")).c_str();
  texBoard = LoadPPMTexture(texpathBoard, tex_cube_width, tex_cube_height);

  //target point
  targetPoint= glm::vec3(static_cast <float> (rand()) / static_cast <float> (RAND_MAX),
                         static_cast <float> (rand()) / static_cast <float> (RAND_MAX),
                         static_cast <float> (rand()) / static_cast <float> (RAND_MAX));
  direction = glm::vec3(1.0f,1.0f,1.0f);

  glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  glClearDepth(1.0f);
  glEnable(GL_DEPTH_TEST);

  return true;
}
PostProcessEdit::PostProcessEdit()
{
    resetGeometry();
    initShaders();
    initFBO();
}