예제 #1
0
파일: raster.c 프로젝트: AluOne/OpenCPN
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
    PUSH_IF_COMPILING(glViewport);
    LOAD_GLES(glViewport);
    if (raster) {
        render_raster();
    }
    gles_glViewport(x, y, width, height);
    viewport.x = x;
    viewport.y = y;
    viewport.width = width;
    viewport.height = height;
}
예제 #2
0
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
    PUSH_IF_COMPILING(glViewport);
    if (state.raster.buf) {
        render_raster();
    }
    if (width < 0 || height < 0) {
        ERROR(GL_INVALID_VALUE);
    }
    update_viewport(x, y, width, height);
    LOAD_GLES(glViewport);
    gles_glViewport(x, y, width, height);
}
예제 #3
0
void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) {
    PUSH_IF_COMPILING(glViewport);
    PROXY_GLES(glViewport);
    if (state.raster.buf) {
        render_raster();
    }
    gles_glViewport(x, y, width, height);
    viewport_state_t *viewport = &state.viewport;
    viewport->x = x;
    viewport->y = y;
    viewport->width = width;
    viewport->height = height;
    viewport->nwidth = npot(width);
    viewport->nheight = npot(height);
}
예제 #4
0
파일: glx.c 프로젝트: ssvb/glshim
void glXSwapBuffers(Display *display,
                    int drawable) {
    static int frames = 0;

    render_raster();
    if (g_vsync && fbdev >= 0) {
        // TODO: can I just return if I don't meet vsync over multiple frames?
        // this will just block otherwise.
        int arg = 0;
        for (int i = 0; i < swap_interval; i++) {
            ioctl(fbdev, FBIO_WAITFORVSYNC, &arg);
        }
    }
    eglSwapBuffers(eglDisplay, eglSurface);
    CheckEGLErrors();

    if (g_showfps) {
        // framerate counter
        static float avg, fps = 0;
        static int frame1, last_frame, frame, now, current_frames;
        struct timeval out;
        gettimeofday(&out, NULL);
        now = out.tv_sec;
        frame++;
        current_frames++;

        if (frame == 1) {
            frame1 = now;
        } else if (frame1 < now) {
            if (last_frame < now) {
                float change = current_frames / (float)(now - last_frame);
                float weight = 0.7;
                if (! fps) {
                    fps = change;
                } else {
                    fps = (1 - weight) * fps + weight * change;
                }
                current_frames = 0;

                avg = frame / (float)(now - frame1);
                printf("libGL fps: %.2f, avg: %.2f\n", fps, avg);
            }
        }
        last_frame = now;
    }
}