本文整理汇总了C++中SimpleShader::use方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleShader::use方法的具体用法?C++ SimpleShader::use怎么用?C++ SimpleShader::use使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleShader
的用法示例。
在下文中一共展示了SimpleShader::use方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderView
// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void RenderView(
size_t eye //< Which eye we are rendering
,
const osvr::renderkit::RenderInfo& renderInfo //< Info needed to render
,
ID3D11RenderTargetView* renderTargetView,
ID3D11DepthStencilView* depthStencilView) {
// Make sure our pointers are filled in correctly. The config file selects
// the graphics library to use, and may not match our needs.
if (renderInfo.library.D3D11 == nullptr) {
std::cerr
<< "SetupDisplay: No D3D11 GraphicsLibrary, this should not happen"
<< std::endl;
return;
}
auto context = renderInfo.library.D3D11->context;
auto device = renderInfo.library.D3D11->device;
float projectionD3D[16];
float viewD3D[16];
XMMATRIX identity = XMMatrixIdentity();
// Set up to render to the textures for this eye
context->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
// Set the viewport to cover the fraction of our render buffer that
// this eye is responsible for. This is always the same width and
// height but shifts over by one width for each eye.
CD3D11_VIEWPORT viewport(
static_cast<float>(eye * renderInfo.viewport.width), 0,
static_cast<float>(renderInfo.viewport.width),
static_cast<float>(renderInfo.viewport.height));
context->RSSetViewports(1, &viewport);
// Make a grey background. Only clear for the first eye,
// because clear in DirectX 10 and 11 does not respect the
// boundaries of the viewport.
FLOAT colorRgba[4] = {0.3f, 0.3f, 0.3f, 1.0f};
if (eye == 0) {
context->ClearRenderTargetView(renderTargetView, colorRgba);
context->ClearDepthStencilView(
depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
}
osvr::renderkit::OSVR_PoseState_to_D3D(viewD3D, renderInfo.pose);
osvr::renderkit::OSVR_Projection_to_D3D(projectionD3D,
renderInfo.projection);
XMMATRIX _projectionD3D(projectionD3D), _viewD3D(viewD3D);
// draw room
simpleShader.use(device, context, _projectionD3D, _viewD3D, identity);
roomCube.draw(device, context);
}
示例2: DrawRightHand
void DrawRightHand(
void* userData //< Passed into AddRenderCallback
,
osvr::renderkit::GraphicsLibrary library //< Graphics library context to use
,
osvr::renderkit::RenderBuffer buffers //< Buffers to use
,
osvr::renderkit::OSVR_ViewportDescription
viewport //< Viewport we're rendering into
,
OSVR_PoseState pose //< OSVR ModelView matrix set by RenderManager
,
osvr::renderkit::OSVR_ProjectionMatrix
projection //< Projection matrix set by RenderManager
,
OSVR_TimeValue deadline //< When the frame should be sent to the screen
) {
// Make sure our pointers are filled in correctly. The config file selects
// the graphics library to use, and may not match our needs.
if (library.D3D11 == nullptr) {
std::cerr
<< "DrawRightHand: No D3D11 GraphicsLibrary, this should not happen"
<< std::endl;
return;
}
if (buffers.D3D11 == nullptr) {
std::cerr
<< "DrawRightHand: No D3D11 RenderBuffer, this should not happen"
<< std::endl;
return;
}
auto context = library.D3D11->context;
auto device = library.D3D11->device;
auto renderTargetView = buffers.D3D11->colorBufferView;
float projectionD3D[16];
float viewD3D[16];
XMMATRIX identity = XMMatrixIdentity();
osvr::renderkit::OSVR_PoseState_to_D3D(viewD3D, pose);
osvr::renderkit::OSVR_Projection_to_D3D(projectionD3D, projection);
XMMATRIX _projectionD3D(projectionD3D), _viewD3D(viewD3D);
// draw right hand
simpleShader.use(device, context, _projectionD3D, _viewD3D, identity);
handCube.draw(device, context);
}
示例3: RenderView
// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void RenderView(
const osvr::renderkit::RenderInfo& renderInfo //< Info needed to render
,
ID3D11RenderTargetView* renderTargetView,
ID3D11DepthStencilView* depthStencilView) {
// Make sure our pointers are filled in correctly. The config file selects
// the graphics library to use, and may not match our needs.
if (renderInfo.library.D3D11 == nullptr) {
std::cerr
<< "SetupDisplay: No D3D11 GraphicsLibrary, this should not happen"
<< std::endl;
return;
}
auto context = renderInfo.library.D3D11->context;
auto device = renderInfo.library.D3D11->device;
float projectionD3D[16];
float viewD3D[16];
XMMATRIX identity = XMMatrixIdentity();
// Set up to render to the textures for this eye
context->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
// Set up the viewport we're going to draw into.
CD3D11_VIEWPORT viewport(static_cast<float>(renderInfo.viewport.left),
static_cast<float>(renderInfo.viewport.lower),
static_cast<float>(renderInfo.viewport.width),
static_cast<float>(renderInfo.viewport.height));
context->RSSetViewports(1, &viewport);
// Make a grey background
FLOAT colorRgba[4] = {0.3f, 0.3f, 0.3f, 1.0f};
context->ClearRenderTargetView(renderTargetView, colorRgba);
context->ClearDepthStencilView(
depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
osvr::renderkit::OSVR_PoseState_to_D3D(viewD3D, renderInfo.pose);
osvr::renderkit::OSVR_Projection_to_D3D(projectionD3D,
renderInfo.projection);
XMMATRIX xm_projectionD3D(projectionD3D), xm_viewD3D(viewD3D);
// draw room
simpleShader.use(device, context, xm_projectionD3D, xm_viewD3D, identity);
roomCube.draw(device, context);
}
示例4: RenderView
// Callbacks to draw things in world space, left-hand space, and right-hand
// space.
void RenderView(
const OSVR_RenderInfoD3D11& renderInfo //< Info needed to render
,
ID3D11RenderTargetView* renderTargetView,
ID3D11DepthStencilView* depthStencilView) {
auto context = renderInfo.library.context;
auto device = renderInfo.library.device;
float projectionD3D[16];
float viewD3D[16];
XMMATRIX identity = XMMatrixIdentity();
// Set up to render to the textures for this eye
context->OMSetRenderTargets(1, &renderTargetView, depthStencilView);
// Set up the viewport we're going to draw into.
CD3D11_VIEWPORT viewport(static_cast<float>(renderInfo.viewport.left),
static_cast<float>(renderInfo.viewport.lower),
static_cast<float>(renderInfo.viewport.width),
static_cast<float>(renderInfo.viewport.height));
context->RSSetViewports(1, &viewport);
// Make a grey background
FLOAT colorRgba[4] = {0.3f, 0.3f, 0.3f, 1.0f};
context->ClearRenderTargetView(renderTargetView, colorRgba);
context->ClearDepthStencilView(
depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
OSVR_PoseState_to_D3D(viewD3D, renderInfo.pose);
OSVR_Projection_to_D3D(projectionD3D,
renderInfo.projection);
XMMATRIX xm_projectionD3D(projectionD3D), xm_viewD3D(viewD3D);
// draw room
simpleShader.use(device, context, xm_projectionD3D, xm_viewD3D, identity);
roomCube.draw(device, context);
}