Ejemplo n.º 1
0
void Scene3D::Resize()
{
	if(hwnd == NULL)
		return;

	GetClientRect(*hwnd, &screenRect);	
	ResizeGLWindow(screenRect.right, screenRect.bottom);	
}
Ejemplo n.º 2
0
/*
================
InitializeOpenGL
================
*/
void InitializeOpenGL( int width, int height ) {
    ghdc = GetDC( ghwnd ); // sets global HDC

	/* Sets pixel format */
    if ( !SetPixelFormat( ghdc ) ) { 
        PostQuitMessage( 0 );
	}

    ghrc = wglCreateContext( ghdc ); // creates rendering context from hdc
    wglMakeCurrent( ghdc, ghrc );	 // use this HRC.
	ResizeGLWindow( width, height ); // setup the screen
}
Ejemplo n.º 3
0
void Scene3D::InitializeOpenGL(int width, int height) 
{  
    hdc = GetDC(*hwnd);//  sets  global HDC

    if (!CreatePixelFormat(hdc))//  sets  pixel format
        PostQuitMessage (0);

    hrc = wglCreateContext(hdc);	//  creates  rendering context from  hdc
    wglMakeCurrent(hdc, hrc);		//	Use this HRC.

	ResizeGLWindow(width, height);	// Setup the Screen
}
Ejemplo n.º 4
0
/*
=======
WndProc
=======
*/
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) {
    switch( message ) {														
		case WM_CREATE:	
			break;

		case WM_SIZE:
			/* Resize the OpenGL window when the window is resized */
			ResizeGLWindow( LOWORD( lParam ), HIWORD( lParam ) );
			/* Adjust camera mouse controls */
			mCamera.AdjustScreenSize( LOWORD( lParam ), HIWORD( lParam ) );
			GetClientRect( hwnd, &gRect );
			break;	

		case WM_KEYDOWN:
			/* Set key bool as true */
			mInput.mKeys[ wParam ] = true;
			break;

		case WM_KEYUP:
			/* Set key bool as false */
			mInput.mKeys[ wParam ] = false;
			break;

		case WM_MOUSEMOVE:
			/* Update Mouse Position */
			mInput.mMouseX = LOWORD( lParam );
			mInput.mMouseY = HIWORD( lParam );
			break;

		case WM_PAINT:
		    break;		

		case WM_DESTROY:	
			PostQuitMessage( 0 );					
			break;	
	}	

	return DefWindowProc( hwnd, message, wParam, lParam );																
}
Ejemplo n.º 5
0
void QVX_Sim::BeginRecording(void) //opens record dialog and begins recording
{
	if (Recording) return; //if we're already recording, don't do anything!

	bool WasPaused = Paused; //pause the sim and remeber whether it was paused or not...
	if (Running && !WasPaused) SimPauseToggle();

	Dlg_VideoCapture VidCapDlg(this);
	if (StopConditionType == SC_MAX_TIME_STEPS) {VidCapDlg.StopEnabled=true; VidCapDlg.CurStopSettings = SS_TIME_STEPS; VidCapDlg.sNumStep = qRound(StopConditionValue);}
	if (StopConditionType == SC_MAX_SIM_TIME) {VidCapDlg.StopEnabled=true; VidCapDlg.CurStopSettings = SS_SIM_TIME; VidCapDlg.sSimTime = StopConditionValue;}
	if (StopConditionType == SC_TEMP_CYCLES) {VidCapDlg.StopEnabled=true; VidCapDlg.CurStopSettings = SS_TEMP_CYCLES; VidCapDlg.sNumCyc = qRound(StopConditionValue);}

	VidCapDlg.UpdateUI();
	VidCapDlg.exec();

	if (VidCapDlg.AcceptedDialog){
		if (VidCapDlg.ResetSimOnBegin) ResetSim();

		emit StopExternalGLUpdate(); //stop external update!
		GLUpdateEveryNFrame = -1; //make sure update every frame is turned off...

		double OutFps = VidCapDlg.OutputFps;
		double OutSpdFctr = VidCapDlg.OutputSpeedFactor;

		switch(VidCapDlg.CurVidSetting){
			case VS_DISPLAY: StartExternalGLUpdate(1000*OutSpdFctr/OutFps); break;
			case VS_SIMULATION: {
					DtFreeze(); //this could be bad for sims with non-linear materials that change dramatically in their stability
					double VideoDt = OutSpdFctr/OutFps; //what the dt step for video should be (in sec)
					if (dt > VideoDt){
						dt = VideoDt; //if simulation timesteps are greater than desired video framerate slow down simulation timesteps
						GLUpdateEveryNFrame=1;
					}
					else { //round dt down so that VideoDt is an even multiple...
						GLUpdateEveryNFrame = (int)(VideoDt/dt) + 1;
						dt = VideoDt/((double)GLUpdateEveryNFrame);
					}

				}
				break;
			case VS_EVERY: GLUpdateEveryNFrame = 1; break;
			default: break;
		}

		if (VidCapDlg.StopEnabled){
			switch (VidCapDlg.CurStopSettings){
				case SS_TIME_STEPS: StopConditionType = SC_MAX_TIME_STEPS; StopConditionValue = (vfloat)VidCapDlg.sNumStep; break;
				case SS_SIM_TIME: StopConditionType = SC_MAX_SIM_TIME; StopConditionValue = (vfloat)VidCapDlg.sSimTime; break;
				case SS_TEMP_CYCLES: StopConditionType = SC_TEMP_CYCLES; StopConditionValue = (vfloat)VidCapDlg.sNumCyc; break;
				default: StopConditionType = SC_NONE;
			}
		}
		else StopConditionType = SC_NONE;

		//reset naming for current files in the selected folder
		VideoOutputFolder=VidCapDlg.CurFolder;
		CurVideoFrameNumber = 0;

		emit ResizeGLWindow(VidCapDlg.WidthPix, VidCapDlg.HeightPix);

		Recording = true;

		if (!Running){ RequestBeginSim(); Running = true;}
		else SimPauseToggle(); //always unpause the simulation if we began recording
	}
	else { //rejected (canceled) return to running or not state.
		if (Running && !WasPaused) SimPauseToggle(); //unpause the simulation if it was running before
	}
}