當前位置: 首頁>>代碼示例>>C++>>正文


C++ Technique::index_count方法代碼示例

本文整理匯總了C++中Technique::index_count方法的典型用法代碼示例。如果您正苦於以下問題:C++ Technique::index_count方法的具體用法?C++ Technique::index_count怎麽用?C++ Technique::index_count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Technique的用法示例。


在下文中一共展示了Technique::index_count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: render

bool SplineTest::render() {
  ADD_PROFILE_SCOPE();
  _ctx->begin_frame();

  int w = GRAPHICS.width();
  int h = GRAPHICS.height();

  KASSERT(w && h);

  XMFLOAT4X4 worldViewProj;
  XMMATRIX xWorldViewProj = XMMatrixMultiply(XMLoadFloat4x4(&_view), XMLoadFloat4x4(&_proj));
  XMStoreFloat4x4(&worldViewProj, XMMatrixMultiply(XMLoadFloat4x4(&_view), XMLoadFloat4x4(&_proj)));
  XMFLOAT4 clipSpaceLightPos(0,100,200,1);
  XMStoreFloat4(&clipSpaceLightPos, XMVector3TransformCoord(XMLoadFloat4(&clipSpaceLightPos), xWorldViewProj));
  // divide by w -> ndc
  clipSpaceLightPos.x /= clipSpaceLightPos.w;
  clipSpaceLightPos.y /= clipSpaceLightPos.w;
  clipSpaceLightPos.z /= clipSpaceLightPos.w;

  // convert to texture space
  struct {
    XMFLOAT4 ssLight;
    XMFLOAT4 texLight;
    XMFLOAT2 screenSize;
  } cbufferLight;

  cbufferLight.texLight.x = (0.5f + 0.5f * clipSpaceLightPos.x);
  cbufferLight.texLight.y = (1.0f - (0.5f + 0.5f * clipSpaceLightPos.y));
  cbufferLight.ssLight.x = cbufferLight.texLight.x * w;
  cbufferLight.ssLight.y = cbufferLight.texLight.y * h;

  cbufferLight.screenSize = XMFLOAT2((float)w, (float)h);

  ScopedRt rtColor(w, h, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateDepthBuffer, "rtColor");
  ScopedRt rtOcclude(w, h, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateDepthBuffer, "rtOcclude");

  {
    Technique *technique;
    Shader *ps, *vs;
    setupTechnique(_ctx, _gradient_technique, true, &technique, &vs, nullptr, &ps);
    _ctx->set_cbuffer(ps->find_cbuffer("WorldToScreenSpace"), 0, ShaderType::kPixelShader, &cbufferLight, sizeof(cbufferLight));

    _ctx->set_render_target(rtColor, true);
    _ctx->draw_indexed(technique->index_count(), 0, 0);

    //_ctx->set_render_target(rtOcclude, true);
    //_ctx->draw_indexed(technique->index_count(), 0, 0);
  }


  GraphicsObjectHandle rts[] = { rtColor, rtOcclude };
  bool clear[] = { false, true };
  _ctx->set_render_targets(rts, clear, 2);

  int w4 = w/4;
  int h4 = h/4;
  ScopedRt rtMirror(w4, h4, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateDepthBuffer, "rtMirror");
  renderSplines(rtMirror);

  _ctx->set_render_target(rtColor, false);
  renderParticles();

  ScopedRt rtMirrorBlur1(w4, h4, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateUav, "rtMirrorBlur1");
  ScopedRt rtMirrorBlur2(w4, h4, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateUav, "rtMirrorBlur2");
  _blur.do_blur(4, rtMirror, rtMirrorBlur1, rtMirrorBlur2, w4, h4, _ctx);

  renderPlane(rtMirrorBlur2);

  int w2 = w/2;
  int h2 = h/2;
  ScopedRt rtDownscale(w2, h2, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv, "rtDownscale");
  ScopedRt rtBlur1(w2, h2, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateUav, "rtBlur1");
  ScopedRt rtBlur2(w2, h2, DXGI_FORMAT_R16G16B16A16_FLOAT, Graphics::kCreateSrv | Graphics::kCreateUav, "rtBlur2");

  post_process(rtOcclude, rtDownscale, _scale);
  _blur.do_blur(10, rtDownscale, rtBlur1, rtBlur2, w2, h2, _ctx);


  {
    Technique *technique;
    Shader *ps, *vs;
    setupTechnique(_ctx, _compose_technique, true, &technique, &vs, nullptr, &ps);

    _ctx->set_cbuffer(ps->find_cbuffer("WorldToScreenSpace"), 0, ShaderType::kPixelShader, &cbufferLight, sizeof(cbufferLight));

    _ctx->set_default_render_target(false);
    TextureArray arr = { rtColor, rtBlur2 };
    _ctx->set_samplers(ps->samplers());
    _ctx->set_shader_resources(arr, ShaderType::kPixelShader);

    _ctx->draw_indexed(technique->index_count(), 0, 0);
    _ctx->unset_shader_resource(0, 2, ShaderType::kPixelShader);
  }

  _ctx->end_frame();

  return true;
}
開發者ID:lundefinedl,項目名稱:kumi,代碼行數:98,代碼來源:spline_test.cpp


注:本文中的Technique::index_count方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。