Shark.cpp
branchv_0
changeset 7 e6065118326f
parent 6 fd93a46db15b
child 8 80ad08521091
equal deleted inserted replaced
6:fd93a46db15b 7:e6065118326f
   100 
   100 
   101 	bool keepRunningX11 = true;
   101 	bool keepRunningX11 = true;
   102 	int x11fd = XConnectionNumber(dpy);
   102 	int x11fd = XConnectionNumber(dpy);
   103 	EPoll epoll;
   103 	EPoll epoll;
   104 	epoll.add(x11fd);
   104 	epoll.add(x11fd);
       
   105 	epoll.add(fileMonitor.getFD());
   105 	try {
   106 	try {
   106 		epoll.add(setNonBlocking(STDIN_FILENO));
   107 		epoll.add(setNonBlocking(STDIN_FILENO));
   107 	} catch (const EPoll::Exception& e) {
   108 	} catch (const EPoll::Exception& e) {
   108 		logOutput << "Will not monitor events on STDIN: " << e.what() << "\n";
   109 		logOutput << "Will not monitor events on STDIN: " << e.what() << "\n";
   109 	}
   110 	}
   209 							<< (int) ch;
   210 							<< (int) ch;
   210 					logOutput << msg.str();
   211 					logOutput << msg.str();
   211 				}
   212 				}
   212 				logOutput << std::endl;
   213 				logOutput << std::endl;
   213 
   214 
       
   215 			} else if (epoll[epollEvent].data.fd == fileMonitor.getFD()) {
       
   216 				std::cout << "FileMonitor event:" << std::endl;
       
   217 				for (FileEvent fe; fileMonitor.readEvent(fe);) {
       
   218 					std::cout << "   "
       
   219 							<< " file: " << fe.fileName
       
   220 							<< " mask: " << fe.mask
       
   221 							<< std::endl;
       
   222 				}
   214 			} else {
   223 			} else {
   215 				logOutput
   224 				logOutput
   216 						<< "error: event on an unexpected FD: "
   225 						<< "error: event on an unexpected FD: "
   217 						<< epoll[epollEvent].data.fd
   226 						<< epoll[epollEvent].data.fd
   218 						<< std::endl;
   227 						<< std::endl;
   351 }
   360 }
   352 
   361 
   353 void Shark::loadTextures() {
   362 void Shark::loadTextures() {
   354 	for (const Configuration::Texture& tex : cfg.textures) {
   363 	for (const Configuration::Texture& tex : cfg.textures) {
   355 		textures.push_back(loadTexture(tex.fileName));
   364 		textures.push_back(loadTexture(tex.fileName));
       
   365 		watchedFiles.push_back(fileMonitor.watch(tex.fileName));
   356 		// TODO: review texture loading and binding
   366 		// TODO: review texture loading and binding
   357 		// works even without this - default texture
   367 		// works even without this - default texture
   358 		// glUniform1i(ProgAttr.jazz, jazz);
   368 		// glUniform1i(ProgAttr.jazz, jazz);
   359 		// checkError(&std::cerr);
   369 		// checkError(&std::cerr);
   360 	}
   370 	}
   398 			std::shared_ptr<Shader> shader = std::make_shared<Shader>(
   408 			std::shared_ptr<Shader> shader = std::make_shared<Shader>(
   399 					type, file, fileName);
   409 					type, file, fileName);
   400 
   410 
   401 			program->attachShader(*shader.get());
   411 			program->attachShader(*shader.get());
   402 			shaders.push_back(shader);
   412 			shaders.push_back(shader);
       
   413 			watchedFiles.push_back(fileMonitor.watch(fileName));
   403 			std::cerr << "GLSL loaded: " << fileName.c_str() << std::endl;
   414 			std::cerr << "GLSL loaded: " << fileName.c_str() << std::endl;
   404 		}
   415 		}
   405 
   416 
   406 		// GLSL compiler does very efficient / aggressive optimization.
   417 		// GLSL compiler does very efficient / aggressive optimization.
   407 		// Attributes and uniforms that are not used in the shader are deleted.
   418 		// Attributes and uniforms that are not used in the shader are deleted.