Mercurial > hg > Game > Cerium
changeset 91:4d6bd3c0d90b
*** empty log message ***
author | akira |
---|---|
date | Wed, 27 Feb 2008 21:19:13 +0900 |
parents | 312b535f121e |
children | 663bc2a213f5 |
files | TaskManager/Test/simple_pack/fb.cpp TaskManager/Test/simple_render/test/LoadTexture/fb.cpp |
diffstat | 2 files changed, 179 insertions(+), 135 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/simple_pack/fb.cpp Wed Feb 27 21:17:47 2008 +0900 +++ b/TaskManager/Test/simple_pack/fb.cpp Wed Feb 27 21:19:13 2008 +0900 @@ -1,73 +1,102 @@ +/* + * fbtst.c + * 2006.7.19 Kensuke Ooyu + */ +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <linux/fb.h> +#include <linux/fs.h> +#include <sys/mman.h> +#include <sys/ioctl.h> +#include <stdlib.h> #include <iostream> -#include <SDL.h> -#include <SDL_opengl.h> -#include <math.h> -#include <unistd.h> -#include "polygon.h" -#include "viewer.h" -#include "sys.h" using namespace std; -void cleanup_fbdev() { - munmap(fbptr, screensize); - close(fd_framebuffer); -} +#define DEVICE_NAME "/dev/fb0" +#define DIV_BYTE 8 + +#define X_PIXEL_MAX 320 +#define Y_LINE_MAX 240 + +#define BORDER1 80 +#define BORDER2 160 + +#define COLOR_RED 0xf800 +#define COLOR_GREEN 0x07e0 +#define COLOR_BLUE 0x001f +#define COLOR_WHITE 0xffff +#define COLOR_BLACK 0x0000 +#define COLOR_YELLOW 0xffe0 + +/* function prototype */ +void send_current_error_msg(char *ptr); +void send_current_information(char *ptr); + +int get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + int x , y ; + int xres,yres,vbpp,line_len; + unsigned short tcolor ; -void send_current_error_msg(char *ptr) { - fprintf( stderr, "%s\n", ptr); -} + /* 読み書き用にファイルを開く */ + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + /* 固定スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } -void send_current_information(char *ptr) { - fprintf( stdout, "%s\n", ptr); + /* 変動スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + /* デバイスをメモリにマップする */ + fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); + if ( (int)fbptr == -1 ) { + send_current_error_msg("Don't get framebuffer device to memory !"); + exit(4); + } + send_current_information("The framebuffer device was mapped !"); + + printf("fb: %x \n",fbptr); + return (int)fbptr; + //munmap(fbptr,screensize); + //close(fd_framebuffer); + //return 0; } -int get_fbdev_addr(void) { - struct fb_var_screeninfo vinfo; - struct fb_fix_screeninfo finfo; - char tmp[DIV_BYTE*10]; - - int xres,yres, vbpp, line_len; - - /* open the file only for read */ - fd_framebuffer = open( DEVICE_NAME, O_RDWR); - if( !fd_framebuffer ) { - send_current_error_msg("Framebuffer device open error\n"); - exit(1); - } - send_current_information("The framebuffer device was opened\n"); - - /* Get the fixed screen info */ - if( ioctl( fd_framebuffer, FBIOGET_FSCREENINFO, &finfo) ) { - send_current_error_msg("Fixed information not gotton !"); - exit(2); - } +void send_current_error_msg(char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} - /* Get the flucture screen info */ - if( ioctl( fd_framebuffer, FBIOGET_VSCREENINFO, &vinfo) ) { - send_current_error_msg("Variable information not gotton !"); - exit(3); - } - - xres = vinfo.xres; - yres = vinfo.yres; - vbpp = vinfo.bits_per_pixel; - line_len = finfo.line_length; - sprintf( tmp, "%d(pixel)x%d(line), %dbpp(bits per pixel)", xres, yres, vbpp); - send_current_information( tmp ); - - /* calcurate screen size per byte */ - screensize = xres * yres * vbpp / DIV_BYTE; - - /* mapping device to memory */ - fbptr = (char *)mmap(0,screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_framebuffer, 0); - if( (int)fbptr == -1) { - send_current_error_msg("Don't get framebuffer device to memory !"); - exit(4); - } - send_current_information("The framebuffer device was mapped !"); - - printf("fbptr:%x\n",(unsigned int)fbptr); - //munmap(fbptr, screensize); - //close(fd_framebuffer); - return (unsigned int)fbptr; +void send_current_information(char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); }
--- a/TaskManager/Test/simple_render/test/LoadTexture/fb.cpp Wed Feb 27 21:17:47 2008 +0900 +++ b/TaskManager/Test/simple_render/test/LoadTexture/fb.cpp Wed Feb 27 21:19:13 2008 +0900 @@ -1,87 +1,102 @@ -#include <iostream> -#include <SDL.h> -#include <SDL_opengl.h> -#include <math.h> +/* + * fbtst.c + * 2006.7.19 Kensuke Ooyu + */ #include <unistd.h> +#include <stdio.h> +#include <fcntl.h> #include <linux/fb.h> +#include <linux/fs.h> #include <sys/mman.h> #include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include "viewer.h" +#include <stdlib.h> +#include <iostream> using namespace std; #define DEVICE_NAME "/dev/fb0" #define DIV_BYTE 8 -int get_fbdev_addr(void); -void send_current_error_msg(char *c); -void send_current_information(char *c); +#define X_PIXEL_MAX 320 +#define Y_LINE_MAX 240 + +#define BORDER1 80 +#define BORDER2 160 + +#define COLOR_RED 0xf800 +#define COLOR_GREEN 0x07e0 +#define COLOR_BLUE 0x001f +#define COLOR_WHITE 0xffff +#define COLOR_BLACK 0x0000 +#define COLOR_YELLOW 0xffe0 + +/* function prototype */ +void send_current_error_msg(char *ptr); +void send_current_information(char *ptr); + +int get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + int x , y ; + int xres,yres,vbpp,line_len; + unsigned short tcolor ; -char *fbptr; -long int screensize; -int fd_framebuffer; -void cleanup_fbdev() { - munmap(fbptr, screensize); - close(fd_framebuffer); -} + /* 読み書き用にファイルを開く */ + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + /* 固定スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } -void send_current_error_msg(char *ptr) { - fprintf( stderr, "%s\n", ptr); -} + /* 変動スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + send_current_information( tmp ); -void send_current_information(char *ptr) { - fprintf( stdout, "%s\n", ptr); + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + /* デバイスをメモリにマップする */ + fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); + if ( (int)fbptr == -1 ) { + send_current_error_msg("Don't get framebuffer device to memory !"); + exit(4); + } + send_current_information("The framebuffer device was mapped !"); + + printf("fb: %x \n",fbptr); + return (int)fbptr; + //munmap(fbptr,screensize); + //close(fd_framebuffer); + //return 0; } -int get_fbdev_addr(void) { - struct fb_var_screeninfo vinfo; - struct fb_fix_screeninfo finfo; - char tmp[DIV_BYTE*10]; - - int xres,yres, vbpp, line_len; - - /* open the file only for read */ - fd_framebuffer = open( DEVICE_NAME, O_RDWR); - if( !fd_framebuffer ) { - send_current_error_msg("Framebuffer device open error\n"); - exit(1); - } - send_current_information("The framebuffer device was opened\n"); - - /* Get the fixed screen info */ - if( ioctl( fd_framebuffer, FBIOGET_FSCREENINFO, &finfo) ) { - send_current_error_msg("Fixed information not gotton !"); - exit(2); - } +void send_current_error_msg(char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} - /* Get the flucture screen info */ - if( ioctl( fd_framebuffer, FBIOGET_VSCREENINFO, &vinfo) ) { - send_current_error_msg("Variable information not gotton !"); - exit(3); - } - - xres = vinfo.xres; - yres = vinfo.yres; - vbpp = vinfo.bits_per_pixel; - line_len = finfo.line_length; - sprintf( tmp, "%d(pixel)x%d(line), %dbpp(bits per pixel)", xres, yres, vbpp); - send_current_information( tmp ); - - /* calcurate screen size per byte */ - screensize = xres * yres * vbpp / DIV_BYTE; - - /* mapping device to memory */ - fbptr = (char *)mmap(0,screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fd_framebuffer, 0); - if( atoi(fbptr) == -1) { - send_current_error_msg("Don't get framebuffer device to memory !"); - exit(4); - } - send_current_information("The framebuffer device was mapped !"); - - printf("fbptr:%x\n",atoi(fbptr)); - //munmap(fbptr, screensize); - //close(fd_framebuffer); - return atoi(fbptr); +void send_current_information(char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); }