Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Chapter 04] Unclear where to put the FileHandler code
#2
Ah that's a good catch, thanks, I had assumed readers were referring to the supplied PhotoFrame code as a reference, I should have been much more explicit  and noted where to add the MyFiles  Filehandler;  line

it should look like this

Code:
int main(int argc, char *argv[])
{
    UserData user_data;
    bcm_host_init(); //RPI needs this        
    esInitContext(p_state);
    init_ogl(p_state, 1024, 768);
    p_state->user_data = &user_data;
    if (!Init(p_state))
        return 0;
    esRegisterDrawFunc(p_state, Draw);    
    MyFiles FileHandler;
........

And yes I also didn't explain the while loop (True) I will make some notes to change that in future editions and add it to the website errata.
It actually only needs the while (true) once you start to load multiple files since the single file load only really needs to load, then call the esMainLoop(p_state) call, before returning safely.


That ESMainloop code is legacy from the hello triangle code which is in all the standard tutorials,  but its not really a good way to do things as you move on, you'll see we slowly escape from it, and go to a more traditional game loop code which is cleaner and easier to follow.
It is currently designed to break from the debugger, it's not the kind of program you really want to run free. In fact all the projects are designed to be run as debugger demo's. But I am working on cleaner running  versions at the moment, with key escapes. It isn't too hard to put an escape system in, but you need to wait till you use the input handler to read keys.

I'll do my best to make notes of any changes, most of the changes are format based due to the small size of a written page and trying not to fill pages with source code, but there are one or 2 minor changes that developed over time, as well as simple errors on my part which I am happy to have pointed out and fix. As the book notes, be flexible, some things will be changed because I discovered errors on different platforms, and some things changed because there were other ways to do them.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's 



Reply


Messages In This Thread
RE: [Chapter 04] Unclear where to put the FileHandler code - by Brian Beuken - 04-10-2018, 02:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)