void GUIGLView::glInit()
{
}
void GUIGLView::paintGL()
{
qglClearColor
(QColor(Qt
::black));
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// only do something if image is availible
if(mImageData.imageBuffer == NULL)
return;
QString debugString
= QString("paintGL called with buffer: 0x%1, size %2").
arg((int)mImageData.
imageBuffer,
8,
16,
QChar('0')).
arg(mImageData.
width);
qDebug(debugString.toAscii().data());
// set projection - disable z-axis
glMatrixMode(GL_PROJECTION);
//clear projection matrix
glLoadIdentity();
//Creating an orthoscopic view matrix going from -1 -> 1 in each
//dimension on the screen (x, y, z).
glOrtho(0, 640, 480, 0, -1, 1);
//Now editing the model-view matrix.
glMatrixMode(GL_MODELVIEW);
//Clearing the model-view matrix.
glLoadIdentity();
//Disabling the depth test (z will not be used to tell what object
//will be shown above another, only the order in which I draw them.)
glDisable(GL_DEPTH_TEST);
// generate a texture
glGenTextures(1, &mTextureID);
// enable texturing
glEnable(GL_TEXTURE_2D);
//specify texture to use
glBindTexture(GL_TEXTURE_2D, mTextureID);
// set texturing parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// copy image to texture
glTexImage2D(GL_TEXTURE_2D, 0, mImageData.samplesPerPixel, mImageData.width, mImageData.height, 0, GL_RGB, GL_UNSIGNED_BYTE, mImageData.imageBuffer);
// draw a textured quad
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex3f( 0, 0,0); //lo
glTexCoord2f(0,1); glVertex3f(256, 0,0); //lu
glTexCoord2f(1,1); glVertex3f(256, 256,0); //ru
glTexCoord2f(1,0); glVertex3f( 0, 256,0); //ro
glEnd;
glDeleteTextures(1, &mTextureID);
mTextureID = 0;
}
void GUIGLView::glInit()
{
}
void GUIGLView::paintGL()
{
qglClearColor(QColor(Qt::black));
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// only do something if image is availible
if(mImageData.imageBuffer == NULL)
return;
QString debugString = QString("paintGL called with buffer: 0x%1, size %2").arg((int)mImageData.imageBuffer,8,16,QChar('0')).arg(mImageData.width);
qDebug(debugString.toAscii().data());
// set projection - disable z-axis
glMatrixMode(GL_PROJECTION);
//clear projection matrix
glLoadIdentity();
//Creating an orthoscopic view matrix going from -1 -> 1 in each
//dimension on the screen (x, y, z).
glOrtho(0, 640, 480, 0, -1, 1);
//Now editing the model-view matrix.
glMatrixMode(GL_MODELVIEW);
//Clearing the model-view matrix.
glLoadIdentity();
//Disabling the depth test (z will not be used to tell what object
//will be shown above another, only the order in which I draw them.)
glDisable(GL_DEPTH_TEST);
// generate a texture
glGenTextures(1, &mTextureID);
// enable texturing
glEnable(GL_TEXTURE_2D);
//specify texture to use
glBindTexture(GL_TEXTURE_2D, mTextureID);
// set texturing parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// copy image to texture
glTexImage2D(GL_TEXTURE_2D, 0, mImageData.samplesPerPixel, mImageData.width, mImageData.height, 0, GL_RGB, GL_UNSIGNED_BYTE, mImageData.imageBuffer);
// draw a textured quad
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex3f( 0, 0,0); //lo
glTexCoord2f(0,1); glVertex3f(256, 0,0); //lu
glTexCoord2f(1,1); glVertex3f(256, 256,0); //ru
glTexCoord2f(1,0); glVertex3f( 0, 256,0); //ro
glEnd;
glDeleteTextures(1, &mTextureID);
mTextureID = 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks