예제 #1
0
/**
 * @brief Renders everything; called once on startup
 * and then to animate hull algorithm steps.
 */
void ConvexHullApp::OnRender()
{
    SDL_FillRect(surf, NULL, SDL_MapRGB(surf->format, 255, 255, 255));    
    draw_points();
    draw_hull();
    SDL_Flip(surf);
}
예제 #2
0
파일: ysym.cpp 프로젝트: finger563/yocto-gl
void window_refresh_callback(GLFWwindow* window) {
    view_params* view = (view_params*)glfwGetWindowUserPointer(window);

    char title[4096];
    sprintf(title, "ysym | %s | %.3g | %d", view->filename.c_str(), view->time,
            view->frame);
    glfwSetWindowTitle(window, title);

    // begin frame
    ym_vec4f background = view->backgrounds[view->background];
    glClearColor(background[0], background[1], background[2], background[3]);
    glEnable(GL_DEPTH_TEST);
    glClearDepth(1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // draw
    shade(view->scene, view->cur_camera, view->shade_prog,
          view->shade_txt.data(), view->exposure, view->gamma, view->view_edges,
          view->camera_lights);

    // draw hull
    if (view->view_hull)
        draw_hull(view->rigid_scene, view->scene, 1, view->cur_camera,
                  view->shade_prog);

    // end frame
    glfwSwapBuffers(window);
}
예제 #3
0
/* Draw the nurb, possibly with trimming */
void draw_nurb(GLboolean trimming) {

    static GLfloat angle = 0.0;
    int i,j;


	/* wave the flag by rotating Z coords though a sine wave */
    for (i=1; i<4; i++)
        for (j=0; j<4; j++)
            ctlpoints[i][j][2] = sin((GLfloat)i+angle);

    angle += 0.1;
    
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

        glTranslatef(2.5,-1.0,0.0);
        glScalef(1.5,1.0,1.0);
        glRotatef(90,0.,0.,1.);
        glRotatef(mousey/10.,1.,0.,0.);
        glRotatef(mousex/10.,0.,1.,0.);
        
	gluBeginSurface(nurbsflag);
            gluNurbsSurface(nurbsflag,S_NUMKNOTS, sknots, T_NUMKNOTS, tknots,
                          3 * T_NUMPOINTS, 3,
                          &ctlpoints[0][0][0], T_ORDER, S_ORDER, GL_MAP2_VERTEX_3);
            if (trimming) {
                dotrim(whole);
                dotrim(path[0]);
                dotrim(path[1]);
                dotrim(path[2]);
            }
        gluEndSurface(nurbsflag);
        
	if (hull) draw_hull(ctlpoints);
    
    glPopMatrix();
    
}