Tutor profile: Daniel D.
Subject: Computer Graphics
How can you tell if a rendered triangle is facing towards the camera, or away from the camera.
If the triangle has a normal, a negative Z value in the normal, means it is facing away. If you only have the vertices of the triangle, then you can compute the normal. If the triangle has vertices A,B,C the normal is the cross product of the two vectors AB and AC.
Subject: C Programming
What is the output on a 16 bit compiler? int a = 257; char *CharPtr = (char *)&a;; int *IntPtr = (int *) &b; a*=2; printf("%d %d,*IntPtr,CharPtr); What if a was 258 at the first line instead?
514 2 A times two, is 514, which is pointed to by IntPtr. CharPtr is only looking at one byte of the answer. 514 in Hex is 0x 0202. So one byte of that answer is 02. If a was 258, that is 0x102 times two, which is 0x204 in hex. This means that the low byte is 4, and the high byte is 2. So if its a little endian platform the answer would be 516 4 For a big endian platform, the answer is 516 2
Subject: Assembly Language
When trying to optimize your assembly language program to run as fast as possible, what are some limiting factors to consider?
First and foremost is optimizing for best cache utilization. Random memory accesses that cause your cache lines to get evicted, or written back are extremely latent, and can block execution of your thread. Secondly, unpredictable branches (branches that aren't loops), can cause your instruction pipeline to flush, and restart.
needs and Daniel will reply soon.