本文整理汇总了C++中cl::Program::prepare方法的典型用法代码示例。如果您正苦于以下问题:C++ Program::prepare方法的具体用法?C++ Program::prepare怎么用?C++ Program::prepare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::Program
的用法示例。
在下文中一共展示了Program::prepare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tick
bool RenderThread::tick()
{
for(int i = 0; i < RenderThread::taskList.getSize(); i++)
{
if(!RenderThread::taskList[i]->invoke())
{
GlobalThread::stop = true;
}
}
RenderThread::taskList.clear();
if(RenderThread::skipRender)
{
return true;
}
GameStates::swapPendingRendering();
GameStates::GameState* state = GameStates::renderingState;
if(GLWindow::instance->rescaled)
{
glViewport(0, 0, GLWindow::instance->width, GLWindow::instance->height);
GLWindow::instance->rescaled = false;
}
normalShaderProgram->bind();
gfxu::Uniforms::camPos.set(state->cam.pos);
gfxu::Uniforms::setColor(1.0f, 1.0f, 1.0f, 1.0f);
if(GlobalThread::world.getBlock(floorf(state->cam.pos.x), floorf(state->cam.pos.y), floorf(state->cam.pos.z)) != Blocks::water)
{
glClearColor(0.5f, 0.875f, 1.0f, 1.0f);
gfxu::Uniforms::setFogColor(0.5f, 0.875f, 1.0f, 1.0f);
gfxu::Uniforms::fogDist.set(16.0f * renderDistance);
}
else
{
glClearColor(0.0f, 0.0f, 0.1f, 1.0f);
gfxu::Uniforms::setFogColor(0.0f, 0.0f, 0.1f, 1.0f);
gfxu::Uniforms::fogDist.set(16.0f);
}
gfxu::Uniforms::reset();
gfxu::Uniforms::PMS.mult(geom::Matrix::perspective(state->FOV, (float)GLWindow::instance->width / (float)GLWindow::instance->height, 0.1f, 16.0f * renderDistance));
gfxu::Uniforms::PMS.mult(geom::Matrix::rotate(state->cam.rot.x, 1.0f, 0.0f, 0.0f));
gfxu::Uniforms::PMS.mult(geom::Matrix::rotate(state->cam.rot.y, 0.0f, 1.0f, 0.0f));
gfxu::Uniforms::PMS.mult(geom::Matrix::rotate(state->cam.rot.z, 0.0f, 0.0f, 1.0f));
gfxu::Uniforms::PMS.mult(geom::Matrix::translate(-state->cam.pos.x, -state->cam.pos.y, -state->cam.pos.z));
float cScale = 1.0f + 90.0f / state->FOV;
int xCam = floorf(state->cam.pos.x / 16.0f);
int yCam = floorf(state->cam.pos.y / 16.0f);
int zCam = floorf(state->cam.pos.z / 16.0f);
geom::Matrix projectionMatrix = gfxu::Uniforms::PMS.getTopmost();
projectionMatrixBuffer.write(commandQueue, projectionMatrix.data);
const size_t global_ws_1[] = {renderDistance * 2 + 2, renderDistance * 2 + 2, renderDistance * 2 + 2};
const size_t local_ws_1[] = {1, 1, 1};
if(!program.prepare("gridTransform")) return false;
if(!program.setArgument(sizeof(const unsigned int), &renderDistance)) return false;
if(!program.setArgument(sizeof(cl_mem), &projectionMatrixBuffer)) return false;
if(!program.setArgument(sizeof(const int), &xCam)) return false;
if(!program.setArgument(sizeof(const int), &yCam)) return false;
if(!program.setArgument(sizeof(const int), &zCam)) return false;
if(!program.setArgument(sizeof(cl_mem), &boolBuffer)) return false;
if(!program.invoke(commandQueue, 3, global_ws_1, local_ws_1)) return false;
const size_t global_ws_2[] = {renderDistance * 2 + 1, renderDistance * 2 + 1, renderDistance * 2 + 1};
const size_t local_ws_2[] = {1, 1, 1};
if(!program.prepare("arrayInsideCheck")) return false;
if(!program.setArgument(sizeof(const unsigned int), &renderDistance)) return false;
if(!program.setArgument(sizeof(cl_mem), &gridBuffer)) return false;
if(!program.setArgument(sizeof(cl_mem), &boolBuffer)) return false;
if(!program.invoke(commandQueue, 3, global_ws_2, local_ws_2)) return false;
if(!gridBuffer.read(commandQueue, bGrid)) return false;
getError();
/*for(int i = 0; i <= renderDistance * 2; i++)
{
int f1 = i - renderDistance;
for(int j = 0; j <= renderDistance * 2; j++)
{
int f2 = j - renderDistance;
for(int k = 0; k <= renderDistance * 2; k++)
{
int f3 = k - renderDistance;
bGrid[i][j][k] = cube.inside((gfxu::Uniforms::PMS.getTopmost() * geom::Vector((xCam + f1) * 16.0f, (yCam + f2) * 16.0f, (zCam + f3) * 16.0f)).wDivide());
}
}
}*/
GlobalThread::world.chunkMapLock.lock();
GlobalThread::world.additionQueueLock.lock();
while(!GlobalThread::world.additionQueue.empty())
{
//.........这里部分代码省略.........