Help building/running SDL/OpenGL code

Richard Mace macerl at telkomsa.net
Wed Dec 23 03:42:55 UTC 2009


On Wednesday 23 December 2009 04:20:28 Pieter de Goeje wrote:
> On Tuesday 22 December 2009 22:00:51 Roland Smith wrote:
> > On Tue, Dec 22, 2009 at 09:57:57PM +0200, Richard Mace wrote:
> > > In the end, as a last resort, I de-installed the nvidia driver and
> > > started X with an empty /etc/X11/xorg.conf (which presumably loads the
> > > "nv" driver). I re-built my code and it runs, albeit without the
> > > smoothest of graphics.
> >
> > On a recent core2 duo or quad, even software rendering isn't that bad.
> 
> True, until you press the full screen(s) button of your program running on
> your dual 1920x1200 monitor setup like I do ;-) Suddenly you're watching a
> slideshow...
> 
> > > I guess that that proves that the problem lies with the NVIDIA driver
> > > and its inter-relationship with the Mesa libraries, which one has to
> > > use if one builds one's own "OpenGL" programs.
> >
> > Yes.
> 
> Agreed. It's quite annoying that the nvidia drivers replace the existing
>  mesa GL libs, which breaks OpenGL when you switch back to mesa rendering.
>  However, because the library is implemented by nvidia for their hardware,
>  it is also blazingly fast.
> 
> > > It is a pity that FreeBSD has not sorted that out, but I hasten to add
> > > that I'm new to FBSD and it could be my error.

What I meant here by "sort out" was that FreeBSD provide some way for Mesa 
libs and NVIDIA drivers to co-exist. It seems that you (as new user) have to 
learn, through error, that you need to install Mesa first, then NVIDIA (and 
whenever Mesa-related apps get an upgrade you need to re-install NVIDIA). 
Would be nice if these two ports could check for each other's existence before 
install and do the necessary to the libGL* symbolic links. 

> > It was nvidia's decision to drop support for older cards from their
> > recent drivers. Nothing that the FreeBSD project can do about that.
> 
> The oldest cards that the new drivers support are the GeForce 6xxx series,
> which are over 5 years old. I'm not saying that I approve dropping support
> but frankly I don't really care for 3D acceleration on graphics cards that
> old.
> 
> The latest nvidia drivers are actually built using a more recent version of
> FreeBSD so you won't have that linking problem. Which is indeed the most
> likely cause of the problem. I don't understand why glxgears does run and
> your simulation does not though... I would've expected both too fail or
>  work.

This is confusing to me, too, which led to the question immediately below.

> > > It does beg the question, though, how one would develop OpenGL apps on
> > > FBSD? I'll revisit this soon, after some careful googling.
> 
> Personally I use a recent nvidia card with the latest nvidia drivers. This
>  has worked well for me, but I don't use SDL. My programs tend to use the
>  simple GLUT/GLU/GL combo or wxGTK/GLU/GL if I need more controls. Loading
>  textures is done using DevIL. Unfortunately my old GeForce 4 is broken so
>  I can't test the legacy drivers any more.
> 
> > Get a card that is well-supported by the drivers in the FreeBSD kernel
> > and Xorg/Mesa. Currently that means Intel's on-board graphics or boards
> > with

Well, right now I am "evaluating" FreeBSD on an "old" machine (Pentium IV, 
NVIDIA FX5200) to see whether I would make the switch from Debian GNU/Linux. I 
don't really want to purchase a new card for this purpose. Perhaps I will try 
to install FBSD on my laptop, which is dual-core and has an NVIDIA Quadro FX 
570M on board.

> 
> If you're going with intel you might as well use software rendering :-)

I'd agree there ;-).

> > ATI/AMD radeon chips, except for the latest chips. AMD released docs for
> > those chips some months ago, and the drivers for accellerated 3D are
> > still evolving.
> 
> Yes, AMD's efforts are very commendable.
> 
> > Accellerated 3D works fine on my Radeon X1650 equipped card with the
> > xf86-video-ati driver and the drm.ko and radeon.ko kernel modules.
> >
> > Roland
> 

Thanks to all for your help and suggestions. 

Incidentally, if there is anyone out there with newer hardware who is 
interested in building the code I am talking about you can find it at:

http://physics.ukzn.ac.za/~richm/courses/phys110/lennard-jones-3d.html

You'll need to change the following lines in the Makefile to get it to 
successfully build under FreeBSD:
==================================================
CFLAGS = -Wall -Wextra -pthread -I/usr/local/include -I/usr/local/include/SDL 
-O3 -march=native

LFLAGS = -Wall -L/usr/local/lib

lennardjones : $(OBJS)
        $(CC) $(LFLAGS) -o lennardjones $(OBJS) -lSDL -lSDL_gfx -lGLU
==================================================

It would be interesting to hear feedback. (Basic controls are: up-arrow add 
heat to crystal; down-arrow cool down gas/crystal. There are a bunch of others 
-- look in main.c). You are welcome to do whatever you wish with my code.

-Richard



More information about the freebsd-questions mailing list