var w = Window.new(800, 600, "Hello Wren")var window_is_open = truewhile (window_is_open) { w.pollEvents {|event| System.print(event) } w.clear() w.render()}void windowPollEvents(WrenVM* vm){ WrenValue* fnCall = wrenMakeCallHandle(vm, "call(_)"); WrenValue* receiver = wrenGetSlotValue(vm, 1); SDL_Event event; while (SDL_PollEvent(&event)) { wrenEnsureSlots(vm, 2); wrenSetSlotValue(vm, 0, receiver); wrenSetSlotDouble(vm, 1, event.type); wrenCall(vm, fnCall); } wrenReleaseValue(vm, fnCall); wrenReleaseValue(vm, receiver);}Hi,
I didn't touched the code for a while but I think wrenCall can be called as this. It is not meant to be reentrant.
--
You received this message because you are subscribed to the Google Groups "Wren" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wren-lang+...@googlegroups.com.
To post to this group, send email to wren...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wren-lang/3dd6f320-6654-4b00-94be-24697f0fca99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Le 12 mai 2016 21:58, "Michel Hermier" <michel....@gmail.com> a écrit :
>
> Hi,
> I didn't touched the code for a while but I think wrenCall can be called as this. It is not meant to be reentrant.
I meant "can't" not "can".
Window.new. How does that implementation look?Cheers,BjørnI would say create a native event object and make pool event return a native event.
To view this discussion on the web visit https://groups.google.com/d/msgid/wren-lang/85000dcf-6031-4ecf-80c0-0cca31f795ef%40googlegroups.com.
void windowAllocate(WrenVM* vm)
{
InternalWindow * window = (InternalWindow*)wrenSetSlotNewForeign(vm, 0, 0, sizeof(InternalWindow));
}
void windowOpen(WrenVM* vm)
{
InternalWindow * window = (InternalWindow*)wrenGetSlotForeign(vm, 0);
int w = (int)wrenGetSlotDouble(vm, 1);
int h = (int)wrenGetSlotDouble(vm, 2);
Uint32 flags = 0;
const char* title = wrenGetSlotString(vm, 3);
SDL_CreateWindowAndRenderer(w, h, flags, &window->window, &window->renderer);
SDL_SetWindowTitle(window->window, title);
}w.pollEvents {|event|
return 42
}As I said afaik wrenCall is not meant to be used like this. From what I remember it should be used after a script was fully evaluated, as function callback.
I would say that for now do a simple implementation of SDL to have something that works. And later do something something more *powerful* either directly if fixable or by an abstraction.
--
You received this message because you are subscribed to the Google Groups "Wren" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wren-lang+...@googlegroups.com.
To post to this group, send email to wren...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wren-lang/5e9a6402-2e55-43f7-8d85-1c6d610642dd%40googlegroups.com.
As I said afaik wrenCall is not meant to be used like this. From what I remember it should be used after a script was fully evaluated, as function callback.
var w = Window.new(800, 600, "Hello Wren")var window_is_open = truewhile (window_is_open) {
var event = w.waitForEvent()System.print(event)w.clear()w.render()}
To view this discussion on the web visit https://groups.google.com/d/msgid/wren-lang/CAAZ5spBSyassB8tN9%2Bq_Tv_s35teZ6E_QpxXvsVs4qw0Tiw_%2Bg%40mail.gmail.com.
#include <wren_vm.h>
void windowPollEvents(WrenVM* vm)
{
WrenValue* receiver = wrenGetSlotValue(vm, 1);
ObjInstance* inst = AS_INSTANCE(receiver->value);
SDL_Event event;
if (SDL_PollEvent(&event))
{
inst->fields[0] = NUM_VAL(42);
wrenSetSlotBool(vm, 0, true);
}
else
{
wrenSetSlotBool(vm, 0, false);
}
wrenReleaseValue(vm, receiver);
}