Exemple #1
0
//定义画图工具
void CVolumeButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC*pDC;
	pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
	DrawBackground(pDC);
	DrawLines(pDC);
}
	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();
	}
Exemple #3
0
void CSkyblue_PinTuView::OnDraw(CDC* pDC)
{
	//a.获取文档数据控制权
	CSkyblue_PinTuDoc* pDoc = (CSkyblue_PinTuDoc*)GetDocument();

	//b.使用内存设备环境memDC
	//  与内存环境关联的内存位图memBmp
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap memBmp;
	memBmp.CreateCompatibleBitmap(pDC,
		pDoc->m_bmpWidth,pDoc->m_bmpHeight);
	memDC.SelectObject(&memBmp);

	//c. 将图像绘制到内存位图memBmp中

	//1.绘制游戏所有当前散乱的方块
	DrawGameBlocks(&memDC);
	//2.绘制空白方块
	DrawBlankBlock(&memDC);
	//3.绘制边界间隔线条
	DrawLines(&memDC);

	//d.整幅图从内存memBmp拷贝到屏幕
	pDC->BitBlt(0,0,pDoc->m_bmpWidth,pDoc->m_bmpHeight,
				&memDC,0,0,SRCCOPY);
}
void TXGLDrawer::DrawFrustrum()
{
	//Set Size
	glEnable(GL_POINT_SMOOTH);
	glPointSize(4.0f);

	// set current color
	glColor3f(1, 0, 0);

	//draw point
	glBegin(GL_POINTS);
		glVertex3f(_camera->_ntl.GetX(),_camera->_ntl.GetY(),_camera->_ntl.GetZ());
		glVertex3f(_camera->_ntr.GetX(),_camera->_ntr.GetY(),_camera->_ntr.GetZ());
		glVertex3f(_camera->_nbl.GetX(),_camera->_nbl.GetY(),_camera->_nbl.GetZ());
		glVertex3f(_camera->_nbr.GetX(),_camera->_nbr.GetY(),_camera->_nbr.GetZ());

		glVertex3f(_camera->_ftl.GetX(),_camera->_ftl.GetY(),_camera->_ftl.GetZ());
		glVertex3f(_camera->_ftr.GetX(),_camera->_ftr.GetY(),_camera->_ftr.GetZ());
		glVertex3f(_camera->_fbl.GetX(),_camera->_fbl.GetY(),_camera->_fbl.GetZ());
		glVertex3f(_camera->_fbr.GetX(),_camera->_fbr.GetY(),_camera->_fbr.GetZ());
	glEnd();

	DrawLines();
	DrawPlanes();
	DrawNormals();
}
Exemple #5
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
}
Exemple #6
0
int ProtHelpObject::HitTest(TimeValue t, INode *inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt) 
{
   if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	 
	 HitRegion hitRegion;
   DWORD savedLimits;
   int res;
   Matrix3 m;
   GraphicsWindow *gw = vpt->getGW();  
   Material *mtl = gw->getMaterial();
   MakeHitRegion(hitRegion,type,crossing,4,p);  
   gw->setRndLimits(((savedLimits = gw->getRndLimits()) | GW_PICK) & ~GW_ILLUM);
   GetMat(t,inode,*vpt,m);
   gw->setTransform(m);
   // if we get a hit on the mesh, we're done
   gw->clearHitCode();
   if (mesh.select( gw, mtl, &hitRegion, flags & HIT_ABORTONHIT )) 
      return TRUE;
   // if not, check the target line, and set the pair flag if it's hit
   gw->clearHitCode();
   res = DrawLines(t, inode, gw, 1);
   gw->setRndLimits(savedLimits);
   return res;
}
Exemple #7
0
void OpenGLWrapper::DrawLines(size_t dim, std::vector<float> const& lines, size_t c_dim, std::vector<float> const& colors) {
	glShadeModel(GL_SMOOTH);
	glEnableClientState(GL_COLOR_ARRAY);
	glColorPointer(c_dim, GL_FLOAT, 0, &colors[0]);
	DrawLines(dim, &lines[0], lines.size() / dim);
	glDisableClientState(GL_COLOR_ARRAY);
	glShadeModel(GL_FLAT);
}
void inline CWaveEditControl::MoveWaveLines(QPoint p)
{
    size_t Pos=BufferPos(p.x());
    if (Pos>m_Length) Pos=m_Length;
    if (WaveLines==wlStart)
    {
        if (m_LoopOn)
        {
            if (Pos>m_LP.LoopStart) Pos=m_LP.LoopStart;
        }
        else
        {
            if (Pos>m_LP.End-(m_LP.FadeIn+m_LP.FadeOut)) Pos=m_LP.End-(m_LP.FadeIn+m_LP.FadeOut);
        }
        m_LP.Start=Pos;
    }
    else if (WaveLines==wlEnd)
    {
        if (m_LoopOn)
        {
            if (Pos<m_LP.LoopEnd) Pos=m_LP.LoopEnd;
        }
        else
        {
            if (Pos<m_LP.Start+m_LP.FadeIn+m_LP.FadeOut) Pos=m_LP.Start+m_LP.FadeIn+m_LP.FadeOut;
        }
        m_LP.End=Pos;
    }
    else if (WaveLines==wlLoopStart)
    {
        if (Pos<m_LP.Start) Pos=m_LP.Start;
        if (Pos>m_LP.LoopEnd) Pos=m_LP.LoopEnd;
        m_LP.LoopStart=Pos;
    }
    else if (WaveLines==wlLoopEnd)
    {
        if (Pos<m_LP.LoopStart) Pos=m_LP.LoopStart;
        if (Pos>m_LP.End) Pos=m_LP.End;
        m_LP.LoopEnd=Pos;
    }
    else if (WaveLines==wlFadeIn)
    {
        if (Pos<m_LP.Start) Pos=m_LP.Start;
        if (Pos>m_LP.End-m_LP.FadeOut) Pos=m_LP.End-m_LP.FadeOut;
            m_LP.FadeIn=Pos-m_LP.Start;
            m_LP.Volume=Pos2Vol(p.y());
    }
    else if (WaveLines==wlFadeOut)
    {
        if (Pos<m_LP.Start+m_LP.FadeIn) Pos=m_LP.Start+m_LP.FadeIn;
        if (Pos>m_LP.End) Pos=m_LP.End;
        m_LP.FadeOut=m_LP.End-Pos;
        m_LP.Volume=Pos2Vol(p.y());
    }
    DrawLines(m_LP,m_LoopOn);
    emit ParameterChanged(m_LP);
}
void XYLineRendererBase::Draw(wxDC &dc, wxRect rc, Axis *horizAxis, Axis *vertAxis, XYDataset *dataset)
{
    if(m_drawLines) {
        DrawLines(dc, rc, horizAxis, vertAxis, dataset);
    }

    if(m_drawSymbols) {
        DrawSymbols(dc, rc, horizAxis, vertAxis, dataset);
    }
}
Exemple #10
0
void CDComView::OnDraw(CDC* dc)
{
    CRect rcBounds;
    GetClientRect(&rcBounds);
    int nFirstLine;
    int nLastLine;
    CRect rcClient;
    CDComDoc* pDoc = GetDocument();
    CPoint ptScroll;
    SDComCfg *pDComCfg;
    CFont font;
    CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();

    if (dc->IsPrinting())
    {
        dc->SetMapMode(MM_LOENGLISH);
    }
    else
    {
        dc->SetMapMode(MM_TEXT);
    }
    ASSERT_VALID(pMainFrm);
    if (!pMainFrm)
    {
        return;
    }
    ASSERT_VALID(pDoc);
    if (!pDoc)
    {
        return;
    }

    pDComCfg = pMainFrm->GetConfig();
    if (!dc->IsPrinting())
    {
        dc->SetBkColor(pDComCfg->m_crBack);
    }

    CMyMemDC pDC(dc);

    font.CreateFontIndirect(&pDComCfg->m_logfont);
    pDC->SelectObject(font);
    font.DeleteObject();

    pDoc->m_cLineBuffer.Enter();

    ptScroll = GetDeviceScrollPosition();
    GetClientRect(&rcClient);

    nFirstLine = ptScroll.y / m_sizeCharDimensions.cy;
    nLastLine = nFirstLine + (rcClient.Height() / m_sizeCharDimensions.cy) + 1;

    DrawLines(nFirstLine, nLastLine, pDComCfg, pDC);
    pDoc->m_cLineBuffer.Exit();
}
Exemple #11
0
void nGraphics::DrawCursor(const nVector2& position,float internal,float external,float angle,const nColor& color)
{
	SetLineWidth(2);

	nMatrix4 matRot,matTrans,matFinal;

	D3DXMatrixRotationZ(&matRot,angle);
	D3DXMatrixTranslation(&matTrans,position.x,position.y,0.0f);

	matFinal = matRot * matTrans;

	nVector2 lines[2];

	lines[0] = nVector2(internal,internal);
	lines[1] = nVector2(external,external);

	D3DXVec2TransformCoordArray((LPD3DXVECTOR2)lines,sizeof(nVector2),(LPD3DXVECTOR2)lines,sizeof(nVector2),&matFinal,2);

	DrawLines(lines,2,color);

	lines[0] = nVector2(-internal,internal);
	lines[1] = nVector2(-external,external);

	D3DXVec2TransformCoordArray((LPD3DXVECTOR2)lines,sizeof(nVector2),(LPD3DXVECTOR2)lines,sizeof(nVector2),&matFinal,2);

	DrawLines(lines,2,color);

	lines[0] = nVector2(internal,-internal);
	lines[1] = nVector2(external,-external);

	D3DXVec2TransformCoordArray((LPD3DXVECTOR2)lines,sizeof(nVector2),(LPD3DXVECTOR2)lines,sizeof(nVector2),&matFinal,2);

	DrawLines(lines,2,color);

	lines[0] = nVector2(-internal,-internal);
	lines[1] = nVector2(-external,-external);

	D3DXVec2TransformCoordArray((LPD3DXVECTOR2)lines,sizeof(nVector2),(LPD3DXVECTOR2)lines,sizeof(nVector2),&matFinal,2);

	DrawLines(lines,2,color);
}
Exemple #12
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();
}
Exemple #13
0
int ProtHelpObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) 
{
   if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here
		DbgAssert(!_T("Invalid viewport!"));
		return FALSE;
	}
	 
	 Matrix3 m;
   GraphicsWindow *gw = vpt->getGW();
   Material *mtl = gw->getMaterial();

   created = TRUE;
   GetMat(t,inode,*vpt,m);
   gw->setTransform(m);
   DWORD rlim = gw->getRndLimits();
   gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) );
   if (inode->Selected()) 
      gw->setColor( LINE_COLOR, GetSelColor());
   else if(!inode->IsFrozen() && !inode->Dependent())
      gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ));
   mesh.render( gw, mtl, NULL, COMP_ALL);
   
   // calc angle
   lastAngle = 0.0;
   #define RadToDegDbl  (180.0 / 3.141592653589793)
   if(refNode[0] && refNode[1]) {
      Point3 origin = m.GetTrans();
      Point3 vec1 = refNode[0]->GetObjectTM(t).GetTrans() - origin;
      Point3 vec2 = refNode[1]->GetObjectTM(t).GetTrans() - origin;
      float len1 = Length(vec1);
      float len2 = Length(vec2);
      if(len1 > 0.00001f && len2 > 0.00001f) {
         double cosAng = (double)DotProd(vec1, vec2) / (double)(len1 * len2);
         if(fabs(cosAng) <= 0.999999)  // beyond float accuracy!
            lastAngle = acos(cosAng) * RadToDegDbl;
         else
            lastAngle = 180.0;
      }
   }
#if 0
   Point3 pt(0,0,0);
   TCHAR buf[32];
   _stprintf(buf, "%g", lastAngle);
   gw->setColor(TEXT_COLOR, GetUIColor(COLOR_TAPE_OBJ));
   gw->text(&pt, buf);
#endif
   DrawLines(t, inode, gw, 1);
   UpdateUI(t);
   gw->setRndLimits(rlim);
   return(0);
}
void CWaveEditControl::Draw(CWaveGenerator::LoopParameters LP)
{
    m_LP=LP;
    if (Enabled)
    {
        if (height())
        {
            DrawWave();
            DrawLines(m_LP,m_LoopOn);
        }
    }
}
Exemple #15
0
void nGraphics::DrawCircle(const nPoint& point,float radius,unsigned long elements,const nColor& color)
{
	nAssert(elements);

	nVector2* lines = new nVector2[elements];

	for(unsigned long i = 0; i < elements; i++)
		lines[i] = nVector2(point.x + radius * sinf(D3DX_PI*2/(elements-1) * i),point.y + radius * cosf(D3DX_PI*2/(elements-1) * i));

	DrawLines(lines,elements,color);

	nSafeFree(lines);
}
Exemple #16
0
int GameRender(TGAME* Juego){
	GraphicManager_ClearBuffer(&(Juego->Pantalla));
	//Primero, dibujamos el marco.
	DrawMainframe(Juego);
	
	//Luego, dibujamos el cursor, las lineas y quien se gano cada celda
	DrawCursor(Juego);
	DrawLines(Juego);
	DrawWins(Juego);
	GraphicManager_SwapBuffer(&(Juego->Pantalla));

	return 0;
}
Exemple #17
0
BOOL TImageWin::EvMouseMove(UINT fwKeys, POINTS pts)
{
	if (status == START) {
		DrawLines(&pts);
	}
	else if (status == DRAW_START) {
		if (!IS_SAME_PTS(drawPts.back().pts.back(), pts)) {
			drawPts.back().pts.push_back(pts);
		}
		DrawMarker();
	}
	return	TRUE;
}
Exemple #18
0
GXLRESULT GXConsole::Render(GrapX::Canvas* pCanvas)
{
  GXSIZE size;
 
  pCanvas->GetTargetDimension(&size);
  size.cy >>= 1;
  pCanvas->FillRectangle(0, 0, size.cx, size.cy, 0xa0000000);

  TextRoundBuffer::LINEDESC LineDesc;
  m_pBuffer->GetLines(size.cy / s_nFontHeight, TextRoundBuffer::LO_End, &LineDesc);

  DrawLines(pCanvas, size.cy - s_nFontHeight * LineDesc.nNumLines, s_nFontHeight, &LineDesc);
  return 0;
}
void LineGraph::RenderGraph(int eventsOfset)
{
	primitives_PaintRect16(m_surface, &m_surfaceRect, g_colorSet->GetColor(COLOR_BLACK));
	primitives_FrameRect16(m_surface, &m_surfaceRect, g_colorSet->GetColor(COLOR_WHITE));
	primitives_FrameRect16(m_surface, &m_graphRect, g_colorSet->GetColor(COLOR_WHITE));

	DrawThisStateImage(
		0,
		m_surface,
		&m_surfaceRect );

	LabelAxes();
	DrawLines(eventsOfset);
	if (m_hasIndicator) DrawIndicator();
}
Exemple #20
0
void ocpnDC::StrokeLines( int n, wxPoint *points) {
#if wxUSE_GRAPHICS_CONTEXT
    if( pgc ) {
        wxPoint2DDouble* dPoints = (wxPoint2DDouble*) malloc( n * sizeof( wxPoint2DDouble ) );
        for( int i=0; i<n; i++ ) {
            dPoints[i].m_x = points[i].x;
            dPoints[i].m_y = points[i].y;
        }
        pgc->SetPen( dc->GetPen() );
        pgc->StrokeLines( n, dPoints );
        free( dPoints );
    } else
#endif
        DrawLines( n, points, 0, 0, true );
}
Exemple #21
0
void DXPrimitives::DrawLineBox(vec3 center, vec3 dimensions, quaternion orientation)
{
	vec3 min = -(dimensions / 2.0f);
	vec3 max = (dimensions / 2.0f);

	vec3 corners[8];
	corners[0] = max;
	corners[1] = max - vec3(0.0f, 0.0f, dimensions.z);
	corners[2] = max - vec3(dimensions.x, 0.0f, dimensions.z);
	corners[3] = max - vec3(dimensions.x, 0.0f, 0.0f);
	corners[4] = min + vec3(dimensions.x, 0.0f, dimensions.z);
	corners[5] = min + vec3(dimensions.x, 0.0f, 0.0f);
	corners[6] = min;
	corners[7] = min + vec3(0.0f, 0.0f, dimensions.z);

	for(int i = 0; i < 8; i++)
		corners[i] = center + (orientation * corners[i]);

	vec4 vertices[24];
	{
		// top rectangle
		for(int i = 0; i < 3; i++)
		{
			vertices[i*2+0] = vec4(corners[i].x, corners[i].y, corners[i].z, 1.0f);
			vertices[i*2+1] = vec4(corners[i + 1].x, corners[i + 1].y, corners[i + 1].z, 1.0f);
		}
		vertices[6] = vec4(corners[0].x, corners[0].y, corners[0].z, 1.0f);
		vertices[7] = vec4(corners[3].x, corners[3].y, corners[3].z, 1.0f);

		// bottom rectangle
		for(int i = 4; i < 7; i++)
		{
			vertices[i*2+0] = vec4(corners[i].x, corners[i].y, corners[i].z, 1.0f);
			vertices[i*2+1] = vec4(corners[i + 1].x, corners[i + 1].y, corners[i + 1].z, 1.0f);
		}
		vertices[14] = vec4(corners[4].x, corners[4].y, corners[4].z, 1.0f);
		vertices[15] = vec4(corners[7].x, corners[7].y, corners[7].z, 1.0f);

		// sides
		for(int i = 0; i < 4; i++)
		{
			vertices[16+i*2+0] = vec4(corners[i].x, corners[i].y, corners[i].z, 1.0f);
			vertices[16+i*2+1] = vec4(corners[i + 4].x, corners[i + 4].y, corners[i + 4].z, 1.0f);
		}
	}
	DrawLines(vertices, 24);
}
Exemple #22
0
	void CPlot::RefreshPlot(CDC* pDC)
	{	
		// 更新布局
		RefreshLayout();
		// 绘制背景
		DrawBackground(pDC);
		// 绘制坐标轴
		DrawAxises(pDC);
		// 绘制网格
		DrawGrids(pDC);
		// 绘制图例
		DrawLegend(pDC,m_rectLegend);
		// 绘制标题
		DrawTile(pDC,m_rectTitle);
		// 绘制曲线
		DrawLines(pDC);
	}
Exemple #23
0
BOOL TImageWin::EvPaint()
{
	PAINTSTRUCT	ps;
	HDC		hDc = ::BeginPaint(hWnd, &ps);
	HBITMAP	hOldBmp = (HBITMAP)::SelectObject(hSelfDc, hSelfBmp);

	::BitBlt(hDc, 0, 0, rect.right - rect.left, rect.bottom - rect.top, hSelfDc, 0, 0, SRCCOPY);
	::SelectObject(hSelfDc, hOldBmp);
	::EndPaint(hWnd, &ps);

	if (status >= START && status <= DRAW_END) {
		DrawLines();
		DrawMarker();
	}

	return	TRUE;
}
Exemple #24
0
void MidiPartition::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(axColor(0.3, 0.3, 0.3), 1.0);
	gc->DrawRectangle(rect0);

	DrawLines(gc, rect0);
	DrawHeighlightedCircle(gc, rect0);
	DrawCircles(gc, rect0);
	DrawSelectedCircle(gc, rect0);

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(rect0);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
    WPARAM wParam, LPARAM lParam) {
    
    switch(msg) {
  
        case WM_PAINT:

            DrawLines(hwnd);
            break;

        case WM_DESTROY:

            PostQuitMessage(0);
            return 0;
    }

    return DefWindowProcW(hwnd, msg, wParam, lParam);
}
Exemple #26
0
void ocpnDC::StrokeLines( int n, wxPoint *points) {
    if(n < 2) /* optimization and also to avoid assertion in pgc->StrokeLines */
        return;

#if wxUSE_GRAPHICS_CONTEXT
    if( pgc ) {
        wxPoint2DDouble* dPoints = (wxPoint2DDouble*) malloc( n * sizeof( wxPoint2DDouble ) );
        for( int i=0; i<n; i++ ) {
            dPoints[i].m_x = points[i].x;
            dPoints[i].m_y = points[i].y;
        }
        pgc->SetPen( dc->GetPen() );
        pgc->StrokeLines( n, dPoints );
        free( dPoints );
    } else
#endif
        DrawLines( n, points, 0, 0, true );
}
Exemple #27
0
void nuiSoftwarePainter::DrawArray(nuiRenderArray* pArray)
{
  if (!mEnableDrawArray)
  {
    pArray->Release();
    return;
  }
  
  switch (pArray->GetMode())
  {
  case GL_POINTS:
    //NGL_OUT(_T("GL_POINTS Not Implemented\n"));
    break;
  case GL_LINES:
    DrawLines(pArray);
    break;
  case GL_LINE_STRIP:
    DrawLineStrip(pArray);
    break;
  case GL_LINE_LOOP:
    DrawLineLoop(pArray);
    break;
  case GL_TRIANGLES:
    DrawTriangles(pArray);
    break;
  case GL_TRIANGLE_FAN:
    DrawTrianglesFan(pArray);
    break;
  case GL_TRIANGLE_STRIP:
    DrawTrianglesStrip(pArray);
    break;
//  case GL_QUADS:
//    DrawQuads(pArray);
//    break;
//  case GL_QUAD_STRIP:
//    DrawQuadStrip(pArray);
//    break;
//  case GL_POLYGON:
//    //NGL_OUT(_T("GL_POLYGON Not Implemented\n"));
//    break;
  }

  pArray->Release();
}
Exemple #28
0
void QMyCanvas::paintEvent(QPaintEvent* event)
{
    if( doDraw == 1 )
        DrawFSJL("000001K","20100310");
    else    if( doDraw == 2 )
        DrawFSJL("000002J","20100311");
    else    if( doDraw == 3 )
        DrawFSJL("000012J","20100311");
    else        if( doDraw == 4 )
        DrawFSJL("000001K","20100310");
    else            if( doDraw == 5 )
        DrawFSJL("000002J","20100311");
    else               if( doDraw == 6 )
        DrawFSJL("000012J","20100311");
    else                    if( doDraw == 7 )
        DrawBK();
        DrawLines();
        //drawShape();
            DrawBK();
}
Exemple #29
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;
}
Exemple #30
0
void liang_barsky_algo(void)
{
    glClear(GL_COLOR_BUFFER_BIT);

    double p[4], q[4], u1, u2, r, dx, dy;
    lines = mainlines;
    for (int i = 0,j; i<lines.size(); i++)
    {
        u1 = 0; u2 = 1;
        dx = lines[i].second.first - lines[i].first.first;
        dy = lines[i].second.second - lines[i].first.second;
        p[0] = -dx;
        p[1] = dx;
        p[2] = -dy;
        p[3] = dy;
        q[0] = lines[i].first.first -  xmin;
        q[1] = xmax - lines[i].first.first;
        q[2] = lines[i].first.second -  ymin;
        q[3] = ymax - lines[i].first.second;

//        cout<<"Line " <<i<<": "<< lines[i].first.first<<" " <<lines[i].first.second<<" : " <<
//               lines[i].second.first<<" "<< lines[i].second.second<<endl;
//        cout<<"dx = "<<dx<<" dy = "<<dy<<endl;
        for (j = 0; j<4; j++)
        {
//            cout<<"p = "<<p[j]<<",q = "<<q[j];
            if(p[j] == 0)
            {
                if(q[j] < 0) break;
                continue;
            }


            r = q[j]/p[j];

            if(p[j]<0) u1 = max(r,u1);
            else u2 = min(r,u2);
//            cout<<": r = "<<r<<endl;
        }

//        cout<<u1<<" uuuuuu "<<u2<<endl;

        if(j<4 || u1>u2)
        {
            lines.erase(lines.begin()+i);
            i--;
            continue;
        }


        int xpart = lines[i].first.first;
        int ypart = lines[i].first.second;


        lines[i].first.first+=(dx*u1);
        lines[i].first.second+=(dy*u1);

        lines[i].second.first=xpart+(dx*u2);
        lines[i].second.second= ypart+(dy*u2);

//        cout<<"Line " <<i<<"--> "<< lines[i].first.first<<" " <<lines[i].first.second<<" : " <<
//               lines[i].second.first<<" "<< lines[i].second.second<<endl;
    }


    glutSwapBuffers();
    DrawLines();
    glutSwapBuffers();
    return;
}