X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fmolecule.c;h=4cc3d0849463a39e5e97879e3afd0d57f8c97766;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=b5e6e8420f945e268a3f65cfe77048e58c318016;hpb=d5186197bc394e10a4402f7f6d23fbb14103bc50;p=xscreensaver diff --git a/hacks/glx/molecule.c b/hacks/glx/molecule.c index b5e6e842..4cc3d084 100644 --- a/hacks/glx/molecule.c +++ b/hacks/glx/molecule.c @@ -1,4 +1,4 @@ -/* molecule, Copyright (c) 2001-2014 Jamie Zawinski +/* molecule, Copyright (c) 2001-2016 Jamie Zawinski * Draws molecules, based on coordinates from PDB (Protein Data Base) files. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -12,7 +12,7 @@ /* Documentation on the PDB file format: - http://en.wikipedia.org/wiki/Protein_Data_Bank_%28file_format%29 + https://en.wikipedia.org/wiki/Protein_Data_Bank_%28file_format%29 http://www.wwpdb.org/docs.html http://www.wwpdb.org/documentation/format32/v3.2.html http://www.wwpdb.org/documentation/format32/sect9.html @@ -31,6 +31,7 @@ "*titleFont: -*-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*\n" \ "*noLabelThreshold: 150 \n" \ "*wireframeThreshold: 150 \n" \ + "*suppressRotationAnimation: True\n" \ # define refresh_molecule 0 # define release_molecule 0 @@ -91,7 +92,7 @@ static const char * const builtin_pdb_data[] = { }; -#ifndef USE_IPHONE +#ifndef HAVE_MOBILE # define LOAD_FILES #endif @@ -479,9 +480,12 @@ draw_bounding_box (ModeInfo *mi) glColor3f (c2[0], c2[1], c2[2]); glBegin(GL_LINES); - if (x1 > 0) x1 = 0; if (x2 < 0) x2 = 0; - if (y1 > 0) y1 = 0; if (y2 < 0) y2 = 0; - if (z1 > 0) z1 = 0; if (z2 < 0) z2 = 0; + if (x1 > 0) x1 = 0; + if (x2 < 0) x2 = 0; + if (y1 > 0) y1 = 0; + if (y2 < 0) y2 = 0; + if (z1 > 0) z1 = 0; + if (z2 < 0) z2 = 0; glVertex3f(x1, 0, 0); glVertex3f(x2, 0, 0); glVertex3f(0 , y1, 0); glVertex3f(0, y2, 0); glVertex3f(0, 0, z1); glVertex3f(0, 0, z2); @@ -1196,6 +1200,14 @@ reshape_molecule (ModeInfo *mi, int width, int height) 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (1/h, 1/h, 1/h); + } +# endif + glClear(GL_COLOR_BUFFER_BIT); } @@ -1368,9 +1380,6 @@ draw_labels (ModeInfo *mi) if (!do_labels) return; - if (!wire) - glDisable (GL_LIGHTING); /* don't light fonts */ - for (i = 0; i < m->natoms; i++) { molecule_atom *a = &m->atoms[i]; @@ -1384,7 +1393,7 @@ draw_labels (ModeInfo *mi) /* First, we translate the origin to the center of the atom. - Then we retrieve the prevailing modelview matrix (which + Then we retrieve the prevailing modelview matrix, which includes any rotation, wandering, and user-trackball-rolling of the scene. @@ -1420,25 +1429,24 @@ draw_labels (ModeInfo *mi) glRotatef (current_device_rotation(), 0, 0, 1); /* right side up */ { - int h; - int w = texture_string_width (mc->atom_font, a->label, &h); - GLfloat s = 1.0 / h; /* Scale to unit */ + XCharStruct e; + int w, h; + GLfloat s; + + texture_string_metrics (mc->atom_font, a->label, &e, 0, 0); + w = e.width; + h = e.ascent + e.descent; + + s = 1.0 / h; /* Scale to unit */ s *= mc->overall_scale; /* Scale to size of atom */ s *= 0.8; /* Shrink a bit */ glScalef (s, s, 1); - glTranslatef (-w * 0.5, h * 0.3 - h, 0); + glTranslatef (-w/2, -h/2, 0); print_texture_string (mc->atom_font, a->label); } glPopMatrix(); } - - /* More efficient to always call glEnable() with correct values - than to call glPushAttrib()/glPopAttrib(), since reading - attributes from GL does a round-trip and stalls the pipeline. - */ - if (!wire) - glEnable (GL_LIGHTING); }