本文整理汇总了C++中Quad::Render方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::Render方法的具体用法?C++ Quad::Render怎么用?C++ Quad::Render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::Render方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
HRESULT FXAAPostProcess::Render(ID3D11DeviceContext* pd3dImmediateContext, ID3D11ShaderResourceView* src,
ID3D11RenderTargetView* dstRTV, Camera* camera, GBuffer* gBuffer, ParticleBuffer* pBuffer, LightBuffer* lightBuffer)
{
BEGIN_EVENT_D3D(L"FXAA");
HRESULT hr;
D3D11_MAPPED_SUBRESOURCE mappedResource;
// Map the properties and set them
V_RETURN(pd3dImmediateContext->Map(_propertiesBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource));
CB_FXAA_PROPERTIES* properties = (CB_FXAA_PROPERTIES*)mappedResource.pData;
properties->InverseSceneSize = _invSceneSize;
properties->Subpixel = _subpixel;
properties->EdgeThreshold = _edgeThreshold;
properties->EdgeThresholdMin = _edgeThresholdMin;
pd3dImmediateContext->Unmap(_propertiesBuffer, 0);
pd3dImmediateContext->PSSetConstantBuffers(0, 1, &_propertiesBuffer);
// Set the sampler
ID3D11SamplerState* samplers[1] = { GetSamplerStates()->GetLinearClamp() };
pd3dImmediateContext->PSSetSamplers(0, 1, samplers);
// Set the other states
pd3dImmediateContext->OMSetDepthStencilState(GetDepthStencilStates()->GetDepthDisabled(), 0);
float blendFactor[4] = {1, 1, 1, 1};
pd3dImmediateContext->OMSetBlendState(GetBlendStates()->GetBlendDisabled(), blendFactor, 0xFFFFFFFF);
// Set the render target
pd3dImmediateContext->OMSetRenderTargets(1, &dstRTV, NULL);
// Set the resources
pd3dImmediateContext->PSSetShaderResources(0, 1, &src);
// Render the quad
Quad* fsQuad = GetFullScreenQuad();
V_RETURN(fsQuad->Render(pd3dImmediateContext, _fxaaPSs[_qualityIndex]->PixelShader));
// Unset the resources
ID3D11ShaderResourceView* ppSRVNULL[1] = { NULL };
pd3dImmediateContext->PSSetShaderResources(0, 1, ppSRVNULL);
END_EVENT_D3D(L"");
return S_OK;
}
示例2: main
int main(void)
{
GLFWwindow* window;
camera = new Camera();
fov = 67;
con = 0.0;
int width, height;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
exit(EXIT_FAILURE);
window = glfwCreateWindow(1600, 900, "Simple example", glfwGetPrimaryMonitor(), NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glewInit();
glfwSetKeyCallback(window, key_callback);
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDisable(GL_CULL_FACE);
Quad* quad = new Quad;
Shader * geom = new Shader("geometry.vert", "geometry.frag");
geom->setAttribute(0, "point");
geom->linkProgram();
geom->bind();
geom->unbind();
float deltaTime = float(0.005);
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDepthMask(GL_TRUE);
camera->Update();
geom->bind();
geom->passUniform(camera->position, "position");
geom->passUniform(camera->direction, "direction");
geom->passUniform(camera->upVector, "upVector");
geom->passUniform(camera->viewMatrix, "viewMatrix");
geom->passUniform(camera->projectionMatrix, "projectionMatrix");
geom->passUniform(con, "con");
quad->Render();
geom->unbind();
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
for (int i = 0; i < wave.size(); ++i) {
mat3 tangentSpace(wave[i].bitangent, wave[i].normal, wave[i].tangent);
float previousDistance = wave[i].distance;
wave[i].position += tangentSpace * wave[i].direction * deltaTime;
wave[i].distance = sdTorus(wave[i].position);
wave[i].position += wave[i].normal * wave[i].distance;
wave[i].normal = getNormal(wave[i].position);
vec3 tangent, bitangent, normal;
vec3 position = wave[i].position;
normal = wave[i].normal;
mat4 rotation = glm::rotate(0.05f, vec3(0, 1.0, 0));
vec3 delta = vec3( rotation*vec4(position, 1.0) );
tangent = delta - wave[i].position;
tangent = normalize(tangent);
bitangent = cross(tangent, normal);
wave[i].bitangent = bitangent;
wave[i].tangent = tangent;
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(67.3801, (GLfloat)1600.0 / (GLfloat)900.0, 0.5, 50.0);
//.........这里部分代码省略.........
示例3: Render
HRESULT MLAAPostProcess::Render(ID3D11DeviceContext* pd3dImmediateContext, ID3D11ShaderResourceView* src,
ID3D11RenderTargetView* dstRTV, Camera* camera, GBuffer* gBuffer, ParticleBuffer* pBuffer,LightBuffer* lightBuffer)
{
BEGIN_EVENT_D3D(L"MLAA");
HRESULT hr;
D3D11_MAPPED_SUBRESOURCE mappedResource;
// Prepare all the settings and map them
V_RETURN(pd3dImmediateContext->Map(_mlaaPropertiesBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource));
CB_MLAA_PROPERTIES* properties = (CB_MLAA_PROPERTIES*)mappedResource.pData;
properties->InverseSceneSize = XMFLOAT2(1.0f / _textureWidth, 1.0f / _textureHeight);
properties->DepthThreshold = _depthThreshold;
properties->NormalThreshold = _normalThreshold;
properties->LuminanceThreshold = _luminanceThreshold;
properties->CameraNearClip = camera->GetNearClip();
properties->CameraFarClip = camera->GetFarClip();
properties->MaxSearchSteps = _maxSearchSteps;
pd3dImmediateContext->Unmap(_mlaaPropertiesBuffer, 0);
// Set all the device states
ID3D11SamplerState* samplers[2] =
{
GetSamplerStates()->GetPointClamp(),
GetSamplerStates()->GetLinearClamp(),
};
pd3dImmediateContext->PSSetSamplers(0, 2, samplers);
float blendFactor[4] = {0, 0, 0, 0};
pd3dImmediateContext->OMSetBlendState(GetBlendStates()->GetBlendDisabled(), blendFactor, 0xFFFFFFFF);
Quad* fsQuad = GetFullScreenQuad();
// Render the edge detection
BEGIN_EVENT_D3D(L"Edge Detection");
pd3dImmediateContext->OMSetRenderTargets(1, &_edgeDetectRTV, _dsv);
// Clear the RT since the edge detection makes use of discard
const float clearColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
pd3dImmediateContext->ClearRenderTargetView(_edgeDetectRTV, clearColor);
pd3dImmediateContext->ClearDepthStencilView(_dsv, D3D11_CLEAR_STENCIL, 0.0f, 0x00);
pd3dImmediateContext->OMSetDepthStencilState(GetDepthStencilStates()->GetStencilReplace(), 0xFFFFFFFF);
ID3D11ShaderResourceView* ppSRVEdgeDetect[3] =
{
_depthDetect ? gBuffer->GetDepthSRV() : NULL,
_normalDetect ? gBuffer->GetNormalSRV() : NULL,
_luminanceDetect ? gBuffer->GetDiffuseSRV() : NULL,
};
pd3dImmediateContext->PSSetShaderResources(0, 3, ppSRVEdgeDetect);
pd3dImmediateContext->PSSetConstantBuffers(0, 1, &_mlaaPropertiesBuffer);
ID3D11PixelShader* _curEdgePS = _edgeDetectPSs[_depthDetect ? 1 : 0][_normalDetect ? 1 : 0][_luminanceDetect ? 1 : 0]->PixelShader;
V_RETURN(fsQuad->Render(pd3dImmediateContext, _curEdgePS));
END_EVENT_D3D(L"");
// Render blend weights
BEGIN_EVENT_D3D(L"Calculate Blend Weights");
// Determine which pixel shader and weight texture to use, max search steps must be <= than
// (max_distance - 1) / 2
UINT weightTexIdx = 0;
for (UINT i = 0; i < NUM_WEIGHT_TEXTURES; i++)
{
if (_maxSearchSteps >= (WEIGHT_TEXTURE_SIZES[i] - 1) / 2)
{
weightTexIdx = i;
}
}
pd3dImmediateContext->OMSetRenderTargets(1, &_blendWeightRTV, _dsv);
pd3dImmediateContext->ClearRenderTargetView(_blendWeightRTV, clearColor);
pd3dImmediateContext->OMSetDepthStencilState(GetDepthStencilStates()->GetStencilEqual(), 0xFFFFFFFF);
ID3D11ShaderResourceView* ppSRVBlendWeight[3] =
{
_edgeDetectSRV,
_weightSRVs[weightTexIdx]->ShaderResourceView,
NULL
};
pd3dImmediateContext->PSSetShaderResources(0, 3, ppSRVBlendWeight);
V_RETURN(fsQuad->Render(pd3dImmediateContext, _blendWeightPSs[weightTexIdx]->PixelShader));
END_EVENT_D3D(L"");
// Copy src into dst
BEGIN_EVENT_D3D(L"Background Copy");
pd3dImmediateContext->OMSetRenderTargets(1, &dstRTV, _dsv);
pd3dImmediateContext->OMSetDepthStencilState(GetDepthStencilStates()->GetDepthDisabled(), 0);
//.........这里部分代码省略.........