OpenGL/GLUT demo program fails

Hi

I tried to run a very simple test program (example 1.2 from the red book). It compiles fine and falls flat on its face once run complaining about memory overflow.

This same program run fine in Mandriva 2009. To elimionate typos I transferred the source file from Mandriva to Suse and it compiled fine and died the same way. Mandriva uses different GLUT (MesaGLUT or something, but not freeglut).

Code is very simple

#include <GL/glut.h>
#include <stdlib.h>

void display(void)
{
	/* clear all pixels */
	glClear(GL_COLOR_BUFFER_BIT);

	/*draw white polygon (rectangle) with corner at
	 * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
	 */
	glColor3f(1.0, 1.0, 1.0);
	glBegin(GL_POLYGON);
		glVertex3f(0.25, 0.25, 0.0);
		glVertex3f(0.75, 0.25, 0.0);
		glVertex3f(0.75, 0.75, 0.0);
		glVertex3f(0.25, 0.75, 0.0);
	glEnd();

	/* Don't wait
	 * start processing buffered OpenGL routines
	 */
	glFlush();
}

void init(void)
{
	/* select clearing (background) color  */
	glClearColor(0.0, 0.0, 0.0, 0.0);

	/* initialize viewing values  */
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

/* 
 * Declare initial window size, position and display mode
 * (single buffer and RGBA). Open window with "Hello"
 * in its title bar. Call initialization routines.
 * Register callback function to display graphics.
 * Enter main loop and process events.
*/

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
	glutInitWindowSize(250, 250);
	glutInitWindowPosition(100, 100);
	glutCreateWindow("Hello");
	init();
	glutDisplayFunc(display);
	glutMainLoop();
	return 0;
}

Compilation was done with this command

gcc helloMd.c -lglut -Wall -g -o helloMd

The backtrace of it points to libGL:

#0  0xb7de7f72 in ?? () from /usr/lib/libGL.so.1
#1  0xb7dc76cc in glXMakeCurrentReadSGI () from /usr/lib/libGL.so.1
#2  0xb7f9a386 in fgOpenWindow () from /usr/lib/libglut.so.3
#3  0xb7f985ef in fgCreateWindow () from /usr/lib/libglut.so.3
#4  0xb7f99ae5 in glutCreateWindow () from /usr/lib/libglut.so.3
#5  0x08048a84 in main (argc=-1214448324, argv=0x1) at helloMd.c:51

I have pretty vanilla Suse 11.1. Hardware is AMD 64X2 4400+, 4 GB RAM, Ati 3650 graphics card with 512 MB DDR2.

Now I’ve seen others complaining about it, but (I think) all got their problem solved by installing graphics card drivers and (probably) afterwards using different OpenGL-implementation by their graphics card manufacturer (nVidia at least). So is this default libGL-library broken or something? Or am I supposed to load Ati-drivers? I would like to continue to use these open source things.

Thanks in advance for any information.

It’s cold comfort to you saying it works on my 64 bit AMD with nVIDIA 6600 machine, but I suspect you do need your ATI OpenGL implementation.

Have you tried linking with Mesa GL libraries? It won’t run as fast as hardware accelerated but it might help you get started.

Thanks for the sympathy:). As far as I know (which isn’t very far) I am linking with Mesa libs. These libGL.so and libGLU.so both come from Mesa install (I think, at least those are filenames that Mesa installs).

Or should I use something else in compile? Now there is that -lglut without which it will not compile.

I think that differences between Mandriva (where code runs) and Suse are

Suse uses Mesa 7.2.0 and Mandriva uses older Mesa 7.0.4

on Mandriva I have Ati fglrx drivers installed while on Suse I
use radeonhd driver

I think that switching to Ati drivers will cure this, but I’ll try to find some other way first. If all else fails I suppose I’ll have to start using ATi drivers. Sigh.

Can you verify that OpenGL is working on your machine? You can try glxgears or whatsoever.

Just installed ATi drivers and now the bloody thing runs just sooo nice. Sigh:(. I think I have to wait for 11.2 to try this open source version of things. On the other hand I probably know bit more about OpenGL by then:). I hope.

Thanks for replies.