program SimpleLoadFromFile; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes, Windows, SysUtils, dglOpenGL, glBitmap, Helper; var oglWindow: TOpenGLWindow; running: Boolean = true; tex: TglBitmap2D; function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; begin case Msg of WM_DESTROY: begin running := false; end; end; result := DefWindowProc(hWnd, Msg, wParam, lParam); end; procedure RenderLoop; begin tex.Bind(); glColor4f(1, 1, 1, 1); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(100, 100); glTexCoord2f(1, 0); glVertex2f(700, 100); glTexCoord2f(1, 1); glVertex2f(700, 500); glTexCoord2f(0, 1); glVertex2f(100, 500); glEnd; tex.Unbind(); end; begin oglWindow := CreateOpenGLWindow('SimpleLoadFromFile', 800, 600, @WindowProc); try // load texture tex := TglBitmap2D.Create; tex.LoadFromFile(ExtractFilePath(ApplicationName) + '../textures/BMP_24_RGB8.bmp'); tex.GenTexture; while running and ProgressMesages do begin RenderLoop; SwapBuffers(oglWindow.DC); end; finally FreeAndNil(tex); DestroyOpenGLWindow(oglWindow); end; end.