void CRimshotView::OnViewZoom() 
{
    CRimshotDoc* pDoc = GetDocument();
    if (pDoc->m_pInput)
    {
	CZoomDlg dlg;
	CRect rect;
	
	GetClientRect(&rect);
	dlg.m_dLeft = pDoc->m_dLeft;
	dlg.m_dRight = pDoc->m_dRight;
	dlg.m_dWidth = pDoc->m_dRight - pDoc->m_dLeft;
	dlg.m_dPerPixel = dlg.m_dWidth / (double)rect.Width();

	if (dlg.DoModal() == IDOK)
	{
	    if (dlg.m_bLR)
	    {
		if (dlg.m_dLeft < dlg.m_dRight)
		{
		    RLOG_EVENT event;
		    pDoc->m_dLeft = dlg.m_dLeft;
		    pDoc->m_dRight = dlg.m_dRight;
		    RLOG_FindGlobalEventBeforeTimestamp(pDoc->m_pInput, (dlg.m_dLeft + dlg.m_dRight) / 2.0, &event);
		    StopDrawing();
		    StartDrawing();
		}
	    }
	    if (dlg.m_bWidth)
	    {
		if (dlg.m_dWidth > 0.0)
		{
		    double middle = (pDoc->m_dLeft + pDoc->m_dRight) / 2.0;
		    pDoc->m_dLeft = middle - (dlg.m_dWidth / 2.0);
		    pDoc->m_dRight = middle + (dlg.m_dWidth / 2.0);
		    StopDrawing();
		    StartDrawing();
		}
	    }
	    if (dlg.m_bPerPixel)
	    {
		dlg.m_dWidth = dlg.m_dPerPixel * (double)rect.Width();
		if (dlg.m_dWidth > 0.0)
		{
		    double middle = (pDoc->m_dLeft + pDoc->m_dRight) / 2.0;
		    pDoc->m_dLeft = middle - (dlg.m_dWidth / 2.0);
		    pDoc->m_dRight = middle + (dlg.m_dWidth / 2.0);
		    StopDrawing();
		    StartDrawing();
		}
	    }
	}
    }
}
void CRimshotView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
    RLOG_EVENT event;
    double d;
    CRimshotDoc* pDoc = GetDocument();

    if (pDoc->m_pInput)
    {
	switch (nChar)
	{
	case VK_RIGHT:
	    if (RLOG_GetNextGlobalEvent(pDoc->m_pInput, &event) == 0)
	    {
		while (!m_Draw.pCursorRanks[event.rank].active)
		{
		    if (RLOG_GetNextGlobalEvent(pDoc->m_pInput, &event) != 0)
			break;
		}
		StopDrawing();
		d = (pDoc->m_dRight - pDoc->m_dLeft) / 2;
		pDoc->m_dLeft = event.start_time - d;
		pDoc->m_dRight = event.start_time + d;
		StartDrawing();
	    }
	    break;
	case VK_LEFT:
	    if (RLOG_GetPreviousGlobalEvent(pDoc->m_pInput, &event) == 0)
	    {
		while (!m_Draw.pCursorRanks[event.rank].active)
		{
		    if (RLOG_GetPreviousGlobalEvent(pDoc->m_pInput, &event) != 0)
			break;
		}
		StopDrawing();
		d = (pDoc->m_dRight - pDoc->m_dLeft) / 2;
		pDoc->m_dLeft = event.start_time - d;
		pDoc->m_dRight = event.start_time + d;
		StartDrawing();
	    }
	    break;
	default:
	    break;
	}
    }

    CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Exemple #3
0
void CRenderer::Polygon(PolygonVertices* _polygon, int color){
	StartDrawing();
	for(int i =0; i<_polygon->size()-1;i++){
		Line(*((*_polygon)[i]),*((*_polygon)[i+1]), color);
	}
	Line(*((*_polygon)[_polygon->size()-1]), *((*_polygon)[0]), color);
	StopDrawing();
}
void CRimshotView::OnResetZoom() 
{
    CRimshotDoc* pDoc = GetDocument();
    StopDrawing();
    pDoc->m_dLeft = pDoc->m_dFirst;
    pDoc->m_dRight = pDoc->m_dLast;
    StartDrawing();
}
void CRimshotView::OnViewUniform() 
{
    CMenu *pMenu = GetParentFrame()->GetMenu();

    m_Draw.bDrawUniform = !m_Draw.bDrawUniform;

    if (pMenu)
	pMenu->CheckMenuItem(ID_VIEW_UNIFORM, MF_BYCOMMAND | m_Draw.bDrawUniform ? MF_CHECKED : MF_UNCHECKED);
    StopDrawing();
    StartDrawing();
}
void WinDrawChar (int x, int y, char c, OSPictContext context)
{
	int oldmode;

	StartDrawing (context);

	oldmode = GetBkMode (context->hDC);
	SetBkMode (context->hDC, TRANSPARENT);
	TextOut (context->hDC, x, y, &c, 1);
	SetBkMode (context->hDC, oldmode);
}	/* WinDrawChar */
	void SpriteRenderer3D::DrawCache()
	{
		StartDrawing();

		for (auto& s : sprites)
		{
			Draw(s);
		}

		EndDrawing();
	}
void CRimshotView::OnZoomOut() 
{
    double d;
    CRimshotDoc* pDoc = GetDocument();

    StopDrawing();
    d = (pDoc->m_dRight - pDoc->m_dLeft) / 2.0;
    pDoc->m_dLeft -= d;
    pDoc->m_dRight += d;
    StartDrawing();
}
Exemple #9
0
void ModelPreview::render( wxPaintEvent& event )
{
    if(mIsDrawing) return;
    //if(!mIsInitialized) { InitializeGLCanvas(); }
    //SetCurrentGLContext();
    //wxPaintDC(this); // only to be used in paint events. use wxClientDC to paint outside the paint event
    //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    if(!StartDrawing(mPointSize)) return;
    Render();
    EndDrawing();
}
void CRimshotView::OnPrevious() 
{
    double d;
    RLOG_EVENT event;
    CRimshotDoc* pDoc = GetDocument();

    StopDrawing();
    d = (pDoc->m_dRight - pDoc->m_dLeft) / 6.0;
    RLOG_FindGlobalEventBeforeTimestamp(pDoc->m_pInput, (pDoc->m_dLeft + pDoc->m_dRight) / 2.0 - d, &event);
    pDoc->m_dLeft = event.start_time - (3.0 * d);
    pDoc->m_dRight = event.start_time + (3.0 * d);
    StartDrawing();
}
void CRimshotView::OnSize(UINT nType, int cx, int cy) 
{
    CView::OnSize(nType, cx, cy);

    if (m_Draw.pCanvas != NULL)
    {
	// stop any current drawing
	StopDrawing();

	if (m_Draw.max_rect_size.cx < cx || m_Draw.max_rect_size.cy < cy)
	{
	    m_Draw.max_rect_size.cx = max(m_Draw.max_rect_size.cx, cx);
	    m_Draw.max_rect_size.cy = max(m_Draw.max_rect_size.cy, cy);
	    // create a new resized canvas bitmap
	    CBitmap *pBmp = new CBitmap();
	    pBmp->CreateDiscardableBitmap(GetDC(), m_Draw.max_rect_size.cx, m_Draw.max_rect_size.cy);
	    
	    if (m_Draw.pBitmap)
	    {
		m_Draw.pCanvas->SelectObject(pBmp);
		delete m_Draw.pBitmap;
		m_Draw.pBitmap = pBmp;
	    }
	    else
	    {
		m_Draw.pOriginalBmp = m_Draw.pCanvas->SelectObject(pBmp);
		m_Draw.pBitmap = pBmp;
	    }
	}
	m_Draw.rect_size.cx = cx;
	m_Draw.rect_size.cy = cy;

	// create the copy bitmap if this is the first size event
	if (m_Draw.pCopyBitmap == NULL)
	{
	    CBitmap *pBmpCopy = new CBitmap();
	    pBmpCopy->CreateDiscardableBitmap(GetDC(), cx, cy);

	    m_Draw.pCopyOriginalBmp = m_Draw.pCopyCanvas->SelectObject(pBmpCopy);
	    m_Draw.pCopyBitmap = pBmpCopy;
	    m_Draw.copy_size.cx = cx;
	    m_Draw.copy_size.cy = cy;
	    m_Draw.max_copy_size.cx = cx;
	    m_Draw.max_copy_size.cy = cy;
	}

	// start redrawing
	StartDrawing();
    }
}
Exemple #12
0
void ModelPreview::Render(const unsigned char *data) {
    if (StartDrawing(mPointSize)) {
        if (PreviewModels != NULL) {
            for (int m=0; m<PreviewModels->size(); m++) {
                int NodeCnt=(*PreviewModels)[m]->GetNodeCount();
                for(int n=0; n<NodeCnt; n++) {
                    int start = (*PreviewModels)[m]->NodeStartChannel(n);
                    (*PreviewModels)[m]->SetNodeChannelValues(n, &data[start]);
                }
                (*PreviewModels)[m]->DisplayModelOnWindow(this);
            }
        }
        EndDrawing();
    }
}
void CRimshotView::OnNext() 
{
    double d;
    RLOG_EVENT event1, event2;
    CRimshotDoc* pDoc = GetDocument();

    StopDrawing();
    d = (pDoc->m_dRight - pDoc->m_dLeft) / 6.0;
    RLOG_GetCurrentGlobalEvent(pDoc->m_pInput, &event1);
    RLOG_FindGlobalEventBeforeTimestamp(pDoc->m_pInput, (pDoc->m_dLeft + pDoc->m_dRight) / 2.0 + d, &event2);
    if (event1.start_time == event2.start_time)
	RLOG_GetNextGlobalEvent(pDoc->m_pInput, &event2);
    pDoc->m_dLeft = event2.start_time - (3.0 * d);
    pDoc->m_dRight = event2.start_time + (3.0 * d);
    StartDrawing();
}
void CRimshotView::OnZoomTo() 
{
    CRect rect;
    RLOG_EVENT event;
    CRimshotDoc* pDoc = GetDocument();
    double width;

    if (pDoc->m_pInput)
    {
	StopDrawing();
	RLOG_GetCurrentGlobalEvent(pDoc->m_pInput, &event);
	GetClientRect(&rect);
	width = event.end_time - event.start_time;
	pDoc->m_dLeft = event.start_time - (10.0 * width);
	pDoc->m_dRight = event.start_time + (10.0 * width);
	StartDrawing();
    }
}
Exemple #15
0
void CRenderer::PolygonFilled(PolygonVertices* _polygon, int color) {
  if (_polygon->size()<3) return;

	StartDrawing();
  float miny, maxy;
  //Znajdujemy max i min na ykach
  miny = maxy = ((*_polygon)[0])->y;
  float temp_x1, temp_x2, temp_y1, temp_y2;
  for (unsigned i=0;i<_polygon->size();i++){
	temp_y1 = ((*_polygon)[i])->y;
    if (miny > temp_y1) {miny = temp_y1;}
    if (maxy < temp_y1) {maxy = temp_y1;}
  }

  //lista xów
  int *xlist = new int[_polygon->size()];
  unsigned xlistsize;

  // dla kazdego yka na wys polygona
  for (float y=miny;y<=maxy;y++) {
    // szukamy przeciec linii
    xlistsize = 0;
    for (unsigned i=0;i<_polygon->size();i++) {
      temp_y1 = ((*_polygon)[i])->y; 
	  temp_y2 = ((*_polygon)[(i+1)%(_polygon->size())])->y;
      if ((y>temp_y1 && y<=temp_y2) || (y>temp_y2 && y<=temp_y1)) {
        temp_x1 = ((*_polygon)[i])->x;
        temp_x2 = ((*_polygon)[(i+1)%(_polygon->size())])->x;
        xlist[xlistsize++] = (int)( temp_x1 + (y-temp_y1)*(temp_x2-temp_x1)/(temp_y2-temp_y1) );
      }
    }
    if (xlistsize==0) { continue; }
//sortujemy xy
	std::sort(xlist,xlist+xlistsize);
//malujemy co drugie
    for (int i=0;i<xlistsize;i+=2) {
      for (int x=xlist[i];x<=xlist[i+1];x++) {
		  PutPixel(x,y,color);
      }
    }
  }
  delete[] xlist;
  StopDrawing();
}
Exemple #16
0
void WinDrawString (int x, int y, char *string, OSPictContext context)
{
	int oldmode;

	StartDrawing (context);

	oldmode = GetBkMode (context->hDC);
	if (context->penMode==iModeXor)					/* Check if currently in XOR mode */
	{
		SetBkMode (context->hDC, OPAQUE);			/* in that case background should be OPAQUE. */
	}
	else
	{
		SetBkMode (context->hDC, TRANSPARENT);		/* otherwise it should be TRANSPARENT. */
	}
	if (!TextOut (context->hDC, x, y, string, strlen(string)))
		rMessageBox (NULL,MB_APPLMODAL,"WinDrawString","TextOut failed.");
	SetBkMode (context->hDC, oldmode);
}	/* WinDrawString */
Exemple #17
0
void WinDrawCurve (int x, int y, int rx, int ry, float from, float to, BOOL clockwise,OSPictContext context)
{
	int arx, ary;
	int cx, cy;
	int ex, ey;

	StartDrawing (context);

	arx	= abs(rx);
	ary	= abs(ry);
	cx	= x  - floor(cos(from)* arx);
	cy	= y  + floor(sin(from)* ary);
	ex	= cx + floor(cos(to)  * arx);
	ey	= cy - floor(sin(to)  * ary);

	if (clockwise)
		Arc (context->hDC, cx-rx, cy-ry, cx+rx, cy+ry, x, y, ex, ey);
	else
		Arc (context->hDC, cx-rx, cy-ry, cx+rx, cy+ry, ex, ey, x, y);
}	/* WinDrawCurve */
void CRimshotView::OnLButtonDown(UINT nFlags, CPoint point) 
{
    bool bHit = false;
    CRimshotDoc* pDoc = GetDocument();
    if (pDoc->m_pInput)
    {
	for (int i=0; i<pDoc->m_pInput->nNumRanks; i++)
	{
	    if (PointInside(point, m_Draw.pCursorRanks[i].rect))
	    {
		m_Draw.pCursorRanks[i].active = !m_Draw.pCursorRanks[i].active;
		//InvalidateRect(&m_Draw.pCursorRanks[i].rect);
		bHit = true;
	    }
	}
    }
    if (bHit)
    {
	StopDrawing();
	StartDrawing();
    }
    CView::OnLButtonDown(nFlags, point);
}
Exemple #19
0
void WinDrawOval (int left, int top, int right, int bot, OSPictContext context)
{
	StartDrawing (context);
	Arc (context->hDC, left, top, right, bot, 0, 0, 0, 0);
}	/* WinDrawOval */
void CRimshotView::OnToggleArrows() 
{
    StopDrawing();
    m_Draw.bDrawArrows = !m_Draw.bDrawArrows;
    StartDrawing();
}
Exemple #21
0
void SetHBVB(const sscpu_timestamp_t event_timestamp, const bool new_hb_status, const bool new_vb_status)
{
 const bool old_hb_status = hb_status;
 const bool old_vb_status = vb_status;

 hb_status = new_hb_status;
 vb_status = new_vb_status;

 if(MDFN_UNLIKELY(vbcdpending & hb_status & (old_hb_status ^ hb_status)))
 {
  vbcdpending = false;

  if(vb_status) // Going into v-blank
  {
   //
   // v-blank erase
   //
   if((TVMR & TVMR_VBE) || FBVBErasePending)
   {
    SS_DBGTI(SS_DBG_VDP1, "[VDP1] VB erase start of framebuffer %d.", !FBDrawWhich);

    FBVBErasePending = false;
    FBVBEraseActive = true;
    FBVBEraseLastTS = event_timestamp;
   }
  }
  else // Leaving v-blank
  {
   // Run vblank erase at end of vblank all at once(not strictly accurate, but should only have visible side effects wrt the debugger and reset).
   if(FBVBEraseActive)
   {
    int32 count = event_timestamp - FBVBEraseLastTS;
    //printf("%d %d, %d\n", event_timestamp, FBVBEraseLastTS, count);
    //
    //
    //
    uint32 y = EraseParams.y_start;

    do
    {
     uint16* fbyptr;
     uint32 x = EraseParams.x_start;

     fbyptr = &FB[!FBDrawWhich][(y & 0xFF) << 9];
     if(EraseParams.rot8)
      fbyptr += (y & 0x100);

     count -= 8;
     do
     {
      for(unsigned sub = 0; sub < 8; sub++)
      {
       //printf("%d %d:%d %04x\n", FBDrawWhich, x, y, fill_data);
       //printf("%lld\n", &fbyptr[x & fb_x_mask] - FB[!FBDrawWhich]);
       fbyptr[x & EraseParams.fb_x_mask] = EraseParams.fill_data;
       x++;
      }
      count -= 8;
      if(MDFN_UNLIKELY(count <= 0))
      {
       SS_DBGTI(SS_DBG_WARNING | SS_DBG_VDP1, "[VDP1] VB erase of framebuffer %d ran out of time.", !FBDrawWhich);
       goto AbortVBErase;
      }
     } while(x < EraseParams.x_bound);
    } while(++y <= EraseParams.y_end);

    AbortVBErase:;
    //
    FBVBEraseActive = false;
   }
   //
   //
   //
   //
   if(!(FBCR & FBCR_FCM) || (FBManualPending && (FBCR & FBCR_FCT)))	// Swap framebuffers
   {
    if(DrawingActive)
    {
     SS_DBGTI(SS_DBG_WARNING | SS_DBG_VDP1, "[VDP1] Drawing aborted by framebuffer swap.");
     DrawingActive = false;
    }

    FBDrawWhich = !FBDrawWhich;

    SS_DBGTI(SS_DBG_VDP1, "[VDP1] Displayed framebuffer changed to %d.", !FBDrawWhich);

    // On fb swap, copy CEF to BEF, clear CEF, and copy COPR to LOPR.
    EDSR = EDSR >> 1;
    LOPR = CurCommandAddr >> 2;

    //
    EraseParams.rot8 = (TVMR & (TVMR_8BPP | TVMR_ROTATE)) == (TVMR_8BPP | TVMR_ROTATE);
    EraseParams.fb_x_mask = EraseParams.rot8 ? 0xFF : 0x1FF;

    EraseParams.y_start = EWLR & 0x1FF;
    EraseParams.x_start = ((EWLR >> 9) & 0x3F) << 3;

    EraseParams.y_end = EWRR & 0x1FF;
    EraseParams.x_bound = ((EWRR >> 9) & 0x7F) << 3;

    EraseParams.fill_data = EWDR;
    //

    if(PTMR & 0x2)	// Start drawing(but only if we swapped the frame)
    {
     StartDrawing();
     SS_SetEventNT(&events[SS_EVENT_VDP1], Update(event_timestamp));
    }
   }

   if(!(FBCR & FBCR_FCM) || (FBManualPending && !(FBCR & FBCR_FCT)))
   {
    if(TVMR & TVMR_ROTATE)
    {
     EraseYCounter = ~0U;
     FBVBErasePending = true;
    }
    else
    {
     EraseYCounter = EraseParams.y_start;
    }
   }

   FBManualPending = false;
  }
 }
Exemple #22
0
void WinDrawRectangle (int left, int top, int right, int bot, OSPictContext context)
{
	StartDrawing (context);
	Rectangle (context->hDC, left, top, right, bot);
}	/* WinDrawRectangle */
Exemple #23
0
void WinDrawLine (int startx, int starty, int endx, int endy, OSPictContext context)
{
	StartDrawing (context);
	MoveToEx (context->hDC, startx, starty, NULL);
	LineTo (context->hDC, endx, endy);
}	/* WinDrawLine */
void C4GraphicsSystem::Execute()
{
	// activity check
	if (!StartDrawing()) return;

	bool fBGDrawn = false;

	// If lobby running, message board only (page flip done by startup message board)
	if (!::pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
		if (::Network.isLobbyActive() || !Game.IsRunning)
			if (!Application.isEditor)
			{
				// Message board
				if (iRedrawBackground) ClearFullscreenBackground();
				MessageBoard->Execute();
				if (!C4GUI::IsActive())
					{ FinishDrawing(); return; }
				fBGDrawn = true;
			}

	// fullscreen GUI?
	if (!Application.isEditor && C4GUI::IsActive() && (::pGUI->HasFullscreenDialog(false) || !Game.IsRunning))
	{
		if (!fBGDrawn && iRedrawBackground) ClearFullscreenBackground();
		::pGUI->Render(!fBGDrawn);
		FinishDrawing();
		return;
	}


	// Reset object audibility
	::Objects.ResetAudibility();

	// some hack to ensure the mouse is drawn after a dialog close and before any
	// movement messages
	if (!C4GUI::IsActive())
		::pGUI->SetMouseInGUI(false, false);

	// Viewports
	::Viewports.Execute(!Application.isEditor && iRedrawBackground);
	if (iRedrawBackground) --iRedrawBackground;

	if (!Application.isEditor)
	{
		// Upper board
		UpperBoard.Execute();

		// Message board
		MessageBoard->Execute();

		// Help & Messages
		DrawHelp();
		DrawHoldMessages();
		DrawFlashMessage();
	}

	// InGame-GUI
	if (C4GUI::IsActive())
	{
		::pGUI->Render(false);
	}

	// done
	FinishDrawing();
}
void C4GraphicsSystem::Execute()
	{
	// activity check
	if (!StartDrawing()) return;

	bool fBGDrawn = false;

	// If lobby running, message board only (page flip done by startup message board)
	if (!Game.pGUI || !Game.pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
		if(Game.Network.isLobbyActive() || !Game.IsRunning)
			if (Application.isFullScreen)
				{
				// Message board
				if (iRedrawBackground) ClearFullscreenBackground();
				MessageBoard.Execute();
				if (!Game.pGUI || !C4GUI::IsActive())
					{ FinishDrawing(); return; }
				fBGDrawn = true;
				}

	// fullscreen GUI?
	if (Application.isFullScreen && Game.pGUI && C4GUI::IsActive() && (Game.pGUI->HasFullscreenDialog(false) || !Game.IsRunning))
		{  
		if (!fBGDrawn && iRedrawBackground) ClearFullscreenBackground();
		Game.pGUI->Render(!fBGDrawn);
		FinishDrawing();
		return;
		}

	// Fixed screen rate in old network
	ScreenRate = 1;

	// Background redraw
	if (Application.isFullScreen)
		if (iRedrawBackground)
			DrawFullscreenBackground();

	// Screen rate skip frame draw
	ScreenTick++; if (ScreenTick>=ScreenRate) ScreenTick=0;

	// Reset object audibility
	Game.Objects.ResetAudibility();

	// some hack to ensure the mouse is drawn after a dialog close and before any
	// movement messages
	if (Game.pGUI && !C4GUI::IsActive())
		SetMouseInGUI(false, false);

	// Viewports
	for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)	
		cvp->Execute();

	if (Application.isFullScreen)
		{
		// Upper board
		UpperBoard.Execute();

		// Message board
		MessageBoard.Execute();

		// Help & Messages
		DrawHelp();
		DrawHoldMessages();
		DrawFlashMessage();
		}

	// InGame-GUI
	if (Game.pGUI && C4GUI::IsActive())
		{  
		Game.pGUI->Render(false);
		}

	// Palette update
	if (fSetPalette) { SetPalette(); /*SetDarkColorTable();*/ fSetPalette=FALSE; }

	// gamma update
	if (fSetGamma)
		{
		ApplyGamma();
		fSetGamma=FALSE;
		}

	// Video record & status (fullsrceen)
	if (Application.isFullScreen)
		Video.Execute();
	
	// done
	FinishDrawing();
	}
Exemple #26
0
void WinDrawPolygon (OSPictContext context)
{
	StartDrawing (context);
	Polyline (context->hDC, thePolygon, thePolygonIndex);
}	/* WinDrawPolygon */