Wednesday, February 24, 2010

Funny Web Accidents

Good News Everyone,

Terrible news everyone... haha. Thought I would post something funny I have found, MAN Google can be fun. Check out site site:

Now answer the BONUS QUESTION: what does "phpects" mean?

Hint (spoiler alert), ever tried replacing ASP with PHP?


Tuesday, February 23, 2010

Compiling wine with processor optimizations

Hi everyone,

Just thought I would show you all a quick trick to compile wine to be as fast as it can be!

You need to look into your compiler (GCC) and which flags it will support for your processor. Since I have an AMD Phenom II, I used -march=amdfam10 for GCC.

Here is a link where you can find out which -march to use :

Note that link is for AMD not sure where intel info is.

CFLAGS="-march=amdfam10 -O2 -pipe -fomit-frame-pointer"
export CFLAGS
./configure --disable-test
make depend && make
sudo make install

And we're done!

Thursday, February 18, 2010

Using Facebook API and using FQL

Using FQL Facebook Query Language


So you've made a facebook application, and you want to start using FQL to query all sorts of interesting things from Facebook's massive database of users

Facebook FQL Programming APIs

There are many API's available for facebook to access the FQL language. Some are for PHP and there are some for python (my favourite).

Aparently there is also one available using HTTP at the following url:

We will be using PHP. You must download the Facebook PHP client library. In our PHP script, we include the main file as shown:

include_once '/path-to-api/facebook-platform/php/facebook.php';

Diving In

Next, we create our instance of our facebook object:

$facebook = new Facebook('API_KEY','SECRET_KEY');
$fb_user = $facebook->require_login(); //require that we log in, because we need the user's id

Make sure you replace the API_KEY and SECRET_KEY with the proper strings, or also you could use php's define. Now what I wanted to do with FQL is generate a list of all the "Pages" that I have created under my account. I created well over 100 so I needed an easy way to get that list. Here is the example FQL query:

page_id IN (SELECT uid, page_id FROM page_admin WHERE uid = {$uid})

Note: FQL does not support standard SQL like JOIN, thus we use the subquery shown and the IN operator.

We use the client fundion "fql_query" in order to return the results of this query. Note I have {$uid} in there, that must also be replaced with the user's ID who created all those pages. Here is the PHP code I used for this:

$uid = $facebook->api_client->user; // get the user id
$query = "SELECT page_id, name, page_url, fan_count FROM page WHERE page_id IN (SELECT uid, page_id FROM page_admin WHERE uid = {$uid})";
$res = $facebook->api_client->fql_query($query);

There you have it! For more info on FQL see the official API documentation here:

FQL Documentation
List of FQL Tables available for query
Sample FQL queries

Wednesday, February 17, 2010

GLSL Shader Examples Vertex and Fragment

Hi Everyone,

Here is a quick example of a GLSL shader I use in my c++ 3d engine. Just thought I'd share some of the GLSL syntax with the internet community. I will fill in more information soon!

Vertex Shader

varying vec3 normal;

void main() {

normal = normalize(gl_NormalMatrix * gl_Normal);

//gl_Position = gl_ModelViewMatrix * gl_Vertex;

/*vec2 test = vec2((gl_MultiTexCoord0.xy - 0.5) * 2.0);
test.x *= 1.01;
test.y *= 1.01;
gl_Position.xy = test.xy;
gl_Position.z = 0.0;
gl_Position.w = 1.0;*/

gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;

Fragment Shader

uniform sampler2D texture_0;
uniform sampler2D texture_1;
varying vec3 normal;

void main() {
vec4 color = vec4(texture2D(texture_0, gl_TexCoord[0].xy));
float NdotL,NdotHV;
vec3 lDir = vec3(0.0, 0.0, 1.0);

if(color.r + color.g + color.b == 0.0)
color = vec4(1.0, 1.0, 1.0, 1.0);

if(color.r < 0.85)
color.r = 0.0;

color.g = color.r;
color.b = color.r;
//color.a = color.r;

vec3 n = normalize(normal);
NdotL = max(dot(n,lDir),0.0);
color.rgb *= NdotL;
gl_FragColor = color;

Thursday, February 11, 2010

Mass Effect 2 Runs in Wine in Ubuntu Linux

Mass Effect 2 using Linux in Wine

Get Wine

So I got mass effect 2 working in wine. Man is it a great game. To get it to work in wine:

go here and download wine (latest version as of now 1.1.38)

(note I would recommend 1.1.38 if you want to use the patches below)

extract and enter the directory in the terminal. Now we need to run the configure script:


Or to speed up compilation:

./configure --disable-tests

Which will skip compiling the wine test suite which generally you won't need.


Two patch files are located at: for the mouse warping for crashes (I didnt seem to need this patch)

Next, you will need to apply some patches. There is one for crashing, and another to fix the mouse warping. I don't have these on hand at the moment. I couldn't get my mouse warping to work properly, so I edited mouse.c under dlls/dinput/ and made it so mouse button 3 would toggle mouse warp (on / off) which is a pain but makes the game more playable. To apply patches to a source, under the source tree, type:


Afterwards you can compile as shown below.


Ensure that you have XML support compiled in, as well as openal. You can determine this through the final output of the configure script. If you don't have the xml and openal dev packages, install them with your favourite package editor.

sudo make install

Again, an interesting way to speed up compilation on a multi core machine is to use:

make -j 4
sudo make install

You can replace "-j 4" with the number of processors you have (I have a quad core).


now run "winecfg" and set up a virtual desktop (I have to using nvidia latest binary driver geforce 9600).

Also, we need to install packages with winetricks to get this to work

sh winetricks d3dx9 d3dx10 vcrun2005 physx

Now run the installer, and finally run the game. I am able to play on full settings with 1900x1080 resolution :D