本文整理汇总了C++中vec2i::square方法的典型用法代码示例。如果您正苦于以下问题:C++ vec2i::square方法的具体用法?C++ vec2i::square怎么用?C++ vec2i::square使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec2i
的用法示例。
在下文中一共展示了vec2i::square方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genNoiseTexture
Texture::Pointer TextureFactory::genNoiseTexture(const vec2i& size, bool norm, const std::string& id)
{
DataStorage<vec4ub> randata(size.square());
for (size_t i = 0; i < randata.size(); ++i)
{
vec4 rand_f = vec4(randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f),
randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f));
if (norm)
rand_f.xyz().normalize();
randata[i].x = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.x, 0.0f, 1.0f));
randata[i].y = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.y, 0.0f, 1.0f));
randata[i].z = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.z, 0.0f, 1.0f));
randata[i].w = static_cast<unsigned char>(255.0f * clamp(0.5f + 0.5f * rand_f.w, 0.0f, 1.0f));
}
TextureDescription::Pointer desc = TextureDescription::Pointer::create();
desc->data = BinaryDataStorage(4 * size.square());
desc->target = TextureTarget::Texture_2D;
desc->internalformat = TextureFormat::RGBA;
desc->format = TextureFormat::RGBA;
desc->type = DataType::UnsignedChar;
desc->size = size;
desc->mipMapCount = 1;
desc->layersCount = 1;
desc->bitsPerPixel = 32;
etCopyMemory(desc->data.data(), randata.data(), randata.dataSize());
return Texture::Pointer::create(renderContext(), desc, id, false);
}
示例2: genNoiseTexture
Texture TextureFactory::genNoiseTexture(const vec2i& size, bool norm, const std::string& id)
{
DataStorage<vec4ub> randata(size.square());
for (size_t i = 0; i < randata.size(); ++i)
{
vec4 rand_f = vec4(randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f),
randomFloat(-1.0f, 1.0f), randomFloat(-1.0f, 1.0f));
randata[i] = vec4f_to_4ub(norm ? vec4(rand_f.xyz().normalize(), rand_f.w) : rand_f);
}
TextureDescription::Pointer desc(new TextureDescription);
desc->data = BinaryDataStorage(4 * size.square());
desc->target = GL_TEXTURE_2D;
desc->format = GL_RGBA;
desc->internalformat = GL_RGBA;
desc->type = GL_UNSIGNED_BYTE;
desc->size = size;
desc->mipMapCount = 1;
desc->layersCount = 1;
desc->bitsPerPixel = 32;
etCopyMemory(desc->data.data(), randata.data(), randata.dataSize());
return Texture(new TextureData(renderContext(), desc, id, false));
}
示例3: readFramebufferData
void Renderer::readFramebufferData(const vec2i& size, TextureFormat format, DataType dataType, BinaryDataStorage& data)
{
ET_ASSERT((8 * data.size()) >= (size.square() * bitsPerPixelForTextureFormat(format, dataType)));
glReadPixels(0, 0, size.x, size.y, textureFormatValue(format), dataTypeValue(dataType), data.data());
checkOpenGLError("glReadPixels");
}
示例4: applicationDidLoad
void MainController::applicationDidLoad(et::RenderContext* rc)
{
#if (ET_PLATFORM_WIN)
application().pushSearchPath("..\\Data");
application().pushSearchPath("Q:\\SDK\\");
application().pushSearchPath("Q:\\SDK\\Models");
application().pushSearchPath("Q:\\SDK\\Textures");
#elif (ET_PLATFORM_MAC)
application().pushSearchPath("/Volumes/Development/SDK");
application().pushSearchPath("/Volumes/Development/SDK/Models");
application().pushSearchPath("/Volumes/Development/SDK/Textures");
#endif
_scene.options.bounces = _productionBounces;
_scene.options.samples = _productionSamples;
_scene.options.exposure = 1.0f;
updateTitle();
rc->renderState().setDepthMask(false);
rc->renderState().setDepthTest(false);
_scene.load(rc);
_textureData.resize(frameSize.square());
_textureData.fill(255);
_outputFunction = [this](const vec2i& pixel, const vec4& color) mutable
{
size_t index = pixel.x + pixel.y * frameSize.x;
_textureData[index].x = static_cast<unsigned char>(255.0f * clamp(color.x, 0.0f, 1.0f));
_textureData[index].y = static_cast<unsigned char>(255.0f * clamp(color.y, 0.0f, 1.0f));
_textureData[index].z = static_cast<unsigned char>(255.0f * clamp(color.z, 0.0f, 1.0f));
};
BinaryDataStorage textureData(reinterpret_cast<unsigned char*>(_textureData.binary()), _textureData.dataSize());
_result = rc->textureFactory().genTexture(TextureTarget::Texture_2D, TextureFormat::RGBA, frameSize,
TextureFormat::RGBA, DataType::UnsignedChar, textureData, "result-texture");
_cameraAngles.setValue(cameraInitialAngles);
_cameraAngles.setTargetValue(cameraInitialAngles);
_cameraAngles.finishInterpolation();
_cameraAngles.updated.connect([this]()
{
updateCamera();
startRender(true);
});
updateCamera();
_cameraAngles.run();
_gestures.pointerPressed.connect([this](et::PointerInputInfo)
{ startRender(true); });
_gestures.pointerReleased.connect([this](et::PointerInputInfo)
{ startRender(false); });
_gestures.drag.connect([this](et::vector2<float> d, unsigned long)
{
_cameraAngles.addTargetValue(0.1f * vec2(d.x, -d.y));
_cameraAngles.finishInterpolation();
});
for (size_t i = 0; i < numThreads; ++i)
_threads.push_back(sharedObjectFactory().createObject<RaytraceThread>(this));
Invocation([this](){ startRender(false); }).invokeInMainRunLoop();
}