예제 #1
0
// This function called by both OpenGL (GLUT) and DirectX
void mouse_drag_func ( int x, int y )
{
	if ( guiMouseDrag ( x, y ) ) return;	// event handling for nv2D GUIs

	int dx = x - last_x;
	int dy = y - last_y;

	float deltx = window_width / cam.getToPos().z;
	float delty = window_height / cam.getToPos().z;
	
	// Camera interaction
	int mode = 0;
	switch ( mode ) {
	case 0:
		if ( dragging == DRAG_LEFT ) {
			glide += Vector3DF( dx / cam.getToPos().z, 0, 0);		
			cam.moveToPos ( 0, dy, 0 );
		} else if ( dragging == DRAG_RIGHT ) {	
			cam.moveToPos ( 0, 0, -dy*0.001 );
			if ( cam.to_pos.z < 0.001 ) cam.to_pos.z = 0.001;
		}
		break;	
	}
	last_x = x;
	last_y = y;
}
예제 #2
0
// Main display loop
void display () 
{
	cam.moveToPos ( glide.x, 0, 0  );
	glide.x *= 0.8;	
		
	PERF_PUSH ( "frame" );

	// Clear framebuffers. OpenGL
	glClearColor( 0.1, 0.1, 0.1, 0.0 );
	glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

	drawOverlay ();

	drawGui ();

	draw2D ();

	#ifdef USE_DX
		// DirectX - Swap buffers		
		checkHR ( g_pSwapChain->Present ( 0, 0 ) );
	#else
		// OpenGL - Swap buffers
		SwapBuffers ( g_hDC );  		
	#endif

	PERF_POP ();

	frame++;
}