如何将颜色存储在unsigned char中?

时间:2016-10-21 16:20:58

标签: c++ image opengl colors soil

我使用openGL的SOIL来加载图像,SOIL_load_image()返回一个unsigned char *,然后openGL使用它来为所有宽度*高度像素着色。

我希望能够传递我自己的unsigned char *来表示一种颜色。如何在字符串/ char *中表示颜色?

这就是我的想法:

GLuint createTextureID(std::string texturePath) {

    int width, height;
    GLuint texID = 0;
    unsigned char* texData = nullptr;

    //currently, all my file paths begin with "..//"
    if (texturePath.at(0) != '.')
    {
        texData = texturePath.c_str();
        width = 1;
        height = 1;
    }
    else
    {
        texData = SOIL_load_image(texturePath.c_str(), &width, &height, 0, SOIL_LOAD_RGBA);
    }

    //UPLOAD texData TO OPENGL
}

0 个答案:

没有答案