It seems I misunderstood the Linux 32-bit thing. It’s just that Linux 24-bit = Windows 32-bit.
Anyway, I’m programming in Pascal with SDL, so I’m not sure how helpful this code is, but I’ve whipped together a quick test program. It sets up the render context, clears the color buffer, reads a single pixel and writes the pixel data to a file, then swaps the buffer and does it again.
PROGRAM test;
USES gl, sdl;
VAR outputfile : text;
pixel : ARRAY [0..3] OF byte;
renderwindow : PSDL_Surface;
BEGIN
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
renderwindow := SDL_SetVideoMode(800, 600, 32, SDL_OPENGL);
IF (renderwindow = NIL) THEN BEGIN
SDL_Quit;
EXIT;
END;
glEnable(GL_TEXTURE_2D);
glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, 800, 600);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 800, 600, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
assign(outputfile, 'output.txt');
rewrite(outputfile);
glClear(GL_COLOR_BUFFER_BIT);
pixel[0] := 0;
pixel[1] := 0;
pixel[2] := 0;
pixel[3] := 0;
glReadPixels(1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, @pixel);
writeln(outputfile, pixel[0]);
writeln(outputfile, pixel[1]);
writeln(outputfile, pixel[2]);
writeln(outputfile, pixel[3]);
SDL_GL_SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT);
pixel[0] := 0;
pixel[1] := 0;
pixel[2] := 0;
pixel[3] := 0;
glReadPixels(1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, @pixel);
writeln(outputfile, pixel[0]);
writeln(outputfile, pixel[1]);
writeln(outputfile, pixel[2]);
writeln(outputfile, pixel[3]);
close(outputfile);
SDL_FreeSurface(renderwindow);
SDL_Quit;
END.
The results in my output.txt file is:
0
0
0
255
0
0
0
255
Meaning that both times it reads the pixel, the alpha is not set to zero, while the RGB values are. (The color values are read correctly if an image is drawn on the buffer before reading the pixel values.)