Guest User

Untitled

a guest
Jul 7th, 2012
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.29 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <gl\GL.h>
  3. #include <gl\GLU.h>
  4. #include <gl\glut.h>
  5. #include "AnimeFunc.h" [/background][/size][/font]
  6. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  7. void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
  8. void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC); [/background][/size][/font]
  9. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  10. LPSTR lpCmdLine, int iCmdShow)
  11. {
  12. WNDCLASS wc;
  13. HWND hWnd; //Window handle
  14. HDC hDC;
  15. HGLRC hRC;
  16. MSG msg;
  17. BOOL quit = FALSE;
  18. float theta = 0.0f; [/background][/size][/font]
  19. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // register window class
  20. wc.style = CS_OWNDC; //Class style
  21. wc.lpfnWndProc = WndProc; // Pointer to Window Procedure
  22. wc.cbClsExtra = 0;
  23. wc.cbWndExtra = 0;
  24. wc.hInstance = hInstance; //Handle to app instance
  25. wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); //Icon for window <NOTE> MUST BE ADDED <NOTE> 32x32
  26. wc.hCursor = LoadCursor( NULL, IDC_ARROW ); //Cursor displayed over Window.
  27. wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); //Background brush (whatever that is).
  28. wc.lpszMenuName = NULL;
  29. wc.lpszClassName = "PokeRedact";
  30. RegisterClass( &wc ); // Small upper left icon. 16x16 [/background][/size][/font]
  31. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // create main window
  32. hWnd = CreateWindow(
  33. "PokeRedact", "Pokemon <REDACTED>",
  34. WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
  35. 0, 0, 640, 480,
  36. NULL, NULL, hInstance, NULL ); [/background][/size][/font]
  37. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // enable OpenGL for the window
  38. EnableOpenGL( hWnd, &hDC, &hRC );
  39. // program main loop
  40. while ( !quit )
  41. { [/background][/size][/font]
  42. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // check for messages
  43. if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
  44. { [/background][/size][/font]
  45. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // handle or dispatch messages
  46. if ( msg.message == WM_QUIT )
  47. {
  48. quit = TRUE;
  49. }
  50. else
  51. {
  52. TranslateMessage( &msg );
  53. DispatchMessage( &msg );
  54. } [/background][/size][/font]
  55. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] }
  56. else
  57. { [/background][/size][/font]
  58. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // OpenGL animation code goes here
  59. glClear( GL_COLOR_BUFFER_BIT );
  60. for (bool i = false; i == false; i = true)
  61. {
  62. SceneSet(0.0,0.0,0.0);
  63. }
  64. IntroAnime();
  65. SwapBuffers( hDC ); [/background][/size][/font]
  66. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] } [/background][/size][/font]
  67. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] } [/background][/size][/font]
  68. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // shutdown OpenGL
  69. DisableOpenGL( hWnd, hDC, hRC ); [/background][/size][/font]
  70. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // destroy the window explicitly
  71. DestroyWindow( hWnd ); [/background][/size][/font]
  72. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] return msg.wParam; [/background][/size][/font]
  73. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]} [/background][/size][/font]
  74. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]// Window Procedure [/background][/size][/font]
  75. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  76. { [/background][/size][/font]
  77. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] switch (message)
  78. { [/background][/size][/font]
  79. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_CREATE:
  80. return 0; [/background][/size][/font]
  81. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_CLOSE:
  82. PostQuitMessage( 0 );
  83. return 0; [/background][/size][/font]
  84. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_DESTROY:
  85. return 0; [/background][/size][/font]
  86. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_KEYDOWN:
  87. switch ( wParam )
  88. { [/background][/size][/font]
  89. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case VK_ESCAPE:
  90. PostQuitMessage(0);
  91. return 0; [/background][/size][/font]
  92. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] }
  93. return 0; [/background][/size][/font]
  94. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] default:
  95. return DefWindowProc( hWnd, message, wParam, lParam ); [/background][/size][/font]
  96. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] } [/background][/size][/font]
  97. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]} [/background][/size][/font]
  98. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]// Enable OpenGL [/background][/size][/font]
  99. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
  100. {
  101. PIXELFORMATDESCRIPTOR pfd;
  102. int format; [/background][/size][/font]
  103. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // get the device context (DC)
  104. *hDC = GetDC( hWnd ); [/background][/size][/font]
  105. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // set the pixel format for the DC
  106. ZeroMemory( &pfd, sizeof( pfd ) );
  107. pfd.nSize = sizeof( pfd );
  108. pfd.nVersion = 1;
  109. pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
  110. pfd.iPixelType = PFD_TYPE_RGBA;
  111. pfd.cColorBits = 24;
  112. pfd.cDepthBits = 16;
  113. pfd.iLayerType = PFD_MAIN_PLANE;
  114. format = ChoosePixelFormat( *hDC, &pfd );
  115. SetPixelFormat( *hDC, format, &pfd ); [/background][/size][/font]
  116. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // create and enable the render context (RC)
  117. *hRC = wglCreateContext( *hDC );
  118. wglMakeCurrent( *hDC, *hRC ); [/background][/size][/font]
  119. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]} [/background][/size][/font]
  120. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]// Disable OpenGL [/background][/size][/font]
  121. [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
  122. {
  123. wglMakeCurrent( NULL, NULL );
  124. wglDeleteContext( hRC );
  125. ReleaseDC( hWnd, hDC );
  126. }
Advertisement
Add Comment
Please, Sign In to add comment