Linking OpenGL demo

Posted:
in macOS edited January 2014
I'm trying to get some OpenGL demos working from the 1997 Advanced OpenGL Siggraph class. Here's a link to the code:



<a href="http://www.sgi.com/software/opengl/advanced97/programs/programs.html"; target="_blank">http://www.sgi.com/software/opengl/advanced97/programs/programs.html</a>;



With a bit of mucking around I can get it to compile and run. Mostly it's getting the right math functions and GL and GLUT headers.



But when I run them they're not Carbon apps so theres no menu or keyboard input. How can I compile and link them so that they are?



I know for the OpenGL examples that come with the Dev Tools, there's a project builder file that makes it do the right thing. But I don't feel like making one for these programs. I'd rather just modify the makefile.



dave

Comments

  • Reply 1 of 2
    rraburrabu Posts: 264member
    I take it you've modified the source so that it does the following include:



    #include &lt;GLUT/glut.h&gt;



    Then, I take it you've changed the cc comand to add:



    cc -framework OpenGL -framework GLUT -framework AppKit -lstdc++



    (note: the last is only needed if using C++ features)



    Using the above, I can compile and run OpenGL programs that I wrote, but don't get a menubar for the program so only keyboard input works.



    Now, to get a regular application you must do the following (assuming you have a program called a.out):



    1. mkdir myapp.app

    2. mkdir myapp.app/Contents

    3. cd myapp.app/Contents

    3. mkdir MacOS

    4. mv ../../a.out MacOS/myapp

    5. echo "APPL????" &gt; PkgInfo

    6. Create a file called Info.plist with the following inside it:



    &lt;?xml version="1.0" encoding="UTF-8"?&gt;

    &lt;!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"&gt;

    &lt;plist version="0.9"&gt;

    &lt;dict&gt;

    &lt;key&gt;CFBundleDevelopmentRegion&lt;/key&gt;

    &lt;string&gt;English&lt;/string&gt;

    &lt;key&gt;CFBundleInfoDictionaryVersion&lt;/key&gt;

    &lt;string&gt;6.0&lt;/string&gt;

    &lt;key&gt;CFBundlePackageType&lt;/key&gt;

    &lt;string&gt;APPL&lt;/string&gt;

    &lt;key&gt;CFBundleSignature&lt;/key&gt;

    &lt;string&gt;????&lt;/string&gt;

    &lt;key&gt;CFBundleVersion&lt;/key&gt;

    &lt;string&gt;0.0.1d1&lt;/string&gt;

    &lt;/dict&gt;

    &lt;/plist&gt;




    Note: I don't know how much of what is in the Info.plist is actually needed. This is copied from what ProjectBuilder created.



    Then cd ../.. to get back up.

    You can then use the finder to double click on myapp or you can launch from the terminal with the command open myapp.



    If you want to do this a lot, I'd suggest writing a quick shell script that does it.



    Or, once you have the directory structure set up, simply copy a different compiled executable into the MacOS directory (with the correct name) and you should be set to go.
  • Reply 2 of 2
    Hey, it worked!



    The funny thing is that the demo reads in a file from the current working directory, which somehow gets changed to



    myapp.app/Contents/Resources



    Thanks.
Sign In or Register to comment.