c++ - How to set up object transformations,properties? -


i'm new opengl, , doing homework online lessons. first task fill skillet code for: rotate, scale, translate, perspective, move left/right, up/down. did it, met problem next task: setting transformations. show me example or links how it? appreciate.

  (int = 0 ; < numobjects ; i++) {     object* obj = &(objects[i]);       // set object transformations      // , pass in appropriate material properties     // again gluniform() related functions useful      // draw object     // provide actual glut drawing functions you.       // remember obj->type notation 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]; 

transformations in modern opengl done using uniform matrices in shader. basically, have query uniform location of transformation variable (glgetuniformlocation) , pass obj->transform member location using gluniformmatrix4fv.

for material parameters workflow same, different gluniform* call fits type.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -