Results 1 to 5 of 5

Thread: Best practice for resource loading?

  1. #1

    Best practice for resource loading?

    Is there any good way to load resources while the zgl app is running (outside of the SYS_LOAD function)? I would really like to have some basic sort of loading screen being drawn as resources load, but doing any loading in the SYS_DRAW function or a thread results in corrupted graphics.

    I've tried creating the loading thread within the SYS_LOAD proc as well as the SYS_DRAW proc, but it it doesn't work in either.

  2. #2
    You can't just create your own thread and load there resources, because tex_*functions uses OpenGL commands and this commands can be executed only in the main thread where OpenGL context was created. You can load your resources in timer(don't forget to call timer_Reset when resources will be loaded), or in SYS_DRAW(but if you use batch2d_Begin/batch2d_End, you must call batch2d_Flush before loading textures). And if you want to draw something - scr_Flush will help little bit, but don't expect that you will get smooth animation and so on. So, code in your timer can be something like this:
    Code:
    procedure Timer;
    begin
      if TimeToLoadResources Then
        begin
          while Progress < 100 do
            begin
              // Choose what to load for current Progress state and load it :) Increment Progress.
    
              scr_Clear();
              // Draw current percentage/etc.
              scr_Flush();
            end;
          timer_Reset();
        end;
    end;
    Background resource loading in separate threads will be available later. Some work for this was done in ZenGL(as you can remember this topic), but only as an experiment. I have fixed all founded problems, but didn't include the code because of architecture questions and some other things.

  3. #3
    Ah thanks. No, I never expected smooth animation for loading resources within the sys_draw proc but with multithreading it would be nice to have it available.

  4. #4
    During the loading procress, if I focus another window, I can't focus anymore the ZenGL Window until the loading finishes. ZenGL window stay in Background!

    Is it possible to avoid this?

  5. #5
    Quote Originally Posted by wagenheimer
    I can't focus anymore the ZenGL Window until the loading finishes. ZenGL window stay in Background!
    You can try to call app_ProcessOS(after scr_Flush) from unit zgl_application. This function is only for internal use, but I can export it if it will be useful

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL