예제 #1
0
파일: caret.c 프로젝트: x2on/NiLogViewer
static void CaretMoveExtend( LPCLASSDATA lpcd, int nMove )
{
	int	nOldStart, nOldEnd;

	/*
	 *	Marker set?
	 */
	if ( HasMark( lpcd ) == FALSE )
		/*
		 *	Setup starting point.
		 */
		lpcd->ptStartPos = lpcd->ptSelStart = lpcd->ptSelEnd = lpcd->ptCaretPos;

	/*
	 *	Copy old values.
	 */
	nOldStart = lpcd->ptSelStart.y;
	nOldEnd   = lpcd->ptSelEnd.y;

	/*
	 *	Move the caret.
	 */
	( FuncTable[ nMove ] )( lpcd );

	/*
	 *	Where are we?
	 */
	if ( lpcd->ptCaretPos.y < lpcd->ptStartPos.y || lpcd->ptCaretPos.y == lpcd->ptStartPos.y && lpcd->ptCaretPos.x < lpcd->ptStartPos.x )
	{
		/*
		 *	Setup new start position.
		 */
		lpcd->ptSelStart = lpcd->ptCaretPos;
		lpcd->ptSelEnd   = lpcd->ptStartPos;
	}
	else
	{
		lpcd->ptSelStart = lpcd->ptStartPos;
		lpcd->ptSelEnd   = lpcd->ptCaretPos;
	}

	/*
	 *	Update visuals.
	 */
	RenderLines( lpcd, nOldStart, lpcd->ptSelStart.y );
	RenderLines( lpcd, nOldEnd,   lpcd->ptSelEnd.y   );

	/*
	 *	Send status message.
	 */
	SendStatusMessage( lpcd );
}
예제 #2
0
void gfx::GraphicsEngine::Render( RenderQueue* drawQueue ){
	m_Camera.CalculateViewProjection();
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
	TextureHandle target = drawQueue->GetTargetTexture();
	m_FrameBuffer.SetTexture(target);
	RenderToTexture(drawQueue);
	RenderActiveTarget();
	RenderGeometry(drawQueue);
	RenderGizmos(drawQueue);
	RenderSprites(drawQueue);
	RenderLines(drawQueue);
	glUseProgram(0);
}
예제 #3
0
void FOculusRiftHMD::DrawDebug(UCanvas* Canvas)
{
#if !UE_BUILD_SHIPPING
	check(IsInGameThread());
	const auto frame = GetFrame();
	if (frame)
	{
		FSettings* FrameSettings = frame->GetSettings();

		if (FrameSettings->Flags.bDrawGrid)
		{
			bool bStereo = Canvas->Canvas->IsStereoRendering();
			Canvas->Canvas->SetStereoRendering(false);
			bool bPopTransform = false;
			if (FrameSettings->EyeRenderDesc[0].DistortedViewport.Size.w != FMath::CeilToInt(Canvas->ClipX) ||
				FrameSettings->EyeRenderDesc[0].DistortedViewport.Size.h != Canvas->ClipY)
			{
				// scale if resolution of the Canvas does not match the viewport
				bPopTransform = true;
				Canvas->Canvas->PushAbsoluteTransform(FScaleMatrix(
					FVector((Canvas->ClipX) / float(FrameSettings->EyeRenderDesc[0].DistortedViewport.Size.w),
					Canvas->ClipY / float(FrameSettings->EyeRenderDesc[0].DistortedViewport.Size.h),
					1.0f)));
			}

			const FColor cNormal(255, 0, 0);
			const FColor cSpacer(255, 255, 0);
			const FColor cMid(0, 128, 255);
			for (int eye = 0; eye < 2; ++eye)
			{
				int lineStep = 1;
				int midX = 0;
				int midY = 0;
				int limitX = 0;
				int limitY = 0;

				int renderViewportX = FrameSettings->EyeRenderDesc[eye].DistortedViewport.Pos.x;
				int renderViewportY = FrameSettings->EyeRenderDesc[eye].DistortedViewport.Pos.y;
				int renderViewportW = FrameSettings->EyeRenderDesc[eye].DistortedViewport.Size.w;
				int renderViewportH = FrameSettings->EyeRenderDesc[eye].DistortedViewport.Size.h;

				lineStep = 48;
				OVR::Vector2f rendertargetNDC = OVR::FovPort(FrameSettings->EyeRenderDesc[eye].Fov).TanAngleToRendertargetNDC(OVR::Vector2f(0.0f));
				midX = (int)((rendertargetNDC.x * 0.5f + 0.5f) * (float)renderViewportW + 0.5f);
				midY = (int)((rendertargetNDC.y * 0.5f + 0.5f) * (float)renderViewportH + 0.5f);
				limitX = FMath::Max(renderViewportW - midX, midX);
				limitY = FMath::Max(renderViewportH - midY, midY);

				int spacerMask = (lineStep << 1) - 1;

				for (int xp = 0; xp < limitX; xp += lineStep)
				{
					float x[4];
					float y[4];
					x[0] = (float)(midX + xp) + renderViewportX;
					y[0] = (float)0 + renderViewportY;
					x[1] = (float)(midX + xp) + renderViewportX;
					y[1] = (float)renderViewportH + renderViewportY;
					x[2] = (float)(midX - xp) + renderViewportX;
					y[2] = (float)0 + renderViewportY;
					x[3] = (float)(midX - xp) + renderViewportX;
					y[3] = (float)renderViewportH + renderViewportY;
					if (xp == 0)
					{
						RenderLines(Canvas->Canvas, 1, cMid, x, y);
					}
					else if ((xp & spacerMask) == 0)
					{
						RenderLines(Canvas->Canvas, 2, cSpacer, x, y);
					}
					else
					{
						RenderLines(Canvas->Canvas, 2, cNormal, x, y);
					}
				}
				for (int yp = 0; yp < limitY; yp += lineStep)
				{
					float x[4];
					float y[4];
					x[0] = (float)0 + renderViewportX;
					y[0] = (float)(midY + yp) + renderViewportY;
					x[1] = (float)renderViewportW + renderViewportX;
					y[1] = (float)(midY + yp) + renderViewportY;
					x[2] = (float)0 + renderViewportX;
					y[2] = (float)(midY - yp) + renderViewportY;
					x[3] = (float)renderViewportW + renderViewportX;
					y[3] = (float)(midY - yp) + renderViewportY;
					if (yp == 0)
					{
						RenderLines(Canvas->Canvas, 1, cMid, x, y);
					}
					else if ((yp & spacerMask) == 0)
					{
						RenderLines(Canvas->Canvas, 2, cSpacer, x, y);
					}
					else
					{
						RenderLines(Canvas->Canvas, 2, cNormal, x, y);
					}
				}
			}
			if (bPopTransform)
			{
				Canvas->Canvas->PopTransform(); // optional scaling
			}
			Canvas->Canvas->SetStereoRendering(bStereo);
		}
		if (IsStereoEnabled() && FrameSettings->Flags.bShowStats)
		{
			static const FColor TextColor(0,255,0);
			// Pick a larger font on console.
			UFont* const Font = FPlatformProperties::SupportsWindowedMode() ? GEngine->GetSmallFont() : GEngine->GetMediumFont();
			const int32 RowHeight = FMath::TruncToInt(Font->GetMaxCharHeight() * 1.1f);

			float ClipX = Canvas->ClipX;
			float ClipY = Canvas->ClipY;
			float LeftPos = 0;

			ClipX -= 100;
			//ClipY = ClipY * 0.60;
			LeftPos = ClipX * 0.3f;
			float TopPos = ClipY * 0.4f;

			int32 X = (int32)LeftPos;
			int32 Y = (int32)TopPos;

			FString Str, StatusStr;
			// First row
// 			Str = FString::Printf(TEXT("TimeWarp: %s"), (FrameSettings->Flags.bTimeWarp) ? TEXT("ON") : TEXT("OFF"));
// 			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
// 
// 			Y += RowHeight;

			//Str = FString::Printf(TEXT("VSync: %s"), (FrameSettings->Flags.bVSync) ? TEXT("ON") : TEXT("OFF"));
			//Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			//Y += RowHeight;

			Str = FString::Printf(TEXT("Upd on GT/RT: %s / %s"), (!FrameSettings->Flags.bDoNotUpdateOnGT) ? TEXT("ON") : TEXT("OFF"),
				(FrameSettings->Flags.bUpdateOnRT) ? TEXT("ON") : TEXT("OFF"));
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);

			Y += RowHeight;

// 			static IConsoleVariable* CFinishFrameVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.FinishCurrentFrame"));
// 			int finFr = CFinishFrameVar->GetInt();
// 			Str = FString::Printf(TEXT("FinFr: %s"), (finFr || FrameSettings->Flags.bTimeWarp) ? TEXT("ON") : TEXT("OFF"));
// 			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
// 
// 			Y += RowHeight;

			Str = FString::Printf(TEXT("PD: %.2f"), FrameSettings->PixelDensity);
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			Y += RowHeight;

			Str = FString::Printf(TEXT("QueueAhead: %s"), (FrameSettings->bQueueAheadEnabled) ? TEXT("ON") : TEXT("OFF"));
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			Y += RowHeight;

			Str = FString::Printf(TEXT("FOV V/H: %.2f / %.2f deg"), 
				FMath::RadiansToDegrees(FrameSettings->VFOVInRadians), FMath::RadiansToDegrees(FrameSettings->HFOVInRadians));
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);

			Y += RowHeight;
			Str = FString::Printf(TEXT("W-to-m scale: %.2f uu/m"), frame->WorldToMetersScale);
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);

			if ((FrameSettings->SupportedHmdCaps & ovrHmdCap_DynamicPrediction) != 0)
			{
				float latencies[5] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
				const int numOfEntries = sizeof(latencies) / sizeof(latencies[0]);
				if (ovrHmd_GetFloatArray(Hmd, "DK2Latency", latencies, numOfEntries) == numOfEntries)
				{
					Y += RowHeight;

					char buf[numOfEntries][20];
					char destStr[100];

					FCStringAnsi::Snprintf(destStr, sizeof(destStr), "Latency, ren: %s tw: %s pp: %s err: %s %s",
						FormatLatencyReading(buf[0], sizeof(buf[0]), latencies[0]),
						FormatLatencyReading(buf[1], sizeof(buf[1]), latencies[1]),
						FormatLatencyReading(buf[2], sizeof(buf[2]), latencies[2]),
						FormatLatencyReading(buf[3], sizeof(buf[3]), latencies[3]),
						FormatLatencyReading(buf[4], sizeof(buf[4]), latencies[4]));

					Str = ANSI_TO_TCHAR(destStr);
					Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
				}
			}

			// Second row
			X = (int32)LeftPos + 200;
			Y = (int32)TopPos;

			StatusStr = ((FrameSettings->SupportedTrackingCaps & ovrTrackingCap_Position) != 0) ?
				((FrameSettings->Flags.bHmdPosTracking) ? TEXT("ON") : TEXT("OFF")) : TEXT("UNSUP");
			Str = FString::Printf(TEXT("PosTr: %s"), *StatusStr);
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			Y += RowHeight;

			Str = FString::Printf(TEXT("Vision: %s"), (frame->Flags.bHaveVisionTracking) ? TEXT("ACQ") : TEXT("LOST"));
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			Y += RowHeight;

			Str = FString::Printf(TEXT("IPD: %.2f mm"), FrameSettings->InterpupillaryDistance*1000.f);
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			Y += RowHeight;

			StatusStr = ((FrameSettings->SupportedHmdCaps & ovrHmdCap_LowPersistence) != 0) ?
				((FrameSettings->Flags.bLowPersistenceMode) ? TEXT("ON") : TEXT("OFF")) : TEXT("UNSUP");
			Str = FString::Printf(TEXT("LowPers: %s"), *StatusStr);
			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
			Y += RowHeight;

// 			StatusStr = ((FrameSettings->SupportedDistortionCaps & ovrDistortionCap_Overdrive) != 0) ?
// 				((FrameSettings->Flags.bOverdrive) ? TEXT("ON") : TEXT("OFF")) : TEXT("UNSUP");
// 			Str = FString::Printf(TEXT("Overdrive: %s"), *StatusStr);
// 			Canvas->Canvas->DrawShadowedString(X, Y, *Str, Font, TextColor);
// 			Y += RowHeight;
		}

		//TODO:  Where can I get context!?
		UWorld* MyWorld = GWorld;
		if (FrameSettings->Flags.bDrawTrackingCameraFrustum)
		{
			DrawDebugTrackingCameraFrustum(MyWorld, Canvas->SceneView->ViewRotation, Canvas->SceneView->ViewLocation);
		}

		if (Canvas && Canvas->SceneView)
		{
			DrawSeaOfCubes(MyWorld, Canvas->SceneView->ViewLocation);
		}
	}

#endif // #if !UE_BUILD_SHIPPING
}
예제 #4
0
파일: render.cpp 프로젝트: Thyfate/melax
void RenderStuff()
{
	extern String techniqueoverride;
	culledlightcount=clippedcount=culledmeshcount=0;

    // Clear the backbuffer and the zbuffer
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,
						 D3DCOLOR_COLORVALUE(clearcolor.x,clearcolor.y,clearcolor.z,1.0f), 1.0f, 0L ); // color macro maps floating point channels (0.f to 1.f range) to D3DCOLOR
	int stencildirty=0;

	g_pd3dDevice->BeginScene();// Begin the scene

	techniqueoverride="";

		techniqueoverride= "unlit";

		drawmeshes(regmeshes);

		techniqueoverride="lightpass";
		extern int lightingpasses;
		lightingpasses=1;
		for(int i=0;i<lights.count;i++) // for each light
		{
			if(!lights[i]->enable || lights[i]->radius<=0.0f) continue;
			if(stencildirty) g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,D3DCOLOR_XRGB(0,0,255), 1.0f, 0L );
			stencildirty=0;
			lightposn   = lights[i]->position;
			lightradius = lights[i]->radius;
			lightradiusinv = 1.0f/lightradius;
			lightcolor  = lights[i]->color;
			if(!camera.SphereVisible(lightposn,lightradius)) {culledlightcount++;continue;}

			ScissorsSetUp();
			if(lights[i]->shadowcast)
			{
				drawmeshes_spherecull(shadowmeshes,lightposn,lightradius);// create shadow volumes for this light 
				stencildirty=1;
			}
			ClipPlanesSetUp();
			//g_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,4) && VERIFY_RESULT;
			//g_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS,4) && VERIFY_RESULT;
			drawmeshes(regmeshes);

			//DWORD junk; g_pd3dDevice->GetRenderState(D3DRS_DEPTHBIAS,&junk);		
			//g_pd3dDevice->SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS,0) && VERIFY_RESULT;
			//g_pd3dDevice->SetRenderState(D3DRS_DEPTHBIAS,0);
			if(stencildirty && stencilclearimmediate)
			{
				g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,D3DCOLOR_XRGB(0,0,255), 1.0f, 0L );
                stencildirty=0;
			}
			ClipPlanesRestore();
			ScissorsRestore();

		}
		techniqueoverride="";
		lightingpasses=0;


	extern int hack_usealpha;
	hack_usealpha++;
	drawmeshes(alphameshes);
	hack_usealpha--;

	RenderLines();

	RenderStrings();  // todo: rename to DrawStrings()


    g_pd3dDevice->EndScene(); 	// End the scene

}
예제 #5
0
void PreviewSubTask()
#endif
{
#ifndef __PPC__
	struct SubTask *st;
#endif
	BOOL done = FALSE, working = FALSE, init = FALSE, stop = FALSE;
	int y;
	struct SubTaskMsg *stm;
	struct PreviewData *data;
	rsiSMALL_COLOR *line;

#ifndef __PPC__
	st = InitSubTask();
#endif
	if(st)
	{
		/*
		** after the sub task is up and running, we go into
		** a loop and process the messages from the main task.
		*/
		while(!done)
		{
			while((stm = (struct SubTaskMsg *)WARPOS_PPC_FUNC(GetMsg)(st->st_Port)))
			{
				switch(stm->stm_Command)
				{
					case STC_SHUTDOWN:
						// This is the shutdown message from KillSubTask().
						done = TRUE;
						working = FALSE;
						break;
					case STC_CLEANUP:
						working = FALSE;
						if(data->preview)
						{
#ifdef __MIXEDBINARY__
							PreviewDelete(data->preview);
#else
							delete data->preview;
#endif
							data->preview = NULL;
						}
						break;
					case STC_START:
						working = TRUE;
						stop = FALSE;
						init = FALSE;
						data = (struct PreviewData*)stm->stm_Parameter;
#ifdef __MIXEDBINARY__
						data->preview = PreviewCreate();
#else
						data->preview = new PREVIEW;
#endif
						if(!data->preview)
							done = TRUE;
						break;
					case STC_STOP:
						stop = TRUE;
						break;
					case STC_RESUME:
						stop = FALSE;
						break;
				}

				/*
				** If we received a shutdown message, we do not reply it
				** immediately. First, we need to free our resources.
				*/
				if(done)
					break;
				WARPOS_PPC_FUNC(ReplyMsg)((struct Message *)stm);
			}
			if(working && !stop)
			{
				if(!init)
				{
#ifdef __MIXEDBINARY__
					if(Init(data->preview, data->width, data->height, LINES, data->surf, data->object))
#else
					if(data->preview->Init(data->width, data->height, LINES, data->surf, data->object))
#endif
					{
						init = TRUE;
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 4, MUIM_MsgHandler_PushMessage, data->renderarea, 1, MUIM_Render_ResetColors);
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_SubTask, st);
#ifdef __MIXEDBINARY__
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, GetLine(data->preview));
#else
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, data->preview->GetLine());
#endif
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Lines, LINES);
						y = 0;
					}
					else
					{
						working = FALSE;
					}
				}

#ifdef __MIXEDBINARY__
				RenderLines(data->preview, y);
				line = GetLine(data->preview);
#else
				data->preview->RenderLines(y);
				line = data->preview->GetLine();
#endif
				DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 6, MUIM_MsgHandler_PushMessage, data->renderarea, 3, MUIM_Set, MUIA_Render_Data, &line[y*data->width]);
				DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 5, MUIM_MsgHandler_PushMessage, data->renderarea, 2, MUIM_Render_DrawUpdate, y);

				y += LINES;
				if(y >= data->height)
				{
					working = FALSE;
					if(data->caller)
					{
						DOMETHOD(app, MUIM_Application_PushMethod, data->msghandler, 4, MUIM_MsgHandler_PushMessage, data->caller, 1, MUIM_SubTask_Finished);
					}
				}
			}
			else
			{
				/* We have nothing to do, just sit quietly and wait for something to happen */
				if(!done)
				{
					WARPOS_PPC_FUNC(WaitPort)(st->st_Port);
				}
			}
		}
#ifdef __PPC__
		ExitSubTaskPPC(st, stm);
#else
		ExitSubTask(st, stm);
#endif
		if(data->preview)
		{
#ifdef __MIXEDBINARY__
			PreviewDelete(data->preview);
#else
			delete data->preview;
#endif
		}
	}
}