本文整理汇总了C++中GLShader::SetUniform方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::SetUniform方法的具体用法?C++ GLShader::SetUniform怎么用?C++ GLShader::SetUniform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLShader
的用法示例。
在下文中一共展示了GLShader::SetUniform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: window
//.........这里部分代码省略.........
glm::vec3 v[] =
{
glm::vec3( 1.0f, 1.0f, 0.0f),
glm::vec3(-1.0f, 1.0f, 0.0f),
glm::vec3(-1.0f, -1.0f, 0.0f),
glm::vec3( 1.0f, -1.0f, 0.0f)
};
GLuint i[] =
{
0, 1, 2,
2, 3, 0
};
positionVbo.AddStatic(12, &v[0].x);
vao.Add(GLDefaultVertexAttribute::Position, &positionVbo);
ibo.AddStatic(6, i);
// ------------------------------------------------------------
double fps = 0.0;
double timeSum = 0.0;
double prevTime = GLTestUtil::CurrentTimeMilli();
int frameCount = 0;
double start = GLTestUtil::CurrentTimeMilli();
float xcparam = -0.8f;
float ycparam = 0.165f;
float inc = 0.001f;
while (window.ProcessEvent())
{
// ------------------------------------------------------------
double currentTime = GLTestUtil::CurrentTimeMilli();
double elapsedTime = currentTime - prevTime;
timeSum += elapsedTime;
frameCount++;
if (frameCount >= 13)
{
fps = 1000.0 * 13.0 / timeSum;
timeSum = 0.0;
frameCount = 0;
}
prevTime = currentTime;
window.SetTitle((boost::format("GLInteropTest_Julia [FPS %.1f]") % fps).str());
// ------------------------------------------------------------
double elapsed = GLTestUtil::CurrentTimeMilli() - start;
if (elapsed >= 1000.0)
{
break;
}
xcparam += inc;
if (xcparam > -0.799f || xcparam < -0.811f)
{
inc *= -1.0f;
}
// ------------------------------------------------------------
HandleCudaError(cudaGraphicsMapResources(1, &cudaPbo, NULL));
// Get device pointer
uchar4* devPtr;
size_t bufferSize;
HandleCudaError(cudaGraphicsResourceGetMappedPointer((void**)&devPtr, &bufferSize, cudaPbo));
Run_GLInteropTestJuliaKernel(bufWidth, bufHeight, prop.multiProcessorCount, xcparam, ycparam, devPtr);
HandleCudaError(cudaGraphicsUnmapResources(1, &cudaPbo, NULL));
texture.Replace(&pbo, glm::ivec4(0, 0, bufWidth, bufHeight), GL_RGBA, GL_UNSIGNED_BYTE);
// ------------------------------------------------------------
glClearBufferfv(GL_COLOR, 0, glm::value_ptr(glm::vec4(0.0f)));
glViewportIndexedfv(0, glm::value_ptr(glm::vec4(0, 0, width, height)));
shader.Begin();
shader.SetUniform("tex", 0);
texture.Bind();
vao.Draw(GL_TRIANGLES, &ibo);
texture.Unbind();
shader.End();
context.SwapBuffers();
}
cudaDeviceReset();
}
catch (const GLException& e)
{
FAIL() << GLTestUtil::PrintGLException(e);
}
}