i was able to compile and link V8 against my game and code interpretation works fine. However I want to divide my code and the game loop should exist in one thread and the scripting engine should run in a second thread alongside my game loop. I am using SDL and therefore tried this code to spawn a new thread
SDL_CreateThread(ScriptingEngine::SpawnMain, NULL);
where the following code is my test scripting engine:
namespace ScriptingEngine {
v8::HandleScope handleScope;
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
v8::Persistent<v8::Context> context;
void Setup() {
// TODO: bind functions to global
// ...
context = v8::Context::New(NULL, global);
}
int SpawnMain(void *arguments) {
v8::Context::Scope scope(context);
v8::Handle<v8::Script> script = v8::Script::Compile(
v8::String::New("'Hello World'")
);
v8::Handle<v8::Value> result = script->Run();
context.Dispose();
return EXIT_SUCCESS;
}
}
However I get an error like Access violation reading location 0x00000000.
in api.cc
line 716: i::Isolate* isolate = env->GetIsolate();
.
Has anyone a clue how I can fix this or what the exact problem is?