* removed native OpenGL support
[glBitmap.git] / examples / SimpleLoadFromFile / SimpleLoadFromFile.lpr
1 program SimpleLoadFromFile;
2
3 {$mode objfpc}{$H+}
4
5 uses
6   {$IFDEF UNIX}{$IFDEF UseCThreads}
7   cthreads,
8   {$ENDIF}{$ENDIF}
9   Classes, Windows, SysUtils, dglOpenGL, glBitmap, Helper;
10
11 var
12   oglWindow: TOpenGLWindow;
13   running: Boolean = true;
14   tex: TglBitmap2D;
15
16 function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
17 begin
18   case Msg of
19     WM_DESTROY: begin
20       running := false;
21     end;
22   end;
23   result := DefWindowProc(hWnd, Msg, wParam, lParam);
24 end;
25
26 procedure RenderLoop;
27 begin
28   tex.Bind();
29   glColor4f(1, 1, 1, 1);
30   glBegin(GL_QUADS);
31     glTexCoord2f(0, 0); glVertex2f(100, 100);
32     glTexCoord2f(1, 0); glVertex2f(700, 100);
33     glTexCoord2f(1, 1); glVertex2f(700, 500);
34     glTexCoord2f(0, 1); glVertex2f(100, 500);
35   glEnd;
36   tex.Unbind();
37 end;
38
39 begin
40   oglWindow := CreateOpenGLWindow('SimpleLoadFromFile', 800, 600, @WindowProc);
41   try
42     // load texture
43     tex := TglBitmap2D.Create;
44     tex.LoadFromFile(ExtractFilePath(ApplicationName) + '../textures/BMP_24_RGB8.bmp');
45     tex.GenTexture;
46
47     while running and ProgressMesages do begin
48       RenderLoop;
49       SwapBuffers(oglWindow.DC);
50     end;
51   finally
52     FreeAndNil(tex);
53     DestroyOpenGLWindow(oglWindow);
54   end;
55 end.
56