OpenGL: disable texture colors?

Is it possible to disable texture colors and use only white color? It will still read the texture, so I cannot use glDisable (GL_TEXTURE_2D), because I want to display alpha channels too.

Now I can think of creating a new texture where all the color data will be white, remaining alpha as it is.

I need to do this without shaders , so is that possible?

Edit: to clarify: I want to use both textures: white and plain color.

Edit: this is NOT POSSIBLE

+3
source share
2 answers

( ) , OpenGL? - , , .

+1

, , , . , glTexImage2D, " " , . () - . GL_RGBA .

: format (, ) , internal format (, ) , .

, -, GL_ALPHA internal format, , , - , , . , ( , ) , , -, .

: , , , ( ), , . -, blend -, , , glTextureEnvf GL_REPLACE, -, GL_BLEND. , () , GL_REPLACE GL_BLEND. gree, (0) (1):

static GLubyte Image[128][128][4];

for (int i=0; i<128; i++)
    for (int j=0; j<128; j++) {
        Image[i][j][0] = 0;
        Image[i][j][1] = 255;
        Image[i][j][2] = 0;
        Image[i][j][3] = i;
    }

, .. :

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

glBegin(GL_QUADS);
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(0.0, 0.0); glVertex3f(-1.0f, 1.0f, 0.0f);
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(1.0, 0.0); glVertex3f(0.0f, 1.0f, 0.0f);
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(1.0, 1.0); glVertex3f(0.0f, -1.0f, 0.0f);
    glColor4f(0.0, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(0.0, 1.0); glVertex3f(-1.0f, -1.0f, 0.0f);
glEnd();

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);

glBegin(GL_QUADS);
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(0.0, 0.0); glVertex3f(0.0f, 1.0f, 0.0f);
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(1.0, 0.0); glVertex3f(1.0f, 1.0f, 0.0f);
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(1.0, 1.0); glVertex3f(1.0f, -1.0f, 0.0f);
    glColor4f(0.0, 0.0f, 1.0f, 1.0f);
    glTexCoord2f(0.0, 1.0); glVertex3f(0.0f, -1.0f, 0.0f);
glEnd();

:

Blended textures

, , GL_REPLACE, , , GL_BLEND ( glBlendFunc -), , , , ​​ .

2: , , , 1- GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_REPEAT. , , , . , - "". , - 8x8 16x16. , , , JPEG MPEG , , () . ( ).

+4

Source: https://habr.com/ru/post/1738037/


All Articles