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/ 

 

 

 

 

 

posted @ 2012-04-05 19:27  vily_雷  阅读(288)  评论(0编辑  收藏  举报