小编wba*_*ari的帖子

openGL纹理和颜色

我正在学习如何在openGL中应用纹理.我将纹理应用于立方体的一个面,并使用原始颜色对其他面进行着色.在我应用纹理之前,颜色看起来很好,在我应用它之后它们变得更暗.怎么了?

void LoadGLTextures() {
    // Load Texture
    Image *image1;
    // allocate space for texture
    image1 = (Image *) malloc(sizeof(Image));
    if (image1 == NULL) {
    printf("Error allocating space for image");
    exit(0);
    }

    if (!ImageLoad("dd.bmp", image1)) {
    exit(1);
    }

    // Create Texture
    glGenTextures(1, &texture[0]);
    glBindTexture(GL_TEXTURE_2D, texture[0]);   // 2d texture (x and y size)

    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // scale linearly when image bigger than texture
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // scale linearly when image smalled than texture

    // 2d texture, level of detail 0 (normal), 3 components (red, …
Run Code Online (Sandbox Code Playgroud)

opengl textures

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

opengl ×1

textures ×1