主题:[原创]Win32环境下OpenGL编程框架
#include <windows.h>
#include <windowsx.h>
#include <gl\gl.h>
#include <gl\glu.h>
#pragma comment(lib,"OpenGL32.lib")
#pragma comment(lib,"GLu32.lib")
TCHAR szTitle[] = TEXT("WndOpenGL");
TCHAR szClass[] = TEXT("WndOpenGL");
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wcex;
HWND hwnd;
MSG msg;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szClass;
wcex.hIconSm = NULL;
if(!RegisterClassEx(&wcex))
{
MessageBox (NULL, TEXT("Failed to Register the Window Class!"), szTitle, MB_ICONERROR);
return 0;
}
hwnd = CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,
szClass,
szTitle,
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, NULL,
hInstance,
NULL);
if(!hwnd) return 0;
ShowWindow(hwnd, SW_MAXIMIZE);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
#include <windowsx.h>
#include <gl\gl.h>
#include <gl\glu.h>
#pragma comment(lib,"OpenGL32.lib")
#pragma comment(lib,"GLu32.lib")
TCHAR szTitle[] = TEXT("WndOpenGL");
TCHAR szClass[] = TEXT("WndOpenGL");
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wcex;
HWND hwnd;
MSG msg;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szClass;
wcex.hIconSm = NULL;
if(!RegisterClassEx(&wcex))
{
MessageBox (NULL, TEXT("Failed to Register the Window Class!"), szTitle, MB_ICONERROR);
return 0;
}
hwnd = CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,
szClass,
szTitle,
WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL, NULL,
hInstance,
NULL);
if(!hwnd) return 0;
ShowWindow(hwnd, SW_MAXIMIZE);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}