enable multi sampling in Windows, fix circle shape

This commit is contained in:
2017-01-18 00:14:50 +00:00
parent 9e123a6a65
commit b351b70ddf
5 changed files with 87 additions and 46 deletions

View File

@@ -198,16 +198,16 @@ int main(int argc, const char * argv[])
#pragma comment (lib, "glew32.lib")
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
HINSTANCE hInst;
HWND hWnd;
HDC hDC;
HGLRC hRC;
char *className;
bool keys[256];
HINSTANCE hInst;
HWND hWnd;
HDC hDC;
HGLRC hRC;
wchar_t* className;
bool keys[256];
int main()
{
WNDCLASSA wc;
WNDCLASS wc;
PIXELFORMATDESCRIPTOR pfd;
App::I.create();
@@ -221,20 +221,19 @@ int main()
// Create the main window
hInst = GetModuleHandle(NULL);
className = "DrosophilaMain";
className = L"EngineMain";
wc.hInstance = hInst;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.lpszClassName = className;
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
RegisterClassA(&wc);
RegisterClass(&wc);
AdjustWindowRect(&clientRect, WS_OVERLAPPEDWINDOW, false);
hWnd = CreateWindowA(wc.lpszClassName, "New Engine", WS_OVERLAPPEDWINDOW,
hWnd = CreateWindow(wc.lpszClassName, L"New Engine", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left,
clientRect.bottom - clientRect.top, 0, 0, hInst, 0);
ShowWindow(hWnd, SW_NORMAL);
// Setup GL Rendering Context
pfd.nSize = sizeof(pfd);
@@ -262,17 +261,41 @@ int main()
// If supported create a 3.1 context
if (wglewIsSupported("WGL_ARB_create_context"))
{
int attribs[] =
int contex_attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 1,
WGL_CONTEXT_FLAGS_ARB, 0,
0
};
auto oldContext = hRC;
hRC = wglCreateContextAttribsARB(hDC, NULL, attribs);
int pixel_attribs[] =
{
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
WGL_COLOR_BITS_ARB, 32,
WGL_DEPTH_BITS_ARB, 24,
WGL_STENCIL_BITS_ARB, 8,
WGL_SAMPLE_BUFFERS_ARB, 1, // Number of buffers (must be 1 at time of writing)
WGL_SAMPLES_ARB, 4, // Number of samples
0
};
UINT numFormat;
wglMakeCurrent(NULL, NULL);
wglDeleteContext(oldContext);
wglDeleteContext(hRC);
DestroyWindow(hWnd);
hWnd = CreateWindow(wc.lpszClassName, L"New Engine", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left,
clientRect.bottom - clientRect.top, 0, 0, hInst, 0);
hDC = GetDC(hWnd);
wglChoosePixelFormatARB(hDC, pixel_attribs, nullptr, 1, &pxfmt, &numFormat);
SetPixelFormat(hDC, pxfmt, &pfd);
hRC = wglCreateContextAttribsARB(hDC, NULL, contex_attribs);
wglMakeCurrent(hDC, hRC);
}
else
@@ -283,6 +306,8 @@ int main()
App::I.init();
ShowWindow(hWnd, SW_NORMAL);
MSG msg;
bool running = true;
unsigned long t0 = GetTickCount();
@@ -315,7 +340,7 @@ int main()
// Clean up
DestroyWindow(hWnd);
UnregisterClassA(className, hInst);
UnregisterClass(className, hInst);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)