Saturday, September 24, 2011

Thursday, September 22, 2011

Xcode libraries

This post is meant to extend the last post, but I felt like making a new one for it. The libraries installed on OSX seem to be places in "/usr/local/include/" (not entirely sure yet, but it seems to be the case). There are a bunch of places where they could be, such as "/usr/include/", "/opt/local/include/" and in the Xcode program folder. There a bunch more, but so far this folder I have found captures all the libraries in one place. G++ seems to know where this library is, so I don't have to use any special compile flags, but on the other hand, Xcode has no clue where this folder is. So to include it (the right way this time). Select the project in the project navigator. Select the project again in the view that comes up (on the left hand side). Use filter "Build Settings", "all" and "levels". Go down to "Search Paths" and input "/usr/local/include/" into "Header Search Paths". And that should do it.

And another note. I put GLM in there. It's kind of convenient that way.

Tuesday, September 6, 2011

Boost and SOIL in Xcode

Well I have been trying to get this working for quite some time, and I finally got it. I first could only get g++ via make to compile it, but soon found out how to get Xcode to compile it.

BOOST
This one was the hardest, mainly because you have to install it instead of just dragging it into the project. To install it (on mac) you can either use "MacPorts" via "sudo port install boost" or my terminal method. It's up to you wich method you pick. My terminal method I came up with is:

#!/bin/bash/


#BOOST INSTALL

clear

echo "### INSTALLING -> BOOST ###"

echo "---This part will take a while, and needs user participation"


cd ~/Downloads/

#see if the file is there to begin with, if it is skip the download part

if [ ! -d "boost_1_47_0" ]; then

echo "---A web browser will open up a website for you to download a"

echo "zip containing BOOST."

echo "---Please let it download to ~/Downloads/"

echo "---When the download has finished come back to this terminal for"

echo "--- further instructions."

echo "---Please press the enter button to commence..."

read

open "http://prdownloads.sourceforge.net/boost/boost_1_47_0.tar.gz"

echo "---Press the enter key when the download is"

echo "--- finished and when you are ready to proceed"

#wait for the user

read

#see if the file is there

if [ -f "boost_1_47_0.tar.gz" ]; then

echo "---Got the file, now continuing"

else

echo "---Could not find the file!"

exit

fi

tar -zxvf "boost_1_47_0.tar.gz"

else

echo "---You already have the tar.gz archive unzipped. Skipping the download"

fi

cd "boost_1_47_0"

echo "---I also need to use your password to install the library"

sudo chmod u+x bootstrap.sh

sudo chmod u+x ./tools/build/v2/engine/build.sh

echo "---Thank you"

echo "---This will take a while..."

sudo ./bootstrap.sh

#echo "---THIS WILL ALSO TAKE A LOOOOONG TIME..."

#sudo ./b2

echo "---ALMOST THERE..."

sudo ./bjam architecture=combined


echo "---DONE WITH INSTALLING BOOST!"

echo "...press enter to continue on with your life..."

read

clear

#END BOOST INSTALL



The terminal code is not the best in the world, but it does its job. And quite nicely. Well now comes part two, which changes if you decide to use g++/make or Xcode. In g++, you have to specify the libraries you are going to compile with, those commands are: -lboost_filesystem -lboost_system. The full makefile should look similar to:

CC = g++

CFLAGS = -Wall

PROG = game


SRCS := $(patsubst %.cpp,%.o,$(wildcard *.c*))

SRCS += $(patsubst %.cpp,%.o,$(wildcard */*.c*))

SRCS += $(patsubst %.cpp,%.o,$(wildcard */*/*.c*))

SRCS += $(patsubst %.cpp,%.o,$(wildcard */*/*/*.c*))


COMPILE = $(CC) $(CFLAGS) -c


ifeq ($(shell uname),Darwin)

LIBS = -framework OpenGL -framework GLUT -framework CoreFoundation

else

LIBS = -lglut

endif


all: $(PROG)


$(PROG): $(SRCS)

$(CC) $(CFLAGS) -lboost_filesystem -lboost_system -o $(PROG) $(SRCS) $(LIBS)


clean:

rm -f $(PROG)

rm -f *.o

rm -f */*.o

rm -f */*/*.o

rm -f */*/*/*.o


%.o: %.cpp

$(COMPILE) -o $@ $<

You might have noticed that I also added in -framework CoreFoundation. This framework is for SOIL (Simple Opengl Image Library).

To get Xcode to compile (in Xcode 4), you first need to include all the frameworks you use in your project. You probably have to include system none the less. To do this, in the "project navigator" (this is the left bar where all the files are) select the project title, this should be at the very top. Select the first item under project and use the filters: "All" and "Levels" under "Build Settings". Scroll down to "Search Paths" and under "User Header Search Paths" include "/usr/include/" (with the quotes). If nothing is there just put in "/usr/include" (with the quotes).
To add all the frameworks, select the first item under "Targets". Go to "Build Phases"->"Link binary with binaries". Click the plus and search for the framework you want.

SOIL does not need anything special to compile in Xcode, just do not include the "origional" folder. Soil will have quite a bit of warnings, but it should compile.

Sunday, September 26, 2010

C++ -> Flash

I am trying to make this into flash:

class Ccc
{
public:
char name[100];
int startTime;
int endTime;
cc() //constructor
{//null out everything
name[0]='\0';
startTime=-1;
endTime=-1;
}
int makeTime(int hr,int min){return hr*60+min;}
};
class Cschd
{
public:
Ccc cc[10];//I sure hope nobody has more than 9 classes in a day
int makeClass(char *name,int start_hr,int start_min,int end_hr,int end_min)
{
int num=0;//the array for which class of the day (0~9)
while (cc[num].name[0]='\0'){num++;}
int len=0;
while (name[len]!='\0'){cc[num].name=name[num];}//cc[num].name=name;
cc[num].startTime=cc[num].makeTime(start_hr,start_min);
cc[num].startTime=cc[num].makeTime(end_hr,end_min);
return num;//returns the id of the class instance
}
};

#define SATURDAY 0
#define MONDAY 1
#define TUESDAY 2
#define WEDNESDAY 3
#define THURSDAY 4
#define FRIDAY 5
#define SUNDAY 6

Cschd schd[7];//the schedule for every day

schd[MONDAY].makeClass("MA241",8,15,9,15);
//etc...

Monday, September 6, 2010

OpenGL and GLUT on Mac

I have been having a bunch of problems with GLUT and OpenGL on mac, but I finally got it!



Before I continue, go into terminal and type in:
"man make"
"man g++"
"man manuals are not found you NEED to upgrade Xcode! (I have no idea how you got MacPorts to work if you have not done this already)
Xcode is about 2.5gB, so it will take a while. But the upgrade is really nice (at least in my opinion). But it is needed for MacPorts.

Next, I will go over all the wrong steps.
MacPorts is a really nice tool, but you will NOT need it to install OpenGL and GLUT. It uses the "port" command from Terminal. Such as: "sudo port install cmake", which installs cmake. I tried installing glut though MacPorts, but it did not help. So I tried installing it manually from a zip file. Which include files are located (from what I currently know of) in two spots on the computer: "/opt/local/include/" and "/usr/local/include". I dragged and dropped some files in there (as well as some "Allegro" files, which is another library. I will be going over "Allegro" for a little bit in here since it also messed me up. I copied .../Allegro5/* into the include folders, but I really needed to copy .../* of the zip into the folder (leaving the Allegro5 folder intact though the copy). This left conflicting packages (ie. Memory.h!). Allegro needed to install something in "/Allegro5/platform/". (try to compile with #include , and it will point out the file). It has a cmake file in that folder, which I believe comments/uncomments out the installed setting or something like that. I tried to install cmake, but it got hung up while installing/compiling. Reading the log file, it died trying to #include . I fixed that by formatting the folder how it was supposed to be. And more useless stuff.

So what should you do?
NOTHING! Thats right, nothing! It is ALREADY INSTALLED ON MACS!!! Lucky you!
But to use it the right way you need to:

Use the right includes:
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>

Terminal users:
g++ main.cpp -o main -framework GLUT -framework OpenGL
gcc main.c -o main -framework GLUT -framework OpenGL
make is the same way

Xcode users:
Right click project in the "Groups & Files" bar (left side)
Add
Existing Frameworks...
Select Glut and OpenGl
You should see them added with your project

Thursday, August 12, 2010

My conflicting dpkg install of g++

This guide to how to do install a 3rd party app from your computer via terminal. Unix only, Windows terminal (Command Prompt) does not have these fancy commands.

Copy everything below and paste it into the terminal. It will auto run when you paste it.

How to extract it & copy it over: (please change the stuff in red)

cd ~/Documents/folder/to/app/
cp Geo.ipa Geo.zip || exit
unzip Geo.zip
cd Payload
rm Geo.zip

scp -r Geo.app root@192.168.1.999:/Applications||rm -rf "Payload" &&exit
rm -rf Payload
ssh root@192.168.1.999 || exit && exit
cd /Applications
cd Geo.app/ || echo "ERROR D" && exit
chmod +x Geo
echo "done!"
exit
exit
<- end highlight right here, then copy

It will prompt for the password two times.

And there we go! Go to the home screen and it should be there. If it isn't look though all your pages. Tf it still is not there, open up an app, use the app for about a minute and close it. If it still isn't there, restart you iPhone.

Wednesday, May 12, 2010

300: Revised Abstract

Laurens Requirement


My research examined the application and benefits of using Solar Power vs. Wind Power as alternative energy. I found that we need to reform our ways of obtaining energy from the carbon emitting producers and replace the process with clean, renewable, options. Without these new options we would soon face the doom of filling our atmosphere with concentrated carbon dioxide. The problem is in finding which option is best in a given situation. My method in analyzing the problem was to explore individual requirement in each case, understanding what it needs, what can be done, when it can be used, etc. By learning which option is best to use, we may develop a more efficient result and a cleaner environment. Unfortunately, there is no clean cut answer to each problem as there are variables to consider, such as reliant climate, sun and wind, environmental protection, and costs. For example, wind generated energy requires a lot of wind. Solar generated energy requires a lot of sun. Placing these options in regions not suited to the particular environment does not make environmental sense.


Some possibilities are being explored now with varying results. Solar generated street signs have been proven too unreliable due to the cost of each solar panel and the unreliability of weather patterns. According to “Solar Powered Signals: Myth or Marvel?” by Coetzee, theft of solar panels was one of the biggest cons for using solar generated street lights. However, there are some good possibilities, such as a US and China solar project to develop the biggest solar farm set for completion in 2019 in the Mongolian Desert with a total of 11,950 megawatts of power. The same US company is also developing three more solar farms, one the Mohave Desert totaling up to be 1,100 megawatts of power.