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?
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,