当前位置: 首页>>代码示例>>C++>>正文


C++ Quad::setDrawCb方法代码示例

本文整理汇总了C++中Quad::setDrawCb方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::setDrawCb方法的具体用法?C++ Quad::setDrawCb怎么用?C++ Quad::setDrawCb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quad的用法示例。


在下文中一共展示了Quad::setDrawCb方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

void init(int argc, char** argv)
{
  g_eye = glm::vec3(0.0, 0.0, 2.0);
  g_center = glm::vec3(0, 0, 0);
  viewMatrix = glm::lookAt(g_eye, g_center, glm::vec3(0, 1, 0));
  projMatrix = glm::perspective(45.f, 1.f, 1.f, 5.f);

  Quad* q = new Quad();
  q->setDrawCb(drawQuad);
  q->setMaterialColor(glm::vec4(1.f));
  q->m_modelMatrix = glm::mat4(1.f);
  q->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * q->m_modelMatrix));
  TinyGL::getInstance()->addResource(MESH, "quad", q);

  Detector d = HARRIS;
  double thresh = 0.9;

  //Basic argument parsing.
  if(argc >= 3) {
    string param = string(argv[1]);
    if(param == "--shi-tomasi" || param == "-s")
      d = SHI_TOMASI;
    param = string(argv[2]);
    stringstream ss(param);
    ss >> thresh;
  } else if(argc == 2) {
开发者ID:Strongc,项目名称:TinyGL,代码行数:26,代码来源:main.cpp

示例2: setupGeometry

void setupGeometry()
{
  Sphere** spheres;
  Quad* screenQuad;
  Cube** bottom_box;

  bottom_box = new Cube*[5];
  for(int i = 0; i < 5; i++) {
    bottom_box[i] = new Cube();
    bottom_box[i]->setDrawCb(drawArrays);
  }

  bottom_box[0]->setMaterialColor(glm::vec4(0.4, 0.6, 0.0, 1.0));
  bottom_box[1]->setMaterialColor(glm::vec4(0, 0.8, 0.0, 1.0));
  bottom_box[2]->setMaterialColor(glm::vec4(0.6, 0, 0.0, 1.0));
  bottom_box[3]->setMaterialColor(glm::vec4(0.4, 0.6, 0.9, 1.0));
  bottom_box[4]->setMaterialColor(glm::vec4(0, 0, 0.8, 1.0));

  bottom_box[0]->m_modelMatrix = glm::translate(glm::vec3(25, 0, 25)) * glm::scale(glm::vec3(50, 0.1, 50));
  bottom_box[1]->m_modelMatrix = glm::translate(glm::vec3(25, 2.5, 0)) * glm::scale(glm::vec3(50, 5, 0.3));
  bottom_box[2]->m_modelMatrix = glm::translate(glm::vec3(50, 2.5, 25)) * glm::scale(glm::vec3(0.3, 5, 50));
  bottom_box[3]->m_modelMatrix = glm::translate(glm::vec3(25, 2.5, 50)) * glm::scale(glm::vec3(50, 5, 0.3));
  bottom_box[4]->m_modelMatrix = glm::translate(glm::vec3(0, 2.5, 25)) * glm::scale(glm::vec3(0.3, 5, 50));

  for(int i = 0; i < 5; i++) {
    bottom_box[i]->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * bottom_box[i]->m_modelMatrix));
    TinyGL::getInstance()->addResource(MESH, "bottom_box" + to_string(i), bottom_box[i]);
  }

  spheres = new Sphere*[NUM_SPHERES];
  for (int i = 0; i < NUM_SPHERES; i++) {
    spheres[i] = new Sphere(60, 60);
    spheres[i]->setDrawCb(drawSphere);
    spheres[i]->setMaterialColor(glm::vec4(1.0, 0.0, 0.0, 1.0));
  }

  for (int i = 0; i < W_SPHERES; i++) {
    for (int j = 0; j < H_SPHERES; j++) {
      spheres[i * W_SPHERES + j]->m_modelMatrix = glm::translate(glm::vec3((i+1) * 4, 1.6, (j+1) * 4)) * glm::scale(glm::vec3(1.5));
      spheres[i * W_SPHERES + j]->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * spheres[i * W_SPHERES + j]->m_modelMatrix));
    }
  }

  for (int i = 0; i < NUM_SPHERES; i++)
    TinyGL::getInstance()->addResource(MESH, "sphere" + to_string(i), spheres[i]);

  screenQuad = new Quad();
  screenQuad->setDrawCb(drawQuad);
  screenQuad->setMaterialColor(glm::vec4(0.f, 0.f, 0.f, 1.f));
  screenQuad->m_modelMatrix = glm::mat4(1.f);
  screenQuad->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * screenQuad->m_modelMatrix));
  TinyGL::getInstance()->addResource(MESH, "screenQuad", screenQuad);
}
开发者ID:Strongc,项目名称:TinyGL,代码行数:53,代码来源:main.cpp

示例3: setupGeometry

void setupGeometry()
{
  Grid* ground;
  Sphere** spheres;
  Quad* screenQuad;

  ground = new Grid(10, 10);
  ground->setDrawCb(drawGrid);
  ground->setMaterialColor(glm::vec4(0.4, 0.6, 0.0, 1.0));
  ground->m_modelMatrix = glm::scale(glm::vec3(50, 1, 50)) * glm::rotate(static_cast<float>(M_PI / 2), glm::vec3(1, 0, 0));
  ground->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * ground->m_modelMatrix));
  TinyGL::getInstance()->addResource(MESH, "ground", ground);

  spheres = new Sphere*[NUM_SPHERES];
  for (int i = 0; i < NUM_SPHERES; i++) {
    spheres[i] = new Sphere(32, 32);
    spheres[i]->setDrawCb(drawSphere);
    spheres[i]->setMaterialColor(glm::vec4(1.0, 0.0, 0.0, 1.0));
  }

  for (int i = 0; i < W_SPHERES; i++) {
    for (int j = 0; j < H_SPHERES; j++) {
      spheres[i * W_SPHERES + j]->m_modelMatrix = glm::translate(glm::vec3(i * 5, 1.5, j * 5)) * glm::scale(glm::vec3(1.5));
      spheres[i * W_SPHERES + j]->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * spheres[i * W_SPHERES + j]->m_modelMatrix));
    }
  }

  for (int i = 0; i < NUM_SPHERES; i++) {
    TinyGL::getInstance()->addResource(MESH, "sphere" + to_string(i), spheres[i]);
  }

  screenQuad = new Quad();
  screenQuad->setDrawCb(drawQuad);
  screenQuad->setMaterialColor(glm::vec4(0.f, 0.f, 0.f, 1.f));
  screenQuad->m_modelMatrix = glm::mat4(1.f);
  screenQuad->m_normalMatrix = glm::mat3(glm::inverseTranspose(viewMatrix * screenQuad->m_modelMatrix));
  TinyGL::getInstance()->addResource(MESH, "screenQuad", screenQuad);
}
开发者ID:schardong,项目名称:TinyGL,代码行数:38,代码来源:main.cpp


注:本文中的Quad::setDrawCb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。