- setBackground( aPicturePath );
-
- // for test texture font
- //genFont();
-/*
- bool ok;
- QFont aFont = QFontDialog::getFont( &ok, this );
- QFontMetrics aFM( aFont );
- int pixelsWidth = aFM.width( "What's the width of this text?" );
- int pixelsHigh = aFM.height();
- int aFontX = 64;
- int aFontY = 64;
-
- while( aFontX < pixelsWidth )
- aFontX = aFontX * 2;
- while( aFontY < pixelsHigh )
- aFontY = aFontY * 2;
-
- myIW = aFontX;
- myIH = aFontY;
-
- QPixmap* aPixmap = new QPixmap( aFontX, aFontY );
- aPixmap->fill( QColor( 255, 255, 255) );
- QPainter aPainter( aPixmap );
- aPainter.setFont( aFont );
- //Painter.setPen( QColor( 0, 0, 0 ) );
- aPainter.drawText ( 0, pixelsHigh, "A" );
- QImage aImage = aPixmap->convertToImage();
-
- aImage.save( "W:\\Temp\\pic.jpg", "JPEG" );
-
- GLubyte* pixels = new GLubyte[aFontX * aFontY * 2];
-
- for( int i = 0; i < aFontY; i++ )
- {
- for( int j = 0; j < aFontX; j++ )
- {
- if( qRed( aImage.pixel( j, myIH - i - 1 ) ) == 0 )
- {
- pixels[i * aFontX * 2 + j * 2] = (GLubyte) 255;
- pixels[i * aFontX * 2 + j * 2 + 1]= (GLubyte) 255;
- }
- else
- {
- pixels[i * aFontX * 2 + j * 2] = (GLubyte) 0;
- pixels[i * aFontX * 2 + j * 2 + 1]= (GLubyte) 0;
- }
- }
- }
-
-
- glBindTexture(GL_TEXTURE_2D, texName);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glTexImage2D(GL_TEXTURE_2D, 0, 2, aFontX,
- aFontY, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels);
-
- delete[] pixels;
-*/
-
- //tex2 = buf.convertDepth( 32, 0 );
-
- //tex1 = QGLWidget::convertToGLFormat( tex2 ); // flipped 32bit RGBA
-
- /*myIW = buf.width();
- myIH = buf.height();
-
- myBackgroundSize = 64;
- while( myBackgroundSize < myIW || myBackgroundSize < myIH)
- myBackgroundSize = myBackgroundSize * 2;
-
- GLubyte* pixels = new GLubyte[myBackgroundSize * myBackgroundSize * 4];
-
- //GLubyte pixels[512][512][3];
- for( int i = 0; i < myBackgroundSize; i++ )
- {
- for( int j = 0; j < myBackgroundSize; j++ )
- {
- if( j < myIW && i < myIH )
- {
- pixels[i * myBackgroundSize * 4 + j * 4] = (GLubyte)qRed( buf.pixel(j,myIH - i - 1) );
- pixels[i * myBackgroundSize * 4 + j * 4 + 1]= (GLubyte)qGreen( buf.pixel(j,myIH - i - 1) );
- pixels[i * myBackgroundSize * 4 + j * 4 + 2] = (GLubyte)qBlue( buf.pixel(j,myIH - i - 1) );
- }
- else
- {
- pixels[i * myBackgroundSize * 4 + j * 4] = (GLubyte)0;
- pixels[i * myBackgroundSize * 4 + j * 4 + 1] = (GLubyte)0;
- pixels[i * myBackgroundSize * 4 + j * 4 + 2] = (GLubyte)0;
- }
- pixels[i * myBackgroundSize* 4 + j * 4 + 3] = (GLubyte)255;
- //cout << "RED = " << qRed( buf.pixel(i,j) ) << " GREEN = " << qGreen( buf.pixel(i,j) ) <<
- // " BLUE = " << qBlue( buf.pixel(i,j) ) << endl;
- }
- }
-
- //initialize texture
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glGenTextures(1, &texName);
- glBindTexture(GL_TEXTURE_2D, texName);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, myBackgroundSize , myBackgroundSize, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- pixels);
-
- delete[] pixels;
- */