int shell_sshot(char **args) { if (!get_framebuffer()) return NO_FRAMEBUFFER; char filename[50]; if (!args[1]) { // creation du nom de fichier en fonction de la date time_t t = time(NULL); struct tm *tmp = localtime(&t); strftime(filename, 50, "screen_%Y-%m-%d_%H:%M:%S.ppm", tmp); } else { strcpy(filename, args[1]); } // ouverture du fichier et ecriture de l'entete FILE *file = fopen(filename, "wb"); fprintf(file, "P5\n%u %u\n255\n", FRAMEBUFFER_W, FRAMEBUFFER_H); // ecriture de chaque pixel du framebuffer unsigned char pixel; for (uint32_t i = 0; i < FRAMEBUFFER_W * FRAMEBUFFER_H; i++) { pixel = get_byte(0xFFFF0600 + i); fwrite(&pixel, 1, 1, file); } // fermeture du fichier fclose(file); return OK; }
void InfiGLDestroyVertexArray( uint32 obj ) { ObjSet* arr = get_framebuffer(); ObjSet::iterator iter = arr->find( obj ); InfiGLDeleteFramebuffers( 1, &(*iter) ); if ( iter != arr->end() ) arr->erase( iter ); }
uint32 InfiGLCreateFramebuffer() { ObjSet* arr = get_framebuffer(); uint32 hnd; InfiGLGenFramebuffers( 1, &hnd ); arr->insert( hnd ); return hnd; }
int gr_init(void) { gglInit(&gr_context); GGLContext *gl = gr_context; gr_mem_surface.data = NULL; gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { gr_vt_fd = open("/dev/tty", O_RDWR | O_SYNC); } if (gr_vt_fd < 0) { // This is non-fatal; post-Cupcake kernels don't have tty0. perror("can't open /dev/tty0"); } else { ioctl(gr_vt_fd, KDGETMODE, &gr_vt_mode); if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { // However, if we do open tty0, we expect the ioctl to work. perror("failed KDSETMODE to KD_GRAPHICS on tty0"); gr_exit(); return -1; } } gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { perror("unable to get framebuffer"); gr_exit(); return -1; } get_memory_surface(&gr_mem_surface); fprintf(stderr, "framebuffer: fd %d (%d x %d)\n", gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; set_active_framebuffer(0); gl->colorBuffer(gl, &gr_mem_surface); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); gr_fb_blank(true); gr_fb_blank(false); return 0; }
int gr_fb_test(void) { release_framebuffer(gr_framebuffer); gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { led_alert("red", 1); gr_exit(); return -1; } return 0; }
int gr_init(void) { gglInit(&gr_context); GGLContext *gl = gr_context; gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { // This is non-fatal; post-Cupcake kernels don't have tty0. } else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { // However, if we do open tty0, we expect the ioctl to work. perror("failed KDSETMODE to KD_GRAPHICS on tty0"); gr_exit(); return -1; } gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { perror("Unable to get framebuffer.\n"); gr_exit(); return -1; } get_memory_surface(&gr_mem_surface); fprintf(stderr, "framebuffer: fd %d (%d x %d)\n", gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; if (!has_overlay) set_active_framebuffer(0); gl->colorBuffer(gl, &gr_mem_surface); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); #ifdef TW_SCREEN_BLANK_ON_BOOT printf("TW_SCREEN_BLANK_ON_BOOT := true\n"); gr_fb_blank(true); gr_fb_blank(false); #endif if (!alloc_ion_mem(fi.line_length * vi.yres)) allocate_overlay(gr_fb_fd, gr_framebuffer); return 0; }
int main(int argc, char *argv[]) { time_t start = time(NULL); printf("Starting recovery on %s", ctime(&start)); gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { return -1; } get_memory_surface(&gr_mem_surface); typedef unsigned short pixel; pixel* dst = gr_framebuffer[gr_active_fb].data; pixel* src = gr_mem_surface.data; int i,j; switch(ROTATE){ case ROTATE_90: for(i = 0;i < vi.yres;i++) { for(j = 0;j < vi.xres;j++) { dst[i * vi.xres + vi.xres - 1 - j] = src[i + j * vi.yres]; } } break; case ROTATE_270: for(i = 0;i < vi.yres;i++) { for(j = 0;j < vi.xres;j++) { dst[(vi.yres -1 - i) * vi.xres + j] = src[i + j * vi.yres]; } } break; default://0 memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data, vi.xres * vi.yres * 2); break; } set_active_framebuffer(0); ioctl(gr_fb_fd, FBIOPAN_DISPLAY, &vi); exit: munmap(gr_framebuffer[0].data, vi.yres * vi.xres * 2); munmap(gr_framebuffer[1].data, vi.yres * vi.xres * 2); munmap(recovery_ebc_buffer_base, recovery_ebc_buffer_len); close(gr_fb_fd); close(recovery_ebc_fd); return 0; }
int gr_init(void) { GGLContext *gl; int fd; gglInit(&gr_context); gl = gr_context; gr_init_font(); fd = open("/dev/tty0", O_RDWR | O_SYNC); if(fd < 0) return -1; if(ioctl(fd, KDSETMODE, (void*) KD_GRAPHICS)) { close(fd); return -1; } gr_fb_fd = get_framebuffer(gr_framebuffer); if(gr_fb_fd < 0) { ioctl(fd, KDSETMODE, (void*) KD_TEXT); close(fd); return -1; } gr_vt_fd = fd; /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; set_active_framebuffer(0); gl->colorBuffer(gl, gr_framebuffer + 1); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); return 0; }
preserve_fbo() { get_framebuffer(o,v); }
bool fbo::setup( GLint color_format, GLint depth_format, GLsizei w, GLsizei h) { ready = false; _w = w, _h = h; GLint o[1], v[4]; get_framebuffer(o, v); $glGenFramebuffersEXT(1, &frame); $glGenTextures (1, &color); $glGenTextures (1, &depth); // Initialize the color render buffer object. $glBindTexture(GL_TEXTURE_2D, color); $glTexImage2D (GL_TEXTURE_2D, 0, color_format, w, h, 0,GL_RGBA, GL_INT, NULL); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Initialize the depth render buffer object. $glBindTexture(GL_TEXTURE_2D, depth); $glTexImage2D (GL_TEXTURE_2D, 0, depth_format, w, h, 0,GL_DEPTH_COMPONENT, GL_INT, NULL); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); $glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); // Initialize the frame buffer object. $glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, frame); $glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, color, 0); $glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_TEXTURE_2D, depth, 0); // Confirm the frame buffer object status. auto result = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ); ; switch( result ) { case GL_FRAMEBUFFER_COMPLETE_EXT: break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: assert( !"Framebuffer incomplete attachment" ); case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: assert( !"Framebuffer missing attachment" ); case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: assert( !"Framebuffer duplicate attachment" ); case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: assert( !"Framebuffer dimensions" ); case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: assert( !"Framebuffer formats" ); case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: assert( !"Framebuffer draw buffer" ); case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: assert( !"Framebuffer read buffer" ); case GL_FRAMEBUFFER_UNSUPPORTED_EXT: assert( !"Framebuffer unsupported" ); default: assert( !"Framebuffer error" ); } // Zero the buffer. $glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); set_framebuffer(o, v); ready = true; return true; }