|
|
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include "ddraw.h"
#define WIN_CLASSNAME "iwtjatpya"
#define WIN_HEIGHT 1024
#define WIN_WIDTH 768
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1:0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0:1)
int game_main(void *parms=NULL, int num_parms=0);
int game_init(void *parms=NULL, int num_parms=0);
int game_shutdown(void *parsm=NULL, int num_parms=0);
HWND hwnd_window=NULL;
LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_PAINT:
{
hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
return(0);
}break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
}break;
default: break;
}
return(DefWindowProc(hwnd,uMsg,wParam,lParam));
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
MSG msg;
HWND hwnd;
WNDCLASSEX winclass;
winclass.cbClsExtra=0;
winclass.cbSize=sizeof(WNDCLASSEX);
winclass.cbWndExtra=0;
winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor=LoadCursor(NULL,IDC_ARROW);
winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
winclass.hInstance=hInstance;
winclass.lpfnWndProc=WindowProc;
winclass.lpszClassName=WIN_CLASSNAME;
winclass.lpszMenuName=NULL;
winclass.style=CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
if(!RegisterClassEx(&winclass))
return(0);
if(!(hwnd=CreateWindowEx(NULL,WIN_CLASSNAME,"NEW DIRECTX",
WS_POPUP | WS_VISIBLE,
0,0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL,NULL,hInstance,NULL)))
return(0);
game_init();
hwnd_window=hwnd;
//while(GetMessage(&msg,NULL,0,0))
// {
// TranslateMessage(&msg);
// DispatchMessage(&msg);
//}
//}
while(1)
{
if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(!GetMessage(&msg, NULL, 0, 0 )) return msg.wParam;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
game_main();
}
game_shutdown();
return(msg.wParam);
}
int game_init(void *parms, int num_parms)
{
return(1);
}
int game_main(void *parms, int num_parms)
{
if(KEYDOWN(VK_ESCAPE))
SendMessage(hwnd_window,WM_CLOSE,0,0);
return(1);
}
int game_shutdown(void* parms, int num_parms)
{
return(1);
} |
|