void myCircle::drawSimple(HDC hdc)
{
     int x = 0, y = R;
     DrawPoints(hdc, Center.x,Center.y,x,y);
     
     while(x < y)
     {
               x++;
               y = (int)(sqrt(R*R - x*x));
               DrawPoints(hdc,Center.x,Center.y,x,y);
     }
}
void myCircle::PolarAlgorithm(HDC hdc)
{
    double x = R, y = 0;
    double dtheta = 1.0/R;
    double cdtheta = cos(dtheta), sdtheta = sin(dtheta);
    DrawPoints(hdc,Center.x,Center.y,R,0);
    while(x>y)
    {
              double x1 = x*cdtheta - y*sdtheta;
              y = x*sdtheta + y*cdtheta;
              x = x1;
              DrawPoints(hdc,Center.x,Center.y,round(x),round(y));
    }     
}
	void DrawEnd()
	{
		IsRendererInitialized();

 		g_CurrentProgram->SetModelViewProjection();
		g_CurrentProgram->SetUniform("color", g_CurrentColor);

		if(!g_DrawVertices->empty() && g_HasDrawBegun)
		{
			switch(g_Drawtype)
			{
			case CL_QUADS:
				DrawQuads();
				break;
			case CL_TRIANGLES:
				DrawTriangles(*g_DrawVertices, *g_DrawTextureCoords, *g_DrawNormals);
				break;
			case CL_POINTS:
				DrawPoints();
				break;
			case CL_LINES:
				DrawLines();
				break;
			}
		}

		g_DrawVertices->clear();
		g_DrawTextureCoords->clear();
		g_DrawNormals->clear();

		g_HasDrawBegun = false;

		g_CurrentProgram->ClearTextureUnits();
	}
示例#4
0
void
loop()
{
    int i;
    SDL_Event event;

    /* Check for events */
    while (SDL_PollEvent(&event)) {
        SDLTest_CommonEvent(state, &event, &done);
    }
    for (i = 0; i < state->num_windows; ++i) {
        SDL_Renderer *renderer = state->renderers[i];
        if (state->windows[i] == NULL)
            continue;
        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
        SDL_RenderClear(renderer);

        DrawRects(renderer);
        DrawLines(renderer);
        DrawPoints(renderer);

        SDL_RenderPresent(renderer);
    }
#ifdef __EMSCRIPTEN__
    if (done) {
        emscripten_cancel_main_loop();
    }
#endif
}
示例#5
0
void RenderScene()
{
  glClear(GL_COLOR_BUFFER_BIT);
  
  //设置贝塞尔曲线,这个函数其实只需要调用一次,可以放在SetupRC中设置
  glMap1f(GL_MAP1_VERTEX_3, //生成的数据类型
    0.0f, //u值的下界
    100.0f, //u值的上界
    3, //顶点在数据中的间隔,x,y,z所以间隔是3
    numOfPoints, //u方向上的阶,即控制点的个数
    &controlPoints[0][0] //指向控制点数据的指针
  );

  //必须在绘制顶点之前开启
  glEnable(GL_MAP1_VERTEX_3);
  //使用画线的方式来连接点
  /*glBegin(GL_LINE_STRIP);
  for (int i = 0; i <= 100; i++)
  {
    glEvalCoord1f((GLfloat)i);
  }
  glEnd();*/

  glMapGrid1f(100, 0.0f, 100.0f);

  glEvalMesh1(GL_LINE, 0, 100);
  DrawPoints();

  glutSwapBuffers();

}
示例#6
0
void ReDraw(void)
{
	glColor3ub(0,0,220);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	glRotatef(330.0f, 1.0f,0.0f,0.0f);
	
	// 定义NURBS曲线
    gluBeginCurve(pNurb);
		gluNurbsCurve(pNurb,     // 定义NURBS对象
			8,                   // knot中的结点数目
			Knots,               // knots数组
			3,                   // 相邻两个曲线控制点之间的偏移量
			&ctrlPoints[0][0],   // 指向控制点数组的指针
			4,                   // 曲线的阶数
			GL_MAP1_VERTEX_3);   // 曲线的类型
	gluEndCurve(pNurb);
	
	DrawPoints();

	glPopMatrix();
	glutSwapBuffers();
}
示例#7
0
int imProcessHoughLinesDraw(const imImage* src_image, const imImage *hough, const imImage *hough_points, imImage *dst_image)
{
  int theta, line_count = 0;

  if (src_image != dst_image)
    imImageCopyData(src_image, dst_image);

  listnode* maxima = findMaxima(hough_points, &line_count, hough);

  ReplaceColor(dst_image);

  costab = (double*)malloc(180*sizeof(double));
  sintab = (double*)malloc(180*sizeof(double));

  for (theta=0; theta < 180; theta++)
  {
    double th = (M_PI*theta)/180.;
    costab[theta] = cos(th);
    sintab[theta] = sin(th);
  }

  DrawPoints(dst_image, maxima);

  free(costab); costab = NULL;
  free(sintab); sintab = NULL;

  return line_count;
}
示例#8
0
void ReDraw(void)
{
	int i;
	glClear(GL_COLOR_BUFFER_BIT);

	glMap1f(GL_MAP1_VERTEX_3,	// 产生的数据类型
	0.0f,						// 参数最小值
	100.0f,						// 参数最大值
	3,							// 控制点数据顶点之间的数目
	nNumPoints,					// 控制点数目
	&ctrlPoints[0][0]);			// 保存控制点的数组

	//启动求职器
	glEnable(GL_MAP1_VERTEX_3);

	// 将曲线上的点连接起来
	glBegin(GL_LINE_STRIP);
		for(i = 0; i <= 100; i++)
		{
			// 计算当前曲线点的坐标
			glEvalCoord1f((GLfloat) i); 
		}
	glEnd();

//	glMapGrid1d(100,0.0,100.0);
//	glEvalMesh1(GL_LINE,0,100);

	DrawPoints();
	glutSwapBuffers();
}
//Called to draw scene
void RenderScene(void)
{
	//Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT);
	
	glColor3f(redC, greenC, blueC);
	//Save the modelview matrix stack
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	//Rotate the mesh around to make it easier to see
	//if(count%3==0)
	//glRotatef(rot++, 1.0f, 1.0f, 0.0f);
	//else if (count%3==1)
	//glRotatef(rot++, 0.0f, 1.0f, 0.0);
//	else
//		glRotatef(rot++, 0.0f, 0.0f, 1.0f);

	//if(rot>=100) rot=0;
	//if(count>=30) count=0;

	//glRotatef(10.0f, 1.0f, 1.0f, 1.0f);


	//Sets up the Bezier
	//This actually only needs to be called once and could go in
	//the setup function
	glMap2f(GL_MAP2_VERTEX_3, //tYPE OF data generated
		0.0f,   //lower u range
		10.0f, //upper u range
		3,   //distance between points in the data
		4,   //dimension in u direction (order)
		0.0f,   //Lower v range
		10.0f, //Upper v range
		12,    //Distance betwen points in the data
		4,   //Dimension in v direction(order)
		&ctrlPoints[0][0][0]);   //array of control points
		
	//Enable the evaluator
	glEnable(GL_MAP2_VERTEX_3);
	glRotatef(10.0f, 1.0f, 1.0f, 0.0f);
	//use higher level functions to mapto a grid, then evaluate the entire thing.

	//Map a grid of 10 points from 0 to 10
	glMapGrid2f(10, 0.0f, 10.0f, 10, 0.0f, 10.0f);

	
	//Evaluate the grid, using lines
	glEvalMesh2(GL_FILL, 0, 10, 0, 10);
	//glEnable(GL_AUTO_NORMAL);

	//Draw the control points
	DrawPoints();

	glPopMatrix();

	//Display the image
	glutSwapBuffers();
}
示例#10
0
//
// スキャンラインアルゴリズムによるレンダリング
int RenderScanLine( void )
{
	int					x, y;
	float				dx, dy, dz;				// 画面中心を基準とした座標
	float				dzsq;					// zの2乗
	int					nBright;
	float				nx, ny, nz;				// 球面上の法線ベクトル
	float				lx = -1.0f / 1.732f;	// 光源の方向ベクトル
	float				ly = -1.0f / 1.732f;
	float				lz =  1.0f / 1.732f;
	float				fAmbient = 128.0f;		// アンビエント光
	float				fDirect = 128.0f;		// ディレクショナル光
	float				fDot;					// 内積
	float				fAngle;					// xz平面上での角度

	for ( y = 0; y < VIEW_HEIGHT; y++ ) {		// y方向ループ
		for ( x = 0; x < VIEW_WIDTH; x++ ) {	// x方向ループ
			dx = x - VIEW_WIDTH  / 2.0f;		// 相対x座標
			dy = y - VIEW_HEIGHT / 2.0f;		// 相対y座標
			dzsq = RAD * RAD - dx * dx - dy * dy;	// zの2乗計算
			if ( dzsq > 0.0f ) {
				dz = sqrtf( dzsq );
				fAngle = atan2f( dz, dx );		// xz平面上での角度
				if ( fAngle < 0.0f ) fAngle += 2.0f * PI;	// プラスの角度に
				nx = dx / RAD;  ny = dy / RAD;  nz = dz / RAD;	// 法線ベクトル
				fDot = nx * lx + ny * ly + nz * lz;				// 内積
				if ( fDot >= 0.0f ) {			// 光源からの光が当たる
					nBright = ( int )( fDot * fDirect + fAmbient );
				}
				else {							// 光源からの光が当たらない
					nBright = ( int )fAmbient;
				}
				if ( ( int )( fAngle / ( 2.0f * PI ) * 16 ) & 1 ) {
					DrawPoints( x, y, nBright, nBright, nBright );	// 白
				}
				else {
					DrawPoints( x, y, nBright, 0, nBright );		// マゼンタ
				}
			}
		}
		FlushDrawingPictures();
	}

	return 0;
}
示例#11
0
void RenderingWidget::Render()
{
	DrawAxes(is_draw_axes_);
	DrawPoints(is_draw_point_);
	DrawEdge(is_draw_edge_);
	DrawHeat(is_draw_heat_);
	DrawBulk(is_draw_bulk_);
	DrawOrder(is_draw_order_);
}
void ChessRecognition::Find_ChessPoint(IplImage *Source, vector<ChessPoint> *Point) {
	if (_EnableThread != false) {
		// init함수를 통하여 설정한 mode에 맞추어 chessboard recognition & 좌표 보정 & src에 좌표 그리기 진행.
		// src : 좌표를 그릴 이미지, point : 연산을 통하여 cross point를 저장할 vector.
		Point->clear();

		if (_MODE == 1) {
			if (_HoughLineBased != NULL) {
				vector<std::pair<float, float> > _TCH_LineX, _TCH_LineY;

				Get_Line(&_TCH_LineX, &_TCH_LineY);
#if !defined(USING_QT)
				_HoughLineBased->DrawLines(_TCH_LineX, Source);
				_HoughLineBased->DrawLines(_TCH_LineY, Source);
#endif
				_HoughLineBased->FindIntersections(_TCH_LineX, _TCH_LineY, Point);
				Refine_CrossPoint(Point);
#if !defined(USING_QT)
				DrawPoints(Source, *Point);
#endif
			}
			else {
				// Not Initialize.
			}
		}
		else if (_MODE == 2) {
			if (_LineSearchBased != NULL) {
				_Vec_ProtectionMutex.lock();
				copy(_CP.begin(), _CP.end(), back_inserter(*Point));
				_Vec_ProtectionMutex.unlock();
				// 보정으로 인한 문제가 발생하여 잠시 보류.
				//Refine_CrossPoint(point);
#if !defined(USING_QT)
				DrawPoints(Source, *Point);
#endif
			}
			else {
				// Not Initialize.
			}
		}
	}
}
void neighbour3D::IllustratePointNeighbour(int p_index, int n)
{
    glPointSize(5);
    for(int i=0; i<n; i++)
    {
        set <int> tmp = GetP2P_Neigh(p_index, i);
        if (i%2 == 0)    glColor3f(1,1-i/double(n),0);
        else glColor3f(0,1-i/double(n),1);
        DrawPoints ( tmp );
    }
}
示例#14
0
void GLFunc::gl_draw_graphics()
{
	//static int font = (int)GLUT_BITMAP_8_BY_13;  //draw text font
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Set location in front of camera
	glLoadIdentity();

	glTranslatef(0, -m_zoom, 0);
	glTranslatef(m_tx, 0, m_ty);
	glRotatef(m_rotx, 1, 0, 0);
	glRotatef(m_roty, 0, 1, 0);

	//draw x,z axis
	glBegin(GL_LINES);
	glColor3ub( 88, 29, 29);  //dark red x axis
	glVertex3i(0, axis_elevation, 0);
	glVertex3i(100000, axis_elevation, 0);
	glColor3ub( 29, 88, 29);   //dark green  z axis
	glVertex3i(0, axis_elevation, 0);
	glVertex3i(0, axis_elevation, 100000);
	glEnd();

	pthread_rwlock_rdlock(&g_lock_opengl);
	DrawPoints();
	DrawGuidePoint();
	//DrawText();
	pthread_rwlock_unlock(&g_lock_opengl);

	//show infomation on screen
	glColor3ub(255, 255, 0);    	//font color
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D( 0, (GLdouble)m_window_width, 0, (GLdouble)m_window_height);
	glScalef(1, -1, 1);
	glTranslatef(0, -m_window_height, 0);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	
	
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);

	// Show the new scene
	glutSwapBuffers();

	glutPostRedisplay();
	
	Sleep(50);
}
void CSpaceInvadersAppView::Draw( const TRect& /*aRect*/ ) const
{
    // Get the standard graphics context
    CWindowGc& gc = SystemGc();
    DrawBackground(gc);
    DrawShip(gc);
    DrawAliens(gc);
    DrawPoints(gc);
    DrawQuitCommand(gc);

}
示例#16
0
void golly_render::pixblit(int x, int y, int w, int h, char* pmdata, int pmscale)
{
    // is Tom's hashdraw code doing unnecessary work???
    if (x >= currwd || y >= currht) return;
    if (x + w <= 0 || y + h <= 0) return;

    // stride is the horizontal pixel width of the image data
    int stride = w/pmscale;

    // clip data outside viewport
    if (pmscale > 1) {
        // pmdata contains 1 byte per `pmscale' pixels, so we must be careful
        // and adjust x, y, w and h by multiples of `pmscale' only
        if (x < 0) {
            int dx = -x/pmscale*pmscale;
            pmdata += dx/pmscale;
            w -= dx;
            x += dx;
        }
        if (y < 0) {
            int dy = -y/pmscale*pmscale;
            pmdata += dy/pmscale*stride;
            h -= dy;
            y += dy;
        }
        if (x + w >= currwd + pmscale) w = (currwd - x + pmscale - 1)/pmscale*pmscale;
        if (y + h >= currht + pmscale) h = (currht - y + pmscale - 1)/pmscale*pmscale;
    }

    int numstates = currlayer->algo->NumCellStates();
    if (pmscale == 1) {
        // draw rgb pixel data at scale 1:1
        if (drawing_paste || numstates == 2) {
            // we can't use DrawTexture to draw paste image because glTexImage2D clobbers
            // any background pattern, so we use DrawPoints which is usually faster than
            // DrawTexture in a sparsely populated universe with only 2 states (eg. Life)
            DrawPoints((unsigned char*) pmdata, x, y, w, h);
        } else {
            DrawTexture((unsigned char*) pmdata, x, y, w, h);
        }
    } else if (showicons && pmscale > 4 && icontextures) {
        // draw icons at scales 1:8 or above
        DrawIcons((unsigned char*) pmdata, x, y, w/pmscale, h/pmscale, pmscale, stride);
    } else {
        // draw magnified cells, assuming pmdata contains (w/pmscale)*(h/pmscale) bytes
        // where each byte contains a cell state
        if (numstates == 2) {
            DrawMagnifiedTwoStateCells((unsigned char*) pmdata, x, y, w/pmscale, h/pmscale, pmscale, stride);
        } else {
            DrawMagnifiedCells((unsigned char*) pmdata, x, y, w/pmscale, h/pmscale, pmscale, stride, numstates);
        }
    }
}
示例#17
0
void COglshapeView::DrawWithOpenGL() {
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(0.0f, 0.0f, 0.0f);

    switch(m_shape) {
    case Points        :
        DrawPoints();
        break;

    case Lines         :
        DrawLines();
        break;

    case LineStrip     :
        DrawLineStrip();
        break;

    case LineLoop      :
        DrawLineLoop();
        break;

    case Polygons      :
        DrawPolygons();
        break;

    case Triangles     :
        DrawTriangles();
        break;

    case TriangleStrip :
        DrawTriangleStrip();
        break;

    case TriangleFan   :
        DrawTriangleFan();
        break;

    case Quads         :
        DrawQuads();
        break;

    case QuadStrip     :
        DrawQuadStrip();
        break;

    case Nonconvex     :
        DrawNonconvex();
        break;
    }

    glFlush();
}
void myCircle::MidPoint(HDC hdc)
{
     int x = 0, y = R, d = 1-R, dch1 = 3, dch2 = (5-2*R);
     DrawPoints(hdc,Center.x,Center.y,x,y);
     
     while(x<y)
     {
               if(d<0)
               {
                      d += dch1;
                      dch2 += 2;
               }
               else
               {
                   d += dch2;
                   y--;
                   dch2 += 4;
               }
               dch1 += 2;
               x++;
               DrawPoints(hdc,Center.x,Center.y,x,y);
     }
}
示例#19
0
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

    // Save the modelview matrix stack
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();

    // Rotate the mesh around to make it easier to see
    glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
    glRotatef(60.0f, 1.0f, 0.0f, 0.0f);

    // Sets up the Bezier
    // This actually only needs to be called once and could go in
    // the setup function
    glMap2f(GL_MAP2_VERTEX_3,	// Type of data generated
    0.0f,						// Lower u range
    10.0f,						// Upper u range
    3,							// Distance between points in the data
    3,							// Dimension in u direction (order)
    0.0f,						// Lover v range
    10.0f,						// Upper v range
    9,							// Distance between points in the data
    3,							// Dimension in v direction (order)
    &ctrlPoints[0][0][0]);		// array of control points

    // Enable the evaluator
    glEnable(GL_MAP2_VERTEX_3);

    // Use higher level functions to map to a grid, then evaluate the
    // entire thing.

    // Map a grid of 10 points from 0 to 10
    glMapGrid2f(10,0.0f,10.0f,10,0.0f,10.0f);

    // Evaluate the grid, using lines
    glEvalMesh2(GL_LINE,0,10,0,10);

    // Draw the Control Points
    DrawPoints();

    // Restore the modelview matrix
    glPopMatrix();

    // Dispalay the image
    glutSwapBuffers();
    }
示例#20
0
void RenderScene(void)
{
  glColor3ub(0,0,220);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();

  glRotatef(330.0f, 1.0f, 0.0f, 0.0f);
  //修剪框是一个闭合的环
  //外修剪框
  GLfloat outSidePts[5][2] = 
  {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}, {0.0f, 0.0f}};
  //内修剪框
  GLfloat inSidePts[4][2] =
  {{0.25f, 0.25f}, { 0.5f, 0.5f}, {0.75f, 0.25f},{0.25f, 0.25f} };

  gluBeginSurface(pNurb);
  //定义NURBS表面
  gluNurbsSurface(pNurb,
    8, Knots, //u定义域内的结点个数,以及结点序列
    8, Knots,//v定义域内的结点个数,以及结点序列
    4 * 3,  //u方向上的控制点间隔
    3,  //v方向上的控制点间隔
    &ctrlPoints[0][0][0], //控制点数组
    4, 4, //u v的次数
    GL_MAP2_VERTEX_3);//产生的类型

  //开始修剪
  gluBeginTrim(pNurb);
  gluPwlCurve(pNurb,
    5,  //修剪点的个数
    &outSidePts[0][0], //修剪点数组
    2, //点之间的间隔
    GLU_MAP1_TRIM_2);//修剪的类型
  gluEndTrim(pNurb);

  gluBeginTrim(pNurb);
  gluPwlCurve(pNurb, 4, &inSidePts[0][0], 2, GLU_MAP1_TRIM_2);
  gluEndTrim(pNurb);
  gluEndSurface(pNurb);

  DrawPoints();
  glPopMatrix();

  glutSwapBuffers();
}
示例#21
0
void CGraphPanel::DrawToDC(CDC* dc_to_draw, CRect& rect_to_draw)
{
    //fill background
    CBrush bkbrush(bkColor);
    CBrush* oldbrush = (CBrush*)dc_to_draw->SelectObject(&bkbrush);

    CRect bkrect(rect_to_draw);
    bkrect.bottom+=1; bkrect.right+=1; bkrect.left-=1; bkrect.top -= 1;
    dc_to_draw->Rectangle(bkrect);
    dc_to_draw->SelectObject(oldbrush);

    //draw points
    DrawPoints(dc_to_draw, rect_to_draw);

    //axis
    if ((m_grflags & GRAPH_DRAW_AXIS) == GRAPH_DRAW_AXIS) DrawAxis(dc_to_draw, rect_to_draw);
}
示例#22
0
// Called to draw scene
void RenderScene(void)
{
    int i;

    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

    // Sets up the bezier
    // This actually only needs to be called once and could go in
    // the setup function
    glMap1f(GL_MAP1_VERTEX_3,	// Type of data generated
            0.0f,						// Lower u range
            100.0f,						// Upper u range
            3,							// Distance between points in the data
            nNumPoints,					// number of control points
            &ctrlPoints[0][0]);			// array of control points

    // Enable the evaluator
    glEnable(GL_MAP1_VERTEX_3);

    // Use a line strip to "connect-the-dots"
    glBegin(GL_LINE_STRIP);
    for(i = 0; i <= 100; i++)
    {
        // Evaluate the curve at this point
        glEvalCoord1f((GLfloat) i);
    }
    glEnd();

    // Use higher level functions to map to a grid, then evaluate the
    // entire thing.
    // Put these two functions in to replace above loop

    // Map a grid of 100 points from 0 to 100
    //glMapGrid1d(100,0.0,100.0);

    // Evaluate the grid, using lines
    //glEvalMesh1(GL_LINE,0,100);

    // Draw the Control Points
    DrawPoints();

    // Flush drawing commands
    glutSwapBuffers();
}
示例#23
0
void COScopeCtrl::AppendPoints(double sTimestamp, const std::vector<float *> &apf)
{
	sLastTimestamp = sTimestamp;

	if (nDelayedPoints) {
		// Ensures that delayed points get added before the new point.
		// We do this by simply drawing the history up to and including
		// the new point.
		int n = std::min(m_rectPlot.GetWidth(), nDelayedPoints + 1);
		nDelayedPoints = 0;
		PlotHistory(n, true, false);
	} else {
		ShiftGraph(1);
		DrawPoints(apf, 1);
	}

	Refresh(false);
}
示例#24
0
/*
================
StudioModel::DrawModel
inputs:
	currententity
	r_entorigin
================
*/
void StudioModel::DrawModel( )
{
	int i;

	g_smodels_total++; // render data cache cookie

	g_pxformverts = &g_xformverts[0];
	g_pvlightvalues = &g_lightvalues[0];

	if (m_pstudiohdr->numbodyparts == 0)
		return;

	glPushMatrix ();

    glTranslatef (m_origin[0],  m_origin[1],  m_origin[2]);

    glRotatef (m_angles[1],  0, 0, 1);
    glRotatef (m_angles[0],  0, 1, 0);
    glRotatef (m_angles[2],  1, 0, 0);

	// glShadeModel (GL_SMOOTH);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

	// glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);

	SetUpBones ( );

	SetupLighting( );
	
	for (i=0 ; i < m_pstudiohdr->numbodyparts ; i++) 
	{
		SetupModel( i );
		DrawPoints( );
	}

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	// glShadeModel (GL_FLAT);

	// glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	glPopMatrix ();
}
示例#25
0
void COScopeCtrl::PlotHistory(unsigned cntPoints, bool bShiftGraph, bool bRefresh)
{
	wxASSERT(graph_type != GRAPH_INVALID);

	if (graph_type != GRAPH_INVALID) {
		unsigned i;
		unsigned cntFilled;
		std::vector<float *> apf(nTrends);
		try {
			for (i = 0; i < nTrends; ++i) {
				apf[i] = new float[cntPoints];
			}
			double sFinal = (bStopped ? sLastTimestamp : -1.0);
			cntFilled = theApp->m_statistics->GetHistory(cntPoints, sLastPeriod, sFinal, apf, graph_type);
			if (cntFilled >1  ||  (bShiftGraph && cntFilled!=0)) {
				if (bShiftGraph) {  // delayed points - we have an fPrev
					ShiftGraph(cntFilled);
				} else {  // fresh graph, we need to preset fPrev, yPrev
					PlotData_t* ppds = pdsTrends;
					for(i=0; i<nTrends; ++i, ++ppds)
						ppds->yPrev = GetPlotY(ppds->fPrev = *(apf[i] + cntFilled - 1), ppds);
					cntFilled--;
				}
				DrawPoints(apf, cntFilled);
				if (bRefresh)
					Refresh(false);
			}
			for (i = 0; i < nTrends; ++i) {
				delete [] apf[i];
			}
		} catch(std::bad_alloc) {
			// Failed memory allocation
			AddLogLineC(wxString(
				wxT("Error: COScopeCtrl::PlotHistory: Insuficient memory, cntPoints == ")) <<
				cntPoints << wxT("."));
			for (i = 0; i < nTrends; ++i) {
				delete [] apf[i];
			}
		}
	} else {
		// No history (yet) for Kad.
	}
}
示例#26
0
void Pentagon::Draw()
{
    if (mFilled)
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    }
    else
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    }
    glColor3d(mRed, mGreen, mBlue);
    glBegin(GL_POLYGON);
    glVertex2d(mVertices[0]->getX(), mVertices[0]->getY());
    glVertex2d(mVertices[1]->getX(), mVertices[1]->getY());
    glVertex2d(mVertices[2]->getX(), mVertices[2]->getY());
    glVertex2d(mVertices[3]->getX(), mVertices[3]->getY());
    glVertex2d(mVertices[4]->getX(), mVertices[4]->getY());
    glEnd();
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    DrawPoints();
}
示例#27
0
// Called to draw scene
void RenderScene(void)
{
    // Draw in Blue
    glColor3ub(0,0,220);

    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Save the modelview matrix stack
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();

    // Rotate the mesh around to make it easier to see
    glRotatef(330.0f, 1.0f,0.0f,0.0f);

    // Render the NURB
    // Begin the NURB definition
    gluBeginCurve(pNurb);

    // Evaluate the surface
    gluNurbsCurve(pNurb,
                  8, Knots,
                  3,
                  &ctrlPoints[0][0],
                  4,
                  GL_MAP1_VERTEX_3);

    // Done with surface
    gluEndCurve(pNurb);

    // Show the control points
    DrawPoints();

    // Restore the modelview matrix
    glPopMatrix();

    // Dispalay the image
    glutSwapBuffers();
}
示例#28
0
//  Take a 'turn' (throw three darts)
void Player::TakeTurn(int cursoractual[], int cursorpos[], int BGPos[], bool playertothrow) {
	int throws = 3;
	int wait = 0;
	p_turnthrows = 0;
	p_turnstartpoints = p_points;
	SetTile(27, 23+5*playertothrow, 1, 5);
	SetTile(27, 23+5*playertothrow-1, 1, 5);
	SetTile(27, 23+5*playertothrow-2, 1, 5);
	
	while ((throws > 0 && p_points > 0) || wait < 40) {
		UpdateObjects();
		
		if (throws > 0 && p_points > 0) {	
			WaitVSync();
			UpdateObjects();
			TakeAShot(cursoractual, cursorpos, BGPos);
			DrawPoints(20+5*playertothrow, 4 + p_throws);
			
			SetTile(27, 23+5*playertothrow-p_turnthrows, 1, 4);
			
			p_throws++;
			p_turnthrows++;
			throws--;
		} else {
			wait++;
		}
		
		for (int i = 0; i < p_turnthrows; i++) {
			darts[i].UpdateDart(BGPos);			
		}
	}
	SetTile(27, 23+5*playertothrow, 1, 4);
	SetTile(27, 23+5*playertothrow-1, 1, 4);
	SetTile(27, 23+5*playertothrow-2, 1, 4);
	ClearObjects();
}
示例#29
0
void CvCalibFilter::DrawPoints( IplImage** dst )
{
    DrawPoints( (CvMat**)dst );
}
示例#30
0
int
main(int argc, char *argv[])
{
    int done;
    SDL_Event event;
    Uint32 then, now, frames;
    SDL_Window *window;
    SDL_Surface *surface;
    SDL_Renderer *renderer;
    SDL_DisplayMode mode;

    /* Enable standard application logging */
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);

    /* Initialize parameters */
    num_objects = NUM_OBJECTS;

    /* Initialize SDL */
    if(SDL_Init(SDL_INIT_VIDEO) != 0)
    {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
        return 1;
    }

    SDL_GetDesktopDisplayMode(0, &mode);

    /* Create window and renderer for given surface */
    window = SDL_CreateWindow("Draw2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, mode.w, mode.h, SDL_WINDOW_SHOWN);
    if(!window)
    {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError());
        return 1;
    }
    surface = SDL_GetWindowSurface(window);
    renderer = SDL_CreateSoftwareRenderer(surface);
    if(!renderer)
    {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
        return 1;
    }

    SDL_SetRenderDrawBlendMode(renderer, blendMode);
    SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
    SDL_RenderClear(renderer);

    srand((unsigned int)time(NULL));

    /* Main render loop */
    frames = 0;
    then = SDL_GetTicks();
    done = 0;
    while (!done) {
        /* Check for events */
        ++frames;
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_KEYDOWN &&
                    event.key.keysym.scancode == SDL_SCANCODE_AC_BACK) {
                done = 1;
            }

            if (event.type == SDL_WINDOWEVENT &&
                    event.window.event == SDL_WINDOWEVENT_RESIZED) {
                SDL_Log("update screen size");
                SDL_DestroyRenderer(renderer);
                surface = SDL_GetWindowSurface(window);
                renderer = SDL_CreateSoftwareRenderer(surface);
                if(!renderer) {
                    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
                    done = 1;
                    break;
                }
                SDL_SetRenderDrawBlendMode(renderer, blendMode);
                SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
                SDL_RenderClear(renderer);
            }
        }

        SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
        SDL_RenderClear(renderer);

        DrawRects(renderer);
        DrawLines(renderer);
        DrawPoints(renderer);

        SDL_RenderPresent(renderer);
        SDL_UpdateWindowSurface(window);
    }

    /* Print out some timing information */
    now = SDL_GetTicks();
    if (now > then) {
        double fps = ((double) frames * 1000) / (now - then);
        SDL_Log("%2.2f frames per second\n", fps);
    }

    SDL_Quit();

    return 0;
}