本文整理汇总了C++中RenderBuffer类的典型用法代码示例。如果您正苦于以下问题:C++ RenderBuffer类的具体用法?C++ RenderBuffer怎么用?C++ RenderBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(FrameBufferTest, instantiation)
{
FrameBuffer fbo;
Texture colorTexture(GL_TEXTURE_2D);
RenderBuffer depthRenderBuffer;
GLfloat clearColor[] = { 0.0f, 0.0f, 0.5f };
colorTexture.setStorage2D(1, GL_RGB16F, _ctx.getWindowSize().x, _ctx.getWindowSize().y);
colorTexture.set(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
colorTexture.set(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
colorTexture.set(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
colorTexture.set(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
depthRenderBuffer.setStorage(GL_DEPTH_COMPONENT, _ctx.getWindowSize().x, _ctx.getWindowSize().y);
colorTexture.bind(0);
fbo.setTexture(GL_COLOR_ATTACHMENT0, colorTexture);
fbo.setRenderBuffer(GL_DEPTH_ATTACHMENT, depthRenderBuffer);
fbo.setDrawBuffer(GL_COLOR_ATTACHMENT0);
if (!fbo.isComplete(GL_FRAMEBUFFER))
throw (std::runtime_error("bad framebuffer"));
fbo.clear<GLfloat>(GL_COLOR, 0, clearColor);
EXPECT_TRUE(fbo.isValid());
}
示例2: Render
void ShimmerEffect::Render(Effect *effect, const SettingsMap &SettingsMap, RenderBuffer &buffer) {
float oset = buffer.GetEffectTimeIntervalPosition();
int Duty_Factor = GetValueCurveInt("Shimmer_Duty_Factor", 50, SettingsMap, oset);
bool Use_All_Colors = SettingsMap.GetBool("CHECKBOX_Shimmer_Use_All_Colors", false);
float cycles = GetValueCurveDouble("Shimmer_Cycles", 1.0, SettingsMap, oset);
int colorcnt=buffer.GetColorCount();
double position = buffer.GetEffectTimeIntervalPosition(cycles);
double ColorIdx = round(position * 0.999 * (double)colorcnt);
double pos2 = position * colorcnt;
while (pos2 > 1.0) {
pos2 -= 1.0;
}
if (pos2 * 100 > Duty_Factor) {
return;
}
xlColor color;
buffer.palette.GetColor(ColorIdx, color);
for (int y=0; y<buffer.BufferHt; y++) {
for (int x=0; x<buffer.BufferWi; x++) {
if(Use_All_Colors) { // Should we randomly assign colors from palette or cycle thru sequentially?
ColorIdx=rand() % colorcnt; // Select random numbers from 0 up to number of colors the user has checked. 0-5 if 6 boxes checked
buffer.palette.GetColor(ColorIdx, color); // Now go and get the hsv value for this ColorIdx
}
buffer.SetPixel(x,y,color); // Turn pixel
}
}
}
示例3: entry
RenderBuffer* RenderBufferCache::get(GLenum format, const uint32_t width, const uint32_t height) {
RenderBuffer* buffer = NULL;
RenderBufferEntry entry(format, width, height);
ssize_t index = mCache.indexOf(entry);
if (index >= 0) {
entry = mCache.itemAt(index);
mCache.removeAt(index);
buffer = entry.mBuffer;
mSize -= buffer->getSize();
RENDER_BUFFER_LOGD("Found %s render buffer (%dx%d)",
RenderBuffer::formatName(format), width, height);
} else {
buffer = new RenderBuffer(format, width, height);
RENDER_BUFFER_LOGD("Created new %s render buffer (%dx%d)",
RenderBuffer::formatName(format), width, height);
}
buffer->bind();
buffer->allocate();
return buffer;
}
示例4: onCreate
void RenderBufferBase::onCreate(const RenderBuffer *source)
{
Inherited::onCreate(source);
if(source != NULL)
{
RenderBuffer *pThis = static_cast<RenderBuffer *>(this);
pThis->setImage(source->getImage());
}
}
示例5: NEX_NEW
RenderTargetPtr MultiRenderTarget::CreateTexture(const TargetParam& tp) {
if (tp.useAsTexture) {
RenderTexture* rt = NEX_NEW(RenderTexture());
rt->Create(TextureBase::TEXTURE_2D, tp.format, dimensions.width,
dimensions.height, 1);
return Assign(rt);
} else {
RenderBuffer* rt = NEX_NEW(RenderBuffer());
rt->Create(tp.format, dimensions.width, dimensions.height);
return Assign(rt);
}
}
示例6: CreateTexturesAndBind
void FrameBuffer::CreateTexturesAndBind()
{
// Create textures for each buffer.
for (int i = 0; i < renderBuffers.Size(); ++i)
{
RenderBuffer * rb = renderBuffers[i];
// Actually create it.
rb->CreateBuffer();
rb->CreateTexture();
// Bind them straight away too.
rb->BindTextureToFrameBuffer();
}
}
示例7: execSyncV
void RenderBufferBase::execSyncV( FieldContainer &oFrom,
ConstFieldMaskArg whichField,
AspectOffsetStore &oOffsets,
ConstFieldMaskArg syncMode,
const UInt32 uiSyncInfo)
{
RenderBuffer *pThis = static_cast<RenderBuffer *>(this);
pThis->execSync(static_cast<RenderBuffer *>(&oFrom),
whichField,
oOffsets,
syncMode,
uiSyncInfo);
}
示例8: RenderOn
void MusicEffect::RenderOn(RenderBuffer &buffer, int x, int bars, int startNote, int endNote, std::list<MusicEvent*>& events, int colourTreatment, bool fade)
{
int event = -1;
for (auto it = events.begin(); it != events.end(); ++it)
{
event++;
if ((*it)->IsEventActive(buffer.curPeriod))
{
float progress = (*it)->OffsetInDuration(buffer.curPeriod);
for (int y = 0; y < buffer.BufferHt; y++)
{
xlColor c = xlWHITE;
float proportion = (float)y / (float)buffer.BufferHt;
if (colourTreatment == 1)
{
// distinct
float percolour = 1.0 / (float)buffer.GetColorCount();
for (int i = 0; i < buffer.GetColorCount(); i++)
{
if (proportion <= ((float)i + 1.0)*percolour)
{
buffer.palette.GetColor(i, c);
break;
}
}
}
else if (colourTreatment == 2)
{
// blend
buffer.GetMultiColorBlend(proportion, false, c);
}
else if (colourTreatment == 3)
{
buffer.palette.GetColor(event % buffer.GetColorCount(), c);
}
if (fade)
{
c.alpha = (1.0 - progress) * 255;
}
buffer.SetPixel(x, y, c);
}
}
}
}
示例9: set_pixel_if_not_color
static void set_pixel_if_not_color(RenderBuffer &buffer, int x, int y, xlColor toColor, xlColor notColor, bool wrapx, bool wrapy)
{
int adjx = x;
int adjy = y;
if (x < 0) {
if (wrapx) {
adjx += buffer.BufferWi;
}
else {
return;
}
}
else if (x >= buffer.BufferWi) {
if (wrapx) {
adjx -= buffer.BufferWi;
}
else {
return;
}
}
if (y < 0) {
if (wrapy) {
adjy += buffer.BufferHt;
}
else {
return;
}
}
else if (y >= buffer.BufferHt) {
if (wrapy) {
adjy -= buffer.BufferHt;
}
else {
return;
}
}
// strip off alpha when comparing
if (buffer.GetTempPixel(adjx, adjy).GetRGB() != notColor.GetRGB()) {
buffer.SetPixel(adjx, adjy, toColor);
}
}
示例10: setRenderBuffer
void FrameBuffer::setRenderBuffer(RenderBuffer& renderBuffer, Attachment attachment)
{
assert(_isBound);
glFramebufferRenderbuffer(
static_cast<GLuint>(_target),
static_cast<GLuint>(attachment),
GL_RENDERBUFFER,
renderBuffer.handle()
);
}
示例11: possible_downward_moves
int static possible_downward_moves(RenderBuffer &buffer, int x, int y)
{
int moves = 0;
// no moves possible from bottom row
if (y == 0) {
return 0;
}
if (buffer.GetTempPixel(x-1 < 0 ? x-1+buffer.BufferWi : x-1, y-1) == xlBLACK) {
moves += 1;
}
if (buffer.GetTempPixel(x, y-1) == xlBLACK) {
moves += 2;
}
if (buffer.GetTempPixel(x+1 >= buffer.BufferWi ? x+1-buffer.BufferWi : x+1, y-1) == xlBLACK) {
moves += 4;
}
return moves;
}
示例12: RenderMorph
void MusicEffect::RenderMorph(RenderBuffer &buffer, int x, int bars, int startNote, int endNote, std::list<MusicEvent*>& events, int colourTreatment, bool bounce, bool fade)
{
bool up = true;
int event = -1;
for (auto it = events.begin(); it != events.end(); ++it)
{
event++;
up = !up;
if ((*it)->IsEventActive(buffer.curPeriod))
{
float progress = (*it)->OffsetInDuration(buffer.curPeriod);
int length = buffer.BufferHt;
int start = -1 * length + progress * 2 * length + 1;
int end = start + length;
for (int y = std::max(0, start); y < std::min(end, buffer.BufferHt); y++)
{
xlColor c = xlWHITE;
float proportion = ((float)end - (float)y) / (float)length;
if (colourTreatment == 1)
{
// distinct
float percolour = 1.0 / (float)buffer.GetColorCount();
for (int i = 0; i < buffer.GetColorCount(); i++)
{
if (proportion <= ((float)i + 1.0)*percolour)
{
buffer.palette.GetColor(i, c);
break;
}
}
}
else if (colourTreatment == 2)
{
// blend
buffer.GetMultiColorBlend(proportion, false, c);
}
else if (colourTreatment == 3)
{
buffer.palette.GetColor(event % buffer.GetColorCount(), c);
}
if (fade)
{
c.alpha = (1.0 -proportion) * 255;
}
if (up || !bounce)
{
buffer.SetPixel(x, y, c);
}
else
{
buffer.SetPixel(x, buffer.BufferHt - y - 1, c);
}
}
}
}
}
示例13: Piano_update_bkg
//update previous bkg:
//if it's a scrolling piano, scroll previous notes up one row
//for eqbars, shorten them
void PianoRenderCache::Piano_update_bkg(RenderBuffer &buffer, int Style, wxSize& canvas, int rowh)
{
debug_function(10);
debug(1, "style %d", Style);
xlColor c;
//TODO: should use GDI+ functions on Windows
//TODO: use GetData for better performance; probably doesn't matter since grid is fairly small (as compared to normal images or screen canvas)
//TODO: speed
switch (Style)
{
case -1: //initialize
debug_more(5, ", init canvas %d x %d", canvas.x, canvas.y);
// PrevRender.clear(); //start with blank canvas
// PrevRender.resize(canvas.x * cnavas.y); //set all pixels off
for (int x = 0; x < canvas.x; ++x)
for (int y = 0; y < canvas.y; ++y)
buffer.SetPixel(x, y, c); //clear all (background canvas is persistent while piano effect is active)
return;
case PIANO_STYLE_SCROLLING: //scroll up one row
debug_more(5, ", scroll %d x %d up by %d", canvas.x, canvas.y, rowh);
for (int x = 0; x < canvas.x; ++x)
for (int y = 0; y < canvas.y; ++y)
if (y < canvas.y - rowh) {
debug_more(30, ", (%d,%d)->(%d,%d)", x, canvas.y - y - rowh - 1, x, canvas.y - y - 1);
buffer.CopyPixel(x, canvas.y - y - rowh - 1, x, canvas.y - y - 1);
} else {
debug_more(30, ", (%d,%d)<-0", x, canvas.y - y - 1);
buffer.SetPixel(x, canvas.y - y - 1, c); //clear bottom row, scroll others
}
return;
case PIANO_STYLE_EQBARS: //scroll down one row (decaying bars)
debug_more(5, ", scroll %d x %d down by %d", canvas.x, canvas.y, rowh);
// c.Set(255, 255, 255); //debug
for (int x = 0; x < canvas.x; ++x)
for (int y = 0; y < canvas.y; ++y)
if (y < canvas.y - rowh) {
debug_more(30, ", (%d,%d)->(%d,%d)", x, y + rowh, x, y);
buffer.CopyPixel(x, y + rowh, x, y);
} else {
debug_more(30, ", (%d,%d)<-0", x, y);
buffer.SetPixel(x, y, c); //clear top row, scroll other rows
}
return;
case PIANO_STYLE_ICICLES: //scroll down one pixel (drip)
debug_more(5, ", scroll %d x %d", canvas.x, canvas.y);
for (int x = 0; x < canvas.x; ++x)
for (int y = 0; y < canvas.y; ++y)
if (y < canvas.y - 1) {
debug_more(30, ", (%d,%d)->(%d,%d)", x, y + 1, x, y);
buffer.CopyPixel(x, y + 1, x, y);
}
// else { debug_more(30, ", (%d,%d)<-0", x, y); buffer.SetPixel(x, y, c); } //clear top pixel, scroll other pixels
return;
default:
debug_more(5, ", no scrolling");
}
}
示例14: Piano_load_shapes
//all shapes are loaded from same image file to reduce file I/O and caching
//thiss also allows animated images to be self-contained
void PianoRenderCache::Piano_load_shapes(RenderBuffer &buffer, const wxString& filename)
{
debug_function(10); //Debug debug("load_shapes('%s')", (const char*)filename.c_str());
debug(1, "load shapes file '%s'", (const char*)filename.c_str());
//reload shapes even if file name hasn't changed; color map might be different now
// if (!CachedShapeFilename.CmpNoCase(filename)) { debug_more(2, ", no change"); return; } //no change
if (!wxFileExists(filename)) return;
Piano_flush_shapes(); //invalidate cached data
if (!Shapes.LoadFile(filename, wxBITMAP_TYPE_ANY, 0) || !Shapes.IsOk())
{
//wxMessageBox("Error loading image file: "+NewPictureName);
Shapes.Clear();
return;
}
if (buffer.GetColorCount() < 2) return; //use colors from shapes file if no user-selected colors
// int imgwidth=image.GetWidth();
// int imght =image.GetHeight();
// std::hash_map<WXCOLORREF, int> palcounts;
//TODO: use wxImage.GetData for better performance?
//TODO: use multiple images within same file?
for (int y = Shapes.GetHeight() - 1; y >= 0; --y) //bottom->top
for (int x = 0; x < Shapes.GetWidth(); ++x) //left->right
if (!Shapes.IsTransparent(x, y))
{
xlColor color, mapped;
color.Set(Shapes.GetRed(x, y), Shapes.GetGreen(x, y), Shapes.GetBlue(x, y));
if (ColorMap.find(color.GetRGB()) != ColorMap.end()) continue; //already saw this color
buffer.palette.GetColor(ColorMap.size() % buffer.GetColorCount(), mapped); //assign user-selected colors to shape palette sequentially, loop if run out of colors
debug(10, "shape color[%d] 0x%x => user-selected color [%d] 0x%x", ColorMap.size(), color.GetRGB(), ColorMap.size() % GetColorCount(), mapped.GetRGB());
ColorMap[color.GetRGB()] = mapped; //.GetRGB();
// ShapePalette.push_back(c.GetRGB()); //keep a list of unique colors in order of occurrence from origin L-R, B-T
}
debug(2, "w %d, h %d, #colors %d", Shapes.GetWidth(), Shapes.GetHeight(), ColorMap.size());
CachedShapeFilename = filename; //don't load same file again
}
示例15: Draw_arm
void PinwheelEffect::Draw_arm(RenderBuffer &buffer,
int base_degrees,int max_radius,int pinwheel_twist,
const xlColor &rgb,int xc_adj,int yc_adj)
{
float r,phi;
int x,y,xc,yc;
float pi_180 = M_PI/180;
int degrees_twist,degrees;
xc= (int)(buffer.BufferWi/2);
yc= (int)(buffer.BufferHt/2);
xc = xc + (xc_adj/100.0)*xc; // xc_adj is from -100 to 100
yc = yc + (yc_adj/100.0)*yc;
for(r=0.0; r<=max_radius; r+=0.5)
{
degrees_twist=(r/max_radius)*pinwheel_twist;
degrees = base_degrees + degrees_twist;
phi = degrees * pi_180;
x = r * buffer.cos (phi) + xc;
y = r * buffer.sin (phi) + yc;
buffer.SetPixel(x, y, rgb);
}
}