Graphics Img libraries for linux/mac os

1.http://cairographics.org/

编译使用方法:

http://www.gaia-gis.it/spatialite-2.4.0-4/mingw_how_to.html#libcairo 

2.small lib:

http://cimg.sourceforge.net/ 

编译和使用

http://cimg.sourceforge.net/reference/group__cimg__overview.html 

3.Simple OpenGL Image Library(建议使用FreeImg Library)

跨平台的opengl 材质资源管理库

http://lonesock.net/soil.html 

code block 使用library:Using libraries with Code::Blocks

http://www.learncpp.com/cpp-tutorial/a3-using-libraries-with-codeblocks/ 

opengl使用freeImg示例

//
thisIsInitGL(){
loadTexture();
}
/// Now the interesting code:
loadTexture(){
FREE_IMAGE_FORMAT formato = FreeImage_GetFileType(textureFile, 0); // Automatocally detects the format(from over 20 formats!)
    FIBITMAP* imagen = FreeImage_Load(formato, textureFile);
    
    FIBITMAP* temp = imagen;
    imagen = FreeImage_ConvertTo32Bits(imagen);
    FreeImage_Unload(temp);
    
     int w = FreeImage_GetWidth(imagen);
     int h = FreeImage_GetHeight(imagen);
    cout<< " The size of the image is:  "<<textureFile<< "  es  "<<w<< " * "<<h<<endl;  // Some debugging code
    
    GLubyte* textura =  new GLubyte[ 4*w*h];
     char* pixeles = ( char*)FreeImage_GetBits(imagen);
     // FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
    
     for( int j=  0; j<w*h; j++){
        textura[j* 4+ 0]= pixeles[j* 4+ 2];
        textura[j* 4+ 1]= pixeles[j* 4+ 1];
        textura[j* 4+ 2]= pixeles[j* 4+ 0];
        textura[j* 4+ 3]= pixeles[j* 4+ 3];
         // cout<<j<<": "<<textura[j*4+0]<<"**"<<textura[j*4+1]<<"**"<<textura[j*4+2]<<"**"<<textura[j*4+3]<<endl;
    }
    
     // Now generate the OpenGL texture object 
    
    glGenTextures( 1, &texturaID);
    glBindTexture(GL_TEXTURE_2D, texturaID);
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, w, h,  0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)textura );
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    
    GLenum huboError = glGetError();
     if(huboError){
        
        cout<< " There was an error loading the texture "<<endl;
    }
    

}

// 

4.a completely OpenSourced alternative to the OpenGL Utility Toolkit (GLUT) library

http://freeglut.sourceforge.net/ 

 

 

 

 

 

转载于:https://www.cnblogs.com/vilyLei/articles/2433613.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值