Exemple #1
0
  virtual bool initialize()
  {
    //_speed = 2.0f;
    // On charge la texture qui sera affichee sur chaque face du cube
    if (_texture.load("assets/textures/tmp/grass.tga") == false)
      {
	std::cerr << "Cannot load the cube texture" << std::endl;
	return (false);
      }

    _geometry.setColor(glm::vec4(1, 1, 1, 1));

    _geometry.pushVertex(glm::vec3(1, -1, -1));
    _geometry.pushVertex(glm::vec3(1, -1, 1));
    _geometry.pushVertex(glm::vec3(-1, -1, 1));
    _geometry.pushVertex(glm::vec3(-1, -1, -1));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    // Tres important, on n'oublie pas de build la geometrie pour envoyer ses informations a la carte graphique
    _geometry.build();
    return (true); 
  }
Exemple #2
0
  void draw(gdl::AShader &shader, gdl::Clock const &clock)
  {

    (void)clock;

    _texture.bind();
    _geometry.draw(shader, getTransformation(), GL_QUADS);
  }
Exemple #3
0
 virtual void draw(gdl::AShader &shader, gdl::Clock const &clock)
 {
   (void)clock;
   // On bind la texture pour dire que l'on veux l'utiliser
   _texture.bind();
   // Et on dessine notre cube
   _geometry.draw(shader, getTransformation(), GL_QUADS);
 }
Exemple #4
0
  bool		initialize()
  {
    if (_texture.load("./assets/herbe.tga") == false)
      {
	std::cerr << "Cannot load the map texture" << std::endl;
	return (false);
      }

    _geometry.pushVertex(glm::vec3(_x, 0, 0));
    _geometry.pushVertex(glm::vec3(_x, 0, _z));
    _geometry.pushVertex(glm::vec3(0, 0, _z));
    _geometry.pushVertex(glm::vec3(0, 0, 0));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.build();
    return (true);
  }
Exemple #5
0
  bool		initialize()
  {
    if (_texture.load(_path) == false)
      {
	std::cerr << "Cannot load the cube texture" << std::endl;
	return (false);
      }
    _geometry.pushVertex(glm::vec3(this->_x, 0, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 0, this->_z));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.pushVertex(glm::vec3(this->_x, 0, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 0, this->_z + 1));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.pushVertex(glm::vec3(this->_x, 0, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x, 0, this->_z));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.pushVertex(glm::vec3(this->_x + 1, 0, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 0, this->_z + 1));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.pushVertex(glm::vec3(this->_x, 0, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 0, this->_z));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z + 1));
    _geometry.pushVertex(glm::vec3(this->_x, 1, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z));
    _geometry.pushVertex(glm::vec3(this->_x + 1, 1, this->_z + 1));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.build();
    return (true);
  }
Exemple #6
0
  virtual bool initialize()
  {
    _speed = 10.0f;
    if (_texture.load("./LibBomberman_linux_x64/assets/textures/blank.tga")==false)
      {
	       std::cerr << "Cannot load the cube texture" << std::endl;
	       return (false);
      }

    _geometry.setColor(glm::vec4(1, 0, 0, 1));

    _geometry.pushVertex(glm::vec3(0.5, -0.5, 0.5));
    _geometry.pushVertex(glm::vec3(0.5, 0.5, 0.5));
    _geometry.pushVertex(glm::vec3(-0.5, 0.5, 0.5));
    _geometry.pushVertex(glm::vec3(-0.5, -0.5, 0.5));

    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.setColor(glm::vec4(1, 1, 1, 1));
    _geometry.pushVertex(glm::vec3(0.5, -0.5, -0.5));
    _geometry.pushVertex(glm::vec3(0.5, 0.5, -0.5));
    _geometry.pushVertex(glm::vec3(-0.5, 0.5, -0.5));
    _geometry.pushVertex(glm::vec3(-0.5, -0.5, -0.5));
    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));
    _geometry.setColor(glm::vec4(0, 1, 1, 1));
    _geometry.pushVertex(glm::vec3(0.5, -0.5, -0.5));
    _geometry.pushVertex(glm::vec3(0.5, 0.5, -0.5));
    _geometry.pushVertex(glm::vec3(0.5, 0.5, 0.5));
    _geometry.pushVertex(glm::vec3(0.5, -0.5, 0.5));
    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));
    _geometry.setColor(glm::vec4(1, 0, 1, 1));
    _geometry.pushVertex(glm::vec3(-0.5, -0.5, 0.5));
    _geometry.pushVertex(glm::vec3(-0.5, 0.5, 0.5));
    _geometry.pushVertex(glm::vec3(-0.5, 0.5, -0.5));
    _geometry.pushVertex(glm::vec3(-0.5, -0.5, -0.5));
    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));
    _geometry.setColor(glm::vec4(0, 1, 0, 1));
    _geometry.pushVertex(glm::vec3(0.5, 0.5, 0.5));
    _geometry.pushVertex(glm::vec3(0.5, 0.5, -0.5));
    _geometry.pushVertex(glm::vec3(-0.5, 0.5, -0.5));
    _geometry.pushVertex(glm::vec3(-0.5, 0.5, 0.5));
    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));
    _geometry.setColor(glm::vec4(0, 0, 1, 1));
    _geometry.pushVertex(glm::vec3(0.5, -0.5, -0.5));
    _geometry.pushVertex(glm::vec3(0.5, -0.5, 0.5));
    _geometry.pushVertex(glm::vec3(-0.5, -0.5, 0.5));
    _geometry.pushVertex(glm::vec3(-0.5, -0.5, -0.5));
    _geometry.pushUv(glm::vec2(0.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 0.0f));
    _geometry.pushUv(glm::vec2(1.0f, 1.0f));
    _geometry.pushUv(glm::vec2(0.0f, 1.0f));

    _geometry.build();
    return (true);
  }