📄 libfbx.h
字号:
/* * libfbx.h -- Primary header file for libfbx * (C)opyright 2000-2001 U4X Labs * * Written by: Paul Mundt <lethal@stampede.org> * Mike Bourgeous <nitrogen@softhome.net> * Mon Jul 24 05:53:11 EDT 2000 * * $Id: libfbx.h,v 1.48 2001/03/03 02:29:19 nitroglycerine Exp $ * * Implementation of a number of basic drawing functions for * the framebuffer system, to be used as a linked library in * other programs using the libfbx API. Forked from the fbdev-init * code to be a standalone library. * * See ChangeLog for modifications, CREDITS for credits. * * All source herein is copyright U4X Labs and its original author. * Any code modifications or additions are (C)opyright the original * author and U4X Labs respectively. * * libfbx is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * libfbx is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with libfbx; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA */#ifndef __LIBFBX_H#define __LIBFBX_H #include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <errno.h> /* Needed by devfs_fs_kernel.h */#include <fcntl.h> /* Needed by devfs_fs_kernel.h */#include <linux/fb.h> /* Just in case user forgets */#include <linux/vt.h> /* For struct vt_mode */#ifdef __cplusplusextern "C" {#endif /* __cplusplus */#include <libfbx/libfbx-arch.h>struct fb_driver;#ifdef PI #undef PI#endif#ifndef VESA_NO_BLANKING /* These #defines must be here for 2.2.x kernels *//* VESA Blanking Levels */#define VESA_NO_BLANKING 0#define VESA_VSYNC_SUSPEND 1#define VESA_HSYNC_SUSPEND 2#define VESA_POWERDOWN 3#endif /* VESA_NO_BLANKING */#define PI 3.141592653589792#define LEN 255#define sqr(x) (x * x)#define DFLT_FB "/dev/fb0"#define DFLT_DEVFS_FB "/dev/fb/0"#define WIDTH fb_screen->vinfo->xres#define HEIGHT fb_screen->vinfo->yres#define VWIDTH fb_screen->vinfo->xres_virtual#define VHEIGHT fb_screen->vinfo->yres_virtual#ifdef TRUE #undef TRUE#endif#ifdef FALSE #undef FALSE#endif#define TRUE -1#define FALSE 0#ifndef MIN#define MIN(x, y) ((x) < (y)) ? (x) : (y)#define MAX(x, y) ((x) > (y)) ? (x) : (y)#endif /* MIN *//* Console states */#define FB_CONSOLE_ACTIVE 0#define FB_CONSOLE_INACTIVE 1#define FB_CONSOLE_ACQ_REQ 2#define FB_CONSOLE_REL_REQ 3typedef struct fb_text { int color; int bgcolor; int mask; int tab_size;} fb_text;typedef struct fb_font { int height, width; unsigned char *data;} fb_font;typedef struct fb_surface { int width; int height; int pixel_size; int bpp; int line_size; int buffer_size; unsigned long mem_offset; char *mem_pointer; unsigned long (*make_color)(int r, int g, int b); int red_size, red_offset; int green_size, green_offset; int blue_size, blue_offset; fb_text text; fb_font font; struct fb_fix_screeninfo *finfo; struct fb_var_screeninfo *vinfo; struct fb_driver *driver; int switch_state, last_switch;} fb_surface;typedef struct point3d { float x, y, z; float v; // for older stuff float nx, ny, nz; float xv, yv, zv; float xo, yo, zo; float r, g, b; float group; float maxgroup;} point3d;/* libfbx-3d.c */extern float view_angle, view_width, view_height, view_scalar_x, view_scalar_y;extern int view_offset_x, view_offset_y;void fb_set_viewport(float angle, int width, int height);void fb_project_3d(float x, float y, float z, int *u, int *v);void fb_putpixel_3d(float x, float y, float z, int r, int g, int b, fb_surface *surface);/* libfbx-font.c */extern char *default_font;void fb_font_init();void fb_setpixels(int pos, int bits);void fb_setpixels_masked(int pos, int bits);void fb_putc(int x, int y, int c);int fb_puts(int x, int y, char *text);void fb_printf(int x, int y, char *format, ...);void fb_ssetpixels(int pos, int bits, fb_surface *surface);void fb_ssetpixels_masked(int pos, int bits, fb_surface *surface);void fb_sputc(int x, int y, int c, fb_surface *surface);int fb_sputs(int x, int y, char *text, fb_surface *surface);void fb_sprintf(int x, int y, fb_surface *surface, char *format, ...);/* libfbx-init.c */extern char *fbptr;extern int fbfd;extern int fbptr_off;extern fb_surface *fb_screen;extern int tty;extern unsigned short red[256], green[256], blue[256];extern char *fb_device;extern struct vt_mode vtmode;int fb_init();void fb_cleanup();void fb_handle_signals();float rand01();char *fb_finddev();int fb_setdev(char *setdev);void fb_driver_ops_init();/* libfbx-polygon.c */void fb_fill_rect(int x1, int y1, int x2, int y2, int r, int g, int b, fb_surface *surface);void fb_rect(int x1, int y1, int x2, int y2, int r, int g, int b, fb_surface *surface);/* libfbx-surface.c */void fb_scls(fb_surface *surface);void fb_cls();fb_surface *fb_create_surface(int width, int height);fb_surface *fb_create_surface_depth(int width, int height, int depth);void fb_destroy_surface(fb_surface *surface);/* libfbx-line.c */void fb_line(int x1, int y1, int x2, int y2, int r, int g, int b, fb_surface *surface);/* libfbx-pixel.c */void fb_putpixel(int x, int y, int r, int g, int b, fb_surface *surface);void fb_getpixel(int x, int y, int *r, int *g, int *b, fb_surface *surface);void fb_putpixel_alpha(int alpha, int x, int y, int r1, int g1, int b1, fb_surface *surface);void fb_putpixel_aa(int alpha, float x, float y, int r, int g, int b, fb_surface *surface);/* libfbx-png.c */int fb_save_png(char *png_filename, fb_surface *surface, int interlace, int grayscale);int ppm2png(FILE *ppm_file, FILE *png_file, int interlace);fb_surface *fb_load_png(char *filename);fb_surface *png2pnm(FILE *png_file, int alpha);/* libfbx-ppm.c */fb_surface *fb_load_ppm(char *filename);int fb_save_ppm(char *filename, fb_surface *surface, int grayscale);/* libfbx-stretch.c */void fb_stretch_image(fb_surface *src, fb_surface *dest, int x, int y, int w, int h);void fb_stretch_image_aa(fb_surface *src, fb_surface *dest, int x, int y, int w, int h);/* libfbx-blit.c */void fb_draw_image(fb_surface *src, fb_surface *dest, int x, int y);void fb_draw_masked_image(fb_surface *src, fb_surface *dest, int x, int y, int w, int h);void fb_put_linux_logo(int xpos, int ypos, int width, int height, unsigned char data[], unsigned char red_map[], unsigned char green_map[], unsigned char blue_map[], fb_surface *destination);/* libfbx-color.c */unsigned long fb_make_color_8(int r, int g, int b);unsigned long fb_make_color_15(int r, int g, int b);unsigned long fb_make_color_16(int r, int g, int b);unsigned long fb_make_color_24(int r, int g, int b);unsigned long fb_make_color_unknown(int r, int g, int b);void fb_get_color(unsigned int hwcolor, int *r, int *g, int *b);void fb_make_332_map(struct fb_cmap *map);void fb_get_textcolor(int *fg, int *bg);void fb_sget_textcolor(fb_surface *surface, int *fg, int *bg);void fb_set_textcolor(int fg, int bg);void fb_sset_textcolor(fb_surface *surface, int fg, int bg);/* libfbx-2d.c */void fb_move_object(float speed, float a, float *Px, float *Py);float fb_get_rad(float x1, float y1, float x2, float y2);float fb_get_angle(float x1, float y1, float x2, float y2);/* libfbx-console.c */void fb_handle_switch_signals(int signal);void fb_switch_release();void fb_switch_acquire();void fb_switch_init();int fb_switch_console();void fb_set_vt(int num);inline void fb_blank(int val);#ifdef __cplusplus}#endif /* __cplusplus */#include <libfbx/libfbx-drivers.h>#endif /* __LIBFBX_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -