Subject: Broken OpenGL on NetBSD3 ?
To: None <netbsd-help@netbsd.org>
From: Matthew Fincham <matthewf@cat.co.za>
List: netbsd-help
Date: 06/06/2006 11:23:45
Hi.

I have a QT widget that uses OpenGL and is causing a segmentation fault in
the OpenGL library. Surprisiningly, the fault can be worked around by
removing some of the light settings. This code works on NetBSD 1.4, 1.5,
1.6, 2.0 and Windows 2000 and XP and so I am drawn to suspect OpenGL on
NetBSD3.

Has anyone else had problems with this or should I check my use of OpenGL?

Many thanks
Matthew Fincham

The gdb backtrace is as follows:

(gdb) bt
#0  0xbd413d9a in light_rgba () from /usr/pkg/lib/libGL.so.1
#1  0xbd41aa2d in run_lighting () from /usr/pkg/lib/libGL.so.1
#2  0xbd401566 in _tnl_run_pipeline () from /usr/pkg/lib/libGL.so.1
#3  0xbd407a2d in _tnl_playback_vertex_list () from /usr/pkg/lib/libGL.so.1
#4  0xbd379256 in execute_list () from /usr/pkg/lib/libGL.so.1
#5  0xbd3797a7 in _mesa_CallList () from /usr/pkg/lib/libGL.so.1
#6  0xbd3e380d in neutral_CallList () from /usr/pkg/lib/libGL.so.1
#7  0xbd35c535 in glCallList () from /usr/pkg/lib/libGL.so.1
#8  0x08098cda in xxxxxxxxxx::paintGL() (this=0x93ffc00) at
xxxxxxxxxx.cpp:157
#9  0xbd9dbfa1 in QGLWidget::glDraw() () from /usr/pkg/qt3/lib/libqt-mt.so.3
#10 0xbd9db99b in QGLWidget::paintEvent(QPaintEvent*) ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#11 0xbd7fb3ca in QWidget::event(QEvent*) ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#12 0xbd77971d in QApplication::internalNotify(QObject*, QEvent*) ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#13 0xbd778d84 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#14 0x0828a600 in FourLRGui::notify(QObject*, QEvent*) (this=0xbfbfe408,
    receiver=0x93ffc00, event=0xbfbfdfa0) at fourlrgui.cpp:459
#15 0xbd71cf3a in QETWidget::translatePaintEvent(_XEvent const*) ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#16 0xbd718d6f in QApplication::x11ProcessEvent(_XEvent*) ()
---Type <return> to continue, or q <return> to quit---
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#17 0xbd72cf0c in QEventLoop::processEvents(unsigned) ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#18 0xbd7892a3 in QEventLoop::enterLoop() ()
   from /usr/pkg/qt3/lib/libqt-mt.so.3
#19 0xbd789168 in QEventLoop::exec() () from /usr/pkg/qt3/lib/libqt-mt.so.3
#20 0xbd77991c in QApplication::exec() () from
/usr/pkg/qt3/lib/libqt-mt.so.3
#21 0x0828b29e in main (argc=1, argv=0xbfbfeb14) at main.cpp:34
#22 0x08071fda in ___start ()



The source code is as follows (with the relevant lines removed using the
BORKEN_OPENGL define)

void xxxxxxxxxx::initializeGL()
{
 qglClearColor( black );
 glShadeModel( GL_SMOOTH );
 glEnable( GL_DEPTH_TEST );

 .... // create some lists

 // Setup lighting
 GLfloat light_ambient[]={ 0.6, 0.6, 0.6 };
 GLfloat light_diffuse[]={ 0.8, 0.8, 0.8 };
 GLfloat light_specular[]={ 0.8, 0.8, 0.8 };
#ifndef BROKEN_OPENGL
 GLfloat light_position[]={ 0.0, 0.0, 10.0 };
#endif
 GLfloat light_spot_dir[]={ 0.0, 0.0, -1.0 };
 GLfloat light_spot_exp[]={ 50.0 };

 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
 glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
#ifndef BROKEN_OPENGL
 glLightfv(GL_LIGHT0, GL_POSITION, light_position);
#endif
 glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light_spot_dir);
 glLightfv(GL_LIGHT0, GL_SPOT_EXPONENT, light_spot_exp);
#ifndef BROKEN_OPENGL
 glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 30.0);
#endif

 glEnable(GL_LIGHT0);
 glEnable(GL_LIGHTING);
}