void loop(int id) { if(estado == MODIFIED){ mydisplay(); estado = IDLE; } else if(estado != IDLE){ mydisplay(); } glutTimerFunc(1000/FPS, loop, id); }
void handleMotion(int x, int y) { mouse_x = x; mouse_y = y; if ((state != MODIFIED) && (state != IDLE)) { ds[state].setCoordXY(x, y); mydisplay(); mydisplay(); } }
void loop(int id) { if (state == MODIFIED) { // A curva deve ser modificada mydisplay(); mydisplay(); state = IDLE; } else if (state != IDLE) { mydisplay(); mydisplay(); } glutTimerFunc(1000/FPS, loop, id); }
void myinit(void) { int i, j, thecolor; float thedir; srand48(time(NULL)); curworms = INITWORMS; for (j = 0; j < curworms; j++) { /* divide the circle up into a number of pieces, and send one worm each direction. */ worms[j].dir = ((2.0 * M_PI) / curworms) * j; thedir = worms[j].dir; worms[j].segx[0] = 0.0; worms[j].segy[0] = 0.0; for (i = 1; i < SEGMENTS; i++) { worms[j].segx[i] = worms[j].segx[i-1] + (STEPSIZE * cos(thedir)); worms[j].segy[i] = worms[j].segx[i-1] + (STEPSIZE * sin(thedir)); }; worms[j].head = (SEGMENTS - 1); /* make this worm one of the predefined colors */ thecolor = (int) COLORS * drand48(); worms[j].color = (GLfloat *) colors[thecolor]; }; /* now that they are all set, draw them as though they have just been uncovered */ mydisplay(); }
int main (int argc, char** argv) { window = inicia_glfw(3, 3, "Quadrado == Leque Triangular"); inicia_glew(); init(); // Ensure we can capture the escape key being pressed below glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); do{ mydisplay(); // Swap buffers glfwPollEvents(); } // Check if the ESC key was pressed or the window was closed while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS && glfwWindowShouldClose(window) == 0 ); glfwTerminate(); }