|
|
@ -1,5 +1,6 @@ |
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <gl/GL.h>
|
|
|
|
#pragma comment(lib, "opengl32.lib")
|
|
|
|
/**
|
|
|
|
*消息处理函数 |
|
|
|
*/ |
|
|
@ -50,6 +51,24 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine |
|
|
|
100, 100, windowWidth, windowHeight, |
|
|
|
NULL, NULL, hInstance, NULL); |
|
|
|
|
|
|
|
/*选定像素格式*/ |
|
|
|
HDC dc = GetDC(hwnd); |
|
|
|
PIXELFORMATDESCRIPTOR pfd; |
|
|
|
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); |
|
|
|
pfd.nVersion = 1; |
|
|
|
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); |
|
|
|
pfd.cColorBits = 32; |
|
|
|
pfd.cDepthBits = 24; |
|
|
|
pfd.cStencilBits = 8; |
|
|
|
pfd.iPixelType = PFD_TYPE_RGBA; |
|
|
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; |
|
|
|
int pixelFormat = ChoosePixelFormat(dc, &pfd); |
|
|
|
SetPixelFormat(dc, pixelFormat, &pfd); |
|
|
|
|
|
|
|
/*创建OpenGL渲染环境*/ |
|
|
|
HGLRC rc = wglCreateContext(dc); |
|
|
|
wglMakeCurrent(dc, rc); |
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW); |
|
|
|
UpdateWindow(hwnd); |
|
|
|
|
|
|
|