text: #include "engine.h"
  
  
  LPCTSTR WndClassName = "firstwindow";
  HWND hwnd = NULL;
  
  const int width = 800;
  const int height = 600;
  
  //Globals
  
  IDXGISwapChain* swapChain;
  ID3D11Device* d3d11Device;
  ID3D11DeviceContext* d3d11DevCon;
  ID3D11RenderTargetView* renderTargetView;
  
  float red = 0.0f;
  float green = 0.0f;
  float blue = 0.0f;
  int colormodr = 1;
  int colormodg = 1;
  int colormodb = 1;
  
  bool InitializeDirect3d11App(HINSTANCE hInstance);
  void ReleaseObjects();
  bool InitScene();
  void UpdateScene();
  void DrawScene();
  
  bool InitializeWindow(HINSTANCE hInstance, int ShowWnd, int width, int height, bool windowed);
  
  int MessageLoop();
  
  LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  
  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
  {
  	if (!InitializeWindow(hInstance, nShowCmd, width, height, true))
  	{
  		MessageBox(0, "Wndow Initialization - Failed", "Error", MB_OK);
  		return 0;
  	}
  
  	if (!InitializeDirect3d11App(hInstance)) //Initialize Direct3D
  	{
  		MessageBox(0, "Direct3D Initialization - Failed", "Error", MB_OK);
  		return 0;
  	}
  
  	if (!InitScene()) //Initialize our scene
  	{
  		MessageBox(0, "Scene Initialization - Failed", "Error", MB_OK);
  		return 0;
  	}
  
  	MessageLoop();
  	ReleaseObjects();
  
  	return 0;
  }
  
  bool InitializeWindow(HINSTANCE hInstance, int ShowWnd, int width, int height, bool windowed)
  {
  	WNDCLASSEX wc;
  
  	wc.cbSize = sizeof(WNDCLASSEX);
  	wc.style = CS_HREDRAW | CS_VREDRAW;
  	wc.lpfnWndProc = WndProc;
  	wc.cbClsExtra = NULL;
  	wc.cbWndExtra = NULL;
  	wc.hInstance = hInstance;
  	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
  	wc.lpszMenuName = NULL; //Menu name
  	wc.lpszClassName = WndClassName;
  	wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
  
  	if (!RegisterClassEx(&wc))
  	{
  		MessageBox(NULL, "Error registering class", "Error", MB_OK | MB_ICONERROR);
  		return 1;
  	}
  
  	hwnd = CreateWindowEx(NULL, WndClassName, "Iszbox!!!", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
  		width, height, NULL, NULL, hInstance, NULL);
  
  	if (!hwnd)
  	{
  		MessageBox(NULL, "Error creating window", "Error", MB_OK | MB_ICONERROR);
  		return 1;
  	}
  
  	ShowWindow(hwnd, ShowWnd);
  	UpdateWindow(hwnd);
  
  	return true;
  }
  
  int MessageLoop()
  {
  	MSG msg;
  
  	ZeroMemory(&msg, sizeof(MSG));
  
  	while (true)
  	{
  		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
  		{
  			if (msg.message == WM_QUIT)
  				break;
  			TranslateMessage(&msg);
  			DispatchMessage(&msg);
  		}
  		else
  		{
  			//To-do game-code
  
  			UpdateScene();
  			DrawScene();
  		}
  	}
  	return msg.wParam;
  }
  
  
  //D3D functions
  
  bool InitializeDirect3d11App(HINSTANCE hInstance)
  {
  	HRESULT hr;
  
  	//Describe our Buffer
  	DXGI_MODE_DESC bufferDesc;
  	
  	ZeroMemory(&bufferDesc, sizeof(DXGI_MODE_DESC));
  
  	bufferDesc.Width = width;
  	bufferDesc.Height = height;
  	bufferDesc.RefreshRate.Numerator = 60;
  	bufferDesc.RefreshRate.Denominator = 1;
  	bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
  	bufferDesc.ScanlineOrdering - DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
  	bufferDesc.Scaling - DXGI_MODE_SCALING_UNSPECIFIED;
  
  	//Describe our swapChain
  	DXGI_SWAP_CHAIN_DESC swapChainDesc;
  
  	ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));
  
  	swapChainDesc.BufferDesc = bufferDesc;
  	swapChainDesc.SampleDesc.Count = 1;
  	swapChainDesc.SampleDesc.Quality = 0;
  	swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
  	swapChainDesc.BufferCount = 1;
  	swapChainDesc.OutputWindow = hwnd;
  	swapChainDesc.Windowed = TRUE;
  	swapChainDesc.SwapEffect - DXGI_SWAP_EFFECT_DISCARD;
  
  	//Create our swapChain
  	hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, NULL, NULL, NULL, D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &d3d11Device, NULL, &d3d11DevCon);
  
  	//Create our BackBuffer
  	ID3D11Texture2D* BackBuffer;
  	hr = swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&BackBuffer);
  
  	//Create our Render Target
  	hr = d3d11Device->CreateRenderTargetView(BackBuffer, NULL, &renderTargetView);
  	BackBuffer->Release();
  
  	//Set our Render Target
  	d3d11DevCon->OMSetRenderTargets(1, &renderTargetView, NULL);
  
  	return true;
  }
  
  void ReleaseObjects()
  {
  	//Release the COM Objects we created
  	swapChain->Release();
  	d3d11Device->Release();
  	d3d11DevCon->Release();
  }
  
  bool InitScene()
  {
  	return true;
  }
  
  void UpdateScene()
  {
  	//Update the colors of our scene
  	red += colormodr * 0.00005f;
  	green += colormodg * 0.00002f;
  	blue += colormodb * 0.00001f;
  
  	if (red >= 1.0f || red <= 0.0f)
  		colormodr *= -1;
  	if (green >= 1.0f || green <= 0.0f)
  		colormodg *= -1;
  	if (blue >= 1.0f || blue <= 0.0f)
  		colormodb *= -1;
  }
  
  void DrawScene()
  {
  	//Clear our backbuffer to the updated color
  	D3DXCOLOR bgColor(red, green, blue, 1.0f);
  
  	d3d11DevCon->ClearRenderTargetView(renderTargetView, bgColor);
  
  	//Present the backbuffer to the screen
  	swapChain->Present(0, 0);
  }
  
  //Callback
  LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
  	switch (msg)
  	{
  	case WM_KEYDOWN:
  		if (wParam == VK_ESCAPE)
  		{
  			if (MessageBox(0, "Are u very very WERY sure u wanna quit?", "QUITTING! :O", MB_YESNO | MB_ICONQUESTION) == IDYES)
  				DestroyWindow(hwnd);
  		}
  		return 0;
  	case WM_DESTROY:
  		PostQuitMessage(0);
  		return 0;
  	}
  
  	return DefWindowProc(hwnd, msg, wParam, lParam);
  }