rafal
04-26-2012, 02:28 AM
a questions are :
1) how to paint framebuffer on a screen ?
2) why rendering the same picture directly on screen is about 10 times slower than renering to frambuffer ? (i have much slower g. card than the rest)
3) im using texture from that framebuffer to display it on screen. but it is not working why ? the simple code belows. frambuffer
context is good.
void oglPlotWidget::renderOffScreen() {
makeCurrent();
fb = new QGLFramebufferObject(this->width(), this->height(), GL_TEXTURE_2D);
fb->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glViewport(0, 0, this->width(), this->height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (-0.01, 2.01, -0.01, 2.01, 0, 1);
glMatrixMode(GL_MODELVIEW);
foreach(plotCurve *curve, m_curves)
if (curve->style() == plotCurve::points)
{
QVector<SamplePointer> samples = curve->samples();
glVertexPointer(2, GL_FLOAT, sizeof(SamplePointer), samples.data() + curve->firstSample());
glColor3f(1, 0.1, 0.1);
glPointSize(10);
glDrawArrays(GL_POINTS, 0, samples.size() - curve->firstSample());
}
fb->release();
textureId = fb->texture();
delete fb;
}
and to paint just generated textureId i use :
void oglPlotWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
if(textureId)
{
glBindTexture(GL_TEXTURE_2D, textureId);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-1.0, 1.0, 0.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(1.0, 1.0, 0.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, -1.0, 0.0);
glEnd();
}
...
1) how to paint framebuffer on a screen ?
2) why rendering the same picture directly on screen is about 10 times slower than renering to frambuffer ? (i have much slower g. card than the rest)
3) im using texture from that framebuffer to display it on screen. but it is not working why ? the simple code belows. frambuffer
context is good.
void oglPlotWidget::renderOffScreen() {
makeCurrent();
fb = new QGLFramebufferObject(this->width(), this->height(), GL_TEXTURE_2D);
fb->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glViewport(0, 0, this->width(), this->height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (-0.01, 2.01, -0.01, 2.01, 0, 1);
glMatrixMode(GL_MODELVIEW);
foreach(plotCurve *curve, m_curves)
if (curve->style() == plotCurve::points)
{
QVector<SamplePointer> samples = curve->samples();
glVertexPointer(2, GL_FLOAT, sizeof(SamplePointer), samples.data() + curve->firstSample());
glColor3f(1, 0.1, 0.1);
glPointSize(10);
glDrawArrays(GL_POINTS, 0, samples.size() - curve->firstSample());
}
fb->release();
textureId = fb->texture();
delete fb;
}
and to paint just generated textureId i use :
void oglPlotWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
if(textureId)
{
glBindTexture(GL_TEXTURE_2D, textureId);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-1.0, 1.0, 0.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(1.0, 1.0, 0.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, -1.0, 0.0);
glEnd();
}
...