GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


Texture creation by irid
1
 
    void CreateGLTexture( Bitmap & bmp )
    {
        glGenTextures( 1, &OpenGLTextureNumber );
        glBindIcon();

        BitmapData bmpdata;
        Rect r( 0, 0, bmp.GetWidth(), bmp.GetHeight() );

        //char temp1[1024];
        //sprintf( temp1, "w=%i, h=%i", bmp.GetWidth(), bmp.GetHeight() );
        //MessageBox( 0, temp1, "Blah?", MB_OK );

        bmp.LockBits( &r, ImageLockModeRead, PixelFormat32bppARGB, &bmpdata ); 
        
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );    // Linear Filtering
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );    // Linear Filtering
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA16, bmp.GetWidth(), bmp.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, bmpdata.Scan0 );
        glFlush();


        bmp.UnlockBits( &bmpdata );

        //CLSID pngClsid;
        //GetEncoderClsid( L"image/png", &pngClsid );
        //wchar_t temp[1024];
        //swprintf( temp, L"data/icon%i.png", OpenGLTextureNumber );
        //bmp.Save( temp, &pngClsid, NULL );
    }