//////////////////////////////////////////////////////////////////////
//
// Project  : BRender Demo Framework
//            Copyright (c) 1996 Argonaut Technologies Ltd.
//            All rights reserved.
//
// Author   : Steve Williams, October 1996
//
// File     : WIN_BITS.H
//
// Requires : BRender V1.3
//            Microsoft DirectX 3, Win95/NT
//
// Comments : Windows specific header
//
//////////////////////////////////////////////////////////////////////

#include <windows.h>
#include <brender.h>

typedef struct WinBits_Tag
{
	char *name ;
	br_boolean bActive ;
	br_uint_8 Current_Device ;
	br_pixelmap *screen ;
   br_pixelmap *back_buffer ;
	br_pixelmap *depth_buffer ;
	br_boolean bUseZBuffer ;
	br_pixelmap *palette ; 
	char *palette_filename ;
	br_boolean bUsePalette ;
   HWND hWnd ;
   br_int_32 Width ;
   br_int_32 Height ;
   br_uint_8 Fullscreen_BPP ;
   br_uint_8 Windowed_BPP ;
   br_uint_16 Offscreen_Height ;
   br_uint_16 Offscreen_Width ;
   br_boolean bFullScreen ;
   br_boolean bStretch ;
   br_int_32 xMousePos ;
   br_int_32 yMousePos ;
   br_actor *pRoot ;
	
} WIN_BITS, *WIN_BITS_PTR ;


typedef br_error (*BRDEMO_MENU_CALLBACK)(void);

#include "timing.h"

br_error BrDemo_Toggle_Fullscreen( WIN_BITS_PTR pBrApp);
br_error BrDemo_Initiallise_BRender();
br_error BrDemo_Remove_Device();
br_error BrDemo_AddMenuItem( char *Name, BRDEMO_MENU_CALLBACK pCallback );
void BrDemo_ReleasePixelmaps();
br_error BrDemo_Allocate_Pixelmaps_Int( WIN_BITS_PTR pBrApp );

br_boolean WinKeyTest( br_uint_8 scancode, br_uint_8 qualifiers, br_uint_8 repeats );
br_error WinMouseRead(br_int_32 *mouse_x, br_int_32 *mouse_y, br_uint_32 *mouse_buttons);
br_uint_32 WinClockRead(void);

br_uint_32 WinGetClockFreq();
br_error BrDemo_InitApp( int argc, char **argv );
br_error BrDemo_Render_Loop();
br_error BrDemo_ShutDown();
br_error BrDemo_OnResize();
br_error BrDemo_Restart();
br_error BrDemo_ClearAppMenuItems();


br_error BrDemo_PaletteSet( br_pixelmap *pNewPal );

void WinKeyBegin();

br_error BrDemo_Allocate_Pixelmaps( char *AppName,
								   br_pixelmap **screen, 
							       br_pixelmap **back_buffer,
							       br_pixelmap **depth_buffer, 
							       br_pixelmap **palette, 
							       char *palette_filename );

br_error BrDemo_SetRootActor( br_actor *pActor );

br_error BrDemo_OnResize();

br_error BrDemo_Refresh_Pointers( br_pixelmap **screen, 
							   br_pixelmap **back_buffer,
							   br_pixelmap **depth_buffer );

void BrWinRegisterKeyState( br_uint_16 VKey, br_boolean bDown, br_uint_16 RepCount );


br_error BrDemo_Attach_Menu( HWND hWnd );
br_error BrDemo_SetDeviceMenuChecks( WIN_BITS_PTR pBrApp );

br_error BrDemo_ResizeOffScreenBuffers( WIN_BITS_PTR pBrApp, 
                               br_uint_16 w, br_uint_16 h );

// DOS compatiblity function redefinitions.

#define DOSKeyTest WinKeyTest
#define DOSMouseRead WinMouseRead
#define MouseReadAbsolute WinMouseReadAbsolute
#define DOSClockRead WinClockRead

#ifndef BR_DOS_CLOCK_RATE
#include "dosio.h"
#endif 


#undef BR_DOS_CLOCK_RATE
#define BR_DOS_CLOCK_RATE WinGetClockFreq()


br_error BrDemo_HandleMenuSelection( WIN_BITS_PTR pBrApp, br_uint_16 Menu_Selection );
