コード例 #1
0
ファイル: glwidget.cpp プロジェクト: circumcoronene/etr
void GLWidget::paintGL()
{
	int i;
	draw_axes();
	draw_disk();
	int nticks = 10;
	renderText(0.0, 0.0, 0.0, "0");
	qglColor( Qt::lightGray );
	for (i=0; i<nticks; i++)	{
		if (i*10.0 < maxb){
			renderText(-i*10.0*xs, 0.0, 0.0, QString("%1").arg(i*10.0));
			renderText(i*10.0*xs, 0.0, 0.0, QString("%1").arg(i*10.0));
			renderText(0.0, -i*10.0*ys, 0.0, QString("%1").arg(i*10.0));
			renderText(0.0, i*10.0*ys, 0.0, QString("%1").arg(i*10.0));
			renderText(0.0, 0.0, -i*10.0*zs, QString("%1").arg(i*10.0));
			renderText(0.0, 0.0, i*10.0*zs, QString("%1").arg(i*10.0));
		}
	}

	if (ex.size()>0 && ey.size()>0 && ez.size()>0 && ei.size()>0){
		glBegin(GL_POINTS);
		qglColor( blue->toRgb() );
		for (i=0; i<ei.size(); i++){
			if (ei[i]*15+50 < 300) {
				qglColor( blue->darker(50+ei[i]*15));
				if (ei[i] == ci || ci == 0)
					glVertex3f(ex[i]*xs, ey[i]*ys, ez[i]*zs);
			}
		}
		glEnd();
	}
}
コード例 #2
0
// Function called by GLUT to display the scene
void display()
{
   //  Clear the screen
   glClear(GL_COLOR_BUFFER_BIT);
   // Load the identity matrix
   glLoadIdentity();
   // Set the view angle
   glRotated(ph, 1, 0, 0);
   glRotated(th, 0, 1, 0);
   // Draw the Lorenz Attractor
   glColor3f(0, 0, 1);
   draw_attractor();
   // Draw the axes
   draw_axes();
   glColor3f(0, 0, 1);
   if(animate == 1) {
	   // Refresh the Attractor
	   draw_attractor();
	   // Draw the animation
	   animate_particle();
	}
   // Print the Lorenz Parameters
   print_params();
   // Make the scene visible
   glFlush();
   // Remove Clipping
   glutSwapBuffers();
}
コード例 #3
0
ファイル: ongr.c プロジェクト: yesyestian/BNB_Globlinear
void simple_plot_linestyle(
    double *x_arr, 
    double *y_arr, 
    int size, 
    char *xlabel, 
    char *ylabel,
    char *linestyle
  )
/*
    linestyle is a 2-character string.
      First character is line style N => no lines joining points
                                    L => lines joining points

      Second character is dot style N => nothing
                                    D => dots
                                    C => little circles
                                    L => lines down to axis
*/
{
  ongr on;
  frame fr;
  clear_ongr(&on);
  compute_axis_limits(x_arr,size,&on.x_axis);
  compute_axis_limits(y_arr,size,&on.y_axis);
  sprintf(on.x_axis.label,xlabel);
  sprintf(on.y_axis.label,ylabel);
  full_screen_frame(&fr);
  compute_axes_details(&on,&fr);
  draw_axes(&fr,&on);
  plot_in_frame(&fr,&on,x_arr,y_arr,size,linestyle);
}
コード例 #4
0
ファイル: glmain.c プロジェクト: Choino/school
void my_display() {
	
	// clear all pixels, reset depth 
	glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT );
	
	glLoadIdentity();
	//setup the camera (1st person? 3rd person?)
	
	if(firstPersonView == 0)
	{
		gluLookAt(10,10,75,10,10,20,0,1,0);
	}else
	{
		
		gluLookAt(my_cam.pos[0],my_cam.pos[1], my_cam.pos[2],
				  my_cam.at[0],my_cam.at[1],my_cam.at[2],
				  my_cam.up[0], my_cam.up[1], my_cam.up[2]);
	}
	
	//update the flashlight to follow the person
	 
	glLightfv(GL_LIGHT0, GL_POSITION, my_cam.at);
	
	glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, my_cam.dir);
	
	//draw the objects

	draw_axes();
	
	draw_objects();
	
	// this buffer is ready
	
	glutSwapBuffers();
}
コード例 #5
0
void render_ui_3d()
{
	LLGLSPipeline gls_pipeline;

	//////////////////////////////////////
	//
	// Render 3D UI elements
	// NOTE: zbuffer is cleared before we get here by LLDrawPoolHUD,
	//		 so 3d elements requiring Z buffer are moved to LLDrawPoolHUD
	//

	/////////////////////////////////////////////////////////////
	//
	// Render 2.5D elements (2D elements in the world)
	// Stuff without z writes
	//

	// Debugging stuff goes before the UI.

	// Coordinate axes
	if (gSavedSettings.getBOOL("ShowAxes"))
	{
		draw_axes();
	}

	stop_glerror();
		
	gViewerWindow->renderSelections(FALSE, FALSE, TRUE); // Non HUD call in render_hud_elements
	stop_glerror();
}
コード例 #6
0
ファイル: opengl.cpp プロジェクト: dtbinh/opengl_scene
//! LA fonction d'affichage
void GLDraw(void)
{
    // Efface la couleur et le ZBuffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

    // Place la scène comme on veut
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    camSetGL(cam);

    glPushAttrib( GL_ENABLE_BIT);
    glPointSize(18);
    glColor3f(1,1,1);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);
    glBegin(GL_POINTS);
    glVertex3f( LightPosition[0], LightPosition[1], LightPosition[2]  );
    glEnd();

    if (bAxe) draw_axes();
    if (bGrid) draw_grid();
    if (bAnim) animDraw(scene.anim);

    glPopAttrib();
    sceneDraw(scene);


    // since this is double buffered, swap the buffers to display what just got drawn.
    glutSwapBuffers();
}
コード例 #7
0
void render_scene()
{
	GLfloat x;
	GLfloat y;
	GLfloat z;
	GLfloat theta;
	GLfloat sizes[2];
	GLfloat size_inc;
	GLfloat point_size;

	glGetFloatv(GL_POINT_SIZE_RANGE, sizes);
	glGetFloatv(GL_POINT_SIZE_GRANULARITY, &size_inc);
	point_size = sizes[0];
	glClear(GL_COLOR_BUFFER_BIT);
	draw_axes();
	glColor3f(0.0f, 1.0f, 0.0f);
	z = -limit / 2.0f;
	for (theta = 0.0f; theta <= max_ang; theta += ang_inc) {
		x = limit / 2.0f * cos(theta);
		y = limit / 2.0f * sin(theta);
		glPointSize(point_size);
		glBegin(GL_POINTS);
			glVertex3f(x, y, z);
		glEnd();
		z += 5.0f * ang_inc;
		point_size += size_inc;
		if (point_size > sizes[1])
			point_size = sizes[0];
	}
}
コード例 #8
0
ファイル: example4.cpp プロジェクト: T-Jin/glui
void myGlutDisplay()
{
  glClearColor( .9f, .9f, .9f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  glFrustum( -xy_aspect*.04, xy_aspect*.04, -.04, .04, .1, 15.0 );

  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  glTranslatef( 0.0, 0.0, -2.6f );

  glScalef( scale, scale, scale );

  /*** Now we render object, using the variables 'obj_type', 'segments', and
    'wireframe'.  These are _live_ variables, which are transparently
    updated by GLUI ***/

  glPushMatrix();
  glTranslatef( -.5, 0.0, 0.0 );
  glRotatef( rotationY, 0.0, 1.0, 0.0 );
  glRotatef( rotationX, 1.0, 0.0, 0.0 );
  if ( wireframe && show_sphere)
    glutWireSphere( .4, segments, segments );
  else if ( show_sphere )
    glutSolidSphere( .4, segments, segments );
  draw_axes(.52f);
  glPopMatrix();

  glPushMatrix();
  glTranslatef( .5, 0.0, 0.0 );
  glRotatef( rotationY, 0.0, 1.0, 0.0 );
  glRotatef( rotationX, 1.0, 0.0, 0.0 );
  if ( wireframe && show_torus )
    glutWireTorus( .15,.3,16,segments );
  else if ( show_torus )
    glutSolidTorus( .15,.3,16,segments );
  draw_axes(.52f);
  glPopMatrix();

  glutSwapBuffers();
}
コード例 #9
0
ファイル: vrpn_gl_client_6dof.C プロジェクト: dborel/vrpn
void on_display()
{
    // Render the scene.

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_axes();
    draw_tracker(tposquat);

    glutSwapBuffers();
}
コード例 #10
0
ファイル: Grid3DView.cpp プロジェクト: spraff/monolith
void
QtUtil :: Grid3DView :: paint (QPainter & p, int w, int h)
const
{
	const int SIZE = 2 * m_width + 1;

	// Background

	p .fillRect (0, 0, w, h, Qt :: gray);

	p .setWindow (QRect (0, SIZE, SIZE, -SIZE));

	for (int i = -m_width; i <= int (m_width); ++i)
	{
		for (int k = -m_width; k <= int (m_width); ++k)
		{
			int I = get_i (m_position) + i;
			int K = get_k (m_position) + k;

			const bool dark  = (0 == I % 10)  || (0 == K % 10);
			const bool light = (0 == I % 100) || (0 == K % 100);

			const auto & ODD  = dark ? BG_DARK_ODD  : BG_ODD;
			const auto & EVEN = dark ? BG_DARK_EVEN : BG_EVEN;

			p .fillRect (
				i + m_width,
				k + m_width,
				1,
				1,
				(I^K)&1
					? (light ? BG_LIGHT_ODD  : ODD)
					: (light ? BG_LIGHT_EVEN : EVEN));
		}
	}

	for (int i = -m_width; i <= int (m_width); ++i)
	{
		for (int k = -m_width; k <= int (m_width); ++k)
		{
			p .save ();

			p .translate (i + m_width, k + m_width);

			draw (p, m_position + to_global (i, k));

			p .restore ();
		}
	}

	draw_cursor (p, w, h);

	draw_axes (p, w, h);
}
コード例 #11
0
static void	drawSlider(btSliderConstraint* pSlider)
{
    draw_axes(pSlider->getRigidBodyA(), pSlider->getFrameOffsetA());
    draw_axes(pSlider->getRigidBodyB(), pSlider->getFrameOffsetB());
    // draw limits in white
    btVector3 from(pSlider->getLowerLinLimit(), 0, 0);
    btVector3 to(pSlider->getUpperLinLimit(), 0, 0);
    btTransform trans;
    if(pSlider->getUseLinearReferenceFrameA())
    {
        trans = pSlider->getRigidBodyA().getWorldTransform() * pSlider->getFrameOffsetA();
    }
    else
    {
        trans = pSlider->getRigidBodyB().getWorldTransform() * pSlider->getFrameOffsetB();
    }
    from = trans * from;
    to = trans * to;
    glBegin(GL_LINES);
    glColor3f(255.0F, 255.0F, 255.0F);
    glVertex3d(from.getX(), from.getY(), from.getZ());
    glVertex3d(to.getX(), to.getY(), to.getZ());
    glEnd();
} // drawSlider()
コード例 #12
0
ファイル: glmain.cpp プロジェクト: JGelpi97/School
void my_display() {

	// clear all pixels, reset depth 
	glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT );

	//Camera view
	cam->CreateView();	

	draw_axes();

	//draw the objects
	draw_objects();

	// this buffer is ready
	glutSwapBuffers();
}
コード例 #13
0
ファイル: main.cpp プロジェクト: sahle123/Personal-Projects
/*  display  */
void display()
{
    Obj_Clank myClank;

    // Clear the image
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Enable Z-buffering depth test
    glEnable(GL_DEPTH_TEST);

    // Enable line smoothing (To make it look nicer)
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

    // Reset previous transforms
    glLoadIdentity();

    /// Choose how to rotate (For ortho and perspective)
    if(Glo_Mode == 1) // Ortho
    {
        // Sets ortho rotation view
        glRotated(Glo_ph, 1, 0, 0);
        glRotated(Glo_th, 0, 1, 0);
    }
    else if(Glo_Mode == 2) // Perspective
    {
        double Ex = -2*Glo_Scale*Sin(Glo_th)*Cos(Glo_ph);
        double Ey = +2*Glo_Scale*Sin(Glo_ph);
        double Ez = +2*Glo_Scale*Cos(Glo_th)*Cos(Glo_ph);
        gluLookAt(Ex, Ey, Ez, 0, 0, 0, 0, Cos(Glo_ph), 0);
    }

    // Code is in clank_builder.h
    myClank.simple_draw_clank();

    // Draw the cartesian coordinate plane
    draw_axes();

    // Display parameters
    glWindowPos2i(5, 5);
    Print("View Angle=%d, %d Glo_Scale=%.1f Glo_FOV=%d Projection=%s",
          Glo_th, Glo_ph, Glo_Scale, Glo_FOV, Glo_Text[Glo_Mode-1].c_str());

    glFlush();
    glutSwapBuffers();
}
コード例 #14
0
ファイル: graphtriangle1.c プロジェクト: srack/fundcomp1
//begin main function
int main (void) 
{		
	int xsize = 800, ysize = 800 ;
	gfx_open( xsize, ysize, "Test Graph of Function triangle_waveform" ) ;

	int stillgoing = 1;

	while (stillgoing) {
		gfx_clear() ;
		gfx_color(255, 255, 255) ;	//axis is white		
		draw_axes( xsize, ysize) ;
		gfx_color(150, 0, 255) ;
		plot_triangle(xsize, ysize, -10., 10, .1) ;
		gfx_flush() ;

		char c = gfx_wait() ;
		if (c == 'q') stillgoing = 0 ;
	}
	return 0 ;
}	//end main		
コード例 #15
0
//Draw our objects
void render_scene()
{
	glClear(GL_COLOR_BUFFER_BIT);
	glPushMatrix();
	glRotatef(rad_to_deg(x_rot), 1.0f, 0.0f, 0.0f);
	glRotatef(rad_to_deg(y_rot), 0.0f, 1.0f, 0.0f);
	draw_axes();
	glColor3f(1.0f, 0.0f, 0.0f);
	//Octagon
	glBegin(GL_POLYGON);
		glVertex2f(-20.0f, 50.0f);
		glVertex2f(20.0f, 50.0f);
		glVertex2f(50.0f, 20.0f);
		glVertex2f(50.0f, -20.0f);
		glVertex2f(20.0f, -50.0f);
		glVertex2f(-20.0f, -50.0f);
		glVertex2f(-50.0f, -20.0f);
		glVertex2f(-50.0f, 20.0f);
	glEnd();
	glPopMatrix();
}
コード例 #16
0
ファイル: llviewerdisplay.cpp プロジェクト: Boy/netbook
void render_ui_3d()
{
	LLGLSPipeline gls_pipeline;

	//////////////////////////////////////
	//
	// Render 3D UI elements
	// NOTE: zbuffer is cleared before we get here by LLDrawPoolHUD,
	//		 so 3d elements requiring Z buffer are moved to LLDrawPoolHUD
	//

	// Render selections
	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);

	/////////////////////////////////////////////////////////////
	//
	// Render 2.5D elements (2D elements in the world)
	// Stuff without z writes
	//

	// Debugging stuff goes before the UI.

	if (gSavedSettings.getBOOL("ShowDepthBuffer"))
	{
		post_show_depth_buffer();
	}

	// Coordinate axes
	if (gSavedSettings.getBOOL("ShowAxes"))
	{
		draw_axes();
	}

	stop_glerror();
		
	gViewerWindow->renderSelections(FALSE, FALSE, TRUE); // Non HUD call in render_hud_elements
	stop_glerror();
}
コード例 #17
0
ファイル: glmain.c プロジェクト: Choino/school
void my_display() {

  // clear all pixels, reset depth 
  glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT );
  
  glLoadIdentity();
  //setup the camera (1st person? 3rd person?)

  gluLookAt(my_cam.pos[0],my_cam.pos[1], my_cam.pos[2],
	    my_cam.at[0],my_cam.at[1],my_cam.at[2],
	    my_cam.up[0], my_cam.up[1], my_cam.up[2]);

  //update the flashlight to follow the person
  
  //draw the objects
  draw_axes();

  draw_objects();

  // this buffer is ready
  glutSwapBuffers();
}
コード例 #18
0
ファイル: glmain.c プロジェクト: Choino/school
/*TODO add on*/
void my_display() {

  // clear all pixels, reset depth 
  glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT );
  
   // init to identity 

   glLoadIdentity() ;

   gluLookAt(x_camera, y_camera, z_camera,  // x,y,z coord of the camera 
	    0.0, 0.0, 0.0,  // x,y,z LookAt
	    0.0, 1.0, 0.0); // the direction of Up (default is y-axis)

   draw_axes();


   draw_object(crt_shape);

  // this buffer is ready

  glutSwapBuffers();

}
コード例 #19
0
void render_ui_3d()
{
	LLGLSPipeline gls_pipeline;

	//////////////////////////////////////
	//
	// Render 3D UI elements
	// NOTE: zbuffer is cleared before we get here by LLDrawPoolHUD,
	//		 so 3d elements requiring Z buffer are moved to LLDrawPoolHUD
	//

	/////////////////////////////////////////////////////////////
	//
	// Render 2.5D elements (2D elements in the world)
	// Stuff without z writes
	//

	// Debugging stuff goes before the UI.

	stop_glerror();
	
	if (LLGLSLShader::sNoFixedFunction)
	{
		gUIProgram.bind();
	}

	// Coordinate axes
	static const LLCachedControl<bool> show_axes("ShowAxes");
	if (show_axes)
	{
		draw_axes();
	}

	gViewerWindow->renderSelections(FALSE, FALSE, TRUE); // Non HUD call in render_hud_elements
	stop_glerror();
}
コード例 #20
0
void CSimpleGraph::update()
{
	CRect rct;
	GetClientRect(rct);

	// If the graph has been resized we need a new DC/bitmap
	if (m_rct != rct)
	{
		m_rct = rct;

		CWnd *pAnc;
		if ((pAnc = GetParent()) != NULL && (pAnc = pAnc->GetParent()) != NULL)
		{
			CRect rctAnc;
			pAnc->GetClientRect(rctAnc);

			// Somehow when the Properties windows is resized small or -ve the graph window
			// becomes bigger than its container so we work out the adjustment here.
			m_rct.bottom = rctAnc.Height() - m_heightAdjust;
		}
		// Delete old DC/bitmap
		if (m_pdc != NULL)
		{
			delete m_pdc;
			m_pdc = NULL;
			m_bm.DeleteObject();
			m_hfnt.DeleteObject();
			m_vfnt.DeleteObject();
		}

		// Recreate DC/bitmap for drawing into
		CDC* pDC = GetDC();
		m_pdc = new CDC();
		m_pdc->CreateCompatibleDC(pDC);
		m_bm.CreateCompatibleBitmap(pDC, rct.Width(), rct.Height());
		m_pdc->SelectObject(&m_bm);

		// Set up text including creating the font
		LOGFONT lf;
		memset(&lf, '\0', sizeof(lf));
		lf.lfHeight = 12;
		strcpy(lf.lfFaceName, "Tahoma");   // Simple font face for small digits
		m_hfnt.CreateFontIndirect(&lf);
		lf.lfEscapement = 900;             // text at 90 degrees
		m_vfnt.CreateFontIndirect(&lf);

		m_pdc->SetBkMode(TRANSPARENT);
		m_pdc->SetTextColor(m_axes);       // use same colour as axes for now
	}

	// Get adjusted colours
	COLORREF *pc = new COLORREF[m_col.size()];
	for (int ii = 0; ii < m_col.size(); ++ii)
		pc[ii] = add_contrast(m_col[ii], m_back);

	// Draw background
	m_pdc->FillSolidRect(0, 0, rct.Width(), rct.Height(), m_back);
	draw_axes();

	int width = m_rct.Width() - m_left - m_right;     // width of the actual graph area
	int height = m_rct.Height() - m_top - m_bottom;   // height of the graph
	int ypos = m_rct.Height() - m_bottom;             // bottom of the graph (dist. from rect top)

	// Draw bars of graph
	ASSERT(m_val.size() == m_col.size());
	int xpos = m_left;
	for (int ii = 0; ii < m_val.size(); ++ii)
	{
		int next_xpos = m_left + (width*(ii+1))/m_val.size();
		int cy = int((m_val[ii]*height)/m_max);

		m_pdc->FillSolidRect(xpos, ypos - cy, next_xpos - xpos, cy, pc[ii]);        // draw bar for this byte value
		//m_pdc->FillSolidRect(xpos, ypos - cy, next_xpos - xpos,  1, RGB(0, 0, 0));  // add black tip to all bars

		// Add ticks
		if (ii % 16 == 0)
		{
			int siz;
			if (ii %64 == 0)
				siz = 4;
			else
				siz = 2;
			m_pdc->FillSolidRect(xpos - 1, ypos + 1, 1, siz, m_axes);
		}
		xpos = next_xpos;
	}
	m_pdc->FillSolidRect(xpos - 1, ypos + 1, 1, 4, m_axes);   // Right end tick
	delete[] pc;

	Invalidate();
}
コード例 #21
0
ファイル: cggfirst.c プロジェクト: actics/cgg
static void draw_graph(cairo_t *cr) {
    int i;
    int screen_width, screen_height;
    int old_y;
    int current_x, current_y;
    
    float *points;
    float min_y, max_y;
    float expansion_x, expansion_y;
    float x;
    
    screen_width  = gtk_widget_get_allocated_width(GTK_WIDGET(drawing_area))+1;
    screen_height = gtk_widget_get_allocated_height(GTK_WIDGET(drawing_area))+1;
    
    screen_width  -= 2*EMPTY_ZONE_WIDTH;
    screen_height -= 2*EMPTY_ZONE_WIDTH;
    
    /***Расчет точек графика***/
    points = (float*) malloc(screen_width*sizeof(float));
    
    min_y = FLT_MAX;
    max_y = FLT_MIN;
    
    expansion_x = (parametr[RIGHT_BOUND] - parametr[LEFT_BOUND]) / screen_width;
    
    x = parametr[LEFT_BOUND];
    for (i=0; i<screen_width; i++, x+=expansion_x) {
        points[i] = f(x);
        if (points[i] > max_y) max_y = points[i];
        if (points[i] < min_y) min_y = points[i];
    }

    expansion_y = screen_height / (min_y - max_y);
    
    draw_axes(cr, screen_width+2*EMPTY_ZONE_WIDTH, screen_height+2*EMPTY_ZONE_WIDTH, min_y, max_y);
    
    /***Отрисовка графика***/
    
    cairo_set_source_rgb(cr, 1, 0, 0);
    cairo_set_line_width(cr, 1.0);
    
    current_x = EMPTY_ZONE_WIDTH;
    old_y = current_y = (int) ((points[0] - max_y)*expansion_y) + EMPTY_ZONE_WIDTH;

    cairo_move_to(cr, EMPTY_ZONE_WIDTH, (int) ((points[0] - max_y)*expansion_y) + EMPTY_ZONE_WIDTH);
    for (i=1; i<screen_width; i++) {
        current_x = i+EMPTY_ZONE_WIDTH;
        current_y = (int) ((points[i] - max_y)*expansion_y) + EMPTY_ZONE_WIDTH;

        if ( fabs(current_y - old_y) <= screen_height / 2 ) {
            cairo_line_to(cr, current_x, current_y);
        }
        else {
            cairo_move_to(cr, current_x, current_y);
        }

        old_y = current_y;
    }
    cairo_stroke(cr);
    
    free(points);
}
コード例 #22
0
ファイル: main.cpp プロジェクト: sahle123/Personal-References
/*  display  */
void display()
{
    Obj_Clank myClank(Glo_th, Glo_ph);

    // Clear the image
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Enable Z-buffering depth test
    glEnable(GL_DEPTH_TEST);

    // Enable line smoothing (To make it look nicer)
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

    // Reset previous transforms
    glLoadIdentity();

    /// Choose how to rotate (For ortho and perspective)
    if(Glo_Mode == 1) // Ortho
    {
        // Sets ortho rotation view
        glRotated(Glo_ph, 1, 0, 0);
        glRotated(Glo_th, 0, 1, 0);
    }
    else if(Glo_Mode == 2) // Perspective
    {
        double Ex = -2*Glo_Scale*Sin(Glo_th)*Cos(Glo_ph);
        double Ey = +2*Glo_Scale*Sin(Glo_ph);
        double Ez = +2*Glo_Scale*Cos(Glo_th)*Cos(Glo_ph);
        gluLookAt(Ex, Ey, Ez, 0, 0, 0, 0, Cos(Glo_ph), 0);
    }

    if(Glo_Light)
    {
        int distance = 5; // Light distance
        myClank.set_light(Glo_Light);
        //  Translate intensity to color vectors
        GLfloat Ambient[]   = {static_cast<GLfloat>(0.01*ambient) ,static_cast<GLfloat>(0.01*ambient) ,static_cast<GLfloat>(0.01*ambient) ,1.0};
        GLfloat Diffuse[]   = {static_cast<GLfloat>(0.01*diffuse) ,static_cast<GLfloat>(0.01*diffuse) ,static_cast<GLfloat>(0.01*diffuse) ,1.0};
        GLfloat Specular[]  = {static_cast<GLfloat>(0.01*specular),static_cast<GLfloat>(0.01*specular),static_cast<GLfloat>(0.01*specular),1.0};
        //  Light position
        GLfloat Position[]  = {static_cast<GLfloat>(distance*Cos(Glo_zh)),ylight,static_cast<GLfloat>(distance*Sin(Glo_zh)),1.0};
        //  Draw light position as ball (still no lighting here)
        glColor3f(1,1,1);
        myClank.ball(Position[0],Position[1],Position[2] , 0.3);
        //  OpenGL should normalize normal vectors
        glEnable(GL_NORMALIZE);
        //  Enable lighting
        glEnable(GL_LIGHTING);
        //  Location of viewer for specular calculations
        glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,local);
        //  glColor sets ambient and diffuse color materials
        glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
        glEnable(GL_COLOR_MATERIAL);
        //  Enable light 0
        glEnable(GL_LIGHT0);
        //  Set ambient, diffuse, specular components and position of light 0
        glLightfv(GL_LIGHT0,GL_AMBIENT ,Ambient);
        glLightfv(GL_LIGHT0,GL_DIFFUSE ,Diffuse);
        glLightfv(GL_LIGHT0,GL_SPECULAR,Specular);
        glLightfv(GL_LIGHT0,GL_POSITION,Position);

        // Code is in clank_builder.h
        myClank.simple_draw_clank();
    }
    else
    {
        glDisable(GL_LIGHTING);
        myClank.set_light(Glo_Light);
        // Code is in clank_builder.h
        myClank.simple_draw_clank();
    }
    glDisable(GL_LIGHTING);

    // Draw the cartesian coordinate plane
    draw_axes();

    // Display parameters
    glWindowPos2i(5, 5);
    Print("View Angle=%d, %d Glo_Scale=%.1f Glo_FOV=%d Projection=%s",
          Glo_th, Glo_ph, Glo_Scale, Glo_FOV, Glo_Text[Glo_Mode-1].c_str());
    // Displays light on or off.
    glWindowPos2i(5,25);
    Print("Light is: %s",Glo_Light?"On":"Off");

    glFlush();
    glutSwapBuffers();
}
コード例 #23
0
ファイル: lab04_01.cpp プロジェクト: bdumitriu/playground
void main()
{
    char c;
    int gata = 0;
    double xx1[DIM], xx2[DIM], yy1[DIM], yy2[DIM];

    initialize_graphic_mode();
    initialize_variable_spaces();
    create_figure();
    draw_figure();
    draw_axes();
    draw_line();

    do
    {
        c = getch();
        for (int i = 0; i < DIM; i++)
        {
            xx1[i] = x1[i];
            xx2[i] = x2[i];
            yy1[i] = y1[i];
            yy2[i] = y2[i];
        }
        switch (c)
        {
        case 9:
            idx++;
            if (idx == 9)
                idx = 1;
            variable_space(1);
            break;
        case '+':
            modify_variable(1);
            break;
        case '-':
            modify_variable(0);
            break;
        case 't':
            draw_figure();
            translate(transX, transY);
            draw_figure();
            break;
        case 's':
            draw_figure();
            scale(scaleX, scaleY);
            draw_figure();
            break;
        case 'c':
            draw_figure();
            center_rotate(rotA);
            draw_figure();
            break;
        case 'r':
            draw_figure();
            origin_rotate(rotA);
            draw_figure();
            break;
        case 'x':
            draw_figure();
            Ox_simetry();
            draw_figure();
            break;
        case 'y':
            draw_figure();
            Oy_simetry();
            draw_figure();
            break;
        case 'o':
            draw_figure();
            origin_simetry();
            draw_figure();
            break;
        case 'd':
            draw_figure();
            random_line_simetry(simX, simY, simA);
            draw_figure();
            break;
        case 27:
            gata = 1;
            break;
        case 0:
            c = getch();
            switch (c)
            {
            case 15:
                idx--;
                if (idx == 0)
                    idx = 8;
                variable_space(0);
                break;
            case 80:
                draw_axes();
                if (y < 427)
                    y++;
                draw_axes();
                break;
            case 72:
                draw_axes();
                if (y > 0)
                    y--;
                draw_axes();
                break;
            case 77:
                draw_axes();
                if (x < 638)
                    x++;
                draw_axes();
                break;
            case 75:
                draw_axes();
                if (x > 0)
                    x--;
                draw_axes();
                break;
            }
        }
        if (not_on_the_screen())
        {
            draw_figure();
            for (int i = 0; i < DIM; i++)
            {
                x1[i] = xx1[i];
                x2[i] = xx2[i];
                y1[i] = yy1[i];
                y2[i] = yy2[i];
            }
            draw_figure();
        }
    }
    while (!gata);

    closegraph();
}
コード例 #24
0
ファイル: ongr.c プロジェクト: yesyestian/BNB_Globlinear
void ongr_basic_histogram( frame *fr, double *x, int size )
{
  double rough_num_cols = int_min(MAX_BARS/6-1,(int) ceil(sqrt((double) size)));
  double xlo,xhi,delta;
  int bars;
  double freq[MAX_BARS],bases[MAX_BARS];
  int i;
  ongr on;

  sensible_limits(doubles_min(x,size),doubles_max(x,size),&xlo,&xhi,&delta);
/* &&& */
/*
  xlo = 0.0;
  xhi = 10.0;
  delta = 0.2;
*/

  bars = (int) ceil((xhi - xlo) / delta);

  while ( bars < rough_num_cols )
  {
    bars *= 2;
    if ( bars < rough_num_cols )
    {
      bars /= 2;
      bars *= 5;
    }
    if ( bars < rough_num_cols )
      bars *= 2;
  }

  if ( bars > MAX_BARS ) my_error("MAX_BARS too small");

  delta = (xhi - xlo) / bars;
  bars += 3;
  xhi += delta;
  xlo -= delta;

  set_realnums_constant(freq,bars,0.0);
  printf("delta = %g, bars = %d\n",delta,bars);
  
  for ( i = 0 ; i < size ; i++ )
  {
    int bar_num = (int) floor(0.5 + (x[i] - xlo)/delta);
    if ( bar_num < 0 || bar_num >= bars ) my_error("oisdncoisna");
    freq[bar_num] += 1.0;
  }

  for ( i = 0 ; i < bars ; i++ )
    bases[i] = xlo + i * (xhi - xlo) / (bars-1);
  clear_ongr(&on);
  compute_axis_limits(bases,bars,&on.x_axis);
  compute_axis_limits(freq,bars,&on.y_axis);
  sprintf(on.y_axis.label,"Histogram Frequency");
  on.y_axis.lowest_val = 0.0;
  
  compute_axes_details(&on,fr);
  draw_axes(fr,&on);
  plot_graphic_in_frame(fr,&on,bases,freq,bars,"NN",delta,AG_PURPLE);

  if ( size < MAX_X_ARR_SIZE )
  {
    double fake_y[MAX_X_ARR_SIZE];
    double v = 0.5;
    set_realnums_constant(fake_y,size,v);
    plot_in_frame(fr,&on,x,fake_y,size,"ND");
  }  
}
コード例 #25
0
ファイル: hand.cpp プロジェクト: timfurlong/TabPlayer
/*
 *  Draw the hand
 *     at (x,y,z)
 *     fingers facing (dx,dy,dz)
 *     up towards (ux,uy,uz)
 */
void hand::drawHand( note n, note prev_n, double t )
{

	vector<double> pt, j, next_pt, prev_pt;
	vector< vector<double> >::iterator j_it;
	finger f = fingers[0]; //dummy assignment to avoid using a constructor
	vector< vector<double> > prev_verts, next_verts, verts;
	vector< vector<double> >::iterator v_it;
	vector< vector< vector<double> > > fingVerts;
	vector< vector< vector<double> > >::iterator f_it;

	// Get current position of all fingers at this time
	if (t<0.1)
		t = t/0.1;
	else
		t =1;
	pt.assign(3,0);
	prev_verts.clear();
	verts.clear();
	fingVerts.clear();
	for (int i=0; i<fingers.size(); i++){
		next_verts  = fingers[i].fVerts;
		prev_verts = this->prevFingers[i].fVerts;
		for (int j=0; j<next_verts.size(); j++){
			prev_pt = prev_verts[j];
			next_pt = next_verts[j];
			pt[0] = next_pt[0]*t + (1-t)*prev_pt[0];
			pt[1] = next_pt[1]*t + (1-t)*prev_pt[1];
			pt[2] = next_pt[2]*t + (1-t)*prev_pt[2];
			verts.push_back(pt);
			pt.assign(3,0);
		}
		fingVerts.push_back(verts);
		verts.clear();
	}

	// Begin drawing  =================================

	// DRAW WRIST (aka base)
	glPushMatrix();
		vector<double> wrist_pt; wrist_pt.assign(3, 0);
		wrist_pt[0]=0; wrist_pt[1]=0; wrist_pt[2]=-(neck_r+buffHelp+baseH);
		glTranslated(this->wrist[0]*t+prevWrist[0]*(1-t),0,0);
		glRotated(-90, 0,0,1);
		glRotated(theta, 0,1,0);
		draw_axes(1,1,1);
		glColor3ub(hRGB[0],hRGB[1],hRGB[2]);

		glTranslated(0,0,baseH);
		glBegin( GL_POLYGON );
			glVertex3d(wrist_pt[0],wrist_pt[1],wrist_pt[2]);
			Vertex(  fingerTh[4]-thHelp, 0, baseLen[4],
						0,0,-(neck_r+buffHelp+baseH) );
			for (int i=0; i<4; i++){
				Vertex(  fingerTh[i], 0, baseLen[i],
							0,0,-(neck_r+buffHelp+baseH) );
			}
		glEnd();
		glTranslated(0,0,-2*baseH);
		glBegin( GL_POLYGON );
			glVertex3d(wrist_pt[0],wrist_pt[1],wrist_pt[2]);
			Vertex(  fingerTh[4]-thHelp, 0, baseLen[4],
						0,0,-(neck_r+buffHelp+baseH) );
			for (int i=0; i<4; i++){
				Vertex(  fingerTh[i], 0, baseLen[i],
							0,0,-(neck_r+buffHelp+baseH) );
			}
		glEnd();

		glBegin( GL_QUAD_STRIP );
			for (int i=0; i<baseVerts.size(); i++){
				pt = baseVerts[i];
				glVertex3d( pt[0],pt[1],pt[2]);
				glVertex3d( pt[0],pt[1],pt[2]+2*baseH);
			}
			pt = baseVerts[0];
			glVertex3d( pt[0],pt[1],pt[2]);
			glVertex3d( pt[0],pt[1],pt[2]+2*baseH);
		glEnd();
	glPopMatrix();

	// DRAW FINGERS
	glColor3ub( hRGB[0], hRGB[1], hRGB[2] );
	for (f_it = fingVerts.begin(); f_it!=fingVerts.end(); f_it++){
		verts = *f_it;
		for (v_it = verts.begin(); v_it!=verts.end()-1; v_it++){
			pt      = *v_it;
			next_pt = *(v_it+1);
			renderCylinder_convenient( pt[0],pt[1],pt[2],
												next_pt[0],next_pt[1],next_pt[2],
												fingRadius, fingSubDiv);
		}
	}



	// DRAW JOINTS
	for (f_it = fingVerts.begin(); f_it!=fingVerts.end(); f_it++){
		verts = *f_it;
		for (v_it = verts.begin(); v_it!=verts.end(); v_it++){
			pt      = *v_it;
			ball( pt[0],pt[1],pt[2],
					jRGB[0],jRGB[1],jRGB[2],
					jointRadius);
		}
	}

	// for (int ii=0; ii<fingers.size(); ii++){
	// 	fingers[ii];
	// 	for (int jj=0; jj<f.joints.size(); jj++){
	// 		j = f.joints[jj];
	// 		ball(j[0],j[1],j[2],
	// 				jRGB[0],jRGB[1],jRGB[2],
	// 				jointRadius);
	// 	}
	// 	ball(f.tip[0],f.tip[1],f.tip[2],
	// 			hRGB[0],hRGB[1],hRGB[2],
	// 			jointRadius);
	// }

	// currentFingers.clear();
	ErrCheck("drawHand");
}
コード例 #26
0
ファイル: smdvrpn.C プロジェクト: ASPePeX/vrpn
int main(int argc, char **argv) {       
  if (argc < 2) {
    printf("%s: Invalid parms\n", argv[0]);
    printf("usage: \n");
    printf("  %s Tracker0@host\n", argv[0]);

    return -1;
  }
  char *server = argv[1];
  pos *phan_position = new pos;
  pos *phan_offset   = new pos;
  force *phan_force  = new force;
  state *atom_state  = new state;

  int ff_enabled, ff_active;
  double kspr = 500.0;  // Units???

  vrpn_Tracker_Remote *tkr;
  vrpn_Button_Remote *btn;
  vrpn_ForceDevice_Remote *fdv;

  printf("Opening: %s ...\n",  server);

  tkr = new vrpn_Tracker_Remote(server);
  tkr->register_change_handler(phan_position, handle_tracker);

  btn = new vrpn_Button_Remote(server);
  btn->register_change_handler(&ff_enabled, handle_button);

  fdv = new vrpn_ForceDevice_Remote(server);
  fdv->register_force_change_handler(phan_force, handle_force);

  void * myglwin = glwin_create(700, 700);
  if (myglwin == NULL) {
    printf("Failed to open OpenGL window!!\n");
    return -1;
  }
  atom_state->x = 0.0; atom_state->y = 0.0; atom_state->z = 0.0;
  atom_state->vx = 0.0; atom_state->vy = 0.0; atom_state->vz = 0.0;
  atom_state->ax = 0.0; atom_state->ay = 0.0; atom_state->az = 0.0;
  atom_state->mass = .001;

  ff_active = 0;
 
  init_graphics(myglwin);
  GLUquadricObj *qobj  = gluNewQuadric();
  GLUquadricObj *qatom = gluNewQuadric();

  /* 
   * main interactive loop
   */
  while (1) {
    // Let the tracker do its thing
    tkr->mainloop();
    btn->mainloop();
    fdv->mainloop();

    run_dynamics(atom_state, phan_force);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (ff_enabled ) {
      if (!ff_active) {
	// Set up force field so initially the force is zero
	phan_offset->x = phan_position->x - .2*atom_state->x;
	phan_offset->y = phan_position->y - .2*atom_state->y;
	phan_offset->z = phan_position->z - .2*atom_state->z;
      }

      // Now turn the force field on
      // scene -> haptic: rotate 180 about the y axis
      fdv->setConstraintMode(vrpn_ForceDevice::POINT_CONSTRAINT);
      float cpos[3];
      cpos[0] = -(.2*atom_state->x + phan_offset->x);
      cpos[1] =  (.2*atom_state->y + phan_offset->y);
      cpos[2] = -(.2*atom_state->z + phan_offset->z);
      fdv->setConstraintPoint(cpos);
      fdv->setConstraintKSpring(kspr);
      fdv->enableConstraint(1); // enable force field


      ff_active = 1;
    }
    else if (ff_active) {
      fdv->enableConstraint(0); // disable force field
      ff_active = 0;
    }        

    draw_axes();

    draw_tracker_and_atom(phan_force, qobj, atom_state, qatom);

    glwin_swap_buffers(myglwin);
  }
}   /* main */
コード例 #27
0
ファイル: main.cpp プロジェクト: sahle123/Personal-References
/*  display  */
void display()
{
    // Light emitter variables
    int light_distance  = 3;    // How far away the light is from the object
    GLfloat light_size  = 0.1;  // The size of the ball of light
    GLfloat ylight      = 2.0;    // y coordinate of light ball.
    // Light variables. (These values can be found in clank_builder.h)
    GLfloat Emission[]  = {emission,emission,emission, 1.0};
    GLfloat Ambient[]   = {ambient,ambient,ambient, 1.0};
    GLfloat Diffuse[]   = {diffuse,diffuse,diffuse, 1.0};
    GLfloat Specular[]  = {specular,specular,specular, 1.0};
    GLfloat Shinyness[] = {shinyness};

    // Position of the ball light and emanating light (Orbit)
    GLfloat Position[]  = {static_cast<GLfloat>(light_distance*Cos(Glo_zh)), ylight,
                           static_cast<GLfloat>(light_distance*Sin(Glo_zh)), 1.0};
    // Position of the ball light and emanating light (Circle)
    GLfloat Position2[] = {static_cast<GLfloat>(Cos(Glo_zh)), static_cast<GLfloat>(ylight + Sin(Glo_zh)), 2, 1};


    // Instantiate myClank object
    Obj_Clank myClank(Glo_th, Glo_ph);

    // Check which animation to use for clank object.
    Glo_is_animated = myClank.set_animation(Glo_is_animated);


    // Clear the image
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Enable Z-buffering depth test
    glEnable(GL_DEPTH_TEST);
    // Reset previous transforms
    glLoadIdentity();

    /// Choose how to rotate (For ortho and perspective)
    if(Glo_Mode == 1) // Ortho
    {
        // Sets ortho rotation view
        glRotated(Glo_ph, 1, 0, 0);
        glRotated(Glo_th, 0, 1, 0);
    }
    else if(Glo_Mode == 2) // Perspective
    {
        double Ex = -2*Glo_dim*Sin(Glo_th)*Cos(Glo_ph);
        double Ey = +2*Glo_dim*Sin(Glo_ph);
        double Ez = +2*Glo_dim*Cos(Glo_th)*Cos(Glo_ph);
        gluLookAt(Ex, Ey+Glo_y, Ez, 0, Glo_y, 0, 0, Cos(Glo_ph), 0);
    }

    // *** Lighting section ***//
    myClank.is_light(Glo_Light);

    // Draw a orbiting light
    if(Glo_Light)
        myClank.light_ball(Position[0],Position[1],Position[2] , light_size);
    // Else draw a circling light
    else
        myClank.light_ball(Position2[0],Position2[1],Position2[2] , light_size);

    //  OpenGL should normalize normal vectors
    glEnable(GL_NORMALIZE);
    //  Enable lighting
    glEnable(GL_LIGHTING);
    //  Enable light 0
    glEnable(GL_LIGHT0);
    //  Set ambient, diffuse, specular components and position of light 0
    glLightfv(GL_LIGHT0,GL_AMBIENT ,Ambient);
    glLightfv(GL_LIGHT0,GL_DIFFUSE ,Diffuse);
    glLightfv(GL_LIGHT0,GL_SPECULAR,Specular);

    // Set the correct lighting according to light ball's position
    if(Glo_Light)
        glLightfv(GL_LIGHT0,GL_POSITION,Position);
    else
        glLightfv(GL_LIGHT0,GL_POSITION,Position2);

    // Set material properties
    glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,Shinyness);
    glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,  Ambient);
    glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,  Diffuse);
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR, Specular);
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION, Emission);
    // *** End of Lighting **//

    // Decide whether to draw Old Clank or New Clank
    if(Glo_oldClank)
    {
        glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
        glEnable(GL_COLOR_MATERIAL);
        myClank.simple_draw_clank();
    }
    else
    {
        // Disable lighting from Old Clank, otherwise render looks bad.
        glDisable(GL_COLOR_MATERIAL);

        // Compile the object file (Important step!!!)
        myClank.compile_clank(OBJ_Hand, OBJ_RightShoulder, OBJ_Right_hand2, OBJ_LeftShoulder,
                              OBJ_Left_hand2, OBJ_Body, OBJ_Head, Glo_Scale);
    }

    // Disable lighting
    glDisable(GL_LIGHTING);

    // Draw the cartesian coordinate plane
    draw_axes();

    // Display parameters
    switch(Glo_is_animated)
    {
    case 0:
        glWindowPos2i(5, 5);
        Print("Animation:   Standing");
        break;
    case 1:
        glWindowPos2i(5, 5);
        Print("Animation:   Waving");
        break;
    case 2:
        glColor3f(0.8,0.8,0);
        glWindowPos2i(5, 5);
        Print("Animation:   Praise the Sun!");
        glColor3f(1,1,1);
        break;
    }
    //Print("View Angle=%d, %d Glo_dim=%.1f Glo_FOV=%d Projection=%s",
    //      Glo_th, Glo_ph, Glo_dim, Glo_FOV, Glo_Text[Glo_Mode-1].c_str());

    glColor3f(1,1,1);
    // Displays Status
    glWindowPos2i(5,25);
    Print("Light Mode: %s",Glo_Light?"Orbiting":"Circling");

    // Rasterized "Hi" text for wave animation
    if(Glo_is_animated == 1)
    {
        glRasterPos3d(1, 4, 0);
        Print("Hi :)");
    }

    glFlush();
    glutSwapBuffers();
}
コード例 #28
0
ファイル: example5.cpp プロジェクト: libglui/glui
void myGlutDisplay( void )
{
  glClearColor( .9f, .9f, .9f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  glFrustum( -xy_aspect*.04, xy_aspect*.04, -.04, .04, .1, 15.0 );

  glMatrixMode( GL_MODELVIEW );

  glLoadIdentity();
  glMultMatrixf( lights_rotation );
  glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
  
  glLoadIdentity();
  glTranslatef( 0.0, 0.0, -2.6f );
  glTranslatef( obj_pos[0], obj_pos[1], -obj_pos[2] ); 
  glMultMatrixf( view_rotate );

  glScalef( scale, scale, scale );

  /*** Now we render object, using the variables 'obj_type', 'segments', and
    'wireframe'.  These are _live_ variables, which are transparently 
    updated by GLUI ***/

  glPushMatrix();
  glTranslatef( -.5, 0.0, 0.0 );
  glMultMatrixf( sphere_rotate );
  if ( wireframe && show_sphere)
    glutWireSphere( .4, segments, segments );
  else if ( show_sphere )
    glutSolidSphere( .4, segments, segments );
  if ( show_axes )
    draw_axes(.52f);
  glPopMatrix();

  glPushMatrix();
  glTranslatef( .5, 0.0, 0.0 );
  glMultMatrixf( torus_rotate );
  if ( wireframe && show_torus )
    glutWireTorus( .15,.3,16,segments );
  else if ( show_torus )
    glutSolidTorus( .15,.3,16,segments );
  if ( show_axes )
    draw_axes(.52f);
  glPopMatrix();

  if ( show_text ) 
  {
    glDisable( GL_LIGHTING );  /* Disable lighting while we render text */
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluOrtho2D( 0.0, 100.0, 0.0, 100.0  );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glColor3ub( 0, 0, 0 );
    glRasterPos2i( 10, 10 );

    /*  printf( "text: %s\n", text );              */

    /*** Render the live character array 'text' ***/
    int i;
    for( i=0; i<(int)strlen( string_list[curr_string] ); i++ )
      glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, string_list[curr_string][i] );
  }

  glEnable( GL_LIGHTING );


  glutSwapBuffers(); 
}
コード例 #29
0
ファイル: scenario.c プロジェクト: ghitakouadri/simbot
static void draw_2d_cartesian_plane()
{
    draw_axes();
    draw_axes_directions();
}
コード例 #30
0
static void	drawSlider(btGeneric6DofConstraint* pSlider)
{
    draw_axes(pSlider->getRigidBodyA(), pSlider->getFrameOffsetA());
    draw_axes(pSlider->getRigidBodyB(), pSlider->getFrameOffsetB());
} // drawSlider()