프로그래밍/OpenGL
OpenGL 초기화
감자1호
2010. 4. 18. 01:31
개인적인 공부를 위해서 김형준님 홈페이지에 있는자료를 가져왔습니다.
이리로 가시면 오픈쥐엘 관련 튜토리얼을 자세히 보실 수 있습니다.
www.gisdeveloper.co.kr

나의 OpenGL 튜어리얼에 온 것을 환영한다. 나는 OpenGL에 대한 열정을 가지고 있는 평범한 사람이다. 내가 처음 OpenGL에 대해서 알게된 때는 3Dfx가 부두1를 위한 OpenGL 가속 드라이버를 배포할 때였다. 바로 나는 OpenGL 꼭 배워야 할 것이라는 것을 느꼈다. 불행이도 OpenGL은 책에서도 또한 인터넷을 통해서도 정보를 얻기 어려웠다. 나는 몇시간 동안 OpenGL에 대한 코드를 작성했고 IRC와 email을 통해서 많은 사람들에게 도움을 요청했다. 그 사람들은 자신이 OpenGL에 대해 엘리트라고 자처했던 사람들이었으나 자신이 알고 있는 지식을 공유하는데는 별 관심이 없었고 나의 수고는 물거품이 되었다.
나는 OpenGL을 배우려는데 관심이 있는 사람들을 위해서 혹 그들이 도움이 필요할 때 방문할 수 있도록 이 웹사이트를 만들었다. 나는 나의 모든 각각의 튜어리얼을 인간적으로 가능한 자세하게 각 라인별로 무엇을 하는지를 설명하려고 노력할 것이다. 나는 VC++의 MFC코드는 사용하지 않고 나의 코드를 이해하기 쉽도록 간단하도록 할 것이다. 나의 사이트는 OpenGL의 튜어리얼을 제공하는 많은 사이트중의 하나일 뿐이다. 만약 당신이 OpenGL의 Hardcore 프로그래머이라면 나의 튜어리얼이 너무 단순하다고 생각할지도 모른다. 하지만 나는 나의 사이트가 많은 것을 제공한다고 생각한다. 이 튜어리얼은 2000년 1월에 완전히 새롭게 다시 작성되었다. 이 튜어리얼은 OpenGL 윈도우를 셉업하는 방법을 제시할 한다. OpenGL 윈도우는 당신이 원하는 해상도와 칼ㄹ 비트값을 가진 전체화면으로 실행될 수 있다. 이 코드는 당신의 모든 OpenGL 프로젝트를 적용할 수 있도록 아주 유연하게 다듬어 졌다. 나의 모든 튜어리얼은 이 코드를 토대로 작성되었다. 나는 이 코드를 유연하게 작성했고 동시에 강력하게 작성했다. 모든 에러는 보고되어져 제거되었고 메모리 누수 또한 없다. 그리고 코드는 읽기 쉬우며 수정하기도 쉽다.나는 Fredric Echols에게 이 코드를 수정해 준 것에 대해서 감사의 말을 전한다.
자! 이 튜어리얼을 시작해보자!!
VC++을 시작하고 새로운 Win32 Application을 생성한다. (Console Application이 아니다). OpenGL 라이브러리를 링크시킬 필요가 있다. VC++의 Project 메뉴로 가서 Settings의 서브 메뉴로 다시 클릭한다. 나타나는 윈도우에서 Link Tab을 클릭하고 "Object/Libary Modules"에서 다음 라인을 추가한다.
OpenGL32.lib; GLu32.lib; GLaux.lib;
여기서 다시 OK버튼을 클릭하면 OpenGL 프로그래밍 준비가 된 것이다.
먼저 Include Header에 다음 4개의 라인을 추가한다. 그 라인은 아래와 같다.
- #include <windows.h> // Header File For Windows
- #include <gl\gl.h> // Header File For The OpenGL32 Library
- #include <gl\glu.h> // Header File For The GLu32 Library
- #include <gl\glaux.h> // Header File For The GLaux Library
먼저 정의할 변수는 Rendering Context를 위한 것이다. 모든 OpenGL 프로그램은 모두 Rendering Context에 연결되어 있다. OpenGL에서의 랜더링 컨텍스트는 디바이스 컨텍스트라고 불린다. hRC가 랜더링 컨텍스트를 정의하는 변수이다. 우리의 프로그램이 윈도우창에 그림을 그리기 위해 디바이스 컨텍스트를 만들 필요가 있다. 윈도우즈 디바이스 컨텍스트를 정의하기 위한 변수가 hDC이다. DC(Device Context)는 윈도우즈의 GDI(Graphics Deive Interface)와 연결되어있다. RC(Rendering Context)는 다시 DC와 OpenGL 매커니즘을 통해서 연결되어 있다.
새번째 줄에 hWnd라는 변수가 있는데 이것은 윈도우즈(OS)에 의해서 우리의 윈도우즈와 연관된 핸들을 가지고 잇다. 마지막 네 번째 라인의 변수는 프로그램의 인스턴스의 헨들이다.
- HGLRC hRC=NULL; // Permanent Rendering Context
- HDC hDC=NULL; // Private GDI Device Context
- HWND hWnd=NULL; // Holds Our Window Handle
- HINSTANCE hInstance; // Holds The Instance Of The Application
- bool keys[256]; // Array Used For The Keyboard Routine
- bool active=TRUE; // Window Active Flag Set To TRUE By Default
- bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
- LRESULTCALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
- GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
- // Resize And Initialize The GL Window
- {
- if (height==0) // Prevent A Divide By Zero By
- {
- height=1; // Making Height Equal One
- }
- glViewport(0, 0, width, height); // Reset The Current Viewport
glMatrixModel(GL_PROJECTION)은 다음에 이어지는 두라인의 코드와 연관되어 Projection Matrix에 영향을 주게 된다. Perspective Matrix는 Perspective View한 장면을 영향을 미치는 매트릭스 체계이다. (역자주: Matrix는 수학에서 행렬인데 실제로 OpenGL은 대부분의 연상을 행렬로 4X4로 처리한다.) glLoadIdentity()는 Matirx를 초기화시킨다. (역자주: 행렬을 단위행렬로 만든다) 이것은 선택한 매트릭스를 원래의 상태로 돌리는 것이다. (역자주: 원래의 상태가 바로 단위행렬 상태이다) glLoadIdentity()를 호출한 다음 우리는 장면연출을 위해 Perspective View를 설정한다. glMatrixMode(GL_MODELVIEW)는 Modelview Matrix에 영향을 미칠 계수가 있다고 알린다. Modelview matrix는 물체의 정보가 저장될 곳이다. (역자주: 물체의 정보라 함은 3차원적 위치, 3차원적 크기, 그리고 3차원적 회전각을 의미하는데 이는 모두 행렬을 통해 이루어진다. 이 행렬 4X4 행렬인데 이 행렬값이 실제적인 물체의 정보이다) 마지막으로 우리는 Modelview Matirx를 초기화할 것이다. 만약 이 부분을 이해하지 못한다고 해서 걱정하지 말기바란다. 나는 이후 모든 튜어리얼에서 설명할 것이다. 단지 멋진 장면(퍼스펙티브한 장면)을 연출하기 위한 준비과정이라고 생각하기 바란다. (역자주: 수학적인 지식이 필요한 부분이다)
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- // Calculate The Aspect Ratio Of The Window
- gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- }
- int InitGL(GLvoid) // All Setup For OpenGL Goes Here
- {
- glShadeModel(GL_SMOOTH);// Enables Smooth Shading
우리는 세 개의 주요 인자(RGB)를 서로 섞어서 여러 가지 색을 만든다. 예를 들어서 glClearColor(0.0f, 0.0f, 1.0f, 0.0f)는 순수한 Blue의 색으로 화면을 지울 색을 선택하는 것이다. 또 예를 들어서 glClearColor(0.5f, 0.0f, 0.0f, 0.0f)일 경우 중간 정도의 Red의 색을 선택하는 것이다. 만약 하얀색의 바탕화면을 얻길 원한다면 세 개의 인자값을 모두 1.0f로 설정해주면 된다. 마찬가지로 검색의 바탕화면을 얻길 원한다면 모든 인자를 0.0f로 설정하면 된다.
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);// Black Background
- glClearDepth(1.0f); // Depth Buffer Setup
- glEnable(GL_DEPTH_TEST); // Enables Depth Testing
- glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do
- // Really Nice Perspective Calculations
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- return TRUE;// Initialization Went OK
반환값을 True로 설정함으로써 우리의 프로그램이 아무런 문제 없이 이 함수 루틴을 실행했음을 알린다. 만약 어떤 이유로 프로그램이 멈추기를 바란다면 False값을 리턴함으로써 그리기가 실패했다고 프로그램에게 알린다. 그러면 결과적으로 프로그램은 종료될 것이다.
- int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
- {
- // Clear The Screen And The Depth Buffer
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity(); // Reset The Current Modelview Matrix
- return TRUE; // Everything Went OK
- }
- GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
- {
- if (fullscreen) // Are We In Fullscreen Mode?
- {
- ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop
- ShowCursor(TRUE); // Show Mouse Pointer
- }
- if (hRC) // Do We Have A Rendering Context?
- {
- if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
- {
- MessageBox(NULL, "Release Of DC And RC Failed.", "SHUTDOWN ERROR",
- MB_OK | MB_ICONINFORMATION);
- } //
- if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
- {
- MessageBox(NULL, "Release Rendering Context Failed.", "SHUTDOWN ERROR",
- MB_OK | MB_ICONINFORMATION);
- }
- hRC=NULL; // Set RC To NULL
- if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC
- {
- MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",
- MB_OK | MB_ICONINFORMATION);
- hDC=NULL; // Set DC To NULL
- }
- if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
- {
- MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",
- MB_OK | MB_ICONINFORMATION);
- hWnd=NULL; // Set hWnd To NULL
- }
- if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class
- {
- MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",
- MB_OK || MB_ICONINFORMATION);
- hInstance=NULL; // Set hInstance To NULL
- }
다음에 설명하는 함수는 Boolean 값을 리턴하며 5개의 인자를 필요로 한다. 그 인자들은 title(윈도우의 제목), width(윈도우의 가로길이), height(윈도우의 세로길이), bits(16/24/32), 그리고 마지막으로 fullscreenflag(전체창 모드인지 아닌지)이다. 반환값이 True일 경우에 성공적으로 OpenGL 창을 생성한 것이고 False인 경우는 OpenGL 창의 생성을 실패한 것이다.
- BOOL CreateGLWindow(char* title, int width, int height, int bits,
- bool fullscreenflag)
- {
- GLuintPixelFormat;// Holds The Results After Searching For A Match
- WNDCLASSwc;// Windows Class Structure
- DWORD dwExStyle; // Window Extended Style
- DWORD dwStyle; // Window Style
- RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
- WindowRect.left=(long)0; // Set Left Value To 0
- WindowRect.right=(long)width; // Set Right Value To Requested Width
- WindowRect.top=(long)0; // Set Top Value To 0
- WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
- fullscreen=fullscreenflag;// Set The Global Fullscreen Flag
- hInstance= GetModuleHandle(NULL); // Grab An Instance For Our Window
- // Redraw On Move, And Own DC For Window
- wc.style= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
- wc.lpfnWndProc= (WNDPROC) WndProc; // WndProc Handles Messages
- wc.cbClsExtra= 0; // No Extra Window Data
- wc.cbWndExtra= 0;// No Extra Window Data
- wc.hInstance= hInstance;// Set The Instance
- wc.hIcon= LoadIcon(NULL, IDI_WINLOGO);// Load The Default Icon
- wc.hCursor= LoadCursor(NULL, IDC_ARROW);// Load The Arrow Pointer
- wc.hbrBackground= NULL;// No Background Required For GL
- wc.lpszMenuName= NULL;// We Don't Want A Menu
- wc.lpszClassName= "OpenGL";// Set The Class Name
- if (!RegisterClass(&wc)) // Attempt To Register The Window Class
- {
- MessageBox(NULL, "Failed To Register The Window Class.", "ERROR",
- MB_OK|MB_ICONEXCLAMATION);
- return FALSE; // Exit And Return FALSE
- }
- if (fullscreen) // Attempt Fullscreen Mode? {
- DEVMODE dmScreenSettings; // Device Mode
- // Makes Sure Memory's Cleared
- memset(&dmScreenSettings,0,sizeof(dmScreenSettings));
- // Size Of The Devmode Structure
- dmScreenSettings.dmSize=sizeof(dmScreenSettings);
- dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
- dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
- dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
- dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
- // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN
- //Gets Rid Of Start Bar.
- if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)
- !=DISP_CHANGE_SUCCESSFUL)
- {
- // If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
- if (MessageBox(NULL,
- "The Requested Fullscreen Mode Is Not Supported By\n"
- "Your Video Card. Use Windowed Mode nstead?",
- "NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) {
- fullscreen=FALSE; // Select Windowed Mode (Fullscreen=FALSE)
- }
- else
- {
- // Pop Up A Message Box Letting User Know The Program Is Closing.
- MessageBox(NULL,"Program Will Now close.","ERROR",MB_OK|MB_ICONSTOP);
- return FALSE; // Exit And Return FALSE
- }
- }
- }
- if (fullscreen) // Are We Still In Fullscreen Mode?
- {
최종적으로 우리는 마우스 포인터를 않보이게 해야 한다. 만약 프로그램이 사용자와의 상호작용이 없다면 마우스 포인터를 않보이게 하는 것은 괜찬다.
- dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
- dwStyle=WS_POPUP; // Windows Style
- ShowCursor(FALSE); // Hide Mouse Pointer
- } else {
- dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // WindowExtendedStyle
- dwStyle=WS_OVERLAPPEDWINDOW;// Windows Style
- }
- // Adjust Window To True Requested Size
- AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
우리가 윈도우 스타일에 WS_CLIPSIBLINGS와 WS_CLIPCHILDREN도 포함하고 있음을 주목하기 바란다. 이 두 스타일 값은 모두 OpenGL에서는 필수적인 것이다. 이 값들은 다른 윈도우가 우리의 OpenGL 윈도위에 그려지는 것을 막는다.
- if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
- "OpenGL", // Class Name
- title, // Window Title
- WS_CLIPSIBLINGS | // Required Window Style
- WS_CLIPCHILDREN | // Required Window Style
- dwStyle, // Selected Window Style
- 0, 0, // Window Position
- WindowRect.right-WindowRect.left, // Calculate Adjusted Window Width
- WindowRect.bottom-WindowRect.top, // Calculate Adjusted Window Height
- NULL, // No Parent Window
- NULL, // No Menu
- hInstance, // Instance
- NULL))) // Don't Pass Anything To WM_CREATE
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- // pfd Tells Windows How We Want Things To Be
- static PIXELFORMATDESCRIPTOR pfd=
- {
- sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
- 1, // Version Number
- PFD_DRAW_TO_WINDOW | // Format Must Support Window
- PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
- PFD_DOUBLEBUFFER, // Must Support Double Buffering
- PFD_TYPE_RGBA, // Request An RGBA Format
- bits, // Select Our Color Depth
- 0, 0, 0, 0, 0, 0, // Color Bits Ignored
- 0, // No Alpha Buffer
- 0, // Shift Bit Ignored
- 0, // No Accumulation Buffer
- 0, 0, 0, 0, // Accumulation Bits Ignored
- 16, // 16Bit Z-Buffer (Depth Buffer)
- 0, // No Stencil Buffer
- 0, // No Auxiliary Buffer
- PFD_MAIN_PLANE, // Main Drawing Layer
- 0, // Reserved
- 0, 0, 0 // Layer Masks Ignored
- };
- if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",
- MB_OK|MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",
- MB_OK|MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
- {
- KillGLWindow();// Reset The Display
- MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return FALSE;// Return FALSE
- }
- if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL,"Can't Create A GL Rendering Context.", "ERROR",
- MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE
- }
- if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL,"Can't Activate The GL Rendering Context.", "ERROR",
- MB_OK|MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- ShowWindow(hWnd,SW_SHOW); // Show The Window
- SetForegroundWindow(hWnd); // Slightly Higher Priority
- SetFocus(hWnd); // Sets Keyboard Focus To The Window
- ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
- if (!InitGL()) // Initialize Our Newly Created GL Window
- {
- KillGLWindow(); // Reset The Display
- MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
- return FALSE; // Return FALSE
- }
- return TRUE; // Success
- LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
- UINT uMsg, // Message For This Window
- WPARAM wParam, // Additional Message Information
- LPARAM lParam) // Additional Message Information
- {
- switch (uMsg) // Check For Windows Messages
- {
- case WM_ACTIVATE: // Watch For Window Activate Message
- {
- if (!HIWORD(wParam)) // Check Minimization State
- {
- active=TRUE; // Program Is Active
- }
- else
- {
- active=FALSE; // Program Is No Longer Active
- }
- return 0; // Return To The Message Loop
- }
- case WM_SYSCOMMAND: // Intercept System Commands
- {
- switch (wParam) // Check System Calls
- {
- case SC_SCREENSAVE: // Screensaver Trying To Start?
- case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
- return 0; // Prevent From Happening
- }
- break; // Exit
- }
- case WM_CLOSE: // Did We Receive A Close Message?
- {
- PostQuitMessage(0); // Send A Quit Message
- return 0; // Jump Back
- }
- case WM_KEYDOWN: // Is A Key Being Held Down?
- {
- keys[wParam] = TRUE; // If So, Mark It As TRUE
- return 0; // Jump Back
- }
- case WM_KEYUP: // Has A Key Been Released?
- {
- keys[wParam] = FALSE; // If So, Mark It As FALSE
- return 0; // Jump Back
- }
- case WM_SIZE: // Resize The OpenGL Window
- {
- ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
- return 0; // Jump Back
- }
- }
- // Pass All Unhandled Messages To DefWindowProc
- return DefWindowProc(hWnd,uMsg,wParam,lParam);
- }
- int WINAPI WinMain( HINSTANCE hInstance, // Instance
- HINSTANCE hPrevInstance, // Previous Instance
- LPSTR lpCmdLine, // Command Line Parameters
- int nCmdShow) // Window Show State
- {
done 변수가 False값을 가지고 있는 한 우리의 프로그램은 계속 실행된다. done변수가 True 값을 갖는 순간 프로그램은 바로 종료된다.
- MSG msg; // Windows Message Structure
- BOOL done=FALSE; // Bool Variable To Exit Loop
- // Ask The User Which Screen Mode They Prefer
- if(MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",
- MB_YESNO|MB_ICONQUESTION)==IDNO)
- {
- fullscreen=FALSE; // Windowed Mode
- }
- // Create Our OpenGL Window
- If (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
- {
- return 0; // Quit If Window Was Not Created
- }
- while(!done) // Loop That Runs Until done=TRUE
- {
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
- {
- if (msg.message==WM_QUIT) // Have We Received A Quit Message?
- {
- done=TRUE; // If So done=TRUE
- }
- else // If Not, Deal With Window Messages
- {
- TranslateMessage(&msg); // Translate The Message
- DispatchMessage(&msg); // Dispatch The Message
- }
- }
- else // If There Are No Messages
- {
- // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
- if ((active && !DrawGLScene()) || keys[VK_ESCAPE]) // Updating View Only If Active
- {
- done=TRUE; // ESC or DrawGLScene Signalled A Quit
- }
- else // Not Time To Quit, Update Screen
- {
- SwapBuffers(hDC); // Swap Buffers (Double Buffering)
- if (keys[VK_F1]) // Is F1 Being Pressed?
- {
- keys[VK_F1]=FALSE; // If So Make Key FALSE
- KillGLWindow(); // Kill Our Current Window
- fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
- // Recreate Our OpenGL Window
- if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
- {
- return 0; // Quit If Window Was Not Created
- }
- }
- }
- }
- // Shutdown
- KillGLWindow(); // Kill The Window
- return (msg.wParam); // Exit The Program
- }
여기까지가 변역입니다.
이상으로 튜어리얼의 번역을 끝마칩니다.