phoboslab/Ejecta — pull request #444 by darionco (2014-11-03 18:35:23+00:00)
Title: Embedded Default Shaders

The embedded header files were generated using the OSX standard command `xxd` as follows:
`xxd -i AlphaTexture.fsh AlphaTexture.fsh.h`

Embedding the default shaders in the code is a step forward in making ejecta compilable as a library or framework by getting rid of its external dependencies. I currently compile ejecta as a library by embedding the ejecta.js file with the following compile time script:

#app root
SCRIPT_SOURCE_FOLDER="${PROJECT_DIR}/LIBS/Ejecta/Source/Ejecta"
SCRIPT_FILE_NAME="ejecta.js"
HEADER_TARGET_FOLDER="${PROJECT_DIR}/P2Platform"

#move to the folder where the script file is
cd "${SCRIPT_SOURCE_FOLDER}"
#generate the header file
xxd -i "${SCRIPT_FILE_NAME}" "${HEADER_TARGET_FOLDER}/${SCRIPT_FILE_NAME}.h"

#move back to the project's folder
cd "${PROJECT_DIR}"

And then in my view controller:

- (void)loadView {
[super loadView];

/* get the js view */
EJJavaScriptView *jsView = (EJJavaScriptView*)self.view;

/* ejecta script */
NSString *ejectaScript = [[NSString alloc] initWithBytesNoCopy:ejecta_js length:ejecta_js_len encoding:NSUTF8StringEncoding freeWhenDone:NO];
[jsView evaluateScript:ejectaScript sourceURL:[NSString stringWithFormat:@"%@/ejecta.js", [[NSBundle mainBundle] bundleIdentifier]]];
}

That solution is works fine and accounts for changes in `ejecta.js`; I can do a push request with those changes as well if you want. I just want to know if you are interested in these kind of design changes.