* Ben Rosenberg (Wed, May 30, 2001 at 07:37:01PM -0700)
Once the proper version of OpenGL is installed then if you have 3D
enabled ..everything works right. I highly recommend using the 2.4.4
kernel, nVidia's new module release and their GLX (opengl)..I haven't
had any issues.
Then you've obviously never had to use color indexed textures .
Try the below and see if you get anything better than a black square in the
middle
Note; you need Motif and GLw
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#define DO_LUMINANCE_ALPHA
//#define USE_EXTENSIONS
static GLXContext glx_context = NULL;
static GLuint tex_name;
static void init_action(Widget glx_widget, XtPointer user_data, XtPointer call_data)
{
GLwDrawingAreaMakeCurrent(glx_widget, glx_context);
#ifdef USE_EXTENSIONS
GLubyte tex_image[4 * 4 * 2];
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++) {
int idx = 8 * y + 2 * x;
if((x + y) % 2 == 1) {
tex_image[idx] = 255;
tex_image[idx + 1] = 255;
}
else {
tex_image[idx] = 0;
tex_image[idx + 1] = 0;
}
}
}
#else
GLubyte tex_image[4 * 4];
for(int y = 0; y < 4; y++) {
for(int x = 0; x < 4; x++) {
int idx = 4 * y + x;
if((x + y) % 2 == 1) {
tex_image[idx] = 255;
}
else {
tex_image[idx] = 0;
}
}
}
#endif
#ifdef USE_EXTENSIONS
GLfloat lut[4 * 256];
for(int i = 0; i < 256; i++) {
int idx = 4 * i;
lut[idx] = (i < 128) ? 1.0 : 1.0 - (i - 128) / 127.0;
lut[idx + 1] = (i < 128) ? i / 127.0 : 1.0 - (i - 128) / 127.0;
lut[idx + 2] = (i < 128) ? 0.0 : (i - 128) / 127.0;
lut[idx + 3] = i / 255.0;
}
#else
GLfloat redMap[256];
GLfloat greenMap[256];
GLfloat blueMap[256];
GLfloat alphaMap[256];
for(int i = 0; i < 256; i++) {
redMap[i] = (i < 128) ? 1.0 : 1.0 - (i - 128) / 127.0;
greenMap[i] = (i < 128) ? i / 127.0 : 1.0 - (i - 128) / 127.0;
blueMap[i] = (i < 128) ? 0.0 : (i - 128) / 127.0;
alphaMap[i] = i / 255.0;
}
glPixelMapfv(GL_PIXEL_MAP_I_TO_R, 256, redMap);
glPixelMapfv(GL_PIXEL_MAP_I_TO_G, 256, greenMap);
glPixelMapfv(GL_PIXEL_MAP_I_TO_B, 256, blueMap);
glPixelMapfv(GL_PIXEL_MAP_I_TO_A, 256, alphaMap);
#endif
glGenTextures(1, &tex_name);
glBindTexture(GL_TEXTURE_2D, tex_name);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, 4, 4, 0,
#ifdef USE_EXTENSIONS
GL_LUMINANCE_ALPHA,
#else
GL_COLOR_INDEX,
#endif
GL_UNSIGNED_BYTE,
tex_image);
glBindTexture(GL_TEXTURE_2D, 0);
#ifdef USE_EXTENSIONS
glColorTableSGI(GL_TEXTURE_COLOR_TABLE_SGI,
#if defined(DO_LUMINANCE_ALPHA)
GL_RGBA,
#else
GL_RGB,
#endif
256,
GL_RGBA,
GL_FLOAT,
lut);
(void)glGetError();
glGetColorTableSGI(GL_TEXTURE_COLOR_TABLE_SGI,
GL_RGB,
GL_FLOAT,
lut);
cout << "glGetColorTableSGI returns error code: 0x" << hex << glGetError() << dec << endl;
#endif
}
static void expose_action(Widget glx_widget, XtPointer user_data, XtPointer call_data)
{
GLwDrawingAreaCallbackStruct *cbs = (GLwDrawingAreaCallbackStruct *)call_data;
GLwDrawingAreaMakeCurrent(glx_widget, glx_context);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, cbs->width, cbs->height);
glClearColor(0.0, 0.5, 0.5, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_TEXTURE_2D);
glColor3f(0.0, 0.0, 0.0);
glLineWidth(1.0);
glBegin(GL_LINES);
for(GLfloat c = -1.0; c < 1.0; c += 0.1) {
glVertex2f(c, -1.0); glVertex2f(c, 1.0);
glVertex2f(-1.0, c); glVertex2f(1.0, c);
}
glEnd();
glBindTexture(GL_TEXTURE_2D, tex_name);
glColor3f(1.0, 1.0, 1.0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifdef USE_EXTENSIONS
glEnable(GL_TEXTURE_COLOR_TABLE_SGI);
#endif
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0.0, 0.0); glVertex2f(-0.8, -0.8);
glTexCoord2f(1.0, 0.0); glVertex2f(0.8, -0.8);
glTexCoord2f(0.0, 1.0); glVertex2f(-0.8, 0.8);
glTexCoord2f(1.0, 1.0); glVertex2f(0.8, 0.8);
glEnd();
GLwDrawingAreaSwapBuffers(glx_widget);
}
int main(int argc, char *argv[])
{
XtToolkitInitialize();
XtAppContext app_ctx = XtCreateApplicationContext();
Display *dpy = XtOpenDisplay(app_ctx, NULL, "widTestMotif", "WIDTestMotif", NULL, 0, &argc, argv);
if(dpy == NULL) exit(1);
int glx_attribs[] = {GLX_RGBA,
GLX_DOUBLEBUFFER,
None};
XVisualInfo *glx_vis = glXChooseVisual(dpy, DefaultScreen(dpy), glx_attribs);
if(glx_vis == NULL) exit(2);
Colormap cmap = XCreateColormap(dpy, RootWindow(dpy, glx_vis->screen), glx_vis->visual, AllocNone);
if(cmap == (Colormap)None) exit(3);
#if defined(DO_LUMINANCE_ALPHA)
const char *app_name = "LUT test RGBA";
#else
const char *app_name = "LUT test RGB";
#endif
Widget toplevel = XtVaAppCreateShell(app_name,
"LUTtest",
applicationShellWidgetClass,
dpy,
XmNvisual, glx_vis->visual,
XmNdepth, glx_vis->depth,
XmNcolormap, cmap,
NULL);
Arg args[32];
int n = 0;
XtSetArg(args[n], XmNwidth, 400); n++;
XtSetArg(args[n], XmNheight, 400); n++;
Widget main_form = XmCreateForm(toplevel, "MainForm", args, n);
XtManageChild(main_form);
glx_context = glXCreateContext(dpy, glx_vis, NULL, GL_TRUE);
if(glx_context == NULL) exit(4);
n = 0;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], GLwNvisualInfo, glx_vis); n++;
Widget glx_widget = GLwCreateMDrawingArea(main_form, "OpenGLwindow", args, n);
XtManageChild(glx_widget);
XtAddCallback(glx_widget, GLwNginitCallback, init_action, NULL);
XtAddCallback(glx_widget, GLwNexposeCallback, expose_action, NULL);
// Realize and loop
XtRealizeWidget(toplevel);
XtAppMainLoop(app_ctx);
exit(0);
}
//
// EOF
//
They're broken.
All you get is
I will try the logging in and out bit..even though I never use KDM..it's
a resource hog and I don't need a gui login. *shrug*
--
Ben Rosenberg
mailto:ben@whack.org
-----
If two men agree on everything, you can
be sure that only one of them is doing
the thinking.
--
To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com
For additional commands send e-mail to suse-linux-e-help@suse.com
Also check the FAQ at http://www.suse.com/support/faq and the
archives at http://lists.suse.com
Currently listening to: Tool - The Patient (Lateralus)
Gerhard, <@jasongeo.com> == The Acoustic Motorbiker ==
--
__O In Italy, for thirty years under the Borgias, they had warfare,
=`\<, terror, murder and bloodshed, but they produced Michelangelo,
(=)/(=) Leonardo da Vinci, and the Renaissance. In Switzerland they had
brotherly love, they had five hundred years of democracy and peace,
and what did they produce? The cuckoo clock.