Shark.cpp
branchv_0
changeset 27 2a156cb51479
parent 25 717653cedc4a
child 28 4cbd9c0beb4c
equal deleted inserted replaced
26:e7ceb915177e 27:2a156cb51479
   464 	glUniformMatrix4fv(ProgAttr.uView, 1, GL_FALSE, &view[0][0]);
   464 	glUniformMatrix4fv(ProgAttr.uView, 1, GL_FALSE, &view[0][0]);
   465 
   465 
   466 	// glBindVertexArray(vao);
   466 	// glBindVertexArray(vao);
   467 
   467 
   468 	glm::mat4 model = glm::mat4(1.0f); // identity matrix
   468 	glm::mat4 model = glm::mat4(1.0f); // identity matrix
   469 	// model = glm::translate(model, glm::vec3(0., 0., 0.));
       
   470 	// float angle = 20.0f;
       
   471 	// glm::vec3 xxx = glm::vec3(1.0f, 0.3f, 0.5f);
       
   472 	// model = glm::rotate(model, glm::radians(angle), xxx);
       
   473 	glUniformMatrix4fv(ProgAttr.uModel, 1, GL_FALSE, &model[0][0]);
   469 	glUniformMatrix4fv(ProgAttr.uModel, 1, GL_FALSE, &model[0][0]);
   474 
   470 
   475 	glDrawArrays(GL_TRIANGLES, 0, 2 * 3); // viz loadVertices() kde plníme data
   471 	glDrawArrays(GL_TRIANGLES, 0, 2 * 3); // see loadVertices()
   476 	std::cerr << "GLSL: glDrawArrays()" << std::endl;
   472 	std::cerr << "GLSL: glDrawArrays()" << std::endl;
   477 }
   473 }
   478 
   474 
   479 void Shark::Impl::log(LogLevel level, std::string message) {
   475 void Shark::Impl::log(LogLevel level, std::string message) {
   480 	::log(logOutput, level, message);
   476 	::log(logOutput, level, message);
   578 		// static const uint32_t watchMask = IN_CLOSE_WRITE | IN_ATTRIB;
   574 		// static const uint32_t watchMask = IN_CLOSE_WRITE | IN_ATTRIB;
   579 		// watchedFiles.push_back(fileMonitor.watch(tex.fileName, watchMask));
   575 		// watchedFiles.push_back(fileMonitor.watch(tex.fileName, watchMask));
   580 		watchedFiles.push_back(fileMonitor.watch(tex.fileName));
   576 		watchedFiles.push_back(fileMonitor.watch(tex.fileName));
   581 		// TODO: review texture loading and binding
   577 		// TODO: review texture loading and binding
   582 		// works even without this - default texture
   578 		// works even without this - default texture
   583 		// glUniform1i(ProgAttr.jazz, jazz);
   579 		// glUniform1i(..., ...);
   584 		// checkError(&std::cerr);
   580 		// checkError(&std::cerr);
   585 	}
   581 	}
   586 }
   582 }
   587 
   583 
   588 bool Shark::Impl::reloadTexture(const std::string& fileName) {
   584 bool Shark::Impl::reloadTexture(const std::string& fileName) {
   605 		GLuint vao;
   601 		GLuint vao;
   606 		glGenVertexArrays(1, &vao);
   602 		glGenVertexArrays(1, &vao);
   607 		glBindVertexArray(vao);
   603 		glBindVertexArray(vao);
   608 		// VAO - something like context for bound data/variables
   604 		// VAO - something like context for bound data/variables
   609 		// We can switch multiple VAOs. VAO can contain multiple VBOs.
   605 		// We can switch multiple VAOs. VAO can contain multiple VBOs.
   610 		// See also https://stackoverflow.com/questions/11821336/
       
   611 		// what-are-vertex-array-objects
   606 		// what-are-vertex-array-objects
   612 
   607 
   613 		// Vertex Buffer Object (VBO):
   608 		// Vertex Buffer Object (VBO):
   614 		GLuint vbo;
   609 		GLuint vbo;
   615 		glGenBuffers(1, &vbo);
   610 		glGenBuffers(1, &vbo);