Wednesday, November 21, 2007

Week 5

Questions and Answers

Question 1
How did it arrive with the transformed coordinates?

The coordinates matrix is multiplied with the transformation matrix.

Question 2
What is/are the transformation(s) applied?

Translation and Scaling.

Question 3 -
OpenGL keeps track of only 1 matrix for transformation.
It will be tedious to do transformation for more than 1 mesh/
polygon/objects to different locations.
Why?


OpenGL can only take in 1 matrix for transformation.
If another matrix is to be added in, it overwrite the first one.

Question 4 -
(a) What is the current operation matrix after this function?

glTranslatef(10,2,4);
glScalef(5,5,5);

( 5 0 0 10 )
( 0 5 0 2 )
( 0 0 5 4 )
( 0 0 0 1 )

(b) What is the current operation matrix after this function?

glPushMatrix();
glRotatef(90,0,1,0);

( 5 0 0 10 )( 0 0 1 0 )=( 0 0 5 10 )
( 0 5 0 2 )( 0 1 0 0 )=( 0 5 0 2 )
( 0 0 5 4 )( -1 0 0 0 )=( -5 0 0 4 )
( 0 0 0 1 )( 0 0 0 1 )=( 0 0 0 1 )

(c) What is the current operation matrix after this function?

glPushMatrix();
glTranslate(2,2,2);

( 1 0 0 10 )( 0 0 5 2 )=( 0 0 5 12 )
( 0 1 0 2 )( 0 5 0 2 )=( 0 5 0 4 )
( 0 0 1 4 )( -5 0 0 2 )=( -5 0 0 6 )
( 0 0 0 1 )( 0 0 0 1 )=( 0 0 0 1 )

(d) What is the current operation matrix after this function?

glPopMatrix();
glScale(2,1,1);

( 0 0 5 10 )( 2 0 0 1 )=( 0 0 5 10 )
( 0 5 0 2 )( 0 1 0 1 )=( 0 5 0 2 )
( -5 0 0 4 )( 0 0 1 1 )=( -5 0 0 4 )
( 0 0 0 1 )( 0 0 0 1 )=( 0 0 0 1 )

(e) What is the current operation matrix after this function?

glPushMatrix();
glLoadIdentity();
glTranslate(0,5,0);

( 1 0 0 0 )( 0 0 0 0 )=( 1 0 0 0 )
( 0 1 0 0 )( 0 0 0 5 )=( 0 1 0 5 )
( 0 0 1 0 )( 0 0 0 0 )=( 0 0 1 0 )
( 0 0 0 1 )( 0 0 0 1 )=( 0 0 0 1 )
(f) What is the current operation matrix after this function?

glPopMatrix();
glPopMatrix();
glRotate(90,1,0,0);
(0 0 5 12)
(0 5 0 4)
(-5 0 0 6)
(0 0 0 1)

Question 5 -
What did you see? Screen shot it and explain why is the 2nd cube appeared at
(0,0,0)?


This is because OpenGL uses the previous matrix which is the first cube.
As it is at (5,0,0) minus 5 units in the x-direction would make the second cube appear at the origin.

Click HERE to download!!

Thursday, November 15, 2007

Week 4

Week 4

Question 1

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glOrtho(-6.4,0,-4.8,0,1,50);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluLookAt(4,4,4,0,1,0,0,1,0);

Question 2

800X600 screen size

Question 3

n =( 4 ,3 ,4 )
u =( 4 ,0 ,-4 )
v =( 12,32,-12)

Question 4

n =( 4 ,3 ,4 )
u =( -4,8 ,-2 )
v =( 38,-8,-44)

Question 5

MODEL VIEW matrix allows the virtual camera to look at the model.
PROJECTION matrix allows the screen to look from the camera point of view.

Question 6

glClear();

Question 7

gluLookAt();

Question 8

gluLookAt ( eyeX , eyeY , eyeZ , centerX , centerY , centerZ , upX , upY , upZ )

Parameters
eyeX, eyeY, eyeZ
Specifies the position of the eye point.

centerX, centerY, centerZ
Specifies the position of the reference point.

upX, upY, upZ
Specifies the direction of the up vector.


Question 9

The red triangle is behind the green triangle.

Question 10

The green triangle is too far away to be seen.

Click here to download Week 4 glut file.

Wednesday, November 7, 2007

Week 3

This is week 3 project..

There are no questions to answer for week 3

Click here for week 3 project

Thursday, November 1, 2007

Week 2

Week 2
Question and Answers

Question 1 – Why there are no errors and nothing has happened?
This is a openGL and there are no commands in the void main() function, when there is no commands in the void main () function,sometimes it will continue to compile.

Question 2 – Define a Callback function?
A callback function is a code that passed an argument to another code and then returns it.

Question 3 - When exactly is RenderScene()called? How do you get to your findings?
RenderScene is called right after the command glutMainLoop() in void main() function, then renderscene would use swapbuffer() back to main.

Question 4 – List the process to access the VRAM.
A struct is created, typedef struct. In void main function, it calls this function and it acceses the VRAM.

Question 5 - What color format are we using here i.e. 8 bits, 16 bits, 24 bits or 32 bits?
24bits color format.

Question 6 - How much memory have we allocated?
1.44MB

Question 7 - Describe what has glDrawPixel() done.
glDrawPixel allows user to input X and Y coordinates in respect to the resolution. It also allows user to input RGB Black(0,0,0) to White(255,255,255).

Click here for the link to download the OpenGL file.