Last active
June 23, 2022 08:16
-
-
Save XProger/0e87eeb135d3c7f40e43 to your computer and use it in GitHub Desktop.
Delphi minimal OpenGL application
This file contains 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
program min_ogl; | |
uses | |
Windows, OpenGL; | |
var | |
pfd : TPixelFormatDescriptor; | |
DC : HDC; | |
begin | |
// Creating window | |
DC := GetDC(CreateWindowEx(0, 'EDIT', nil, WS_POPUP or WS_VISIBLE, 0, 0, 640, 480, 0, 0, 0, nil)); | |
ShowCursor(False); // hide cursor | |
// OpenGL initialization | |
pfd.dwFlags := PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER; | |
SetPixelFormat(DC, ChoosePixelFormat(DC, @pfd), @pfd); | |
wglMakeCurrent(DC, wglCreateContext(DC)); | |
// Main Loop | |
while GetAsyncKeyState(27) = 0 do | |
begin | |
glBegin(GL_QUADS); | |
glColor3f(1, 0, 0); glVertex2f(-0.4, -0.4); | |
glColor3f(0, 1, 0); glVertex2f( 0.4, -0.4); | |
glColor3f(0, 0, 1); glVertex2f( 0.4, 0.4); | |
glColor3f(1, 0, 1); glVertex2f(-0.4, 0.4); | |
glEnd; | |
SwapBuffers(DC); | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome!