本文整理汇总了C++中Framebuffer类的典型用法代码示例。如果您正苦于以下问题:C++ Framebuffer类的具体用法?C++ Framebuffer怎么用?C++ Framebuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Framebuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DiscardFramebufferEXT
void GL_APIENTRY DiscardFramebufferEXT(GLenum target, GLsizei numAttachments, const GLenum *attachments)
{
EVENT("(GLenum target = 0x%X, GLsizei numAttachments = %d, attachments = 0x%0.8p)", target, numAttachments, attachments);
Context *context = GetValidGlobalContext();
if (context)
{
if (!context->getExtensions().discardFramebuffer)
{
context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled"));
return;
}
if (!ValidateDiscardFramebufferEXT(context, target, numAttachments, attachments))
{
return;
}
Framebuffer *framebuffer = context->getState().getTargetFramebuffer(target);
ASSERT(framebuffer);
// The specification isn't clear what should be done when the framebuffer isn't complete.
// We leave it up to the framebuffer implementation to decide what to do.
Error error = framebuffer->discard(numAttachments, attachments);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
示例2:
void
SceneContext::render(Framebuffer& fb, const Rect& rect)
{
// Render all buffers
// FIXME: Render all to pbuffer for later combining of them
if (impl->use_cliprect)
{
fb.push_cliprect(impl->cliprect);
impl->color.render(fb, rect);
fb.pop_cliprect();
}
else
{
impl->color.render(fb, rect);
}
#if 0
{ // lightmap support
impl->light.render(impl->canvas.get_gc());
impl->canvas.sync_surface();
//impl->lightmap.set_blend_func(blend_src_alpha, blend_one);
impl->lightmap.set_blend_func(blend_dest_color, blend_zero);
//GL_DST_COLOR, GL_ZERO
impl->lightmap.set_scale(SCALE_FACTOR, SCALE_FACTOR);
impl->lightmap.draw();
impl->canvas.get_gc()->clear();
}
#endif
impl->highlight.render(fb, rect);
}
示例3: releaseSurface
void Context::releaseSurface()
{
Framebuffer *defaultFBO = mFramebufferMap[0];
defaultFBO->resetAttachment(GL_BACK);
defaultFBO->resetAttachment(GL_DEPTH);
defaultFBO->resetAttachment(GL_STENCIL);
}
示例4: clear
ImageWrapper& ImageWrapper::operator=(const ImageWrapper& rhs)
{
clear();
if (rhs.m_source == NONE)
{
return *this;
}
else if(rhs.getFbo())
{ // Copy the FBO
m_source = FBO;
Framebuffer* rhsFBO = rhs.getFbo();
m_fbo = std::make_shared<Framebuffer>(rhsFBO->size());
Framebuffer::blitFramebuffer(*m_fbo, *rhsFBO);
m_size = rhs.size();
}
else
{ // Create an image
m_source = IMAGE;
m_image = std::make_shared<Image>(rhs.getImage().clone());
m_size = rhs.size();
}
return *this;
}
示例5: ReadnPixelsEXT
void GL_APIENTRY ReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLsizei bufSize,
GLvoid *data)
{
EVENT("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
"GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
x, y, width, height, format, type, bufSize, data);
Context *context = GetValidGlobalContext();
if (context)
{
if (width < 0 || height < 0 || bufSize < 0)
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
if (!ValidateReadPixelsParameters(context, x, y, width, height,
format, type, &bufSize, data))
{
return;
}
Framebuffer *framebufferObject = context->getState().getReadFramebuffer();
ASSERT(framebufferObject);
Rectangle area(x, y, width, height);
Error error = framebufferObject->readPixels(context, area, format, type, data);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
示例6: make_fb
static void make_fb()
{
// tcol is a 2D RGB texsize x texsize texture
// RGB is a constant that represents 8-bit RGB texture
// See the definition of TexFormat enum in texture.h for other values allowed.
// Stencil may require new hardware/drivers to work properly.
tcol = new Texture(RGB,texsize,texsize);
// tdepth is a depth texture, i.e. it stores depth values as the values of texels.
tdepth = new Texture(Depth,texsize,texsize);
// allocate new Framebuffer
fb = new Framebuffer;
// attach color and depth textures to it; the tcol texture will play the role of color
// buffer and tdepth - of the depth buffer.
fb->attachColor(tcol);
fb->attachDepth(tdepth);
// Print out the status of the frame buffer. In particular, if the textures are of
// wrong type/format, the framebuffer will not be `complete', i.e. suitable for
// rendering into it. If this is the case, you should get a message complaining
// about it in the terminal. For example, it is wrong to use a color texture as
// the depth texture or the other way around. The restrictions are mostly common
// sense. See specification for more details.
fb->printLog();
}
示例7: blit
void
Renderbuffer::blit(Framebuffer& target_fbo)
{
blit(target_fbo,
0, 0, m_width, m_height,
0, 0, target_fbo.get_width(), target_fbo.get_height());
}
示例8: BlitFramebufferANGLE
void GL_APIENTRY BlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
{
EVENT("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
"GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
"GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateBlitFramebufferParameters(context, srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1, mask, filter,
true))
{
return;
}
Framebuffer *readFramebuffer = context->getState().getReadFramebuffer();
ASSERT(readFramebuffer);
Framebuffer *drawFramebuffer = context->getState().getDrawFramebuffer();
ASSERT(drawFramebuffer);
Rectangle srcArea(srcX0, srcY0, srcX1 - srcX0, srcY1 - srcY0);
Rectangle dstArea(dstX0, dstY0, dstX1 - dstX0, dstY1 - dstY0);
Error error = drawFramebuffer->blit(context->getState(), srcArea, dstArea, mask, filter, readFramebuffer);
if (error.isError())
{
context->recordError(error);
return;
}
}
}
示例9: this_rect
void
DrawingContext::render(Framebuffer& fb, const Rect& parent_rect)
{
Rect this_rect(Math::max(rect.left + parent_rect.left, parent_rect.left),
Math::max(rect.top + parent_rect.top, parent_rect.top),
Math::min(rect.right + parent_rect.left, parent_rect.right),
Math::min(rect.bottom + parent_rect.top, parent_rect.bottom));
if (do_clipping)
fb.push_cliprect(this_rect);
std::stable_sort(drawingrequests.begin(), drawingrequests.end(), DrawingRequestsSorter());
if (0)
{
std::cout << "<<<<<<<<<<<<<<" << std::endl;
for(DrawingRequests::iterator i = drawingrequests.begin(); i != drawingrequests.end(); ++i)
std::cout << (*i)->get_z_pos() << std::endl;
std::cout << ">>>>>>>>>>>>>>" << std::endl;
}
for(DrawingRequests::iterator i = drawingrequests.begin(); i != drawingrequests.end(); ++i)
{
//std::cout << this << ": " << (*i)->get_z_pos() << std::endl;
(*i)->render(fb, this_rect); // FIXME: Should we clip size against parent rect?
}
if (do_clipping)
fb.pop_cliprect();
}
示例10: ValidateStateQuery
bool ValidateStateQuery(gl::Context *context, GLenum pname, GLenum *nativeType, unsigned int *numParams)
{
if (!context->getQueryParameterInfo(pname, nativeType, numParams))
{
return gl::error(GL_INVALID_ENUM, false);
}
if (pname >= GL_DRAW_BUFFER0 && pname <= GL_DRAW_BUFFER15)
{
unsigned int colorAttachment = (pname - GL_DRAW_BUFFER0);
if (colorAttachment >= context->getMaximumRenderTargets())
{
return gl::error(GL_INVALID_OPERATION, false);
}
}
switch (pname)
{
case GL_TEXTURE_BINDING_2D:
case GL_TEXTURE_BINDING_CUBE_MAP:
case GL_TEXTURE_BINDING_3D:
case GL_TEXTURE_BINDING_2D_ARRAY:
if (context->getActiveSampler() >= context->getMaximumCombinedTextureImageUnits())
{
return gl::error(GL_INVALID_OPERATION, false);
}
break;
case GL_IMPLEMENTATION_COLOR_READ_TYPE:
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
{
Framebuffer *framebuffer = context->getReadFramebuffer();
ASSERT(framebuffer);
if (framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
return gl::error(GL_INVALID_OPERATION, false);
}
Renderbuffer *renderbuffer = framebuffer->getReadColorbuffer();
if (!renderbuffer)
{
return gl::error(GL_INVALID_OPERATION, false);
}
}
break;
default:
break;
}
// pname is valid, but there are no parameters to return
if (numParams == 0)
{
return false;
}
return true;
}
示例11: render
void render(Framebuffer& fb)
{
if (m_push)
{
fb.push_cliprect(m_rect);
}
else
{
fb.pop_cliprect();
}
}
示例12: render
void Renderer::render (Framebuffer& buf, size_t) {
const auto& camera = m_scene.camera ();
for (size_t x = 0; x < buf.width (); ++ x) {
for (size_t y = 0; y < buf.height (); ++ y) {
const auto dx = rng () - 0.5;
const auto dy = rng () - 0.5;
const auto ray = camera.spawnRay (x + dx, y + dy);
buf.addColour (x, y, render (ray));
}
}
}
示例13: storeFramebuffer
inline void storeFramebuffer(int resultIndex,
const FilePath& pngDir,
const FilePath& exrDir,
const FilePath& baseName,
float gamma,
const Framebuffer& framebuffer) {
// Create output directories in case they don't exist
createDirectory(pngDir.str());
createDirectory(exrDir.str());
// Path of primary output image files
FilePath pngFile = pngDir + baseName.addExt(".png");
FilePath exrFile = exrDir + baseName.addExt(".exr");
// Make a copy of the image
Image copy = framebuffer.getChannel(0);
// Store the EXR image "as is"
storeEXRImage(exrFile.str(), copy);
// Post-process copy of image and store PNG file
copy.flipY();
copy.divideByAlpha();
copy.applyGamma(gamma);
storeImage(pngFile.str(), copy);
// Store complete framebuffer as a single EXR multi layer image
auto exrFramebufferFilePath = exrDir + baseName.addExt(".bnzframebuffer.exr");
storeEXRFramebuffer(exrFramebufferFilePath.str(), framebuffer);
// Store complete framebuffer as PNG indivual files in a dediacted subdirectory
auto pngFramebufferDirPath = pngDir + "framebuffers/";
createDirectory(pngFramebufferDirPath.str());
if(resultIndex >= 0) {
pngFramebufferDirPath = pngFramebufferDirPath + toString3(resultIndex); // Split different results of the same batch in different subdirectories
}
createDirectory(pngFramebufferDirPath.str());
// Store each channel of the framebuffer
for(auto i = 0u; i < framebuffer.getChannelCount(); ++i) {
auto name = framebuffer.getChannelName(i);
// Prefix by the index of the channel
FilePath pngFile = pngFramebufferDirPath + FilePath(toString3(i)).addExt("_" + name + ".png");
auto copy = framebuffer.getChannel(i);
copy.flipY();
copy.divideByAlpha();
copy.applyGamma(gamma);
storeImage(pngFile.str(), copy);
}
}
示例14: main
int main(void) {
Framebuffer fb;
fb.drawRectangle(2,2,125,61);
fb.drawRectangle(6,6,12,12,1);
fb.show();
// Invert uses direct hardware commands
// So no need to send the framebuffer again
// => no need to fb.show();
fb.invert(1);
return 0;
}
示例15: DrawBuffersEXT
void GL_APIENTRY DrawBuffersEXT(GLsizei n, const GLenum *bufs)
{
EVENT("(GLenum n = %d, bufs = 0x%0.8p)", n, bufs);
Context *context = GetValidGlobalContext();
if (context)
{
if (n < 0 || static_cast<GLuint>(n) > context->getCaps().maxDrawBuffers)
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
ASSERT(context->getState().getDrawFramebuffer());
if (context->getState().getDrawFramebuffer()->id() == 0)
{
if (n != 1)
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
if (bufs[0] != GL_NONE && bufs[0] != GL_BACK)
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
}
else
{
for (int colorAttachment = 0; colorAttachment < n; colorAttachment++)
{
const GLenum attachment = GL_COLOR_ATTACHMENT0_EXT + colorAttachment;
if (bufs[colorAttachment] != GL_NONE && bufs[colorAttachment] != attachment)
{
context->recordError(Error(GL_INVALID_OPERATION));
return;
}
}
}
Framebuffer *framebuffer = context->getState().getDrawFramebuffer();
ASSERT(framebuffer);
framebuffer->setDrawBuffers(n, bufs);
}
}