Lines Matching defs:gear

28  *   * Refactor gear drawing.
72 * Struct representing a gear.
74 struct gear {
75 /** The array of vertices comprising the gear */
77 /** The number of vertices comprising the gear */
79 /** The array of triangle strips comprising the gear */
81 /** The number of triangle strips comprising the gear */
90 static struct gear *gear1, *gear2, *gear3;
91 /** The current gear rotation angle */
104 * Fills a gear vertex.
128 * Create a gear wheel.
132 * @param width width of gear
136 * @return pointer to the constructed struct gear
138 static struct gear *
145 struct gear *gear;
151 /* Allocate memory for the gear */
152 gear = malloc(sizeof *gear);
153 if (gear == NULL)
156 /* Calculate the radii used in the gear */
164 gear->nstrips = STRIPS_PER_TOOTH * teeth;
165 gear->strips = calloc(gear->nstrips, sizeof (*gear->strips));
168 gear->vertices = calloc(VERTICES_PER_TOOTH * teeth, sizeof(*gear->vertices));
169 v = gear->vertices;
188 gear->strips[cur_strip].first = v - gear->vertices; \
192 int _tmp = (v - gear->vertices); \
193 gear->strips[cur_strip].count = _tmp - gear->strips[cur_strip].first; \
268 gear->nvertices = (v - gear->vertices);
271 glGenBuffers(1, &gear->vbo);
272 glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
273 glBufferData(GL_ARRAY_BUFFER, gear->nvertices * sizeof(GearVertex),
274 gear->vertices, GL_STATIC_DRAW);
276 return gear;
446 * Draws a gear.
448 * @param gear the gear to draw
450 * @param x the x position to draw the gear at
451 * @param y the y position to draw the gear at
452 * @param angle the rotation angle of the gear
453 * @param color the color of the gear
456 draw_gear(struct gear *gear, GLfloat *transform,
463 /* Translate and rotate the gear */
484 /* Set the gear color */
488 glBindBuffer(GL_ARRAY_BUFFER, gear->vbo);
500 /* Draw the triangle strips that comprise the gear */
502 for (n = 0; n < gear->nstrips; n++)
503 glDrawArrays(GL_TRIANGLE_STRIP, gear->strips[n].first, gear->strips[n].count);