<commit_before>// This file is part of the Sculpt-VR Project.
// Licensing information can be found in the LICENSE file.
// (C) 2014 The Sculpt-VR Team. All rights reserved.

#include "common.h"
#include "framebuffer.h"

#include <../Src/OVR_CAPI_GL.h>

class SculptVR : public Leap::Listener
{
public:
  SculptVR();

  ~SculptVR()
  {
    Destroy();
  }

  void Init();
  void Run();
  void Destroy();

private:
  void HMDInit();
  void SDLCreateWindow(int width, int height, SDL_Window** window, SDL_GLContext* context, int monitor);
  void HMDConf();
  void GLInit();
  void GLDrawScene(const glm::mat4& view, const glm::mat4& proj);
  void GLRender();
  void GLCleanup();
  void RotateModel();
  void RebuildModel();
  glm::vec3 GetArcballVector(const glm::ivec2& pos);
  
  void DismissWarning();
  void onConnect(const Leap::Controller& c) {
    std::cout << "Connected to leap motion controller." << std::endl;
  }

  void onFrame(const Leap::Controller& c) {
    leftHand.tracked = false;
    rightHand.tracked = false;
    for (const auto& hand : c.frame().hands()) {
      if (leftHand.tracked || !leftHand.update(hand)) {
        rightHand.update(hand);
      }
    }
  }
private:
  volatile bool running;
  SDL_Window *window[2];
  SDL_GLContext context[2];

  //LeapMotion leap;
  Shader shPlane;
  Shader shModel;
  Shader shHand;
  Plane  msGround;
  int vpWidth = 640;
  int vpHeight = 480;
  bool mouseDown;
  glm::ivec2 mouseLast;
  glm::ivec2 mousePos;
  glm::quat viewQuat;
  glm::mat4 cameraMat;
  Volume volume;
  std::vector<Triangle> triangles;

  /// Really big VBO.
  GLuint vbo;
  /// VAO for the Really big VBO.
  GLuint vao;

  // VR Stuff
  ovrHmd hmd;
  ovrVector3f offset[2];
  ovrTexture tex[2];
  ovrEyeRenderDesc erd[2];
  Framebuffer* buffer[2];
  /// Leap motion.
  Leap::Controller controller; 

  /// Two hands. Hopefully.
  Hand leftHand;
  Hand rightHand; 
};


SculptVR::SculptVR()
  : running(false)
  , shModel("model")
  , shPlane("plane")
  , shHand("hand")
  , leftHand(Hand::Type::LEFT)
  , rightHand(Hand::Type::RIGHT)
  , msGround(20.0f, 20.0f)
  , mouseDown(false)
  , viewQuat(0, 0, 0, 1)
  , cameraMat(glm::lookAt(
      glm::vec3(7.0f, 7.0f, 7.0f),
      glm::vec3(0.0f, 0.0f, 0.0f),
      glm::vec3(0.0f, 1.0f, 0.0f)))
  , volume(128)
{
  triangles.resize(2000);
}

void SculptVR::Init()
{
  HMDInit();

  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    throw std::runtime_error("Cannot initialise SDL video.");
  }
  
  // GL hints
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
  SDL_GL_SetSwapInterval(1);<commit_msg>Flipped shit over.<commit_after>// This file is part of the Sculpt-VR Project.
// Licensing information can be found in the LICENSE file.
// (C) 2014 The Sculpt-VR Team. All rights reserved.

#include "common.h"
#include "framebuffer.h"

#include <../Src/OVR_CAPI_GL.h>

class SculptVR : public Leap::Listener
{
public:
  SculptVR();

  ~SculptVR()
  {
    Destroy();
  }

  void Init();
  void Run();
  void Destroy();

private:
  void HMDInit();
  void SDLCreateWindow(int width, int height, SDL_Window** window, SDL_GLContext* context, int monitor);
  void HMDConf();
  void GLInit();
  void GLDrawScene(const glm::mat4& view, const glm::mat4& proj);
  void GLRender();
  void GLCleanup();
  void RotateModel();
  void RebuildModel();
  glm::vec3 GetArcballVector(const glm::ivec2& pos);
  
  void DismissWarning();
  void onConnect(const Leap::Controller& c) {
    std::cout << "Connected to leap motion controller." << std::endl;
  }

  void onFrame(const Leap::Controller& c) {
    leftHand.tracked = false;
    rightHand.tracked = false;
    for (const auto& hand : c.frame().hands()) {
      if (leftHand.tracked || !leftHand.update(hand)) {
        rightHand.update(hand);
      }
    }
  }
private:
  volatile bool running;
  SDL_Window *window[2];
  SDL_GLContext context[2];

  //LeapMotion leap;
  Shader shPlane;
  Shader shModel;
  Shader shHand;
  Plane  msGround;
  int vpWidth = 640;
  int vpHeight = 480;
  bool mouseDown;
  glm::ivec2 mouseLast;
  glm::ivec2 mousePos;
  glm::quat viewQuat;
  glm::mat4 cameraMat;
  Volume volume;
  std::vector<Triangle> triangles;

  /// Really big VBO.
  GLuint vbo;
  /// VAO for the Really big VBO.
  GLuint vao;

  // VR Stuff
  ovrHmd hmd;
  ovrVector3f offset[2];
  ovrTexture tex[2];
  ovrEyeRenderDesc erd[2];
  Framebuffer* buffer[2];
  /// Leap motion.
  Leap::Controller controller; 

  /// Two hands. Hopefully.
  Hand leftHand;
  Hand rightHand; 
};


SculptVR::SculptVR()
  : running(false)
  , shModel("model")
  , shPlane("plane")
  , shHand("hand")
  , leftHand(Hand::Type::LEFT)
  , rightHand(Hand::Type::RIGHT)
  , msGround(20.0f, 20.0f)
  , mouseDown(false)
  , viewQuat(1, 0, 0, 0)
  , cameraMat(glm::lookAt(
      glm::vec3(7.0f, 7.0f, 7.0f),
      glm::vec3(0.0f, 0.0f, 0.0f),
      glm::vec3(0.0f, 1.0f, 0.0f)))
  , volume(128)
{
  triangles.resize(2000);
}

void SculptVR::Init()
{
  HMDInit();

  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    throw std::runtime_error("Cannot initialise SDL video.");
  }
  
  // GL hints
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
  SDL_GL_SetSwapInterval(1);
{'fraction_non_alphanumeric': 0.1432258064516129, 'fraction_numerical': 0.02433179723502304, 'mean_word_length': 3.6695352839931155, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 7, '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': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1800891', 'n_tokens_mistral': 2222, 'n_tokens_neox': 2094, 'n_words': 467}