Author Topic: Read file asynchronously without blocking the game  (Read 1227 times)

mindslight

  • Administrator
  • Full Member
  • *****
  • Posts: 123
  • Karma: +0/-0
    • View Profile
    • Jo Engine
Read file asynchronously without blocking the game
« on: September 18, 2016, 08:36:45 pm »
I added some functions to read file asynchronously, because I working on a video reader, but it's working for any file and any usage :)

If you're interested, here 's how it works:

The function bellow will be called when the file is loaded:

Code: [Select]
void            my_async_read(char *contents, int length, int optional_token)
{
}

To read a file asynchronously, you just have to call jo_fs_read_file_async() with the filename, the callback and an optional token (user value for the callback)

Code: [Select]
jo_fs_read_file_async("DEMO.TXT", my_async_read, 0);

In attachement, you will find a sample code to load a background image (TGA) from the CD asynchronously

NeoSnk

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
    • Titan Game Studios
Re: Read file asynchronously without blocking the game
« Reply #1 on: September 22, 2016, 01:28:55 am »
Amazing, tks man!

mindslight

  • Administrator
  • Full Member
  • *****
  • Posts: 123
  • Karma: +0/-0
    • View Profile
    • Jo Engine
Re: Read file asynchronously without blocking the game
« Reply #2 on: September 22, 2016, 11:01:09 am »
you're welcome  ;)

NeoSnk

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
    • Titan Game Studios
Re: Read file asynchronously without blocking the game
« Reply #3 on: December 16, 2016, 02:45:30 pm »
is it possible to execute this function while the CD is playing some music? I'm trying here but the music stops.


Tks man!!!!
« Last Edit: December 16, 2016, 03:01:07 pm by NeoSnk »

NeoSnk

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
    • Titan Game Studios
Re: Read file asynchronously without blocking the game
« Reply #4 on: December 17, 2016, 04:33:29 am »
I think the problem is when the console will read a image from the CD it stops to read the music... I don't know if it can read two things at the same time!

mindslight

  • Administrator
  • Full Member
  • *****
  • Posts: 123
  • Karma: +0/-0
    • View Profile
    • Jo Engine
Re: Read file asynchronously without blocking the game
« Reply #5 on: December 19, 2016, 09:23:22 am »
You can read multiple file at the same time but not with the audio CD (I think)

NeoSnk

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
    • Titan Game Studios
Re: Read file asynchronously without blocking the game
« Reply #6 on: December 19, 2016, 03:33:58 pm »
Yes, I realized that, but I found another way to do what I wanted heheheh! Thank you :)

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk