Wednesday, October 31, 2007

Week 2 ~ Answers to the questions.

Here are my answers to week 2's practical questions.

Question 1 – Why there are no errors and nothing has happened?

The glut.h file was initially missing from the header file. In order to correct that, I had to remove the header file and add the GLUT file in itself, that is, adding the "glut.h" file into the header after taking away "header.h" to prevent errors.

Question 2 – Define a Callback function?

A Callback function can be described as a function that is called when something happens. This function is declared beforehand.

Question 3 – When exactly is RenderScene()called? How do you get to your
findings?

Since the function -> glutDisplayFunc(RenderScene) has the RenderScene function registered to it, that function is called back after glutDisplayFunc runs.

Question 4 – List the process to access the VRAM.

~If according to the code that I'm gonna post~
Start by creating a struct. This struct represents a pixel on the screen. Do create a pointer to create a memory space for the application size. (in this case, an array, size 800 by 600)

Copy the memory buffer, then clean it for rendering the image. The buffer will copy the image onto the VRAM to be displayed on the screen.

Delete the dynamic array created after use! Memory leak is dangerous!!!

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

Since we are using (Red,Blue,Green), we are using 24bits.

Question 6 – How much memory have we allocated?

(array size) x (24 bits / 8) = 1,440,000 bytes (approx. 1.37 MB)

Question 7 – Describe what has glDrawPixel() done.

glDrawPixel() transfers a pixel array out of host memory to the framebuffer.

Here is an example.
glDrawPixels(800,600,GL_RGB,GL_UNSIGNED_BYTE, g_pBuffer);

I shall post the code up on my blog, since I do not know how to make files available for download.

No comments: