if (background_image)
{
// Probably need to render to frame buffer
glEnable(GL_TEXTURE_2D);
if (!png.load(background_path))
{
png.
fill(QColor(255,
255,
255,
255).
rgba());
}
// If png was read, instantiate texture parameters
GLuint bg_texture;
glGenTextures(1,&bg_texture);
glBindTexture(GL_TEXTURE_2D,bg_texture);
glTexImage2D(GL_TEXTURE_2D,0,3,png.width(),png.height(),0,GL_RGBA,GL_UNSIGNED_BYTE,png.bits());
framer.bind();
framer.
drawTexture(QRectF(0.0f,0.0f,
(float)width,
(float)height
),bg_texture
);
draw();
framer.
blitFramebuffer(0,
QRect(0,
0,width,height
),
&framer,
QRect(0,
0,width,height
),
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
framer.release();
// double distance = box_min[2] - 5;
// double pl_height = qCeil(2*qTan(15.0/180.0*PI)*(-distance));
// double pl_width = qCeil((double)width/(double)height*pl_height);
// glPushMatrix();
// glLoadIdentity();
// glColor3f(1.0f,1.0f,1.0f);
// glBegin(GL_QUADS);
// glTexCoord2i(0,0);
// glVertex3d(-pl_width/2,-pl_height/2,distance);
// glTexCoord2i(1,0);
// glVertex3d(pl_width/2,-pl_height/2,distance);
// glTexCoord2i(1,1);
// glVertex3d(pl_width/2,pl_height/2,distance);
// glTexCoord2i(0,1);
// glVertex3d(-pl_width/2,pl_height/2,distance);
// glEnd();
// glFlush();
// glPopMatrix();
}
// Accumulation Style AntiAliasing
if ((antialiasing) && (antialiasing_mode == ACCUMULATION))
{
framer.bind();
draw();
framer.
blitFramebuffer(0,
QRect(0,
0,width,height
),
&framer,
QRect(0,
0,width
*4,height
*4));
framer.release();
// float jitter[] = {0.5625,0.4375,0.0625,0.9375,0.3125,0.6875,0.6875,0.8125,
// 0.8125,0.1875,0.9375,0.5625,0.4375,0.0625,0.1875,0.3125};
// double lim = 1/scale;
// for (int j = 0; j < 16; j+=2)
// {
// // Define projection matrix
// projectionMatrix(1.0,(double)(width+jitter[j]*lim)/(double)(height+jitter[j+1]*lim),
// (enable_split_screen) ? 2.0 : 1.0);
// draw();
// glAccum(GL_ACCUM,1/8);
// }
// glAccum(GL_RETURN,1.0f);
} else {
// projectionMatrix(1.0,(double)width/(double)height,(enable_split_screen) ? 2.0 : 1.0);
draw();
}
if (background_image)
{
// Probably need to render to frame buffer
glEnable(GL_TEXTURE_2D);
QImage png;
if (!png.load(background_path))
{
png = QImage(16,16,QImage::Format_ARGB32);
png.fill(QColor(255,255,255,255).rgba());
}
png = QGLWidget::convertToGLFormat(png);
// If png was read, instantiate texture parameters
GLuint bg_texture;
glGenTextures(1,&bg_texture);
glBindTexture(GL_TEXTURE_2D,bg_texture);
glTexImage2D(GL_TEXTURE_2D,0,3,png.width(),png.height(),0,GL_RGBA,GL_UNSIGNED_BYTE,png.bits());
QGLFramebufferObject framer(width,height,QGLFramebufferObject::Depth);
framer.bind();
framer.drawTexture(QRectF(0.0f,0.0f,(float)width,(float)height),bg_texture);
draw();
framer.blitFramebuffer(0,QRect(0,0,width,height),&framer,QRect(0,0,width,height),
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
framer.release();
// double distance = box_min[2] - 5;
// double pl_height = qCeil(2*qTan(15.0/180.0*PI)*(-distance));
// double pl_width = qCeil((double)width/(double)height*pl_height);
// glPushMatrix();
// glLoadIdentity();
// glColor3f(1.0f,1.0f,1.0f);
// glBegin(GL_QUADS);
// glTexCoord2i(0,0);
// glVertex3d(-pl_width/2,-pl_height/2,distance);
// glTexCoord2i(1,0);
// glVertex3d(pl_width/2,-pl_height/2,distance);
// glTexCoord2i(1,1);
// glVertex3d(pl_width/2,pl_height/2,distance);
// glTexCoord2i(0,1);
// glVertex3d(-pl_width/2,pl_height/2,distance);
// glEnd();
// glFlush();
// glPopMatrix();
}
// Accumulation Style AntiAliasing
if ((antialiasing) && (antialiasing_mode == ACCUMULATION))
{
QGLFramebufferObject framer(width*4,height*4,QGLFramebufferObject::Depth);
framer.bind();
draw();
framer.blitFramebuffer(0,QRect(0,0,width,height),&framer,QRect(0,0,width*4,height*4));
framer.release();
// float jitter[] = {0.5625,0.4375,0.0625,0.9375,0.3125,0.6875,0.6875,0.8125,
// 0.8125,0.1875,0.9375,0.5625,0.4375,0.0625,0.1875,0.3125};
// double lim = 1/scale;
// for (int j = 0; j < 16; j+=2)
// {
// // Define projection matrix
// projectionMatrix(1.0,(double)(width+jitter[j]*lim)/(double)(height+jitter[j+1]*lim),
// (enable_split_screen) ? 2.0 : 1.0);
// draw();
// glAccum(GL_ACCUM,1/8);
// }
// glAccum(GL_RETURN,1.0f);
} else {
// projectionMatrix(1.0,(double)width/(double)height,(enable_split_screen) ? 2.0 : 1.0);
draw();
}
To copy to clipboard, switch view to plain text mode
Bookmarks