graphic

Graphic

What you see is not what you think.

I want to change the style of my note book because recording the procedure of discovery maybe more useful.
1. The problem of definition of a function pointer array which contains those function in "glut" with similar function signature.
Suppose you want to call a series of functions in "glut", say to draw a series of predefined objects, it is really tedious to call one by one.
And in some other cases, calling by its index becomes more useful. Therefore I want to define a function pointer array to hold those similar
functions in it so that I can call them in a loop.
The usual way for a c/c++ programmer to do is to define a new type for this function pointer. If you do like this:
typedef void (*FuncType)(void);
It seems pretty normal. But when I try to initialize the array with OpenGL functions defined in "glut", it gives strange errors.
FuncType funcArray[2]={glutWireTeapot, glutSolidTeapot};
Why doesn't it work? It takes me more than half day to figure out that it is due to calling convention and this is NOT a problem when I try to
compile in Linux with g++. It seems Gnu compiler is smarter than VC++ compiler. 
The correct way is to define like this way:
typedef void (__stdcall *FuncType)(void);

FuncType funcArray[2]={glutWireTeapot, glutSolidTeapot};
Pay attention to "__stdcall" which is the default calling convention for windows API and many other functions in DLL.
2. Does the order of dot product matter?
A quite interesting question! And honestly speaking, I had prepared to ask this question in yesterday's lecture. However, I think I later figure it out myself. What does it matter? I mean the either picture can be correct!
 
1. <v,u>= |u||v|cos(theta) = |u|cos(theta) |v| = |v| cos(theta) |u|
    Because the product of <u,v> is just a scalor or a real value with no direction at all. So, either picture can be regarded correct because the value are the same.
 
2. And another question is how to define the angle between two vector, in textbook, it mentions that we should choose the smaller angle between two vector, but does it matter with "dot product" which calculates with cos(theta)? You see, cos(PI+theta)=cos(PI-theta). Therefore, in case of "dot product", nothing matters.
 
3. Does it matter in "cross product"? Surely it matters, first sin(PI+theta)= - sin(PI-theta), secondly the cross product is a vector with direction which must be specified clearly.
 
4. Actually I think you have a keen eye in noticing the difference in your picture between prof's lecture notes and textbook and I originally want to ask the quesion. But you know, I am becoming so lazy these days. :)
 
3. Why cannot I see the reflection of ground when I use a big cube or sphere as ground?
Answer: 
Lighting calculations need more vertices to give you accurate results.
Remember that the calculations are done ONLY at vertices and the results are
interpolated across the QUAD/TRIANGLE.
So a finely tessellated mesh has better lighting on its surface than a
simple quad of the same size.
Comment:
Exactly! And I really appreciate your quick reply! By the way, does anybody ask the similar question because I thought this must be a very 
common problem and I would be surprised that nobody asks about it. Or do they figure out themselves.

Thank you very much,
Answer:
It¨s a common question :)
Cheers,

 




                                 back.gif (341 bytes)       up.gif (335 bytes)         next.gif (337 bytes)