I’m trying to compress a texture using OpenGL glTexImage2D function. Everything works fine under Windows, but under Linux compression just doesn’t happen. I’ve made a simple test program to locate problem, here it is:
#define GLX_GLXEXT_PROTOTYPES
#include <GL/glx.h> // includes gl, glext
#include <GL/glu.h>
#include <stdio.h>
#include <string.h>
//----------------------------------------------------------------------------
int main (int argc, char *argv[])
{
int attributes[] =
{
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24,
0
};
Display *display = XOpenDisplay(NULL);
if (!display)
{
printf ("Cannot open display.
");
return 1;
}
XVisualInfo *vinfo = glXChooseVisual(display, DefaultScreen(display), attributes);
if (!vinfo)
{
printf ("Cannot get visual.
");
return 1;
}
GLXContext context = glXCreateContext(display, vinfo, 0, GL_TRUE);
XSetWindowAttributes winattrs;
winattrs.event_mask = 0;
winattrs.border_pixel = 0;
winattrs.bit_gravity = StaticGravity;
int winmask = CWBorderPixel | CWColormap | CWBitGravity | CWEventMask;
Window rw = DefaultRootWindow(display);
winattrs.colormap = XCreateColormap(display, rw, vinfo->visual, AllocNone);
Window window = XCreateWindow(display, rw,
0, 0, 100, 100, 0, vinfo->depth
,InputOutput
,vinfo->visual
,winmask
,&winattrs);
glXMakeCurrent(display, window, context);
// -------------- Compressing texture here ----------------
unsigned char tx[] =
{
0x00, 0x00, 0xff, 0x00, 0xff, 0xff,
0xff, 0xff, 0x00, 0x00, 0xff, 0x00
};
// glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_ARB, 2, 2,
0, GL_BGR_EXT, GL_UNSIGNED_BYTE, tx);
int compressed = -1;
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_COMPRESSED_ARB, &compressed);
printf ("Compressed = %d
", compressed);
// ---------------------------------------------------------
glXDestroyContext(display, context);
XCloseDisplay (display);
return 0;
}
It prints “Compressed = 0” (analoguous code returns 1 in “compressed” variable under Windows).
Printed list of extensions, which contains GL_ARB_texture_compression. glTexImage2D produce “no error” code. Checked internal format of texture, it is equal to GL_COMPRESSED_RGB_ARB, yet GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB returns zero.
All other GL functions works fine.
Could anyone say what’s happening, or at least point where to dig?
System: Fedora Core 6, gcc 4.1.1, Video Intel 945 (last drivers included in FC6, according to Intel)