本文整理汇总了C++中FrameBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ FrameBuffer类的具体用法?C++ FrameBuffer怎么用?C++ FrameBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrameBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IMB_exr_read_channels
void IMB_exr_read_channels(void *handle)
{
ExrHandle *data = (ExrHandle *)handle;
FrameBuffer frameBuffer;
ExrChannel *echan;
/* check if exr was saved with previous versions of blender which flipped images */
const StringAttribute *ta = data->ifile->header().findTypedAttribute <StringAttribute> ("BlenderMultiChannel");
short flip = (ta && strncmp(ta->value().c_str(), "Blender V2.43", 13) == 0); /* 'previous multilayer attribute, flipped */
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
if (echan->rect) {
if (flip)
frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)echan->rect,
echan->xstride * sizeof(float), echan->ystride * sizeof(float)));
else
frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)(echan->rect + echan->xstride * (data->height - 1) * data->width),
echan->xstride * sizeof(float), -echan->ystride * sizeof(float)));
}
else
printf("warning, channel with no rect set %s\n", echan->name);
}
data->ifile->setFrameBuffer(frameBuffer);
try {
data->ifile->readPixels(0, data->height - 1);
}
catch (const std::exception &exc) {
std::cerr << "OpenEXR-readPixels: ERROR: " << exc.what() << std::endl;
}
}
示例2: imb_save_openexr_float
static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flags)
{
const int channels = ibuf->channels;
const int is_alpha = (channels >= 4) && (ibuf->planes == 32);
const int is_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL; /* summarize */
const int width = ibuf->x;
const int height = ibuf->y;
try
{
Header header(width, height);
openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS);
openexr_header_metadata(&header, ibuf);
header.channels().insert("R", Channel(Imf::FLOAT));
header.channels().insert("G", Channel(Imf::FLOAT));
header.channels().insert("B", Channel(Imf::FLOAT));
if (is_alpha)
header.channels().insert("A", Channel(Imf::FLOAT));
if (is_zbuf)
header.channels().insert("Z", Channel(Imf::FLOAT));
FrameBuffer frameBuffer;
/* manually create ofstream, so we can handle utf-8 filepaths on windows */
OFileStream file_stream(name);
OutputFile file(file_stream, header);
int xstride = sizeof(float) * channels;
int ystride = -xstride * width;
float *rect[4] = {NULL, NULL, NULL, NULL};
/* last scanline, stride negative */
rect[0] = ibuf->rect_float + channels * (height - 1) * width;
rect[1] = (channels >= 2) ? rect[0] + 1 : rect[0];
rect[2] = (channels >= 3) ? rect[0] + 2 : rect[0];
rect[3] = (channels >= 4) ? rect[0] + 3 : rect[0]; /* red as alpha, is this needed since alpha isn't written? */
frameBuffer.insert("R", Slice(Imf::FLOAT, (char *)rect[0], xstride, ystride));
frameBuffer.insert("G", Slice(Imf::FLOAT, (char *)rect[1], xstride, ystride));
frameBuffer.insert("B", Slice(Imf::FLOAT, (char *)rect[2], xstride, ystride));
if (is_alpha)
frameBuffer.insert("A", Slice(Imf::FLOAT, (char *)rect[3], xstride, ystride));
if (is_zbuf)
frameBuffer.insert("Z", Slice(Imf::FLOAT, (char *) (ibuf->zbuf_float + (height - 1) * width),
sizeof(float), sizeof(float) * -width));
file.setFrameBuffer(frameBuffer);
file.writePixels(height);
}
catch (const std::exception &exc)
{
printf("OpenEXR-save: ERROR: %s\n", exc.what());
return (0);
}
return (1);
// printf("OpenEXR-save: Done.\n");
}
示例3: IMB_exr_write_channels
void IMB_exr_write_channels(void *handle)
{
ExrHandle *data = (ExrHandle *)handle;
FrameBuffer frameBuffer;
ExrChannel *echan;
if (data->channels.first) {
for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) {
/* last scanline, stride negative */
float *rect = echan->rect + echan->xstride * (data->height - 1) * data->width;
frameBuffer.insert(echan->name, Slice(Imf::FLOAT, (char *)rect,
echan->xstride * sizeof(float), -echan->ystride * sizeof(float)));
}
data->ofile->setFrameBuffer(frameBuffer);
try {
data->ofile->writePixels(data->height);
}
catch (const std::exception &exc) {
std::cerr << "OpenEXR-writePixels: ERROR: " << exc.what() << std::endl;
}
}
else {
printf("Error: attempt to save MultiLayer without layers.\n");
}
}
示例4: setCullState
PipeLine::PipeLine(FrameBuffer& fbo,int regsN)
:fbo_(fbo),registers_(regsN),
uniforms_((Uniforms*)registers_.regs_.data()),
worldTransform_(),
viewfrustum_(),
cam_(viewfrustum_,0.1,0.01)
{
setCullState(FT_CCW,CT_BACK);
viewfrustum_.setFrustum(90.0f,fbo.width(),fbo.height(),5,500);
//viewfrustum_.setFrustum(-400,400,-300,300,50,500);
setViewPort(fbo.width(),fbo.height(),0,0);
uniforms_->wpvMatrix_ = viewfrustum_.getProjectionViewMatrix();
using PT = Mesh::PrimitiveT;
// FIXME
//drawFunction_[PT::POLYPOINT] = &PipeLine::drawPolypoint;
//drawFunction_[PT::POLYSEGMENT_DISJOINT] = &PipeLine::drawPolylineDisjoint;
//drawFunction_[PT::POLYSEGMENT_CONTIGUOUS] = &PipeLine::drawPolylineContiguous;
//drawFunction_[PT::TRISTRIP]=
drawFunction_[PT::TRIMESH] = &PipeLine::drawTriMesh;
rasterAlgo_[RasAlgo::SCANLINE_ALGO] = &PipeLine::scanlineAlgo;
}
示例5: FrameBufferRequest
void SSAOShader::generateRandomTexture(){
// Genero un request para la nueva textura de random a crear
GraphicDeviceConstantCatalog* catalog = GraphicDevice::getInstance()->getConstantCatalog();
FrameBufferRequest* request = new FrameBufferRequest();
TextureRequest* textureRequest = new TextureRequest(4, 4, catalog->getFormatRGB(), catalog->getFormatRGB());
textureRequest->addFilterRequest(new TextureFilterRequest(catalog->getTextureMagFilterFlag(), catalog->getTextureNearestFilterFlag()));
textureRequest->addFilterRequest(new TextureFilterRequest(catalog->getTextureMinFilterFlag(), catalog->getTextureNearestFilterFlag()));
textureRequest->addFilterRequest(new TextureFilterRequest(catalog->getTextureWrapSFlag(), catalog->getTextureRepeatFlag()));
textureRequest->addFilterRequest(new TextureFilterRequest(catalog->getTextureWrapTFlag(), catalog->getTextureRepeatFlag()));
request->addTextureRequest(textureRequest);
// Consigo un fbo, dibujo en el, y vuelvo al fbo anterior
FrameBuffer* currentFbo = FrameBufferManager::getInstance()->getActiveFrameBuffer();
static FrameBuffer* randomTextureFbo = NULL;
if(randomTextureFbo != NULL){
randomTextureFbo->getOutputTextures()->at(0)->setWriteLock(false);
}
randomTextureFbo = FrameBufferManager::getInstance()->getFrameBufferAndBind(request, randomTextureFbo);
GraphicDevice::getInstance()->setViewport(0, 0, 4, 4);
RandomTextureGeneratorShader::getInstance()->draw(vec2(4, 4), 0.0f, 1.0f);
currentFbo->bind();
vec2 size = currentFbo->getOutputTextures()->at(0)->getSize();
GraphicDevice::getInstance()->setViewport(0, 0, size.x, size.y);
// Me guardo la textura (no libero el writelock del fbo, porque sino se me borra la textura)
this->randomTexture = randomTextureFbo->getOutputTextures()->at(0);
delete request;
}
示例6: lock
void
TiledRgbaOutputFile::setFrameBuffer (const Rgba *base,
size_t xStride,
size_t yStride)
{
if (_toYa)
{
Lock lock (*_toYa);
_toYa->setFrameBuffer (base, xStride, yStride);
}
else
{
size_t xs = xStride * sizeof (Rgba);
size_t ys = yStride * sizeof (Rgba);
FrameBuffer fb;
fb.insert ("R", Slice (HALF, (char *) &base[0].r, xs, ys));
fb.insert ("G", Slice (HALF, (char *) &base[0].g, xs, ys));
fb.insert ("B", Slice (HALF, (char *) &base[0].b, xs, ys));
fb.insert ("A", Slice (HALF, (char *) &base[0].a, xs, ys));
_outputFile->setFrameBuffer (fb);
}
}
示例7: parseOption
bool ProtocolDHCP::parseOption(const FrameBuffer& buffer, size_t& offset)
{
if (buffer.sizeBytes() <= offset) {
return false;
}
Poco::UInt8 type = buffer[offset];
if (type == 0xff)
{
return false;
}
if (buffer.sizeBytes() <= offset) {
return false;
}
offset++;
Poco::UInt8 length = buffer[offset];
offset++;
if (!enoughFor(buffer, offset, length)) {
return false;
}
std::string data((const char*)(buffer.begin()+offset), length);
offset += length;
_options[type] = data;
return true;
}
示例8: name
void
CompositeDeepScanLine::setFrameBuffer(const FrameBuffer& fr)
{
//
// count channels; build map between channels in frame buffer
// and channels in internal buffers
//
_Data->_channels.resize(3);
_Data->_channels[0]="Z";
_Data->_channels[1]=_Data->_zback ? "ZBack" : "Z";
_Data->_channels[2]="A";
_Data->_bufferMap.resize(0);
for(FrameBuffer::ConstIterator q=fr.begin();q!=fr.end();q++)
{
string name(q.name());
if(name=="ZBack")
{
_Data->_bufferMap.push_back(1);
}else if(name=="Z")
{
_Data->_bufferMap.push_back(0);
}else if(name=="A")
{
_Data->_bufferMap.push_back(2);
}else{
_Data->_bufferMap.push_back(_Data->_channels.size());
_Data->_channels.push_back(name);
}
}
_Data->_outputFrameBuffer=fr;
}
示例9: ReadEXR
static bool ReadEXR(const char *name, float *&rgba, int &xRes, int &yRes, bool &hasAlpha)
{
InputFile file(name);
Box2i dw = file.header().dataWindow();
xRes = dw.max.x - dw.min.x + 1;
yRes = dw.max.y - dw.min.y + 1;
half *hrgba = new half[4 * xRes * yRes];
// for now...
hasAlpha = true;
int nChannels = 4;
half *hp = hrgba - nChannels * (dw.min.x + dw.min.y * xRes);
FrameBuffer frameBuffer;
frameBuffer.insert("R", Slice(HALF, (char *)hp,
4*sizeof(half), xRes * 4 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("G", Slice(HALF, (char *)hp+sizeof(half),
4*sizeof(half), xRes * 4 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("B", Slice(HALF, (char *)hp+2*sizeof(half),
4*sizeof(half), xRes * 4 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("A", Slice(HALF, (char *)hp+3*sizeof(half),
4*sizeof(half), xRes * 4 * sizeof(half), 1, 1, 1.0));
file.setFrameBuffer(frameBuffer);
file.readPixels(dw.min.y, dw.max.y);
rgba = new float[nChannels * xRes * yRes];
for (int i = 0; i < nChannels * xRes * yRes; ++i)
rgba[i] = hrgba[i];
delete[] hrgba;
return rgba;
}
示例10: readEXRRED
void readEXRRED(const char* filename, int width, int height, float* data)
{
InputFile file(filename);
Box2i dw = file.header().dataWindow();
int size = (width)*(height);
half *rPixels = new half[size];
FrameBuffer frameBuffer;
frameBuffer.insert ("R", // name
Slice (HALF, // type
(char *) rPixels,
sizeof (*rPixels) * 1, // xStride
sizeof (*rPixels) * (width),// yStride
1, 1, // x/y sampling
0.0)); // fillValue
file.setFrameBuffer (frameBuffer);
file.readPixels (dw.min.y, dw.max.y);
for(int j=0; j<height; j++)
for(int i=0; i<width; i++) {
data[j*width+i] = rPixels[(height-1-j)*width+i];
}
delete[] rPixels;
}
示例11: main
int main() {
printf("start of program\n");
FrameBuffer FB;
FB.initAvailable();
Polygon pmouth(0, 0, 0, mouth, 18);
pmouth.setPosition(0, 0, 0);
pmouth.setMultiplication(10);
pmouth.setCenter(0, 0, 0);
pmouth.setFillColor(135, 206, 250);
static Polygon* arrStar[] = {
&pmouth
};
vector<Polygon*> star(arrStar, arrStar + sizeof(arrStar) / sizeof(arrStar[0]) );
FB.canvas();
FB.draw(star);
//FB.drawBeizer(star);
FB.render();
return 0;
}
示例12: WriteEXR
void WriteEXR(const char *name, float *frgba, int xRes, int yRes, bool hasAlpha)
{
Header header(xRes, yRes);
header.channels().insert("R", Channel (HALF));
header.channels().insert("G", Channel (HALF));
header.channels().insert("B", Channel (HALF));
if (hasAlpha)
header.channels().insert("A", Channel (HALF));
int stride = hasAlpha ? 4 : 3;
half *rgba = new half[xRes*yRes * stride];
for (int i = 0; i < xRes*yRes * stride; ++i)
rgba[i] = frgba[i];
FrameBuffer fb;
fb.insert("R", Slice(HALF, (char *)rgba, stride*sizeof(half),
stride*xRes*sizeof(half)));
fb.insert("G", Slice(HALF, (char *)rgba+sizeof(half), stride*sizeof(half),
stride*xRes*sizeof(half)));
fb.insert("B", Slice(HALF, (char *)rgba+2*sizeof(half), stride*sizeof(half),
stride*xRes*sizeof(half)));
if (hasAlpha)
fb.insert("A", Slice(HALF, (char *)rgba+3*sizeof(half), stride*sizeof(half),
stride*xRes*sizeof(half)));
OutputFile file(name, header);
file.setFrameBuffer(fb);
file.writePixels(yRes);
}
示例13: TmpID
Result_t
ASDCP::TimedText::DCSubtitleParser::h__SubtitleParser::ReadAncillaryResource(const byte_t* uuid, FrameBuffer& FrameBuf,
const IResourceResolver& Resolver) const
{
FrameBuf.AssetID(uuid);
UUID TmpID(uuid);
char buf[64];
ResourceTypeMap_t::const_iterator rmi = m_ResourceTypes.find(TmpID);
if ( rmi == m_ResourceTypes.end() )
{
DefaultLogSink().Error("Unknown ancillary resource id: %s\n", TmpID.EncodeHex(buf, 64));
return RESULT_RANGE;
}
Result_t result = Resolver.ResolveRID(uuid, FrameBuf);
if ( KM_SUCCESS(result) )
{
if ( (*rmi).second == MT_PNG )
FrameBuf.MIMEType("image/png");
else if ( (*rmi).second == MT_OPENTYPE )
FrameBuf.MIMEType("application/x-font-opentype");
else
FrameBuf.MIMEType("application/octet-stream");
}
return result;
}
示例14: renderMotionBlur
void PostProcessing::renderMotionBlur(unsigned , FrameBuffer &in_fbo, FrameBuffer &out_fbo)
{
MotionBlurProvider * const cb = (MotionBlurProvider *)irr_driver->
getCallback(ES_MOTIONBLUR);
Camera *cam = Camera::getActiveCamera();
unsigned camID = cam->getIndex();
scene::ICameraSceneNode * const camnode = cam->getCameraSceneNode();
// Calculate the kart's Y position on screen
if (cam->getKart())
{
const core::vector3df pos = cam->getKart()->getNode()->getPosition();
float ndc[4];
core::matrix4 trans = camnode->getProjectionMatrix();
trans *= camnode->getViewMatrix();
trans.transformVect(ndc, pos);
const float karty = (ndc[1] / ndc[3]) * 0.5f + 0.5f;
setMotionBlurCenterY(camID, karty);
}
else
setMotionBlurCenterY(camID, 0.5f);
out_fbo.Bind();
glClear(GL_COLOR_BUFFER_BIT);
FullScreenShader::MotionBlurShader::getInstance()->SetTextureUnits(in_fbo.getRTT()[0], irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::MotionBlurShader>(
// Todo : use a previousPVMatrix per cam, not global
cam->getPreviousPVMatrix(),
core::vector2df(0.5, 0.5),
cb->getBoostTime(cam->getIndex()) * 10, // Todo : should be framerate dependent
0.15f);
}
示例15: file
// EXR Function Definitions
COREDLL Spectrum *ReadImage(const string &name, int *width, int *height) {
try {
InputFile file(name.c_str());
Box2i dw = file.header().dataWindow();
*width = dw.max.x - dw.min.x + 1;
*height = dw.max.y - dw.min.y + 1;
half *rgb = new half[3 * *width * *height];
FrameBuffer frameBuffer;
frameBuffer.insert("R", Slice(HALF, (char *)rgb,
3*sizeof(half), *width * 3 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("G", Slice(HALF, (char *)rgb+sizeof(half),
3*sizeof(half), *width * 3 * sizeof(half), 1, 1, 0.0));
frameBuffer.insert("B", Slice(HALF, (char *)rgb+2*sizeof(half),
3*sizeof(half), *width * 3 * sizeof(half), 1, 1, 0.0));
file.setFrameBuffer(frameBuffer);
file.readPixels(dw.min.y, dw.max.y);
Spectrum *ret = new Spectrum[*width * *height];
// XXX should do real RGB -> Spectrum conversion here
for (int i = 0; i < *width * *height; ++i) {
float c[3] = { rgb[3*i], rgb[3*i+1], rgb[3*i+2] };
ret[i] = Spectrum(c);
}
delete[] rgb;
return ret;
} catch (const std::exception &e) {
Error("Unable to read image file \"%s\": %s", name.c_str(),
e.what());
return NULL;
}
}