Etiketler

,

#include <Windows.h>
#include <WindowsX.h>
#include <d3d9.h>
#include <time.h>

#define EKRAN_GENISLIK 1152
#define EKRAN_YUKSEKLIK 864
#define TUS(vk_code)((GetAsyncKeyState(vk_code)&0x8000)?1:0)

LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 directx;

int r=100,g=200,b=200;
void D3Dbaslat(HWND hWnd);
void kare_goruntule(void);
void D3Dtemizle(void);


void D3Dbaslat(HWND hWnd)
{
 d3d=Direct3DCreate9(D3D_SDK_VERSION);

 D3DPRESENT_PARAMETERS direct3d;

 ZeroMemory(&direct3d,sizeof(direct3d));
 direct3d.Windowed=FALSE;
 direct3d.SwapEffect=D3DSWAPEFFECT_DISCARD;
 direct3d.hDeviceWindow=hWnd;
 direct3d.BackBufferFormat=D3DFMT_X8R8G8B8;
 direct3d.BackBufferWidth=EKRAN_GENISLIK;
 direct3d.BackBufferHeight=EKRAN_YUKSEKLIK;

 d3d->CreateDevice(D3DADAPTER_DEFAULT,
 D3DDEVTYPE_HAL,
 hWnd,
 D3DCREATE_SOFTWARE_VERTEXPROCESSING,
 &direct3d,
 &directx);

 return;
}

void kare_goruntule(void)
{
 srand ( time(NULL) );

 r=rand()%255+1;
 b=rand()%255+1;
 g=rand()%255+1;
	
 directx->Clear(0,NULL,D3DCLEAR_TARGET,
 D3DCOLOR_XRGB(r,b,g),1.0f,0);

 directx->BeginScene();

 directx->EndScene();

 directx->Present(NULL,NULL,NULL,NULL);

}


void D3Dtemizle(void)
{
 directx->Release();
 d3d->Release();

 return;
}

LRESULT CALLBACK WindowProc(HWND hWnd,
 UINT message,
 WPARAM wParam,
 LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance,
 HINSTANCE hPrevInstance,
 LPSTR lpCmdLine,
 int nCmdShow)
{
 HWND hWnd;
 WNDCLASSEX ps;

 ZeroMemory(&ps,sizeof(WNDCLASSEX));
 ps.cbSize=sizeof(WNDCLASSEX);
 ps.style=CS_HREDRAW|CS_VREDRAW;
 ps.lpfnWndProc=(WNDPROC)WindowProc;
 ps.hInstance=hInstance;
 ps.hCursor=LoadCursor(NULL,IDC_ARROW);
 ps.hbrBackground=(HBRUSH)COLOR_WINDOW;
 ps.lpszClassName=L"PencereSinifi01";

 RegisterClassEx(&ps);

 hWnd=CreateWindowEx(NULL,
 L"PencereSinifi01",
 L"Ilk Direct3D programimiz by HuluCPlusPlus",
 WS_EX_TOPMOST|WS_POPUP,
 0,0,
 EKRAN_GENISLIK,
 EKRAN_YUKSEKLIK,
 NULL,NULL,
 hInstance,NULL);

 ShowWindow(hWnd, nCmdShow);

 D3Dbaslat(hWnd);

 MSG mesaj;

 while(TRUE)
 {
 DWORD baslangic_noktasi=GetTickCount();

 if(PeekMessage(&mesaj,NULL,0,0,PM_REMOVE))
 {
 if(mesaj.message==WM_QUIT)
 {
 break;
 }

 TranslateMessage(&mesaj);
 DispatchMessage(&mesaj);
 }

 kare_goruntule();

 if(TUS(VK_ESCAPE))
 PostMessage(hWnd,WM_DESTROY,0,0);

 if(TUS(VK_DOWN))
 {
 kare_goruntule();


 /*directx->Clear(0,NULL,D3DCLEAR_TARGET,
 D3DCOLOR_XRGB(0,0,0),1.0f,0);

 directx->BeginScene();

 directx->EndScene();

 directx->Present(NULL,NULL,NULL,NULL);*/
 }

 if(TUS(VK_UP))
 {
 kare_goruntule();


 /*directx->Clear(0,NULL,D3DCLEAR_TARGET,
 D3DCOLOR_XRGB(100,50,200),1.0f,0);

 directx->BeginScene();

 directx->EndScene();

 directx->Present(NULL,NULL,NULL,NULL);*/
 }
			


 while((GetTickCount()-baslangic_noktasi)<25);
 }

 D3Dtemizle();

 return mesaj.wParam;
}

LRESULT CALLBACK WindowProc(HWND hWnd,
 UINT message,
 WPARAM wParam,
 LPARAM lParam)
{
 switch(message)
 {
 case WM_DESTROY:
 {
 PostQuitMessage(0);
 return 0;
 }break;
 }

 return DefWindowProc(hWnd,
 message,
 wParam,
 lParam);
}
Reklamlar