From owner-freebsd-questions@FreeBSD.ORG Thu Dec 24 04:34:28 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44C6B1065672 for ; Thu, 24 Dec 2009 04:34:28 +0000 (UTC) (envelope-from macerl@telkomsa.net) Received: from rrba-ip-smtp-2-3.saix.net (rrba-ip-smtp-2-3.saix.net [196.25.240.236]) by mx1.freebsd.org (Postfix) with ESMTP id D3EB68FC1B for ; Thu, 24 Dec 2009 04:34:27 +0000 (UTC) Received: from toutatis.localnet (dsl-146-138-03.telkomadsl.co.za [165.146.138.3]) by rrba-ip-smtp-2-3.saix.net (Postfix) with ESMTP id 66C183B3; Thu, 24 Dec 2009 06:34:24 +0200 (SAST) From: Richard Mace To: Pieter de Goeje Date: Thu, 24 Dec 2009 06:34:02 +0200 User-Agent: KMail/1.12.4 (FreeBSD/8.0-RELEASE; KDE/4.3.4; i386; ; ) References: <200912221736.20023.macerl@telkomsa.net> <200912230542.28400.macerl@telkomsa.net> <200912232154.07830.pieter@degoeje.nl> In-Reply-To: <200912232154.07830.pieter@degoeje.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200912240634.02686.macerl@telkomsa.net> Cc: Roland Smith , freebsd-questions@freebsd.org, Roger Subject: Re: Help building/running SDL/OpenGL code X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2009 04:34:28 -0000 On Wednesday 23 December 2009 22:54:07 Pieter de Goeje wrote: > On Wednesday 23 December 2009 04:42:28 Richard Mace wrote: > > 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. > > Arrr. Same problem here at startup: segfault in glXGetFBConfigAttribSGIX. A > simple test case is the following: > > pyotr@nox:~% cat test.c > int main() {} > pyotr@nox:~% cc -o test test.c -L/usr/local/lib -lSDL -lGL > pyotr@nox:~% ./test > zsh: segmentation fault (core dumped) ./test > > Then I attempted to switch the arguments around... > > pyotr@nox:~% cc -o test test.c -L/usr/local/lib -lGL -lSDL > pyotr@nox:~% ./test > pyotr@nox:~% > > Voila! (Admittedly much to my surprise ;)) > > So then I changed the Makefile to use these libraries: -lGLU -lSDL > -lSDL_gfx. Result: a perfectly working ./lennardjones. The only minor > issue is that it presented me with exactly one option: > > pyotr@nox:~/temp/lennard-jones-gas-3d% ./lennardjones > Current pixel depth: 32 > Available Modes > 0 => 3840 x 1200 > Select your preferred video mode: > > So apparently I prefer mode 0 :D. It run fine (and smooth) though. > > It is clear something goes wrong during the runtime linking process, which > this library order works around. The actual problem is still a mystery to > me. It might be worthwhile to post a bugreport on the nvnews.net FreeBSD > forum. > > Best regards, > > Pieter de Goeje > Pieter, many, many thanks for taking the time to test and diagnose this. Your solution works perfectly: ensure that libGLU PRECEDES all the SDL libraries in the link line of the Makefile. Wow! I never would have thought.... About your allowable modes being only 3840 x 1200: I had the same issue at work (Linux) where I run dual monitors (2 x 1680 x 1050). Just create an NVIDIA metamode in your xorg.conf that blanks one monitor (I do not recall the exact syntax here, but I think you need to use NULL for the one monitor). It is also useful for some games ;-) Then you can use one screen and avoid staring at the crack between your monitors during simulations. Again, many thanks. This for me is proof that I can continue to do some scientific programming (with rendering in 3D) under FreeBSD . -Richard