PDA

View Full Version : Using GLUT, windows are transparent. Configuration problem?



kaiserdave
09-18-2005, 09:41 AM
Hiya. I've just started on the red book, and when trying the first GLUT example I don't get any rendering. The new window is not blank, it displays whatever was behind the window when it was created.

I'm running FreeBSD 6.0, Xorg, and WindowMaker. OpenGL is enabled in xorg.conf (the OpenGL screensavers in xscreensaver work fine).

The source (a modified version of hello.c) compiles and links without errors, and liberal calls to glGetError() haven't showed any errors. A few printf() lines were added to the display() function to test that it's really being executed (it is).

Any help would be greatly appreciated.

Just yell if any other info is needed to diagnose. (source? output of glxinfo? screen capture?)

Thanks.

ETA: I found older, similar topics suggesting that it's a driver issue, but is that possible since other OpenGL applications still work?

mikael_aronsson
09-18-2005, 08:44 PM
The source code might be useful to have a look at.

Mikael

kaiserdave
09-18-2005, 09:20 PM
Thanks for the quick response, Mikael.
Here's the source:


#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
#include <X11/Xlib.h>

#define CHKERR if (glGetError() != GL_NO_ERROR) printf("oops\n");

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
CHKERR;
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.5, 0.75, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glEnd();
glFlush();
CHKERR;
printf(" display(): FLAG\n");
}

void init(void)
{
glClearColor(0.0, 0.0, 1.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int argc, char** argv)
{
glutInit(&amp;argc, argv);
CHKERR;
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
CHKERR;
glutInitWindowSize(300, 300);
CHKERR;
glutInitWindowPosition(400, 400);
CHKERR;
glutCreateWindow("hiya");
CHKERR;
init();
CHKERR;
glutDisplayFunc(display);
CHKERR;
glutMainLoop();
return 0;
}This was compiled with:
cc -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lGL -lGLU -lXext -lglut -ohello hello.c

I also tried leaving out various libs, once with only glut. All with the same result.

Thanks again!

09-21-2005, 01:23 AM
Works fine for me on XP with msvc 6.

kaiserdave
09-21-2005, 07:49 PM
Thanks for the heads up Zenix. It's good to get confirmation that it isn't the code.

So has anyone else seen this transparent window thing? While configuration advice would be more directly applicable from Linux/BSD users, I could certainly use some pointers from the Windows/Mac people that have seen something similar.

Cheers.

RigidBody
09-21-2005, 09:44 PM
i suppose that your window is not really transparent. if you move it around,
its contents stays the same, right? it seems that the window buffer is not updated when you call
glFlush(). what happens when you create a double-buffered window (don't forget to call
SwapBuffers)?

kaiserdave
09-21-2005, 10:31 PM
Yes, that's exactly right. Also, whenever a window is dragged in WindowMaker the coordinates of the window are displayed. These display boxes, like the background, "stick" in the opengl window instead of disappearing after dragging is complete. Here's a jpg of the single buffer, "transparent" window (http://www.jumbledpile.com/images/misc/opengl_error.jpg) .

There are a bunch of "display(): FLAG" lines of output while dragging, so it looks like the display() function is being called for each new coordinate box.

I tried a double buffered window with the following changes:

17a18
> glutSwapBuffers();
35c36
< glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
---
> glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);I don't get a blank window anymore, which is good, but instead I get a solid magenta window (http://www.jumbledpile.com/images/misc/opengl_error2.jpg) , which is not good even though I'm happy to see a new side of the problem.

BTW, for the double buffered case, the coordinates displayed by the window manager disappear after dragging is complete, as expected. The opengl window is "correctly" redrawn as completely solid magenta.

RigidBody
09-22-2005, 07:00 AM
i've finally managed to install GLUT, and i'm almost sorry that i have to say: it works!
i compiled the first version that you posted, with a single buffer, and i get a white triangle
on a blue background. the problem does not seem to be in your code.

what does glxinfo say? are there any other programs on your computer, which use opengl and run
correctly, e.g. glxgears?

Christina
09-22-2005, 07:59 AM
I'm having the exact same problem with my program for a Graphics assignment, and have been trying everything to get something drawn. The double buffering doesn't seem to have any effect on mine.

kaiserdave
09-22-2005, 05:26 PM
All of the OpenGL screensavers in xscreensaver work fine, as does glxgears, so it seems like whatever I'm missing is probably something small and easy to fix.

Here is my output from glxinfo (http://www.jumbledpile.com/glxinfo.txt) and from glxgears -info (http://www.jumbledpile.com/glxgears.txt) . I notice that GLUT isn't mentioned anywhere, even though these are present:

/usr/X11R6/include/GL/glut.h
/usr/X11R6/lib/libglut.a
/usr/X11R6/lib/libglut.so -> libglut.so.3
/usr/X11R6/lib/libglut.so.3

Does that mean something is off with just the GLUT installation? The package libglut-6.0.1 was automatically installed as a requirement for xscreensaver, so I think I've got a handle on what to look for.

I'll update if I can get it working.

kaiserdave
10-14-2005, 07:51 PM
Quick update, in case anyone else is having the same problem.

According to a few relevant threads from the FreeBSD lists, the problem is that DRI must be enabled (http://lists.freebsd.org/pipermail/freebsd-stable/2005-October/018645.html) .

Here are a few useful places to check out:
DRI Wiki - Building (http://dri.freedesktop.org/wiki/Building)
DRI on BSD (http://people.freebsd.org/~anholt/dri/)
ATI Mobility Radeon 9600 driver (http://www.thinkwiki.org/wiki/ATI_Mobility_Radeon_9600)

kaiserdave
10-16-2005, 12:42 AM
Direct rendering is now enabled, and everything works fine!

Thanks all.