void main(void) { int i=0; initgraph(&gd,&gm,""); while(!kbhit()) { if((i%2)==1) { setvisualpage(1); setactivepage(0); clearviewport(); face1->mood=0; drawface(); delay(1000); } else { setvisualpage(0); setactivepage(1); clearviewport(); face1->mood=1; drawface(); delay(300); } i++; } getch(); closegraph(); }
void rectangle::draw_shape(ShZshader *pShader) { pShader->begin(); glBindVertexArray(m_vao); drawface(pShader); glBindVertexArray(0); pShader->end(); }
void draw_face(void) { if (face_first) createface(); face_rotate = old_face_rotate; face_rotate = reduce_vsync(face_rotate); face_time += face_rotate; render_face(); drawface(); drawblur(5, 0.01f, 0.4f); }
void drawbox(void) { glPushMatrix(); /* drawface(); */ glRotatef(90.0, 0.0, 1.0, 0.0); drawface(); if (normson) drawnorms(); glRotatef(90.0, 0.0, 1.0, 0.0); drawface(); if (normson) drawnorms(); glRotatef(90.0, 0.0, 1.0, 0.0); /* drawface(); */ glRotatef(-90.0, 1.0, 0.0, 0.0); drawface(); if (normson) drawnorms(); glRotatef(180.0, 1.0, 0.0, 0.0); /* drawface(); */ glPopMatrix(); }
void updatetimes(void) { int i; Face *f; for(i=0; i<nfaces; i++){ f = faces[i]; if(f == nil) continue; if(((long)(now - f->time) <= HhmmTime) != f->recent) drawface(f, i); } }
static void render_face(void) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDisable(GL_BLEND); glEnable(GL_NORMALIZE); glEnable(GL_DEPTH_TEST); glViewport(0, 0, 128, 128); drawface(); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, 128, 128, 0); glClearColor(0.0f, 0.2f, 0.4f, 0.4f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, point_general->WIDTH, point_general->HEIGHT); }
void drawscreen(int clear) { int i; if(clear){ geometry(screen->r); draw(screen, screen->r, bkgd, nil, ZP); } border(screen, rbig, -1, display->black, ZP); draw(screen, rbig, orig, nil, orig->r.min); border(screen, rramp, -1, display->black, ZP); draw(screen, rramp, ramp, nil, ramp->r.min); drawrampbar(red, &state); border(screen, rectaddpt(state.selr, subpt(rbig.min, orig->r.min)), -2, red, ZP); if(clear){ drawface(-1); for(i=0; i<nelem(face); i++) drawface(i); } }
void addface(Face *f) /* always adds at 0 */ { Face **ofaces; Rectangle r0, r1, r; int y, nx, ny; if(f == nil) return; if(first != 0){ first = 0; eresized(0); } findbit(f); nx = nacross; ny = (nfaces+(nx-1)) / nx; lockdisplay(display); for(y=ny; y>=0; y--){ /* move them along */ r0 = facerect(y*nx+0); r1 = facerect(y*nx+1); r = r1; r.max.x = r.min.x + (nx - 1)*(Facesize+Facesep); draw(screen, r, screen, nil, r0.min); /* copy one down from row above */ if(y != 0){ r = facerect((y-1)*nx+nx-1); draw(screen, r0, screen, nil, r.min); } } ofaces = faces; faces = emalloc((nfaces+1)*sizeof(Face*)); memmove(faces+1, ofaces, nfaces*(sizeof(Face*))); free(ofaces); nfaces++; setlast(); drawarrows(); faces[0] = f; drawface(f, 0); flushimage(display, 1); unlockdisplay(display); }
void delface(int j) { Rectangle r0, r1, r; int nx, ny, x, y; if(j < first) first--; else if(j < last){ nx = nacross; ny = (nfaces+(nx-1)) / nx; x = (j-first)%nx; for(y=(j-first)/nx; y<ny; y++){ if(x != nx-1){ /* move them along */ r0 = facerect(y*nx+x); r1 = facerect(y*nx+x+1); r = r0; r.max.x = r.min.x + (nx - x - 1)*(Facesize+Facesep); draw(screen, r, screen, nil, r1.min); } if(y != ny-1){ /* copy one up from row below */ r = facerect((y+1)*nx); draw(screen, facerect(y*nx+nx-1), screen, nil, r.min); } x = 0; } if(last < nfaces) /* first off-screen becomes visible */ drawface(faces[last], last-1); else{ /* clear final spot */ r = facerect(last-first-1); draw(screen, r, bgrnd, nil, r.min); } } freeface(faces[j]); memmove(faces+j, faces+j+1, (nfaces-(j+1))*sizeof(Face*)); nfaces--; setlast(); drawarrows(); }
void lab4::draw() { glPushMatrix(); { glBegin(GL_LINES); { glVertex2f(10, -10); glVertex2f(10, 10); glVertex2f(-10, 10); glVertex2f(-10, -10); } glEnd(); float l_x = -10; float l_y = func(l_x); float t = 0.05f; float next_x = l_x + t; float next_y = func(next_x); bool prev_hi = false; while(l_x <= 10) { bool is_hi = false; if(next_y - l_y > 0) is_hi = true; if(is_hi) glColor3f(1.0, 0, 0); else glColor3f(0, 1.0, 0); glBegin(GL_LINES); { glVertex2f(l_x, l_y); glVertex2f(next_x, next_y); } glEnd(); if(prev_hi != is_hi) { glPointSize(5); glBegin(GL_POINT); { glColor3f(0, 1.0, 1.0); drawface(next_x, next_y); } glEnd(); glPointSize(1); } prev_hi = is_hi; l_x = next_x; l_y = next_y; next_x = l_x + t; next_y = func(next_x); } } glPopMatrix(); }