コード例 #1
0
ファイル: GLWidget.cpp プロジェクト: levelplane/circa
void GLWidget::mouseReleaseEvent ( QMouseEvent * qevent )
{
    caValue* event = circa_alloc_list(2);
    circa_set_int(circa_index(event, 0), 2);
    circa_set_vec2(circa_index(event, 1), qevent->x(), qevent->y());
    onInputEvent(event);
}
コード例 #2
0
ファイル: ShaderUtils.cpp プロジェクト: mokerjoke/circa
void compile_shader(GLenum type, caValue* contents, caValue* shaderOut)
{
    GLint status;
    GLuint shader;
    
    shader = glCreateShader(type);
    const char* source = circa_string(contents);
    glShaderSource(shader, 1, &source, NULL);
    glCompileShader(shader);
    check_gl_error();
    
#if defined(DEBUG)
    GLint logLength;
    glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
    if (logLength > 0) {
        GLchar *log = (GLchar *)malloc(logLength);
        glGetShaderInfoLog(shader, logLength, &logLength, log);
        printf("Shader compile log: %s\n", log);
        free(log);
    }
#endif
    
    glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
    if (status == 0) {
        glDeleteShader(shader);
        circa_set_error(shaderOut, "Failed to compile");
        return;
    }

    check_gl_error();
    circa_set_int(shaderOut, shader);
    Log("successfully compiled shader, index: ", shaderOut);
}
コード例 #3
0
ファイル: reload_loop.cpp プロジェクト: RickMoynihan/circa
int main(int argc, char** argv)
{
    caWorld* world = circa_initialize();

    circa_add_module_search_path(world, "tests/embed");

    int iteration = 0;

    while (true) {

        caValue* value = circa_alloc_value();
        circa_set_int(value, iteration);

        circa_actor_run_message(world, "TestA", value);
        sleep(1);
        iteration++;
    }

    circa_shutdown(world);
}
コード例 #4
0
ファイル: interpreter.cpp プロジェクト: julianhaslinger/circa
void test_cast_first_inputs()
{
    // Pass an input of [1] to a branch that expects a compound type.
    // The function will need to cast the [1] to T in order for it to work.

    Branch branch;
    branch.compile("type T { int i }");
    Term* f = branch.compile("def f(T t) -> int { return t.i }");

    Stack context;
    push_frame(&context, function_contents(f));

    caValue* in = circa_input((caStack*) &context, 0);
    circa_set_list(in, 1);
    circa_set_int(circa_index(in, 0), 5);

    run_interpreter(&context);

    test_assert(circa_int(circa_output((caStack*) &context, 0)) == 5);
}