1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
#include <Windows.h>
#include <gl/GL.h>
#include "Entity.h"
#include "Player.h"
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HWND WindowHandle;
HDC hDC;
HGLRC hRC;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hInstancePrev, PSTR nCmdLine, int CmdShow)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hIconSm = 0;
wcex.lpfnWndProc = WndProc;
wcex.hCursor = LoadCursor(0, IDC_ARROW);
wcex.hIcon = LoadIcon(0, IDI_APPLICATION);
wcex.hInstance = hInstance;
wcex.cbWndExtra = 0;
wcex.cbWndExtra = 0;
wcex.lpszClassName = L"My class";
wcex.style = CS_OWNDC;
wcex.lpszMenuName = 0;
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
RegisterClassEx(&wcex);
WindowHandle = CreateWindowEx(0, L"My Class", L"DirtyCraft", WS_OVERLAPPEDWINDOW, 100, 100, 640, 480, 0, 0, hInstance, 0);
if (!WindowHandle)
MessageBoxA(0, "Init Failed", "This fucking failed to init....", 0);
ShowWindow(WindowHandle, CmdShow);
UpdateWindow(WindowHandle);
MSG msg;
int ReturnValue = 0;
PIXELFORMATDESCRIPTOR pfd;
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 24;
pfd.cStencilBits = 8;
int iFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, iFormat, &pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
while ((ReturnValue = GetMessage(&msg, 0, 0, 0)) != 0)
{
if (ReturnValue == -1)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.5f, 0.5f, 0.15f, 1.0f);//I tried to put 0 at alpha, but it has no result
SwapBuffers(hDC);
}
glMatrixMode(GL_PROJECTION);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hRC);
return 0;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
|