New Paste :: Recent Pastes:: No Line Numbers
Init GL by Sacha
1
//... in WinMain() hWnd = CreateWindow ( "Bots", "Bots", /*WS_CAPTION |*/ WS_POPUPWINDOW | WS_VISIBLE, 0, 0, 1024, 768, NULL, NULL, hInstance, NULL); EnableOpenGL (hWnd, &hDC, &hRC); defBots(); BuildFont(); // glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_MULTISAMPLE_ARB); LoadTGA(&textures[0],"Script"); LoadTGA(&textures[1],"FacesL"); //... void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC) { PIXELFORMATDESCRIPTOR pfd; int iFormat; *hDC = GetDC (hWnd); 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; if(!arbMultisampleSupported) iFormat = ChoosePixelFormat (*hDC, &pfd); else iFormat = arbMultisampleFormat; SetPixelFormat (*hDC, iFormat, &pfd); *hRC = wglCreateContext( *hDC ); SetupGL(); wglMakeCurrent( *hDC, *hRC ); } void SetupGL() { glViewport(0, 0, 1024, 768); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(30.0f, 1024/768, 0.1f, 10.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0.0f, 0.0f, 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // glShadeModel(GL_SMOOTH); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glColor3f(0.5f, 0.5f, 1.0f); }