<commit_before>#include "renderer.h"

// Constructor, initializes an empty axis coordinate VAO to optimize Render()
//   Allows for Verbose Debugging Mode
//   @param bool debug_flag, true will enable verbose debugging
//   @warn assert will end program prematurely with debugging enabled
Renderer::Renderer(const bool &debug_flag) 
  : coord_vao_handle(0), is_debugging_(debug_flag) {
}

//   Renders the passed in water to the scene
//   Should be called in the controller
//   @param Water * water, the skybox to render
//   @param Camera * camera, to get the camera matrix and correctly position world
//   @warn this function is not responsible for NULL PTRs
void Renderer::RenderWater(const Water * water, const Object* object, const Camera * camera, const Skybox * Sky) const
{
  glUseProgram(water->watershader());

  //printf("The Water shader ID is (inside of renderwater2) %d \n", water->watershader());
  int mvHandle = glGetUniformLocation(water->watershader(), "modelview_matrix");
  if (mvHandle == -1) {
    if (is_debugging_) {
      assert(0 && "Error: can't find matrix uniforms\n");
    }
  }

  int camPosHandle = glGetUniformLocation(water->watershader(), "cameraPos");
  if (camPosHandle == -1) {
    printf("Couldnt get the campos for water reflections\n");
  }
  glUniformMatrix3fv(camPosHandle, 1, false, glm::value_ptr(camera->cam_pos()));

  int texHandle = glGetUniformLocation(water->watershader(), "skybox");
  if (texHandle == -1) {
    
      fprintf(stderr, "Could not find uniform variables (WATER - SKYCUBE)\n");
   
  }

  int normHandle = glGetUniformLocation(water->watershader(), "normal_matrix");
  if (normHandle == -1) {
    if (is_debugging_) {
      fprintf(stderr, "Could not find uniform variables\n");
      exit(1);
    }
  }
  
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glEnable(GL_BLEND);
  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );


  glm::mat4 view_matrix = camera->view_matrix();


  //object->translation().y
  //view_matrix = glm::translate(view_matrix, glm::vec3(-15.0f, -5.0f, 15.0f));
  // Mitch this needs to be based on where the road is
  view_matrix = glm::translate(view_matrix, glm::vec3(object->translation().x - 100.0f , -3.0f, camera->cam_pos().z ));

  // Do not scale on X (this is the up-down axis)
  view_matrix = glm::scale(view_matrix , glm::vec3(1.0f, 1.0f, 1.0f));


  //view_matrix = glm::rotate(view_matrix, object->rotation().y, glm::vec3(0, 1, 0));
  //view_matrix = glm::rotate(view_matrix, object->rotation().x, glm::vec3(1, 0, 0));
  //view_matrix = glm::rotate(view_matrix, object->rotation().z, glm::vec3(0, 0, 1));

  glUniformMatrix4fv(mvHandle, 1, false, glm::value_ptr(view_matrix) );

  // Create and send normal matrix
  glm::mat3 normMatrix;
  normMatrix = glm::mat3(view_matrix);
  glUniformMatrix3fv(normHandle, 1, false, glm::value_ptr(normMatrix));

  // Send the cubemap (for reflections)
  glBindTexture(GL_TEXTURE_CUBE_MAP, Sky->skyboxtex());
  glUniform1i(texHandle, 0);

  // Render the Skybox
  glBindVertexArray(water->watervao());

  // MITCH - TODO COnsider changing this to triangles, whichever gives most FPS
  glDrawElements(GL_TRIANGLE_STRIP, water->water_index_count(), GL_UNSIGNED_INT, 0 );
  glDisable(GL_BLEND);<commit_msg>changed rotation<commit_after>#include "renderer.h"

// Constructor, initializes an empty axis coordinate VAO to optimize Render()
//   Allows for Verbose Debugging Mode
//   @param bool debug_flag, true will enable verbose debugging
//   @warn assert will end program prematurely with debugging enabled
Renderer::Renderer(const bool &debug_flag) 
  : coord_vao_handle(0), is_debugging_(debug_flag) {
}

//   Renders the passed in water to the scene
//   Should be called in the controller
//   @param Water * water, the skybox to render
//   @param Camera * camera, to get the camera matrix and correctly position world
//   @warn this function is not responsible for NULL PTRs
void Renderer::RenderWater(const Water * water, const Object* object, const Camera * camera, const Skybox * Sky) const
{
  glUseProgram(water->watershader());

  //printf("The Water shader ID is (inside of renderwater2) %d \n", water->watershader());
  int mvHandle = glGetUniformLocation(water->watershader(), "modelview_matrix");
  if (mvHandle == -1) {
    if (is_debugging_) {
      assert(0 && "Error: can't find matrix uniforms\n");
    }
  }

  int camPosHandle = glGetUniformLocation(water->watershader(), "cameraPos");
  if (camPosHandle == -1) {
    printf("Couldnt get the campos for water reflections\n");
  }
  glUniformMatrix3fv(camPosHandle, 1, false, glm::value_ptr(camera->cam_pos()));

  int texHandle = glGetUniformLocation(water->watershader(), "skybox");
  if (texHandle == -1) {
    
      fprintf(stderr, "Could not find uniform variables (WATER - SKYCUBE)\n");
   
  }

  int normHandle = glGetUniformLocation(water->watershader(), "normal_matrix");
  if (normHandle == -1) {
    if (is_debugging_) {
      fprintf(stderr, "Could not find uniform variables\n");
      exit(1);
    }
  }
  
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  glEnable(GL_BLEND);
  glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );


  glm::mat4 view_matrix = camera->view_matrix();


  //object->translation().y
  //view_matrix = glm::translate(view_matrix, glm::vec3(-15.0f, -5.0f, 15.0f));
  // Mitch this needs to be based on where the road is
  view_matrix = glm::translate(view_matrix, glm::vec3(object->translation().x - 100.0f , -3.0f, camera->cam_pos().z ));

  // Do not scale on X (this is the up-down axis)
  view_matrix = glm::scale(view_matrix , glm::vec3(1.0f, 1.0f, 1.0f));

  glm::mat4 rotate = glm::mat4(1.0f);
  rotate = glm::rotate(rotate, object->rotation().y, glm::vec3(0, 1, 0));
  //view_matrix = glm::rotate(view_matrix, object->rotation().y, glm::vec3(0, 1, 0));
  //view_matrix = glm::rotate(view_matrix, object->rotation().x, glm::vec3(1, 0, 0));
  //view_matrix = glm::rotate(view_matrix, object->rotation().z, glm::vec3(0, 0, 1));

  view_matrix = view_matrix * rotate;

  glUniformMatrix4fv(mvHandle, 1, false, glm::value_ptr(view_matrix) );

  // Create and send normal matrix
  glm::mat3 normMatrix;
  normMatrix = glm::mat3(view_matrix);
  glUniformMatrix3fv(normHandle, 1, false, glm::value_ptr(normMatrix));

  // Send the cubemap (for reflections)
  glBindTexture(GL_TEXTURE_CUBE_MAP, Sky->skyboxtex());
  glUniform1i(texHandle, 0);

  // Render the Skybox
  glBindVertexArray(water->watervao());

  // MITCH - TODO COnsider changing this to triangles, whichever gives most FPS
  glDrawElements(GL_TRIANGLE_STRIP, water->water_index_count(), GL_UNSIGNED_INT, 0 );
  glDisable(GL_BLEND);
{'fraction_non_alphanumeric': 0.13921009160534614, 'fraction_numerical': 0.01772037843520048, 'mean_word_length': 4.358004827031376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1486184', 'n_tokens_mistral': 2374, 'n_tokens_neox': 2242, 'n_words': 576}