static void draw_unichar (ModeInfo *mi) { unicrud_configuration *bp = &bps[MI_SCREEN(mi)]; char text[10]; char title[400]; XCharStruct e; int w, h, i, j; GLfloat s; i = utf8_encode (bp->unichar, text, sizeof(text) - 1); text[i] = 0; *title = 0; sprintf (title + strlen(title), "Plane:\t%s\n", bp->charplane); sprintf (title + strlen(title), "Block:\t%s\n", bp->charblock); # ifdef HAVE_JWXYZ sprintf (title + strlen(title), "Name:\t%s\n", (bp->charname ? bp->charname : "")); #endif sprintf (title + strlen(title), "Unicode:\t%04lX\n", bp->unichar); sprintf (title + strlen(title), "UTF-8:\t"); for (j = 0; j < i; j++) sprintf (title + strlen(title), "%02X ", ((unsigned char *)text)[j]); texture_string_metrics (bp->char_font, text, &e, 0, 0); w = e.width; h = e.ascent; s = 9; glScalef (s, s, s); s = 1.0 / (h > w ? h : w); /* Scale to unit */ glScalef (s, s, s); glTranslatef (-w/2, -h/2, 0); glColor4fv (bp->color); print_texture_string (bp->char_font, text); glColor3f (1, 1, 0); if (do_titles) print_texture_label (mi->dpy, bp->title_font, mi->xgwa.width, mi->xgwa.height, 1, title); }
ENTRYPOINT void draw_spheremonics (ModeInfo *mi) { spheremonics_configuration *cc = &ccs[MI_SCREEN(mi)]; Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (!cc->glx_context) return; glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(cc->glx_context)); gl_init(mi); glShadeModel(GL_SMOOTH); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix (); glScalef(1.1, 1.1, 1.1); { double x, y, z; get_position (cc->rot, &x, &y, &z, !cc->button_down_p); glTranslatef((x - 0.5) * 8, (y - 0.5) * 6, (z - 0.5) * 8); gltrackball_rotate (cc->trackball); get_rotation (cc->rot, &x, &y, &z, !cc->button_down_p); glRotatef (x * 360, 1.0, 0.0, 0.0); glRotatef (y * 360, 0.0, 1.0, 0.0); glRotatef (z * 360, 0.0, 0.0, 1.0); } glScalef(7,7,7); mi->polygon_count = 0; glScalef (cc->scale, cc->scale, cc->scale); glCallList (cc->dlist); mi->polygon_count += cc->polys1; if (cc->mesher >= 0 /* || cc->button_down_p */) { glDisable (GL_LIGHTING); glCallList (cc->dlist2); mi->polygon_count += cc->polys2; if (cc->mesher >= 0) cc->mesher--; } do_tracer(mi); if (cc->button_down_p) { char buf[200]; sprintf (buf, ((cc->m[0]<10 && cc->m[1]<10 && cc->m[2]<10 && cc->m[3]<10 && cc->m[4]<10 && cc->m[5]<10 && cc->m[6]<10 && cc->m[7]<10) ? "%d%d%d%d%d%d%d%d" : "%d %d %d %d %d %d %d %d"), cc->m[0], cc->m[1], cc->m[2], cc->m[3], cc->m[4], cc->m[5], cc->m[6], cc->m[7]); glColor3f(1.0, 1.0, 0.0); print_texture_label (mi->dpy, cc->font_data, mi->xgwa.width, mi->xgwa.height, 1, buf); } if (!static_parms) { if (cc->change_tick++ >= duration && !cc->button_down_p) { generate_spheremonics(mi); cc->change_tick = 0; cc->mesher = -1; /* turn off the mesh when switching objects */ } } glPopMatrix(); if (mi->fps_p) do_fps (mi); glFinish(); glXSwapBuffers(dpy, window); }
/* Draw the given sprite at the phase of its animation dictated by its creation time compared to the current wall clock. */ static void draw_sprite (ModeInfo *mi, sprite *sp) { slideshow_state *ss = &sss[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); image *img = sp->img; if (! sp->img) abort(); if (! img->loaded_p) abort(); glPushMatrix(); { glTranslatef (sp->current.x, sp->current.y, 0); glScalef (sp->current.w, sp->current.h, 1); if (wire) /* Draw a grid inside the box */ { GLfloat dy = 0.1; GLfloat dx = dy * img->w / img->h; GLfloat x, y; if (sp->id & 1) glColor4f (sp->opacity, 0, 0, 1); else glColor4f (0, 0, sp->opacity, 1); glBegin(GL_LINES); glVertex3f (0, 0, 0); glVertex3f (1, 1, 0); glVertex3f (1, 0, 0); glVertex3f (0, 1, 0); for (y = 0; y < 1+dy; y += dy) { GLfloat yy = (y > 1 ? 1 : y); for (x = 0.5; x < 1+dx; x += dx) { GLfloat xx = (x > 1 ? 1 : x); glVertex3f (0, xx, 0); glVertex3f (1, xx, 0); glVertex3f (yy, 0, 0); glVertex3f (yy, 1, 0); } for (x = 0.5; x > -dx; x -= dx) { GLfloat xx = (x < 0 ? 0 : x); glVertex3f (0, xx, 0); glVertex3f (1, xx, 0); glVertex3f (yy, 0, 0); glVertex3f (yy, 1, 0); } } glEnd(); } else /* Draw the texture quad */ { GLfloat texw = img->geom.width / (GLfloat) img->tw; GLfloat texh = img->geom.height / (GLfloat) img->th; GLfloat texx1 = img->geom.x / (GLfloat) img->tw; GLfloat texy1 = img->geom.y / (GLfloat) img->th; GLfloat texx2 = texx1 + texw; GLfloat texy2 = texy1 + texh; glBindTexture (GL_TEXTURE_2D, img->texid); glColor4f (1, 1, 1, sp->opacity); glNormal3f (0, 0, 1); glBegin (GL_QUADS); glTexCoord2f (texx1, texy2); glVertex3f (0, 0, 0); glTexCoord2f (texx2, texy2); glVertex3f (1, 0, 0); glTexCoord2f (texx2, texy1); glVertex3f (1, 1, 0); glTexCoord2f (texx1, texy1); glVertex3f (0, 1, 0); glEnd(); if (debug_p) /* Draw a border around the image */ { if (!wire) glDisable (GL_TEXTURE_2D); if (sp->id & 1) glColor4f (sp->opacity, 0, 0, 1); else glColor4f (0, 0, sp->opacity, 1); glBegin (GL_LINE_LOOP); glVertex3f (0, 0, 0); glVertex3f (0, 1, 0); glVertex3f (1, 1, 0); glVertex3f (1, 0, 0); glEnd(); if (!wire) glEnable (GL_TEXTURE_2D); } } if (do_titles && img->title && *img->title && (sp->state == IN || sp->state == FULL)) { glColor4f (1, 1, 1, sp->opacity); print_texture_label (mi->dpy, ss->font_data, mi->xgwa.width, mi->xgwa.height, 1, img->title); } } glPopMatrix(); if (debug_p) { if (!wire) glDisable (GL_TEXTURE_2D); if (sp->id & 1) glColor4f (1, 0, 0, 1); else glColor4f (0, 0, 1, 1); /* Draw the "from" and "to" boxes */ glBegin (GL_LINE_LOOP); glVertex3f (sp->from.x, sp->from.y, 0); glVertex3f (sp->from.x + sp->from.w, sp->from.y, 0); glVertex3f (sp->from.x + sp->from.w, sp->from.y + sp->from.h, 0); glVertex3f (sp->from.x, sp->from.y + sp->from.h, 0); glEnd(); glBegin (GL_LINE_LOOP); glVertex3f (sp->to.x, sp->to.y, 0); glVertex3f (sp->to.x + sp->to.w, sp->to.y, 0); glVertex3f (sp->to.x + sp->to.w, sp->to.y + sp->to.h, 0); glVertex3f (sp->to.x, sp->to.y + sp->to.h, 0); glEnd(); if (!wire) glEnable (GL_TEXTURE_2D); } }
ENTRYPOINT void draw_wip24(ModeInfo *mi) { uint64_t frame_start = get_time(); wip24_state* state = states + MI_SCREEN(mi); glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(state->glx_context)); glBindFramebuffer(GL_FRAMEBUFFER, state->framebuffer); glDrawBuffer(GL_COLOR_ATTACHMENT0); glViewport(0, 0, MI_WIDTH(mi)/state->undersample, MI_HEIGHT(mi)/state->undersample); if (state->program) { glUseProgram(state->program); update_uniforms(mi, state); glRectf(-1.0f, -1.0f, 1.0f, 1.0f); } glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, MI_WIDTH(mi), MI_HEIGHT(mi)); glUseProgram(0); glBindTexture(GL_TEXTURE_2D, state->fb_texture); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, 1.0f); glEnd(); if (mi->fps_p) do_fps(mi); print_texture_label(MI_DISPLAY(mi), state->font, MI_WIDTH(mi), MI_HEIGHT(mi), get_boolean_resource(MI_DISPLAY(mi), "fpsTop", "FPSTop")?2:1, state->shader_info); glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi)); state->time_delta = get_time() - frame_start; state->frame_count++; float dest = mi->pause / 1000.0f; float current = state->time_delta / 1000000.0f; float* undersample = state->undersamples + state->frame_count%4; if (current > (dest+1.0f)) *undersample += 0.1f; else if (current<(dest-1.0f) && state->undersample>1.0f) *undersample -= 0.1f; else goto no_reshape; state->undersample = (state->undersamples[0]+state->undersamples[1]+ state->undersamples[2]+state->undersamples[3]) / 2.0f; state->undersample = state->undersample>undersample_max ? undersample_max:state->undersample; reshape_wip24(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); no_reshape: ; mi->pause = dest>current ? dest-current : 0; if ((get_time() - state->start_time)/1000000000.0f > shader_duration) init_shader(mi, state); }