Advertisement
Tkap1

Untitled

Jun 26th, 2024
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.70 KB | None | 0 0
  1. // compile with
  2. // cl.exe -nologo main.c -link opengl32.lib user32.lib gdi32.lib && main.exe
  3.  
  4. #include <Windows.h>
  5. #include <GL/GL.h>
  6.  
  7. LRESULT window_proc(HWND window, UINT msg, WPARAM wparam, LPARAM lparam)
  8. {
  9.     LRESULT result = 0;
  10.     switch(msg) {
  11.         case WM_CLOSE:
  12.         case WM_DESTROY: {
  13.             PostQuitMessage(0);
  14.         } break;
  15.  
  16.         default: { result = DefWindowProc(window, msg, wparam, lparam); }
  17.  
  18.     }
  19.     return result;
  20. }
  21.  
  22. int main()
  23. {
  24.     WNDCLASSEX c = {0};
  25.     c.cbSize = sizeof(c);
  26.     c.lpfnWndProc = window_proc;
  27.     c.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
  28.     c.lpszClassName = "hi youtube";
  29.     c.hInstance = GetModuleHandle(NULL);
  30.     RegisterClassEx(&c);
  31.  
  32.     HWND window = CreateWindow("hi youtube", "subscribe", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);
  33.     HDC dc = GetDC(window);
  34.     PIXELFORMATDESCRIPTOR pfd = {0};
  35.     pfd.nSize = sizeof(pfd);
  36.     pfd.nVersion = 1;
  37.     pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
  38.     pfd.cColorBits = 32;
  39.     pfd.cAlphaBits = 8;
  40.     pfd.cDepthBits = 24;
  41.     int format = ChoosePixelFormat(dc, &pfd);
  42.     SetPixelFormat(dc, format, &pfd);
  43.     HGLRC glrc = wglCreateContext(dc);
  44.     wglMakeCurrent(dc, glrc);
  45.     MSG msg;
  46.     while(1) {
  47.         while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) > 0) {
  48.             if(msg.message == WM_QUIT) { return 0; }
  49.             TranslateMessage(&msg);
  50.             DispatchMessage(&msg);
  51.         }
  52.         glClearColor(0.1f, 0, 0, 0);
  53.         glClear(GL_COLOR_BUFFER_BIT);
  54.  
  55.  
  56.         glBegin(GL_TRIANGLES);
  57.         glColor3f(1, 0, 0);
  58.         glVertex2f(0, 0.5f);
  59.         glColor3f(0, 1, 0);
  60.         glVertex2f(-0.25f, -0.5f);
  61.         glColor3f(0, 0, 1);
  62.         glVertex2f(0.25f, -0.5f);
  63.         glEnd();
  64.         SwapBuffers(dc);
  65.     }
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement