1
我是OpenGL的新手,並從在線課程中做功課。我的第一個任務是填寫一個代碼爲:旋轉,縮放,翻譯,透視,左/右,上/下。我做到了,但遇到了下一個任務的問題:設置轉換。你能告訴我一個例子或者一些鏈接怎麼做嗎? 任何幫助將不勝感激。如何設置對象轉換屬性?
for (int i = 0 ; i < numobjects ; i++) {
object* obj = &(objects[i]);
// Set up the object transformations
// And pass in the appropriate material properties
// Again glUniform() related functions will be useful
// Actually draw the object
// We provide the actual glut drawing functions for you.
// Remember that obj->type is notation for accessing struct fields
if (obj->type == cube) {
glutSolidCube(obj->size);
}
else if (obj->type == sphere) {
const int tessel = 20;
glutSolidSphere(obj->size, tessel, tessel);
}
else if (obj->type == teapot) {
glutSolidTeapot(obj->size);
}
}
const int maxobjects = 10 ;
EXTERN int numobjects ;
EXTERN struct object {
shape type ;
GLfloat size ;
GLfloat ambient[4] ;
GLfloat diffuse[4] ;
GLfloat specular[4] ;
GLfloat emission[4] ;
GLfloat shininess ;
mat4 transform ;
} objects[maxobjects];