Exemplo n.º 1
0
void CCamera::Update()
{
    // Initialize a variable for the cross product result
    CVector3 vCross = Cross(m_vView - m_vPosition, m_vUpVector);

    // Normalize the strafe vector
    m_vStrafe = Normalize(vCross);

    // Move the camera's view by the mouse
    SetViewByMouse();

    // This checks to see if the keyboard was pressed
    CheckForMovement();


/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

    // We stick this function in our camera source file so that we can move
    // time base movement and camera functionality together between tutorials
    // relatively easily.

    // We calculate our frame rate and set our frame interval for time based movement
    CalculateFrameRate();

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *


}
void CCamera::Update() 
{
	// Initialize a variable for the cross product result
	CVector3 vCross = Cross(m_vView - m_vPosition, m_vUpVector);

	// Normalize the strafe vector
	m_vStrafe = Normalize(vCross);

	// Move the camera's view by the mouse
	SetViewByMouse();


/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// We commented this line out so the camera can't move around
	// in this tutorial.

	// This checks to see if the keyboard was pressed
	//CheckForMovement();

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *
	

	// Calculate our frame rate and set our frame interval for time-based movement
	CalculateFrameRate();
}
Exemplo n.º 3
0
int render(struct winampVisModule *this_mod)
{	
	displayScene(this_mod);
	SwapBuffers(hDC);																				// Die Puffer werden getauscht
	CalculateFrameRate();
	if (done==TRUE)
		return 1;
	else	
		return 0;			
}
Exemplo n.º 4
0
int NMS_SceneRenderer::renderingLoop()
{
	while(rendering) {
		SINGLEFRAME_ALLOC->clear();
		NMS_EVENT_MANAGER.pollEvents();
		if(!stopped)
		{
			currentTime+=0.0008f;
			physics->simulatePhysics();
		}
		render();
		CalculateFrameRate();
	}
	return 0;
}
Exemplo n.º 5
0
void RenderScene() 
{
	int i=0;	

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();									// Reset The matrix
	
		// 	  Position      View	   Up Vector
	gluLookAt(0, 0, 6,     0, 0, 0,     0, 1, 0);		// This determines where the camera's position and view is

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// Here we create a static variable that will count forever.  This is used for the rotation degree.
	static float rotY = 0;

	// Pass in our current rotation value to glRotatef() for rotation around the Y axis (0, 1, 0)
	glRotatef(rotY, 0, 1, 0);

	// Increase the rotation by 2 degrees
	rotY += 2;

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// Below we say that we want to draw triangles
	glBegin (GL_TRIANGLES);								// This is our BEGIN to draw

		glColor3ub(255, 0, 0);							// Make the top vertex RED
		glVertex3f(0, 1, 0);							// Here is the top point of the triangle

		glColor3ub(0, 255, 0);							// Make the left vertex GREEN
		glVertex3f(-1, 0, 0);							// Here is the left point of the triangle

		glColor3ub(0, 0, 255);							// Make the right vertex BLUE
		glVertex3f(1, 0, 0);							// Here is the right point of the triangle
	glEnd();											// This is the END of drawing

	SwapBuffers(g_hDC);									// Swap the backbuffers to the foreground

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// Call our new function to count and calculate the frames for each second.
	// This needs to be called every time the screen renders so we get a correct frame rate.
	// Because of its static variables inside, we don't need any globals or outside variables.
	CalculateFrameRate();

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

}
Exemplo n.º 6
0
void CGraphCanvas::Render()
{

	int w = m_size.x, h = m_size.y;

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glViewport(0, 0, w, h);

	CDataManager *dm =  GetDataManager();
	
	//m_Ortho[0] =m_Ortho[2] =0- dm->m_LayoutParameter.range;
	//m_Ortho[1] =m_Ortho[3] =dm->m_LayoutParameter.range;
 
	glOrtho( m_Ortho[0], m_Ortho[1], m_Ortho[2], m_Ortho[3], m_Ortho[4], m_Ortho[5] );

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	
	if(dm->m_ifGraphReady)
	{
		DrawExtraInfo();
			
		DrawGeneralGraph();

		CalculateFrameRate();
		DrawRenderingStatus();

		glFlush();
		SwapBuffers();
	}
	 
}
Exemplo n.º 7
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)			// Here is our "main()" for windows.  Must Have this for a windows app.
{														
	// Create the handle to the window.  
    HWND        hwnd;										
	// Create the variable to hold the window messages
    MSG         msg;	
	
	// Create the structure that holds the attributes of the window.
	// I just crammed them in like this to save space because we know what they do.
    WNDCLASSEX  wndclass = {sizeof (wndclass), CS_HREDRAW | CS_VREDRAW, WndProc, 0, 0, hInstance,
						  LoadIcon (NULL, IDI_WINLOGO), LoadCursor (NULL, IDC_ARROW), (HBRUSH) GetStockObject (WHITE_BRUSH),
						  NULL, "Window Class", LoadIcon (NULL, IDI_WINLOGO)};
	

	// Register the window class with the operating system
	RegisterClassEx (&wndclass);	
	
	// Now, we actually create the window
    hwnd = CreateWindow ("Window Class",					// window class name 
						 "Bitmap Background",	  			// window's Title    
						 WS_SYSMENU,						// window style	- This style won't allow the window to resize
						 CW_USEDEFAULT,						// initial x position
						 CW_USEDEFAULT,						// initial y position
						 WIDTH,								// Here we pass in our desired width (800)	 
						 HEIGHT,						    // Here we pass in our desired height (600)	 
						 NULL,								// This is the parent window handle.  
						 NULL,								// This is the window menu handle
						 hInstance,						    // This is the programs instance handle.
						 NULL);								// We don't want to pass any extra data in, so NULL

	// This shows our window. 
    ShowWindow (hwnd, iCmdShow);							

	// This pretty much paints our window to the screen.
    UpdateWindow (hwnd);									

	// Here is our main loop. 
	while (1)					
    {	
		// *We use PeekMessage() instead of GetMessage() to see if there is a message
		// from windows, if not, then we want to animate when nothing is going on.*

		// Check if there is a window message and remove it from the queue
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			// If the message was to quit, break out of the while loop
			if(msg.message == WM_QUIT) break;

			// This Translates messages so windows understands them.
			TranslateMessage (&msg);					
		
			// This sends the messages to the WndProc().
			DispatchMessage (&msg);							
		}
		else
		{
			// *Now we do the computationally expensive stuff in this else*

			// Check if we want to animate the next frame of animation
			if(AnimateNextFrame(FRAME_RATE))
			{
				// Calculate the frames per second of our application
				CalculateFrameRate(hwnd);				

				// Animate the monster2 sprite
				AnimateSprite(&gBuffer, &gMonster);  
				
				// Move the sprite along the screen
				MoveSprite(&gMonster);

				// Now swap the backbuffer to display it to the front and clear the screen
				SwapBackBuffer(&gBuffer, FALSE);

				// Now we want erase the position of the monster with a part of the background
				// We do this so we don't have to blit the WHOLE background each time (SLOWWWWW)
				EraseSprite(&gBuffer, &gMonster, hBackground);	
			}

		}
    }

	// Unregister the window class with the operating system
	UnregisterClass("Window Class",hInstance);
    
	// Quit the program
	return msg.wParam ;										
}