⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wexbasic.c

📁 2410/vxworks/tornado下的基本实验包括 serial,ramdrv,interrupt,multi-FTP,TCP,UDP-Under the basic experimental
💻 C
📖 第 1 页 / 共 2 页
字号:
/* wexbasic.c - WindML Basic Graphics Primitive example program *//* Copyright 2000 - 2003 Wind River Systems, Inc. All Rights Reserved *//*modification history--------------------01n,08may03,jlb  Remove UGL_LOCAL on function prototype01m,16apr03,jlb  Improved comments and program documentation01l,01apr03,sts  [SPR 86504] Use uglRegistryFind() safely.01k,22feb02,msr  Backward compatibility for input API.01j,29jan02,rbp  Addition of support for Native Unix.01i,05nov01,gav  Fixed misnamed devIds01h,05nov01,gav  Change to new registry01g,05nov01,gav  Change to new registry01f,09oct01,msr  Ported to new UGL_Q_EVENT architecture.01e,19dec00,gav  Entry point identical to filename w/o extension.01d,20nov00,gav  Relative object positioning.01c,27oct00,rfm  Added stdio usage01b,26oct00,rfm  Modified entry point01a,25oct00,rfm  Added modification history*//*DESCRIPTIONThis example program demonstrates how to draw basic primitives to the screen. To start the example: -> ld < wexbasic_ugl.o -> wexbasic To stop the example: -> wexbasicStop *//* This is included for a printf prototype. */#include <stdio.h>/* Include the UGL header file to use UGL functions, etc. */#include <ugl/ugl.h>#include <ugl/uglos.h>#include <ugl/uglinput.h>/* A forward declaration for this program. */int windMLExampleBasic (void);/* Global variables *//* Control variable to signal when to stop program */UGL_LOCAL volatile UGL_BOOL stopWex;/* Some graphics environment information */UGL_LOCAL int displayHeight, displayWidth;/* input service */UGL_LOCAL UGL_INPUT_SERVICE_ID inputServiceId;/** The color table is where we define the colors we want* to have available.  The format is an array of* ARGB values paired with their allocated uglColor.  As* of this writing, we don't need to worry about Alpha* ("A") values unless we are using video.*/UGL_LOCAL struct _colorStruct    {    UGL_ARGB rgbColor;    UGL_COLOR uglColor;    }colorTable[] =    {    { UGL_MAKE_ARGB(0xff, 0, 0, 0), 0},    /* The color table uses ARGB's */    { UGL_MAKE_ARGB(0xff, 0, 0, 168), 0},  /* (see uglColorAlloc).        */    { UGL_MAKE_ARGB(0xff, 0, 168, 0), 0},  /* Initialize alpha to 255 for */    { UGL_MAKE_ARGB(0xff, 0, 168, 168), 0},/* now (opaque).               */    { UGL_MAKE_RGB(168, 0, 0), 0},         /* UGL_MAKE_RGB takes care of  */    { UGL_MAKE_RGB(168, 0, 168), 0},       /* the alpha for us.           */    { UGL_MAKE_RGB(168, 84, 0), 0},    { UGL_MAKE_RGB(168, 168, 168), 0},    { UGL_MAKE_RGB(84, 84, 84), 0},    { UGL_MAKE_RGB(84, 84, 255), 0},    { UGL_MAKE_RGB(84, 255, 84), 0},    { UGL_MAKE_RGB(84, 255, 255), 0},    { UGL_MAKE_RGB(255, 84, 84), 0},    { UGL_MAKE_RGB(255, 84, 255), 0},    { UGL_MAKE_RGB(255, 255, 84), 0},    { UGL_MAKE_RGB(255, 255, 255), 0}    };/* Label the colors we defined */#define BLACK			(0)#define BLUE			(1)#define GREEN			(2)#define CYAN			(3)#define RED				(4)#define MAGENTA			(5)#define BROWN			(6)#define LIGHTGRAY		(7)#define DARKGRAY		(8)#define LIGHTBLUE		(9)#define LIGHTGREEN		(10)#define LIGHTCYAN		(11)#define LIGHTRED		(12)#define LIGHTMAGENTA	(13)#define YELLOW			(14)#define WHITE			(15)/* * This is the data for a user defined fill pattern that* can be used with various drawing primitives.  This data* will be used to create a monochrome DIB (MDIB), which* will be used in turn to create a monochrome "bitmap".* It is the bitmap that is used by the drawing primitives.** Solid fills do not need to have a pattern defined, just* pass an UGL_NULL value in the pattern parameter to* revert (it is the default) to solid fills.*/UGL_LOCAL struct    {    int width;    int height;    unsigned char data[32];    } patternData =    {    16, 16,        {         0xFF, 0xFF, /* a brick pattern */        0x00, 0x01,        0x00, 0x01, /* 8 pixels per byte */        0x00, 0x01,        0x00, 0x01,        0x00, 0x01,        0x00, 0x01,        0x00, 0x01,        0xFF, 0xFF,         0x01, 0x00,        0x01, 0x00,        0x01, 0x00,        0x01, 0x00,        0x01, 0x00,        0x01, 0x00,        0x01, 0x00        }    };/**************************************************************************** ClearScreen - clear the screen** This routine clears the screen by drawing a black rectangle to the display.** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/UGL_LOCAL void ClearScreen    (    UGL_GC_ID gc                /* Graphics context */    )    {    uglBackgroundColorSet(gc, colorTable [BLACK].uglColor);    uglForegroundColorSet(gc, colorTable [BLACK].uglColor);    uglLineStyleSet(gc, UGL_LINE_STYLE_SOLID);    uglLineWidthSet(gc, 1);    uglRectangle(gc, 0, 0, displayWidth - 1, displayHeight - 1);    }/**************************************************************************** wexPause - wait for input from keyboard** Wait for the signal to stop.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL*/UGL_LOCAL void wexPause (void)    {    while (!stopWex)        {        UGL_MSG msg;        if ((uglInputMsgGet (inputServiceId, &msg, 140) != UGL_STATUS_Q_EMPTY) &&            msg.type == MSG_KEYBOARD)            stopWex = UGL_TRUE;        }    }#if defined(WINDML_NATIVE) && defined(__unix__)/**************************************************************************** main - start of demo program for unix native simulator** Start the example program.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/int main (int argc, char *argv [])    {    windMLExampleBasic();    return (0);    }#elif defined(WINDML_NATIVE) && defined(_WIN32)/**************************************************************************** WinMain - start of demo program for windows native simulator** Start the example program.  ** RETURNS: ** ERRNO: N/A** SEE ALSO:  ** NOMANUAL**/int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,                   LPSTR lpCmdLine, int nShowCmd)    {    uglWin32Parameters(hInstance, hPrevInstance, lpCmdLine, nShowCmd);    windMLExampleBasic();    return (0);    }#else/**************************************************************************** wexbasic - demonstrate basic graphics primitives** This routine demonstrates the basic WindML graphics primitives.  ** This example program demonstrates how to:**\ml *\m Initialize WindML*\m Identify the graphics device and input devices*\m Determine the resolution of the display*\m Create a graphics context*\m Allocate colors*\m Draw lines (solid and dashed with various widths)*\m Draw a rectangle with a fill pattern*\m Draw polygons, both filled and not filled*\m Draw an ellipse*\m Draw a pie slice*\m Releasing all resources and terminating a WindML application.*\me*** RETURNS: ** ERRNO: N/A** SEE ALSO: wexbasicStop() **/void wexbasic (void)    {    stopWex = UGL_FALSE;    printf("To stop wexbasic, type 'wexbasicStop'\n");    uglOSTaskCreate("tWindMLbas", (UGL_FPTR)windMLExampleBasic, 110,                     0, 10240,0,0,0,0,0);    }#endif/**************************************************************************** wexbasicStop - stop the basic graphics example program** This routine stops the basic graphics primitive example program.** RETURNS: ** ERRNO: N/A** SEE ALSO: wexbasic() **/void wexbasicStop (void)    {    stopWex = UGL_TRUE;    }/**************************************************************************** windMLExampleBasic - set up demo program and render graphics images** This routine initializes the graphics device and input device and then* draws some basic primitives to the display.** RETURNS: ** ERRNO: N/A** SEE ALSO:** NOMANUAL  **/int windMLExampleBasic (void)    {    /* For registry lookups. */    UGL_REG_DATA *pRegistryData;    /* An int for miscellaneous counters,etc. */    int i;    /*     * The UGL Graphics Context (GC) is an important concept in UGL.    * The GC contains data that various UGL functions can use.    * If there were no such thing as a GC, most function calls    * would require several more parameters to communicate that    * information.    */    UGL_GC_ID gc;    /*     * This structure is filled in with data about the frame buffer    * by the uglInfo() function.    */        UGL_MODE_INFO modeInfo;        /*    * The device ID is critical to the operation of UGL.  It    * identifies individual "devices" (display adapter, keyboard,    * font engine, etc.) to functions that may be able to work    * with more than one device.    */    UGL_DEVICE_ID devId;    /*    * As mentioned in the comments to patternData, the fill pattern    * is defined as a monochrome bitmap for certain drawing primitives.    * To create the bitmap (UGL_MDDB_ID), a Device Independent Bitmap    * (DIB) is used; in particular a monochrome DIB (UGL_MDIB).  The    * "DDB" in UGL_MDDB_ID stands for Device Dependent Bitmap.  Often    * the DDB is simply referred to as a "bitmap" and the DIB is    * called a "dib" (it's easier to pronounce dib than ddb).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -