📄 generic1.c
字号:
/*=========================================================================== 2D Graphics Library ALL RIGHTS RESERVED, COPYRIGHT (C) FUJITSU LIMITED 1993-2002 LICENSED MATERIAL - PROGRAM PROPERTY OF FUJITSU LIMITED ===========================================================================*//*=======================================================================* Most simple example of how Graphics library is used *=======================================================================*/#include "gl.h"#include "color.h"/*------------------------------------------------------------------------ * Definition of parameter * * Defines parameter of GL. */#define PAGES 1 /* Number of pages */#define STYLES 2 /* Number of line styles */#define TILES 2 /* Number of tiles */#define IMAGES 2 /* Number of images */#define WIDTH 320 /* Number of horizontal pixels */#define HEIGHT 240 /* Number of vertical pixels */#define TMPAREASIZE 16384 /* Size of temporary buffer */#define VRAMTYPE GL_VRAM16M /* Type of VRAM */#define VRAMBPP 2 /* Number of bytes per pixel */#define PLANES 1 /* Number of Planes */#define HOOKTABLE _GL_defhook16m /* Hook table for implement */ /* modules *//*------------------------------------------------------------------------ * VRAM area * * Defines VRAM area. * In this sample, VRAM area is defined in other source file. * If VRAM area is fixed in hardware, specify address directory. * [Example] * #define Vram (void *)0x00400000 *//*------------------------------------------------------------------------ * Configuration table * * In configuration table, type of VRAM to be used, maximum number of * each definitions, etc. are described. */const GL_CONFIG video_config = { VRAMTYPE, /*VRAMmode ; VRAM type */ /* GL_VRAM1 (0) 1bit *1plane */ /* GL_VRAM16P (1) 1bit * 4planes */ /* GL_VRAM16 (2) 4bits* 1plane */ /* GL_VRAM256 (3) 8bits* 1plane */ /* GL_VRAM256G (4) 8bits* 1plane */ /* GL_VRAM64K (5) 16bits* 1plane */ /* GL_VRAM16MP (6) 8bits* 3planes */ /* GL_VRAM16MH (7) 16bits* 3planes */ /* GL_VRAM16M (8) 24bits* 1plane */ 0, /*VRAMbpl ; bytes per line of VRAM */ /* 0:automatic */ (void *)0, /* VRAMtbl ; pointer of VRAM address table */ &HOOKTABLE, /* *hook ; pointer of a hook table */ PAGES, /* pages ; VRAM pages */ WIDTH, /* width ; VRAM width */ HEIGHT, /* lines ; VRAM height */ STYLES, /* styles ; maximum of line styles */ TILES, /* tiles ; maximum of tile patterns */ IMAGES, /* images ; maximum of images */ 1, /* linesize ; standard line size */ 0 /* ciradj ; adjustment of circle (n:256) */};/*------------------------------------------------------------------------ * Work area * * This is work area for graphics library. Accurate size of a temporary * buffer in this area (defined as TMPAREASIZE here) is depend on type of * VRAM, the number of definition of tiles, etc. For detailed information, * refer to specification. * * Work area must be set at 64 bit address boundary. Entry point of work * area is corrected in Sample program (UserMain()). * */char glwork[GL_WORKSIZE(PAGES,STYLES,TILES,IMAGES,TMPAREASIZE)+8] ;/*--------------------------------------------------------------------------- * Main program * * Most basic example of programming for GL. * Initializes GL, and draw a circle and Draw "OK" in it. * */int main(){ unsigned char *Vram; GL_WP *gp ; char *hello="\0H\0e\0l\0l\0o\0,\0 \0w\0o\0r\0l\0d\0!"; long n, workmax ; /*-- Begin : Hardware dependence -----------------------*/ /* */ Vram =(unsigned char*)vdc_init(); /* */ /*-- End : Hardware dependence -----------------------*/ /* Initialization */ n = -(long)glwork & 7 ; gp = (GL_WP *)((long)glwork+n); workmax = sizeof(glwork)-n; GL_setup(gp, workmax, Vram, (GL_CONFIG *)&video_config); GL_init(gp,0); /* Drawing */ GL_filltype(gp,GL_FILL) ; GL_color2(gp,GL_FILLC, White) ; GL_circle(gp,128,100,50) ; GL_color2(gp,GL_FILLC, Blue) ; GL_circle(gp,128,100,40) ; GL_sizechar(gp,20,20) ; GL_color2(gp,GL_DRAWC, Yellow) ; GL_putstr(gp,(short *)hello,13,28,100) ; sleep(10); vdc_close(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -