X-Git-Url: https://git.delphigl.com/?p=LazOpenGLCore.git;a=blobdiff_plain;f=examples%2FTextureFromFunction%2FTextureFromFunction.lpr;fp=examples%2FTextureFromFunction%2FTextureFromFunction.lpr;h=7c60833a3da41446edf97abcaaea4f96b077c480;hp=f960c255192721437b32cfdd542651f38a39fc62;hb=c110c2d190cfdd632a622163d3edb7c9c90cf21a;hpb=fb955156e23a85973e7ee2f89954d90574982fef diff --git a/examples/TextureFromFunction/TextureFromFunction.lpr b/examples/TextureFromFunction/TextureFromFunction.lpr index f960c25..7c60833 100644 --- a/examples/TextureFromFunction/TextureFromFunction.lpr +++ b/examples/TextureFromFunction/TextureFromFunction.lpr @@ -11,6 +11,7 @@ uses var oglWindow: TOpenGLWindow; running: Boolean = true; + data: TglBitmapData; tex: TglBitmap2D; function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; @@ -74,14 +75,19 @@ end; begin oglWindow := CreateOpenGLWindow('TextureFromFunction', 800, 600, @WindowProc); try - // create texture use either GenerateTextureFunc1 or GenerateTextureFunc2 - tex := TglBitmap2D.Create( - glBitmapSize(512, 512), - tfRGBA8ub4, - @GenerateTextureFunc1 - //@GenerateTextureFunc2 - ); - tex.GenTexture; + tex := TglBitmap2D.Create; // create texture object + data := TglBitmapData.Create; // create texture data object + try + data.LoadFromFunc( // generate texture data using either GenerateTextureFunc1 or GenerateTextureFunc2 + glBitmapSize(512, 512), + tfRGBA8ub4, + @GenerateTextureFunc1 + //@GenerateTextureFunc2 + ); + tex.UploadData(data); // upload data to video card + finally + FreeAndNil(data); // after upload is done, the data object could be freed to save memory + end; while running and ProgressMesages do begin RenderLoop;