Last active
April 3, 2023 22:52
-
-
Save zeux/ef4bca0585d113d70d3110b1da9e4851 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
#include <windows.h> | |
#include <GL/gl.h> | |
#include <stdio.h> | |
#pragma comment(lib, "opengl32.lib") | |
void glview() | |
{ | |
HWND hWnd = CreateWindow(L"ListBox", L"Title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL); | |
HDC hDC = GetDC(hWnd); | |
PIXELFORMATDESCRIPTOR pfd = { sizeof(pfd), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, 0, 32 }; | |
SetPixelFormat(hDC, ChoosePixelFormat(hDC, &pfd), &pfd); | |
wglMakeCurrent(hDC, wglCreateContext(hDC)); | |
ShowWindow(hWnd, SW_SHOWNORMAL); | |
MSG msg; | |
while (GetMessage(&msg, hWnd, 0, 0) && msg.message) | |
{ | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
RECT rect; | |
GetClientRect(hWnd, &rect); | |
glViewport(0, 0, rect.right - rect.left, rect.bottom - rect.top); | |
glClear(GL_COLOR_BUFFER_BIT); | |
glBegin(GL_TRIANGLES); | |
glColor3f(1.0f, 0.0f, 0.0f); | |
glVertex2i(0, 1); | |
glColor3f(0.0f, 1.0f, 0.0f); | |
glVertex2i(-1, -1); | |
glColor3f(0.0f, 0.0f, 1.0f); | |
glVertex2i(1, -1); | |
glEnd(); | |
SwapBuffers(hDC); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment