コード例 #1
0
ファイル: figure.cpp プロジェクト: econstantinidis/spuc
    void figure_t_t::draw_layer_list() {
        if(layers.size() <= 1) return;
        int l,w,h,r;
        std::string s;
        l = 1;
        w = 20;//button_width;
        h = 20;//button_height;
        r = 3;

        if(xPassive < 25) {
            glViewport(0,0, (int)(window_w),(int)(window_h));
            glLoadIdentity();
            gluOrtho2D( 0.0, (int)(window_w), (int)(window_h),0 );

            glDisable(GL_LINE_STIPPLE);
            gl2psDisable(GL2PS_LINE_STIPPLE);

            glLineWidth(2);
            glColor3d(0,0,1);

            int j = 0;
            for(layers_t::iterator lit = layers.begin(); lit != layers.end(); ++j, ++lit) {
                glBegin(GL_LINE_STRIP);// Draw the box
                    glVertex2d(l+r   ,h*j+r );
                    glVertex2d(l+r   ,h*j+h-r );
                    glVertex2d(l+w-r ,h*j+h-r );
                    glVertex2d(l+w-r ,h*j+r );
                    glVertex2d(l+r   ,h*j+r );
                glEnd();

                if(lit->second->is_visible()) {// Tick the box
                    glBegin(GL_LINE_STRIP);
                        glVertex2d(l+9 ,h*j+5 );
                        glVertex2d(l+8 ,h*j+15 );
                        glVertex2d(l+15  ,h*j+7 );
                    glEnd();
                }

                glColor3f(0,0,1);
                glRasterPos2f( 22, h*j+h-6);
                s = lit->second->layername;
                gl2psText(s.c_str(), "Arial", 12);
                for(unsigned int i = 0; i < s.size(); ++i) {
                    glutBitmapCharacter( GLUT_BITMAP_HELVETICA_12, s[i] );
                }
            }
        }
    }
コード例 #2
0
void display(void){
  unsigned int i;
  char *help = "Press 's' to save image or 'q' to quit";  

  glClearColor(0.3, 0.5, 0.8, 0.);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glPushMatrix();
  glRotatef(-60., 2., 0., 1.);
  glEnable(GL_LIGHTING);
  glutSolidTorus(0.3, 0.6, 30, 30);
  glDisable(GL_LIGHTING);
  glPopMatrix();
  glColor3f(1.,1.,1.);
  glRasterPos2d(-0.9,-0.9);
  gl2psText(help, "Times-Roman", 24);
  for (i = 0; i < strlen(help); i++)
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, help[i]);
  glFlush();
}
コード例 #3
0
static void display(void)
{
  unsigned int i;
  unsigned int N = 50;
  const char *help = "Press 's' to save image or 'q' to quit";

  glClearColor(0.3, 0.5, 0.8, 0.);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  /* draw a smooth-shaded torus */
  glPushMatrix();
  glRotatef(-60., 2., 0., 1.);
  glEnable(GL_LIGHTING);
	/*  glutSolidTorus(0.3, 0.6, 30, 30);*/
	drawCube(0.5);
  glDisable(GL_LIGHTING);
  glPopMatrix();

  glColor3f(1.,1.,1.);

  /* draw a stippled line with many small segments (this tests the
     ability of gl2ps to render lines using as few strokes as
     possible) */
  glEnable(GL_LINE_STIPPLE);
  glLineStipple(1, 0x087F);
  gl2psEnable(GL2PS_LINE_STIPPLE);
  glBegin(GL_LINE_STRIP);
  for(i = 0; i < N; i++) glVertex3f(-0.75 + 1.5 * (double)i/(double)(N - 1), 0.75, -0.9);
  glEnd();
  glDisable(GL_LINE_STIPPLE);
  gl2psDisable(GL2PS_LINE_STIPPLE);

  /* draw a text string */
  glRasterPos2d(-0.9,-0.9);
  gl2psText(help, "Times-Roman", 24);
  for (i = 0; i < strlen(help); i++)
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, help[i]);

  glFlush();
}
コード例 #4
0
static void ysGlPlotBitmap2d_retina(int iflag_retina,
                                    GLfloat x_plot, GLfloat y_plot,
                                    const char *label){
    if(iflag_retina == IONE){
        ysGlPlotBitmap2d(ibase_16x24, (x_plot-HALF), (y_plot-HALF), (GLubyte *)label);
        ysGlPlotBitmap2d(ibase_16x24, (x_plot+HALF), (y_plot-HALF), (GLubyte *)label);
        ysGlPlotBitmap2d(ibase_16x24, (x_plot+HALF), (y_plot+HALF), (GLubyte *)label);
        ysGlPlotBitmap2d(ibase_16x24, (x_plot-HALF), (y_plot+HALF), (GLubyte *)label);

        ysGlPlotBitmap2d(ibase_16x24, (x_plot-HALF), (y_plot    ), (GLubyte *)label);
        ysGlPlotBitmap2d(ibase_16x24, (x_plot+HALF), (y_plot    ), (GLubyte *)label);
        ysGlPlotBitmap2d(ibase_16x24, (x_plot    ), (y_plot-HALF), (GLubyte *)label);
        ysGlPlotBitmap2d(ibase_16x24, (x_plot    ), (y_plot+HALF), (GLubyte *)label);

        ysGlPlotBitmap2d(ibase_16x24, (x_plot    ), (y_plot    ), (GLubyte *)label);
    } else {
        ysGlPlotBitmap2d(ibase_8x12, (x_plot    ), (y_plot    ), (GLubyte *)label);
    }
    
    gl2psText(label, "Times",12);
    return;
}
コード例 #5
0
ファイル: gl2psTestSimple.c プロジェクト: Avogadro/avogadro
static void display(void)
{
  unsigned int i;
  unsigned int N = 50;
  const char *help = "Press 's' to save image or 'q' to quit";

  glClearColor(0.3, 0.5, 0.8, 0.);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  /* draw a smooth-shaded torus */
  glPushMatrix();
  glRotatef(-60., 2., 0., 1.);
  glEnable(GL_LIGHTING);
  glutSolidTorus(0.3, 0.6, 30, 30);
  glDisable(GL_LIGHTING);
  glPopMatrix();


  /* draw three triangles on the same zplane and use polygon offset
     to order the layers: the grey triangle should be drawn on the
     middle layer */
  glEnable(GL_POLYGON_OFFSET_FILL);
  glPolygonOffset(1.0, 1.0);
  gl2psEnable(GL2PS_POLYGON_OFFSET_FILL);
  glColor3f(0.,0.,0.);
  glBegin(GL_TRIANGLES);
  glVertex3f(0.6, 0.8, 0);
  glVertex3f(0.8, 0.8, 0);
  glVertex3f(0.7, 0.92, 0);
  glEnd();

  glPolygonOffset(2.0, 2.0);
  gl2psEnable(GL2PS_POLYGON_OFFSET_FILL);
  glColor3f(1.,1.,1.);
  glBegin(GL_TRIANGLES);
  glVertex3f(0.7, 0.8, 0);
  glVertex3f(0.9, 0.8, 0);
  glVertex3f(0.8, 0.92, 0);
  glEnd();

  glPolygonOffset(1.5, 1.5);
  gl2psEnable(GL2PS_POLYGON_OFFSET_FILL);
  glColor3f(0.5,0.5,0.5);
  glBegin(GL_TRIANGLES);
  glVertex3f(0.65, 0.86, 0);
  glVertex3f(0.85, 0.86, 0);
  glVertex3f(0.75, 0.98, 0);
  glEnd();

  glDisable(GL_POLYGON_OFFSET_FILL);
  gl2psDisable(GL2PS_POLYGON_OFFSET_FILL);

  glColor3f(0.1,0.1,0.1);

  /* draw a stippled line with many small segments (this tests the
     ability of gl2ps to render lines using as few strokes as
     possible) */
  glEnable(GL_LINE_STIPPLE);
  glLineStipple(1, 0x087F);
  gl2psEnable(GL2PS_LINE_STIPPLE);
  glBegin(GL_LINE_STRIP);
  for(i = 0; i < N; i++)
    glVertex3f(-0.75 + 1.5 * (double)i/(double)(N - 1), 0.75, -0.9);
  glEnd();
  glDisable(GL_LINE_STIPPLE);
  gl2psDisable(GL2PS_LINE_STIPPLE);

  /* draw a text string */
  glRasterPos2d(-0.9,-0.9);
  gl2psText(help, "Times-Roman", 24);
  for (i = 0; i < strlen(help); i++)
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, help[i]);

  glFlush();
}