//Get Device Context DeviceContext = GetDC(Window); if (!DeviceContext){ printf("Failed To Retrieve Device Context %lu", GetLastError()); goto destroywindow; } SetLastError(NO_ERROR);
{ //Find A Suitable Pixel Format, Manually PIXELFORMATDESCRIPTOR PixelFormatDescriptor = {0}; int PixelFormat; PixelFormat = 1; for (;;++PixelFormat){ int NumPixelFormats; printf("Checking Pixel Format %d\n", PixelFormat); NumPixelFormats = DescribePixelFormat( DeviceContext, PixelFormat, sizeof(PixelFormatDescriptor), &PixelFormatDescriptor ); if (!NumPixelFormats){ printf("Failed To Describe PixelFormat %lu", GetLastError()); goto releasedevicecontext; } SetLastError(NO_ERROR); if ( PixelFormatDescriptor.dwFlags & PFD_SUPPORT_OPENGL && PixelFormatDescriptor.dwFlags & PFD_DOUBLEBUFFER && PixelFormatDescriptor.cDepthBits > 1 ) break; if (PixelFormat == NumPixelFormats){ puts("All Formats Checked - Cannot Find A Suitable OpenGL Pixel Format"); goto releasedevicecontext; } } puts("Format Is Suitable");
//Set Pixel Format if (!SetPixelFormat(DeviceContext, PixelFormat, &PixelFormatDescriptor)){ printf("Failed To Set Pixel Format %lu", GetLastError()); goto releasedevicecontext; } SetLastError(NO_ERROR); }
//Make OpenGl Rendering Context Current if (!wglMakeCurrent(DeviceContext, RenderingContext)){ printf("Failed To Make OpenGL Rending Context Current %lu", GetLastError()); goto deleterenderingcontext; } puts("Initialized OpenGL Rendering Context");
RenderQuad(DeviceContext);
//Make OpenGl Rendering Context Not Current if(!wglMakeCurrent(NULL, NULL)) printf("\nFailed To Make OpenGL Rendering Context Not Current %lu", GetLastError());
deleterenderingcontext: SetLastError(NO_ERROR); if (!wglDeleteContext(RenderingContext)) printf("\nFailed To Delete OpenGL Rendering Context %lu", GetLastError());
releasedevicecontext: SetLastError(NO_ERROR); if (!ReleaseDC(Window, DeviceContext)) printf("\nFailed To Release Device Context %lu", GetLastError());
destroywindow: SetLastError(NO_ERROR); if (!DestroyWindow(Window)) printf("\nFailed To Destroy Window %lu", GetLastError());
unregisterclass: SetLastError(NO_ERROR); if (!UnregisterClassW(WindowClass.lpszClassName, Instance)) printf("\nFailed To Unregister Class %lu", GetLastError()); return 0; } [/code] ... Однако, он продолжает рисовать треугольник:
Почему рендель Как работает glbegin (gl_quads) ? Как я могу исправить renderquad так, чтобы он производил ожидаемый выход?