Quote question - "How many textures can they use if they are limited to 256 x 256, with a 24 bits palette of 8 bits colour depth?"
- still trying to figure out -
32MB/(256*256*24) = 268435456 bytes /1572864
= 170.6666667
hmm, different answer...
Side note: This week's lecture, 2, is mainly about pixels, resolution, colours, and rendering. New terms such as buffer, double buffer, as well as old terms like bits, bytes, megabytes. Now I know how the flickering problem was 'solved'.
Now, back to the task at hand. This post will be dedicated for Week 2's Practical.
Questions & Answers(hopefully)
Qn 1: Define a Callback function
Ans 1: A callback function is a function which is executable code which is passed to another function as an argument, eg, function_Name(callback_Function);
Qn 2: When exactly is myDisplay() called? How do you get to your findings?
Ans 2: It is called, JUST after the program draws the screen. Upon debugging, if we keep track of the function, it will show us precisely when a function is carried out.
Qn 3: List the process to access the VRAM.
Ans 3: Memory pointer to the VRAM is obtained. A double buffer memory is obtained. It is then cleared before being modified. After which, it is copied to the VRAM before being cleared once again.
Question 4: What colour format are we using here i.e. 8 bits, 16 bits, 24 bits or 32 bits?
A pixel takes up to 1 byte of information, as the values range from 0 to 255. Thus we are using 8 bits colour format since 8 bits = 1 byte.
Question 5: How much memory have we allocated?
Ans 5: 800*600*1 = 480 000 bytes
About ~ 468.8 kilobytes
Question 6: Describe what has glDrawPixel() done.
Ans 6: glDrawPixel() has just sent data for the system to draw the plotted pixels on the screen/window which was previously created.
Practical Results
Here are some of the screenshots of the pixels which I was able to plot, from modifying the code.
"Vertical Lights"

What I 'created' by accident. I actually wanted to code a 'Melt Up', but I got this instead. Still it's cool. And no, it's not random vertical lines being drawn to the screen. It starts out full screen. At
certain intervals, the lines disappear, making it seem like a laser show.
"Batik Design"

As the name suggest, it looks like part of a "Batik" design.
"Tiled Floors"

Looking at this reminds me of special tile designs, usually seen in documentaries from some magnificent building.
*Tip for readers: If you want to get these odd colurs, try inserting varying values for the colours.
All in all, it was a good practice, especially since this is out first time learning and using OpengGL.
No comments:
Post a Comment