C++ 土壤图像加载库参数

C++ 土壤图像加载库参数,c++,image,opengl,soil,C++,Image,Opengl,Soil,我正在使用此土壤函数在OpenGL中加载纹理文件。但是,我想访问: 加载图像的高度和宽度 图像(8、24等)的Bpp(每字节像素值) 数据指针 给定函数不返回任何此类特征。我想要一些关于如何使用这个或任何其他类似土壤功能找到这些的帮助。这是我使用的函数 GLuint loadSOIL(const char* imagePath) { cout << "Reading image: " << imagePath << endl; GLuin

我正在使用此土壤函数在OpenGL中加载纹理文件。但是,我想访问:

  • 加载图像的高度和宽度
  • 图像(8、24等)的Bpp(每字节像素值)
  • 数据指针
给定函数不返回任何此类特征。我想要一些关于如何使用这个或任何其他类似土壤功能找到这些的帮助。这是我使用的函数

GLuint loadSOIL(const char* imagePath) {
    cout << "Reading image: " << imagePath << endl;

    GLuint texture = 0;

    //Load Image File Directly into an OpenGL Texture
    texture = SOIL_load_OGL_texture
    (
        imagePath,
        SOIL_LOAD_RGB,
        SOIL_CREATE_NEW_ID,
        SOIL_FLAG_TEXTURE_REPEATS
    );

    // error check
    if (texture == 0) {
        cout << "SOIL loading error: " << SOIL_last_result() << endl;
    }

    return texture;
}
GLuint loadSOIL(const char*imagePath){
cout
土壤荷载图像()
将填充其宽度/高度/通道参数:

/**
    Loads an image from disk into an array of unsigned chars.
    Note that *channels return the original channel count of the
    image.  If force_channels was other than SOIL_LOAD_AUTO,
    the resulting image has force_channels, but *channels may be
    different (if the original image had a different channel
    count).
    \return 0 if failed, otherwise returns 1
**/
unsigned char*
    SOIL_load_image
    (
        const char *filename,
        int *width, int *height, int *channels,
        int force_channels
    );
有了这些信息,您可以使用
SOIL\u create\u OGL\u texture()
创建OpenGL纹理:


请注意,最好使用
!texture
而不是
texture==0
(与
texture==false
相同)
/**
    Creates a 2D OpenGL texture from raw image data.  Note that the raw data is
    _NOT_ freed after the upload (so the user can load various versions).
    \param data the raw data to be uploaded as an OpenGL texture
    \param width the width of the image in pixels
    \param height the height of the image in pixels
    \param channels the number of channels: 1-luminous, 2-luminous/alpha, 3-RGB, 4-RGBA
    \param reuse_texture_ID 0-generate a new texture ID, otherwise reuse the texture ID (overwriting the old texture)
    \param flags can be any of SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS | SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MULTIPLY_ALPHA | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT
    \return 0-failed, otherwise returns the OpenGL texture handle
**/
unsigned int
    SOIL_create_OGL_texture
    (
        const unsigned char *const data,
        int width, int height, int channels,
        unsigned int reuse_texture_ID,
        unsigned int flags
);