Created
April 24, 2022 19:34
-
-
Save RealNeGate/b2510861eeb17f09d5ef0ee74fe4a741 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Reject modernity, return to wrinkly ass GL shit | |
| #if !defined(_WIN32) | |
| #error "Fuck you" | |
| #endif | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> | |
| #include <GL/gl.h> | |
| #pragma comment(lib, "opengl32.lib") | |
| #pragma comment(lib, "gdi32.lib") | |
| #pragma comment(lib, "user32.lib") | |
| // no need for do while crap if it's an expression :p | |
| // it's basically an assert but it doesn't get vaporized | |
| #define CHECK(x) ((x) ? (void)0 : abort()) | |
| static LRESULT CALLBACK WindowProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam) { | |
| if (msg == WM_DESTROY) { | |
| PostQuitMessage(0); | |
| return 0; | |
| } | |
| return DefWindowProcW(wnd, msg, wparam, lparam); | |
| } | |
| int main() { | |
| WNDCLASSEXW wc = { | |
| .cbSize = sizeof(wc), | |
| .lpfnWndProc = WindowProc, | |
| .hInstance = GetModuleHandleA(NULL), | |
| .lpszClassName = L"MINE" | |
| }; | |
| CHECK(RegisterClassExW(&wc)); | |
| HWND window = CreateWindowExW( | |
| WS_EX_APPWINDOW, L"MINE", L"Da square", WS_OVERLAPPEDWINDOW, | |
| CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, NULL, NULL, wc.hInstance, NULL | |
| ); | |
| CHECK(window); | |
| ShowWindow(window, SW_SHOW); | |
| SetFocus(window); | |
| // WGL shit | |
| HDC dc = GetDC(window); | |
| PIXELFORMATDESCRIPTOR pfd = { | |
| .nSize = sizeof(pfd), | |
| .nVersion = 1, | |
| .iPixelType = PFD_TYPE_RGBA, | |
| .dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, | |
| .cColorBits = 32, | |
| .cAlphaBits = 8, | |
| .iLayerType = PFD_MAIN_PLANE | |
| }; | |
| int pixel_format; | |
| CHECK(pixel_format = ChoosePixelFormat(dc, &pfd)); | |
| CHECK(SetPixelFormat(dc, pixel_format, &pfd)); | |
| HGLRC glctx; | |
| CHECK(glctx = wglCreateContext(dc)); | |
| CHECK(wglMakeCurrent(dc, glctx)); | |
| for (;;) { | |
| // da pump | |
| MSG msg; | |
| while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { | |
| if (msg.message == WM_QUIT) goto exit; | |
| TranslateMessage(&msg); | |
| DispatchMessageW(&msg); | |
| } | |
| glClear(GL_COLOR_BUFFER_BIT); | |
| glBegin(GL_TRIANGLE_FAN); | |
| { | |
| glColor3f(0.5f, 0.5f, 0.0f); | |
| glVertex2f(-0.5f, -0.5f); | |
| glColor3f(1.0f, 0.5f, 0.0f); | |
| glVertex2f( 0.5f, -0.5f); | |
| glColor3f(1.0f, 1.0f, 0.0f); | |
| glVertex2f( 0.5f, 0.5f); | |
| glColor3f(0.5f, 1.0f, 0.0f); | |
| glVertex2f(-0.5f, 0.5f); | |
| } | |
| glEnd(); | |
| SwapBuffers(dc); | |
| } | |
| exit: | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment