Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <gl\GL.h>
- #include <gl\GLU.h>
- #include <gl\glut.h>
- #include "AnimeFunc.h" [/background][/size][/font]
- [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);
- void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
- void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int iCmdShow)
- {
- WNDCLASS wc;
- HWND hWnd; //Window handle
- HDC hDC;
- HGLRC hRC;
- MSG msg;
- BOOL quit = FALSE;
- float theta = 0.0f; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // register window class
- wc.style = CS_OWNDC; //Class style
- wc.lpfnWndProc = WndProc; // Pointer to Window Procedure
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance; //Handle to app instance
- wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); //Icon for window <NOTE> MUST BE ADDED <NOTE> 32x32
- wc.hCursor = LoadCursor( NULL, IDC_ARROW ); //Cursor displayed over Window.
- wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); //Background brush (whatever that is).
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "PokeRedact";
- RegisterClass( &wc ); // Small upper left icon. 16x16 [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // create main window
- hWnd = CreateWindow(
- "PokeRedact", "Pokemon <REDACTED>",
- WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,
- 0, 0, 640, 480,
- NULL, NULL, hInstance, NULL ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // enable OpenGL for the window
- EnableOpenGL( hWnd, &hDC, &hRC );
- // program main loop
- while ( !quit )
- { [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // check for messages
- if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
- { [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // handle or dispatch messages
- if ( msg.message == WM_QUIT )
- {
- quit = TRUE;
- }
- else
- {
- TranslateMessage( &msg );
- DispatchMessage( &msg );
- } [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] }
- else
- { [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // OpenGL animation code goes here
- glClear( GL_COLOR_BUFFER_BIT );
- for (bool i = false; i == false; i = true)
- {
- SceneSet(0.0,0.0,0.0);
- }
- IntroAnime();
- SwapBuffers( hDC ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] } [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] } [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // shutdown OpenGL
- DisableOpenGL( hWnd, hDC, hRC ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // destroy the window explicitly
- DestroyWindow( hWnd ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] return msg.wParam; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]} [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]// Window Procedure [/background][/size][/font]
- [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)
- { [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] switch (message)
- { [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_CREATE:
- return 0; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_CLOSE:
- PostQuitMessage( 0 );
- return 0; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_DESTROY:
- return 0; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case WM_KEYDOWN:
- switch ( wParam )
- { [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] case VK_ESCAPE:
- PostQuitMessage(0);
- return 0; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] }
- return 0; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] default:
- return DefWindowProc( hWnd, message, wParam, lParam ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] } [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]} [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]// Enable OpenGL [/background][/size][/font]
- [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)
- {
- PIXELFORMATDESCRIPTOR pfd;
- int format; [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // get the device context (DC)
- *hDC = GetDC( hWnd ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // set the pixel format for the DC
- ZeroMemory( &pfd, sizeof( pfd ) );
- pfd.nSize = sizeof( pfd );
- pfd.nVersion = 1;
- pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.cColorBits = 24;
- pfd.cDepthBits = 16;
- pfd.iLayerType = PFD_MAIN_PLANE;
- format = ChoosePixelFormat( *hDC, &pfd );
- SetPixelFormat( *hDC, format, &pfd ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)] // create and enable the render context (RC)
- *hRC = wglCreateContext( *hDC );
- wglMakeCurrent( *hDC, *hRC ); [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]} [/background][/size][/font]
- [font=verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif][size=3][background=rgb(240, 240, 240)]// Disable OpenGL [/background][/size][/font]
- [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)
- {
- wglMakeCurrent( NULL, NULL );
- wglDeleteContext( hRC );
- ReleaseDC( hWnd, hDC );
- }
Advertisement
Add Comment
Please, Sign In to add comment