// WinProc
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    const float kMoveAmt = 0.05f; // Amount to move light by

    switch(message)
    {
    case WM_SYSKEYDOWN:

        // Toggle on ALT + ENTER
        if(wparam == VK_RETURN && (lparam & (1 << 29)))
        {
            // Shut down are render texture and render target
            gRenderTarget.deinit();

            g3D->toggleFullScreen(); // Toggle!

            // Reinitialize the render texture and target
            gRenderTarget.init(256, 256, D3DFMT_A8R8G8B8, D3DFMT_D24S8);

            g3D->setViewMatrix(kEyePos, CPos(0.0f, 0.0f, 0.0f)); // Reset the view of our scene
            return 0;
        }

        break; // Allow other system keys to be handled by DefWindowProc()

    case WM_KEYDOWN:

        switch(wparam)
        {
        case VK_ESCAPE:
            SendMessage(hwnd, WM_CLOSE, 0, 0);
            break;

        case VK_F8:
            gToggle = !gToggle;
            break;
        }

        return 0;

    case WM_DESTROY:
    {
        PostQuitMessage(0);
        return 0;
    }
    }

    return DefWindowProc(hwnd, message, wparam, lparam);
}
Exemple #2
0
// WinProc
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	const float kMoveAmt = 0.05f; // Amount to move light by

	switch(message)
    {
		case WM_SYSKEYDOWN:

			// Toggle on ALT + ENTER				
			if(wparam == VK_RETURN && (lparam & (1 << 29)))
			{
				// Shut down are render texture and render target
				gShadowMap.deinit();
				gRenderTarget.deinit();
				
				g3D->toggleFullScreen(); // Toggle!
				
				// Reinitialize the render texture and target
				gShadowMap.createRenderTexture(512, 512, D3DFMT_R32F);
				gRenderTarget.init(512, 512, D3DFMT_R32F, D3DFMT_D24S8);
				
				g3D->setViewMatrix(kEyePos, CPos(0.0f, 0.0f, 0.0f)); // Reset the view of our scene
					return 0;
			}

			break; // Allow other system keys to be handled by DefWindowProc()
    
		case WM_KEYDOWN:
					
			switch(wparam)
			{
				case VK_LEFT: // Move the light along the -X axis
					gLightPos.x -= kMoveAmt;
						break;
						
				case VK_RIGHT: // Move the light along the +X axis
					gLightPos.x += kMoveAmt;
						break;
						
				case VK_UP: // Move the light along the +Z axis
					gLightPos.z += kMoveAmt;
						break;
						
				case VK_DOWN: // Move the light along the -Z axis
					gLightPos.z -= kMoveAmt;
						break;
					
				case VK_ESCAPE:
					SendMessage(hwnd, WM_CLOSE, 0, 0);
						break;
			}
							
			return 0;

		case WM_DESTROY:
		{
			PostQuitMessage(0);
				return 0;
		}
    }

    return DefWindowProc(hwnd, message, wparam, lparam);
}