コード例 #1
0
ファイル: title.c プロジェクト: AMD-FirePro/SDK
int main(void)
{
    GLFWwindow window;

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL);
    if (!window)
    {
        fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    glfwSwapInterval(1);

    glfwSetWindowSizeCallback(window_size_callback);

    while (glfwIsWindow(window) == GL_TRUE)
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers();
        glfwWaitEvents();
    }

    exit(EXIT_SUCCESS);
}
コード例 #2
0
ファイル: title.c プロジェクト: alkama/Bonzomatic
int main(void)
{
    GLFWwindow* window;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    window = glfwCreateWindow(400, 400, "English 日本語 русский язык 官話", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    gladLoadGL(glfwGetProcAddress);
    glfwSwapInterval(1);

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #3
0
ファイル: clipboard.c プロジェクト: AMD-FirePro/SDK
int main(int argc, char** argv)
{
    int ch;
    GLFWwindow window;

    while ((ch = getopt(argc, argv, "h")) != -1)
    {
        switch (ch)
        {
            case 'h':
                usage();
                exit(EXIT_SUCCESS);

            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(EXIT_FAILURE);
    }

    window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL);
    if (!window)
    {
        glfwTerminate();

        fprintf(stderr, "Failed to open GLFW window\n");
        exit(EXIT_FAILURE);
    }

    glfwSwapInterval(1);
    glfwSetKeyCallback(key_callback);
    glfwSetWindowSizeCallback(size_callback);

    glMatrixMode(GL_PROJECTION);
    glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
    glMatrixMode(GL_MODELVIEW);

    glClearColor(0.5f, 0.5f, 0.5f, 0);

    while (glfwIsWindow(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        glColor3f(0.8f, 0.2f, 0.4f);
        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);

        glfwSwapBuffers();
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #4
0
ファイル: peter.c プロジェクト: FeiZhan/smf_view
int main(void)
{
    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(EXIT_FAILURE);
    }

    if (!open_window())
    {
        fprintf(stderr, "Failed to open GLFW window\n");
        exit(EXIT_FAILURE);
    }

    glClearColor(0.f, 0.f, 0.f, 0.f);

    while (glfwGetWindowParam(GLFW_OPENED))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        glfwSwapBuffers();
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #5
0
ファイル: Input.cpp プロジェクト: kosua20/GL_Template
void Input::update(){
	if(_minimized){
		glfwWaitEvents();
	}
	
	// Reset temporary state (first, last).
	for(unsigned int i = 0; i < GLFW_KEY_LAST+1; ++i){
		_keys[i].first = false;
		_keys[i].last = false;
	}
	for(unsigned int i = 0; i < GLFW_MOUSE_BUTTON_LAST+1; ++i){
		_mouseButtons[i].first = false;
		_mouseButtons[i].last = false;
	}
	_mouse.scroll = glm::vec2(0.0f,0.0f);
	_resized = false;
	// Update only the active joystick if it exists.
	_joystickConnected = false;
	_joystickDisconnected = false;
	if(_activeController >= 0){
		_controllers[_activeController]->update();
	}
	
	glfwPollEvents();
	
}
コード例 #6
0
ファイル: glfwApp.cpp プロジェクト: enterstudio/tangram-es
void run() {

    loadSceneFile(true);

    double lastTime = glfwGetTime();

    // Loop until the user closes the window
    while (!glfwWindowShouldClose(main_window)) {

        double currentTime = glfwGetTime();
        double delta = currentTime - lastTime;
        lastTime = currentTime;

        // Render
        map->update(delta);
        map->render();

        // Swap front and back buffers
        glfwSwapBuffers(main_window);

        // Poll for and process events
        if (platform->isContinuousRendering()) {
            glfwPollEvents();
        } else {
            glfwWaitEvents();
        }
    }
}
コード例 #7
0
ファイル: fsfocus.c プロジェクト: jeapostrophe/glfw
int main(void)
{
    GLFWwindow* window;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    window = glfwCreateWindow(640, 480, "Fullscreen focus", glfwGetPrimaryMonitor(), NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);

    glfwSetWindowFocusCallback(window, window_focus_callback);
    glfwSetKeyCallback(window, window_key_callback);

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers(window);
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #8
0
ファイル: threads.c プロジェクト: eledot/Plum
int main(void)
{
    int i, result;
    Thread threads[] =
    {
        { NULL, "Red", 1.f, 0.f, 0.f, 0 },
        { NULL, "Green", 0.f, 1.f, 0.f, 0 },
        { NULL, "Blue", 0.f, 0.f, 1.f, 0 }
    };
    const int count = sizeof(threads) / sizeof(Thread);

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW: %s\n",
                glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    for (i = 0;  i < count;  i++)
    {
        glfwWindowHint(GLFW_POSITION_X, 200 + 250 * i);
        glfwWindowHint(GLFW_POSITION_Y, 200);
        threads[i].window = glfwCreateWindow(200, 200,
                                             GLFW_WINDOWED,
                                             threads[i].title,
                                             NULL);
        if (!threads[i].window)
        {
            fprintf(stderr, "Failed to open GLFW window: %s\n",
                    glfwErrorString(glfwGetError()));
            exit(EXIT_FAILURE);
        }

        if (thrd_create(&threads[i].id, thread_main, threads + i) !=
            thrd_success)
        {
            fprintf(stderr, "Failed to create secondary thread\n");
            exit(EXIT_FAILURE);
        }
    }

    while (running)
    {
        assert(glfwGetCurrentContext() == NULL);

        glfwWaitEvents();

        for (i = 0;  i < count;  i++)
        {
            if (glfwGetWindowParam(threads[i].window, GLFW_CLOSE_REQUESTED))
                running = GL_FALSE;
        }
    }

    for (i = 0;  i < count;  i++)
        thrd_join(threads[i].id, &result);

    exit(EXIT_SUCCESS);
}
コード例 #9
0
ファイル: sharing.c プロジェクト: deltaluca/glfw
int main(int argc, char** argv)
{
    int x, y, width;
    GLuint texture;

    glfwSetErrorCallback(error_callback, NULL);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    windows[0] = open_window("First", NULL, OFFSET, OFFSET);
    if (!windows[0])
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    // This is the one and only time we create a texture
    // It is created inside the first context, created above
    // It will then be shared with the second context, created below
    texture = create_texture();

    glfwGetWindowPos(windows[0], &x, &y);
    glfwGetWindowSize(windows[0], &width, NULL);

    // Put the second window to the right of the first one
    windows[1] = open_window("Second", windows[0], x + width + OFFSET, y);
    if (!windows[1])
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    // Set drawing color for both contexts
    glfwMakeContextCurrent(windows[0]);
    glColor3f(0.6f, 0.f, 0.6f);
    glfwMakeContextCurrent(windows[1]);
    glColor3f(0.6f, 0.6f, 0.f);

    glfwMakeContextCurrent(windows[0]);

    while (!glfwWindowShouldClose(windows[0]) &&
           !glfwWindowShouldClose(windows[1]))
    {
        glfwMakeContextCurrent(windows[0]);
        draw_quad(texture);

        glfwMakeContextCurrent(windows[1]);
        draw_quad(texture);

        glfwSwapBuffers(windows[0]);
        glfwSwapBuffers(windows[1]);

        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #10
0
ファイル: ctx.c プロジェクト: cloudhead/px
void ctx_tick(struct context *ctx)
{
	if (glfwGetWindowAttrib(ctx->win, GLFW_FOCUSED)) {
		glfwPollEvents();
	} else {
		glfwWaitEvents();
	}
}
コード例 #11
0
ファイル: threads.c プロジェクト: 6453mike/Graphics-Framework
int main(void)
{
    int i, result;
    Thread threads[] =
    {
        { NULL, "Red", 1.f, 0.f, 0.f, 0 },
        { NULL, "Green", 0.f, 1.f, 0.f, 0 },
        { NULL, "Blue", 0.f, 0.f, 1.f, 0 }
    };
    const int count = sizeof(threads) / sizeof(Thread);

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);

    for (i = 0;  i < count;  i++)
    {
        threads[i].window = glfwCreateWindow(200, 200,
                                             threads[i].title,
                                             NULL, NULL);
        if (!threads[i].window)
        {
            glfwTerminate();
            exit(EXIT_FAILURE);
        }

        glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200);
        glfwShowWindow(threads[i].window);

        if (thrd_create(&threads[i].id, thread_main, threads + i) !=
            thrd_success)
        {
            fprintf(stderr, "Failed to create secondary thread\n");

            glfwTerminate();
            exit(EXIT_FAILURE);
        }
    }

    while (running)
    {
        glfwWaitEvents();

        for (i = 0;  i < count;  i++)
        {
            if (glfwWindowShouldClose(threads[i].window))
                running = GL_FALSE;
        }
    }

    for (i = 0;  i < count;  i++)
        thrd_join(threads[i].id, &result);

    exit(EXIT_SUCCESS);
}
コード例 #12
0
ファイル: events.c プロジェクト: emailhy/JellyFish
int main(void)
{
    GLFWwindow* window;
    int width, height;

    setlocale(LC_ALL, "");

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    printf("Library initialized\n");

    window = glfwCreateWindow(640, 480, "Event Linter", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    printf("Window opened\n");

    glfwSetMonitorCallback(monitor_callback);

    glfwSetWindowPosCallback(window, window_pos_callback);
    glfwSetWindowSizeCallback(window, window_size_callback);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
    glfwSetWindowCloseCallback(window, window_close_callback);
    glfwSetWindowRefreshCallback(window, window_refresh_callback);
    glfwSetWindowFocusCallback(window, window_focus_callback);
    glfwSetWindowIconifyCallback(window, window_iconify_callback);
    glfwSetMouseButtonCallback(window, mouse_button_callback);
    glfwSetCursorPosCallback(window, cursor_position_callback);
    glfwSetCursorEnterCallback(window, cursor_enter_callback);
    glfwSetScrollCallback(window, scroll_callback);
    glfwSetKeyCallback(window, key_callback);
    glfwSetCharCallback(window, char_callback);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwGetWindowSize(window, &width, &height);
    printf("Window size should be %ix%i\n", width, height);

    printf("Main loop starting\n");

    while (!glfwWindowShouldClose(window))
    {
        glfwWaitEvents();

        // Workaround for an issue with msvcrt and mintty
        fflush(stdout);
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #13
0
void mainloop(int refresh) {
    if (mainloop_active)
        throw std::runtime_error("Main loop is already running!");

    mainloop_active = true;

    std::thread refresh_thread;
    if (refresh > 0) {
        /* If there are no mouse/keyboard events, try to refresh the
           view roughly every 50 ms (default); this is to support animations
           such as progress bars while keeping the system load
           reasonably low */
        refresh_thread = std::thread(
            [refresh]() {
                std::chrono::milliseconds time(refresh);
                while (mainloop_active) {
                    std::this_thread::sleep_for(time);
                    glfwPostEmptyEvent();
                }
            }
        );
    }

    try {
        while (mainloop_active) {
            int numScreens = 0;
            for (auto kv : __nanogui_screens) {
                Screen *screen = kv.second;
                if (!screen->visible()) {
                    continue;
                } else if (glfwWindowShouldClose(screen->glfwWindow())) {
                    screen->setVisible(false);
                    continue;
                }
                screen->drawAll();
                numScreens++;
            }

            if (numScreens == 0) {
                /* Give up if there was nothing to draw */
                mainloop_active = false;
                break;
            }

            /* Wait for mouse/keyboard or empty refresh events */
            glfwWaitEvents();
        }

        /* Process events once more */
        glfwPollEvents();
    } catch (const std::exception &e) {
        std::cerr << "Caught exception in main loop: " << e.what() << std::endl;
        leave();
    }

    if (refresh > 0)
        refresh_thread.join();
}
コード例 #14
0
JNIEXPORT void JNICALL Java_com_badlogic_jglfw_Glfw_glfwWaitEventsJni(JNIEnv* env, jclass clazz, jobject javaCallback) {


//@line:831

		glfwWaitEvents();
	

}
コード例 #15
0
int main(int argc, char** argv)
{
    int ch;
    GLFWwindow* window;

    while ((ch = getopt(argc, argv, "h")) != -1)
    {
        switch (ch)
        {
            case 'h':
                usage();
                exit(EXIT_SUCCESS);

            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(EXIT_FAILURE);
    }

    window = glfwCreateWindow(200, 200, "Clipboard Test", NULL, NULL);
    if (!window)
    {
        glfwTerminate();

        fprintf(stderr, "Failed to open GLFW window\n");
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
    glfwSwapInterval(1);

    glfwSetKeyCallback(window, key_callback);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

    glClearColor(0.5f, 0.5f, 0.5f, 0);

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        glfwSwapBuffers(window);
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #16
0
ファイル: util.c プロジェクト: MetsThe2/gl_util
void maybe_complete_pause(GLFWwindow *window)
{
    /* In a finished app, there's usually still things to update and render when
    paused, but this function is good for initial prototyping / debugging. */
    if (toggle_pause(window)) {
        while (!(glfwWindowShouldClose(window) || toggle_pause(window))) {
            glfwWaitEvents();
        }
    }
}
コード例 #17
0
ファイル: events.c プロジェクト: bioinfornatics/glfw
int main(void)
{
    GLFWwindow window;
    int width, height;

    setlocale(LC_ALL, "");

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    printf("Library initialized\n");

    glfwSetWindowSizeCallback(window_size_callback);
    glfwSetWindowCloseCallback(window_close_callback);
    glfwSetWindowRefreshCallback(window_refresh_callback);
    glfwSetWindowFocusCallback(window_focus_callback);
    glfwSetWindowIconifyCallback(window_iconify_callback);
    glfwSetMouseButtonCallback(mouse_button_callback);
    glfwSetCursorPosCallback(cursor_position_callback);
    glfwSetCursorEnterCallback(cursor_enter_callback);
    glfwSetScrollCallback(scroll_callback);
    glfwSetKeyCallback(key_callback);
    glfwSetCharCallback(char_callback);

    window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL);
    if (!window)
    {
        glfwTerminate();

        fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    printf("Window opened\n");

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwGetWindowSize(window, &width, &height);
    printf("Window size should be %ix%i\n", width, height);

    printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled");
    printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled");

    printf("Main loop starting\n");

    while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
        glfwWaitEvents();

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #18
0
int main(void)
{
    GLFWwindow* window;

    // Initialise GLFW
    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(EXIT_FAILURE);
    }

    // Open OpenGL window
    window = glfwCreateWindow(500, 500, "Split view demo", NULL, NULL);
    if (!window)
    {
        fprintf(stderr, "Failed to open GLFW window\n");

        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    // Set callback functions
    glfwSetFramebufferSizeCallback(window, framebufferSizeFun);
    glfwSetWindowRefreshCallback(window, windowRefreshFun);
    glfwSetCursorPosCallback(window, cursorPosFun);
    glfwSetMouseButtonCallback(window, mouseButtonFun);
    glfwSetKeyCallback(window, key_callback);

    // Enable vsync
    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwGetFramebufferSize(window, &width, &height);
    framebufferSizeFun(window, width, height);

    // Main loop
    for (;;)
    {
        // Only redraw if we need to
        if (do_redraw)
            windowRefreshFun(window);

        // Wait for new events
        glfwWaitEvents();

        // Check if the window should be closed
        if (glfwWindowShouldClose(window))
            break;
    }

    // Close OpenGL window and terminate GLFW
    glfwTerminate();

    exit(EXIT_SUCCESS);
}
コード例 #19
0
//--------------------------------------------------------------
void testApp::draw(){

    
    
    if (mode != MODE_ADDON ) {
        
        ofSetColor(100);
        logo.draw(64, 61,logo.getWidth(),logo.getHeight());
        
        //ofSetColor(74,255,203);
        titleFont.drawString("PROJECT", 64 + logo.getWidth() + 25, 85);
        titleFont.drawString("GENERATOR",  64 + logo.getWidth() + 25, 117);
    }
    
	if (mode == 0){
		for (int i = 0; i < buttons.size(); i++){
			buttons[i].draw();
		}
        
        generateButton.draw();
        
    } else if (mode == 1){
        panelCoreAddons.draw();
        if (bHaveNonCoreAddons){
            panelOtherAddons.draw();
        }
    } else if (mode == 2){
        panelPlatforms.draw();
    }
    //cout << panelAddons.getShape().height << endl;


    
    
    if (mode == 1 ){
        addonButton.draw();
        
        ofRectangle rect = secondFont.getStringBoundingBox("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60);
        ofSetColor(220,220,220);
        ofRect(rect.x-10, rect.y-10, rect.width+20, rect.height+20);
        ofSetColor(0,0,0);
        secondFont.drawString("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60);
    }
    
    if (mode == 0){
        ofFill();
        ofSetColor(0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy));
        ofRect(0,ofGetHeight(), ofGetWidth(), -25);
        ofSetColor(255,255,255, 255 * statusEnergy);
        ofDrawBitmapString(status, 10,ofGetHeight()-8);
    }
    
    glfwWaitEvents();
}
コード例 #20
0
ファイル: ysym.cpp プロジェクト: finger563/yocto-gl
// uiloop
void ui_loop(const ym_string& filename, const ym_string& imfilename,
             yo_scene* scene, ysr_scene* rigid_scene, float dt, int w, int h,
             bool camera_lights, float amb, bool no_ui) {
    // view data
    view_params* view = init_view_params(
        filename, imfilename, scene, rigid_scene, dt, w, h, camera_lights, amb);

    // glfw
    if (!glfwInit()) exit(EXIT_FAILURE);
    GLFWwindow* window = glfwCreateWindow(view->w, view->h, "yshade", 0, 0);
    glfwMakeContextCurrent(window);
    glfwSetWindowUserPointer(window, view);

    // callbacks
    glfwSetCharCallback(window, text_callback);
    glfwSetWindowSizeCallback(window, window_size_callback);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
    glfwSetMouseButtonCallback(window, mouse_button_callback);
    glfwSetCursorPosCallback(window, mouse_pos_callback);
    glfwSetWindowRefreshCallback(window, window_refresh_callback);

// init gl extensions
#ifndef __APPLE__
    if (glewInit() != GLEW_OK) exit(EXIT_FAILURE);
#endif

    // init shade state
    view->shade_prog = yg_stdshader_make_program();
    view->shade_txt.resize(scene->textures.size());
    for (int i = 0; i < scene->textures.size(); i++) {
        yo_texture* txt = &scene->textures[i];
        view->shade_txt[i] =
            yg_make_texture(txt->pixels.data(), txt->width, txt->height,
                            txt->ncomp, false, true);
    }

    // ui loop
    while (!glfwWindowShouldClose(window)) {
        window_refresh_callback(window);

        if (view->simulating) {
            simulate_step(view);
            glfwPollEvents();
        } else {
            glfwWaitEvents();
        }
    }

    glfwDestroyWindow(window);
    glfwTerminate();

    delete view;
}
コード例 #21
0
void GLFWView::run() {
    while (!glfwWindowShouldClose(window)) {
        glfwWaitEvents();
        const bool dirty = !clean.test_and_set();
        if (dirty) {
            const double started = glfwGetTime();
            map->renderSync();
            report(1000 * (glfwGetTime() - started));
            if (benchmark) {
                map->update(mbgl::Update::Repaint);
            }
        }
    }
}
コード例 #22
0
int main(void)
{
    setlocale(LC_ALL, "");

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW\n");
        exit(1);
    }

    printf("Library initialized\n");

    if (!glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW))
    {
        glfwTerminate();

        fprintf(stderr, "Failed to create GLFW window");
        exit(1);
    }

    printf("Window opened\n");

    glfwSetWindowTitle("Event Linter");
    glfwSwapInterval(1);

    glfwSetWindowSizeCallback(window_size_callback);
    glfwSetWindowCloseCallback(window_close_callback);
    glfwSetWindowRefreshCallback(window_refresh_callback);
    glfwSetMouseButtonCallback(mouse_button_callback);
    glfwSetMousePosCallback(mouse_position_callback);
    glfwSetMouseWheelCallback(mouse_wheel_callback);
    glfwSetKeyCallback(key_callback);
    glfwSetCharCallback(char_callback);

    printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled");
    printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled");

    printf("Main loop starting\n");

    while (glfwGetWindowParam(GLFW_OPENED) == GL_TRUE)
    {
        glfwWaitEvents();
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers();
    }

    glfwTerminate();
    exit(0);
}
コード例 #23
0
ファイル: app-gl.c プロジェクト: septag/darkhammer
void app_window_run()
{
    struct app_gl* app = g_app;
    ASSERT(g_app->wnd);

    while (!glfwWindowShouldClose(g_app->wnd))   {
        if (app->active || app->always_active)
            glfwPollEvents();
        else
            glfwWaitEvents();

        if (g_app->update_fn)
            g_app->update_fn();
    }
}
コード例 #24
0
void GLFWView::run() {
    while (!glfwWindowShouldClose(window)) {
        glfwWaitEvents();
        const bool dirty = !clean.test_and_set();
        if (dirty) {
            const double started = glfwGetTime();
            map->renderSync();
            report(1000 * (glfwGetTime() - started));
            if (benchmark) {
                map->setNeedsRepaint();
            }
            map->nudgeTransitions();
        }
    }
}
コード例 #25
0
ファイル: Application.cpp プロジェクト: FallenShard/vesper
    void Application::run()
    {
        glClearColor(0.0f, 0.3f, 0.0f, 1.0f);

        while (!glfwWindowShouldClose(m_mainWindow))
        {
            // Wait for events, saves processing power
            glfwWaitEvents();

            // Render the content to the back buffer
            m_renderer->render();

            // Swap the back and front buffers
            glfwSwapBuffers(m_mainWindow);
        }
    }
コード例 #26
0
ファイル: MC_drawer.cpp プロジェクト: eryeden/MCsim
void GLFW_test2::join(){
	while (1){
		if (window == NULL){
			break;
		}

		glfwWaitEvents();

		if (glfwWindowShouldClose(window)){
			std::cout << "CLOSE" << std::endl;
			break;
		}
	}
		
	glfwDestroyWindow(window);
	pthread_join(ctxt_thread, NULL);
}
コード例 #27
0
int GLFWView::run() {
    map->start();

    while (!glfwWindowShouldClose(window)) {
        if (map->needsSwap()) {
            glfwSwapBuffers(window);
            map->swapped();
            fps();
        }

        glfwWaitEvents();
    }

    map->stop();

    return 0;
}
コード例 #28
0
ファイル: main.cpp プロジェクト: PirtualVineapple/LightsOut
void startGame()
{
    GLFWwindow* Window = initWindow();
    bool Clicked = false;
    GLuint VAO[2];
    GLuint VBO[2];
    GLuint LinesVBO[2];
    glGenVertexArrays(2, VAO);
    
    CellList cellList = createCellList();
    GLfloat* cellVertexArray = createCellVertexArray(cellVertexArray, cellList);
    GLfloat* cellColorArray = constructCellColorArray(cellColorArray, cellList, true);
    constructVO(VAO[0], VBO, cellVertexArray, cellColorArray);
    //constructLines(VAO[1], LinesVBO);
    createShaders();
    glClearColor(1.0, 1.0, 1.0, 1.0);

    while (!glfwWindowShouldClose(Window)){
        glClear(GL_COLOR_BUFFER_BIT);

        constructCellColorArray(cellColorArray, cellList, false);
        constructVO(VAO[0], VBO, cellVertexArray, cellColorArray);

        glBindVertexArray(VAO[0]);
        glDrawArrays(GL_TRIANGLES, 0, cellDim * cellDim * 12);

        glBindVertexArray(VAO[1]);
        //glDrawArrays(GL_LINES, 0, cellDim * 8);

        glfwSwapBuffers(Window);
        glfwWaitEvents();
        if (glfwGetMouseButton(Window, GLFW_MOUSE_BUTTON_LEFT) == 1 && !Clicked){
            Clicked = true;
            mouseClick(Window, cellList);
        }
        if (glfwGetMouseButton(Window, GLFW_MOUSE_BUTTON_LEFT) == 0 && Clicked)
            Clicked = false;
    }
    glfwDestroyWindow(Window);
    glfwTerminate();
    

}
コード例 #29
0
ファイル: yview.c プロジェクト: mariano-gn/yocto-gl
// uiloop
void
ui_loop(int nimgs, view_img* imgs) {
    // view params
    view_params* view = init_view_params(nimgs, imgs);

    // window
    if (!glfwInit()) exit(EXIT_FAILURE);
    GLFWwindow* window = glfwCreateWindow(view->w, view->h, "imview", 0, 0);
    glfwMakeContextCurrent(window);
    glfwSetWindowUserPointer(window, view);

    // callbacks
    glfwSetCharCallback(window, text_callback);
    glfwSetWindowSizeCallback(window, window_size_callback);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
    glfwSetMouseButtonCallback(window, mouse_button_callback);
    glfwSetCursorPosCallback(window, mouse_pos_callback);
    glfwSetWindowRefreshCallback(window, window_refresh_callback);

    // init gl extensions
#ifdef YG_USING_GLEW
    if (glewInit() != GLEW_OK) exit(EXIT_FAILURE);
#endif
    
    // load textures
    for (int i = 0; i < nimgs; i++) {
        imgs[i].tex_glid = yg_make_texture(imgs[i].pixels, imgs[i].w, imgs[i].h,
                                           imgs[i].nc, true, false);
    }

    // ui loop
    while (!glfwWindowShouldClose(window)) {
        window_refresh_callback(window);
        glfwWaitEvents();
    }

    glfwDestroyWindow(window);
    glfwTerminate();

    free(view);
}
コード例 #30
0
ファイル: main.c プロジェクト: ziocroc/random
int main(int argc, char **argv)
{
	GLFWwindow *window = (GLFWwindow *) 0;
	mc_world world;
	mc_gc context;

	if (!glfwInit()) {
		mc_error(1, "GLFW error.");
	}

	atexit(glfwTerminate);
	glfwSetErrorCallback((GLFWerrorfun) mc_error);

	window = glfwCreateWindow(640, 480, "UntitledCraft", NULL, NULL);

	if (!window) {
		mc_error(1, "Window error.");
	}

	glfwMakeContextCurrent(window);

	if (!mc_graphics_init(&context)) {
		mc_error(1, "Context error.");
	}

	if (!mc_world_init(&world, (unsigned int) time(NULL))) {
		mc_error(1, "World.");
	}

	glfwPollEvents();

	while (!glfwWindowShouldClose(window)) {
		mc_graphics_clear(&context);

		glfwSwapBuffers(window);
		glfwWaitEvents();
	}

	return 0;
}