invert colors
Milan Mimica

How do I display a texture with inverted colors with OpenGL? Here is the code I tried to use:

1#include <allegro.h>
2#include <alleggl.h>
3 
4int main()
5{
6 allegro_init();
7 install_allegro_gl();
8 install_keyboard();
9 install_timer();
10 
11 allegro_gl_set(AGL_COLOR_DEPTH, 16);
12 allegro_gl_set(AGL_DOUBLEBUFFER, 1);
13 allegro_gl_set(AGL_RENDERMETHOD, 1);
14 allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_DOUBLEBUFFER | AGL_RENDERMETHOD);
15 
16 if (set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0))
17 return 1;
18 allegro_gl_set_allegro_mode();
19 
20 BITMAP *bmp = load_bitmap("mysha.pcx", NULL);
21 
22 GLint tex = allegro_gl_make_texture_ex(AGL_TEXTURE_RESCALE, bmp, GL_RGB8);
23 glBindTexture(GL_TEXTURE_2D, tex);
24 glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ZERO);
25 glEnable(GL_BLEND);
26 glBegin(GL_QUADS);
27 glTexCoord2f(0, 0);
28 glVertex2f(0, 0);
29 glTexCoord2f(1, 0);
30 glVertex2f(bmp->w, 0);
31 glTexCoord2f(1, 1);
32 glVertex2f(bmp->w, bmp->h);
33 glTexCoord2f(0, 1);
34 glVertex2f(0, bmp->h);
35 glEnd();
36 glDisable(GL_BLEND);
37 
38 allegro_gl_flip();
39 readkey();
40 
41 destroy_bitmap(bmp);
42 
43 return 0;
44}

Attached is mysha.pcx - the example input file.

As a result I get something similar to a inverted picture, but it's obviously different to what any image editor would give me. What I'm I doing wrong?

EDIT:
Fixed using:
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_COPY_INVERTED);
without blending.

Thread #590930. Printed from Allegro.cc