Skip to content

Instantly share code, notes, and snippets.

@XProger
Last active June 23, 2022 08:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XProger/0e87eeb135d3c7f40e43 to your computer and use it in GitHub Desktop.
Save XProger/0e87eeb135d3c7f40e43 to your computer and use it in GitHub Desktop.
Delphi minimal OpenGL application
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.
@audinue
Copy link

audinue commented Jun 23, 2022

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment